Changeset 1412 in 3DVCSoftware for branches/HTM-16.2-dev/source/Lib/TLibEncoder/TEncTop.cpp
- Timestamp:
- 12 Apr 2018, 11:12:21 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-16.2-dev/source/Lib/TLibEncoder/TEncTop.cpp
r1405 r1412 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 6, ITU/ISO/IEC6 * Copyright (c) 2010-2017, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 54 54 // ==================================================================================================================== 55 55 56 TEncTop::TEncTop() 57 { 56 #if !NH_MV 57 TEncTop::TEncTop() : 58 m_spsMap(MAX_NUM_SPS) 59 , m_ppsMap(MAX_NUM_PPS) 60 #else 61 TEncTop::TEncTop( ParameterSetMap<TComSPS>& spsMap, ParameterSetMap<TComPPS>& ppsMap ) : 62 m_spsMap(spsMap) 63 , m_ppsMap(ppsMap) 64 #endif 65 { 66 58 67 m_iPOCLast = -1; 59 68 m_iNumPicRcvd = 0; … … 79 88 m_ivPicLists = NULL; 80 89 #endif 81 #if NH_3D _IC90 #if NH_3D 82 91 m_aICEnableCandidate = NULL; 83 92 m_aICEnableNum = NULL; … … 91 100 TEncTop::~TEncTop() 92 101 { 93 #if NH_3D_FIX_LEAK 94 #if NH_3D_IC 102 #if NH_3D 95 103 if ( m_aICEnableCandidate != NULL ) 96 104 { … … 104 112 #endif 105 113 106 #endif107 114 #if ENC_DEC_TRACE 108 115 if (g_hTrace != stdout) … … 222 229 #endif 223 230 { 231 #if NH_MV 232 Int parameterSetId = getParameterSetId( ); 233 234 TComSPS& sps0 = *(m_spsMap.allocatePS( parameterSetId ) ); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues. 235 TComPPS& pps0 = *(m_ppsMap.allocatePS( parameterSetId ) ); 236 #else 237 TComSPS &sps0=*(m_spsMap.allocatePS(0)); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues. 238 TComPPS &pps0=*(m_ppsMap.allocatePS(0)); 239 #endif 224 240 // initialize SPS 225 241 #if H_3D 226 242 // Assuming that all PPS indirectly refer to the same VPS via different SPS 227 m_cSPS.setVPS(m_cVPS); 228 #endif 229 xInitSPS(); 230 xInitVPS(); 231 232 #if U0132_TARGET_BITS_SATURATION 243 sps.setVPS(m_cVPS); 244 #endif 245 246 #if NH_MV 247 Bool initParameterSets = getSendParameterSets(); 248 249 if ( initParameterSets ) 250 { 251 xInitSPS( sps0 ); 252 } 253 #else 254 xInitSPS( sps0 ); 255 xInitVPS((*m_cVPS), sps0); 256 #endif 257 233 258 if (m_RCCpbSaturationEnabled) 234 259 { 235 m_cRateCtrl.initHrdParam( m_cSPS.getVuiParameters()->getHrdParameters(), m_iFrameRate, m_RCInitialCpbFullness);236 } 237 #endif 260 m_cRateCtrl.initHrdParam(sps0.getVuiParameters()->getHrdParameters(), m_iFrameRate, m_RCInitialCpbFullness); 261 } 262 238 263 m_cRdCost.setCostMode(m_costMode); 239 264 240 265 #if NH_MV 241 // This seems to be incorrect, but irrelevant for the MV-HEVC 242 *(m_cVPS->getPTL()) = *m_cSPS.getPTL(); 243 m_cVPS->getTimingInfo()->setTimingInfoPresentFlag ( false ); 244 #endif 245 // initialize PPS 246 xInitPPS(); 247 xInitRPS(isFieldCoding); 248 249 xInitPPSforTiles(); 250 #if NH_3D_IC 266 if ( initParameterSets ) 267 { 268 // This seems to be incorrect, but irrelevant for the MV-HEVC 269 if (m_layerId == 0 ) 270 { 271 *(m_cVPS->getPTL()) = *sps0.getPTL(); 272 m_cVPS->getTimingInfo()->setTimingInfoPresentFlag ( false ); 273 } 274 #endif 275 // initialize PPS 276 xInitPPS(pps0, sps0); 277 xInitRPS(sps0, isFieldCoding); 278 xInitScalingLists(sps0, pps0); 279 280 if (m_wcgChromaQpControl.isEnabled()) 281 { 282 #if NH_MV 283 AOT( true ); // This is currently not supported. 284 #endif 285 TComPPS &pps1=*(m_ppsMap.allocatePS(1)); 286 xInitPPS(pps1, sps0); 287 xInitScalingLists(sps0, pps1); 288 } 289 #if NH_MV 290 } 291 292 // Copy initialized PS 293 m_activeSps = sps0; 294 m_activePps = pps0; 295 296 // Infer layer specific values for copy 297 m_activeSps.inferRepFormat( m_cVPS, getLayerId(), initParameterSets ); 298 #endif 299 300 #if NH_3D 251 301 m_aICEnableCandidate = new Int[ 10 ]; 252 302 m_aICEnableNum = new Int[ 10 ]; … … 258 308 } 259 309 #endif 310 260 311 261 312 // initialize processing unit classes … … 263 314 m_cSliceEncoder.init( this ); 264 315 m_cCuEncoder. init( this ); 316 m_cCuEncoder.setSliceEncoder(&m_cSliceEncoder); 265 317 266 318 #if KWU_RC_MADPRED_E0227 … … 273 325 m_useRDOQ, 274 326 m_useRDOQTS, 275 #if T0196_SELECTIVE_RDOQ276 327 m_useSelectiveRDOQ, 277 #endif278 328 true 279 329 ,m_useTransformSkipFast … … 287 337 288 338 m_iMaxRefPicNum = 0; 289 290 xInitScalingLists(); 291 } 292 293 Void TEncTop::xInitScalingLists() 339 } 340 341 Void TEncTop::xInitScalingLists(TComSPS &sps, TComPPS &pps) 294 342 { 295 343 // Initialise scaling lists … … 297 345 const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] = 298 346 { 299 m_cSPS.getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA),300 m_cSPS.getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA)347 sps.getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA), 348 sps.getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA) 301 349 }; 302 350 if(getUseScalingListId() == SCALING_LIST_OFF) 303 351 { 304 getTrQuant()->setFlatScalingList(maxLog2TrDynamicRange, m_cSPS.getBitDepths());352 getTrQuant()->setFlatScalingList(maxLog2TrDynamicRange, sps.getBitDepths()); 305 353 getTrQuant()->setUseScalingList(false); 306 m_cSPS.setScalingListPresentFlag(false);307 m_cPPS.setScalingListPresentFlag(false);354 sps.setScalingListPresentFlag(false); 355 pps.setScalingListPresentFlag(false); 308 356 } 309 357 else if(getUseScalingListId() == SCALING_LIST_DEFAULT) 310 358 { 311 m_cSPS.getScalingList().setDefaultScalingList ();312 m_cSPS.setScalingListPresentFlag(false);313 m_cPPS.setScalingListPresentFlag(false);314 315 getTrQuant()->setScalingList(&( m_cSPS.getScalingList()), maxLog2TrDynamicRange, m_cSPS.getBitDepths());359 sps.getScalingList().setDefaultScalingList (); 360 sps.setScalingListPresentFlag(false); 361 pps.setScalingListPresentFlag(false); 362 363 getTrQuant()->setScalingList(&(sps.getScalingList()), maxLog2TrDynamicRange, sps.getBitDepths()); 316 364 getTrQuant()->setUseScalingList(true); 317 365 } 318 366 else if(getUseScalingListId() == SCALING_LIST_FILE_READ) 319 367 { 320 m_cSPS.getScalingList().setDefaultScalingList ();321 if( m_cSPS.getScalingList().xParseScalingList(getScalingListFileName()))368 sps.getScalingList().setDefaultScalingList (); 369 if(sps.getScalingList().xParseScalingList(getScalingListFileName())) 322 370 { 323 371 Bool bParsedScalingList=false; // Use of boolean so that assertion outputs useful string … … 325 373 exit(1); 326 374 } 327 m_cSPS.getScalingList().checkDcOfMatrix();328 m_cSPS.setScalingListPresentFlag(m_cSPS.getScalingList().checkDefaultScalingList());329 m_cPPS.setScalingListPresentFlag(false);330 getTrQuant()->setScalingList(&( m_cSPS.getScalingList()), maxLog2TrDynamicRange, m_cSPS.getBitDepths());375 sps.getScalingList().checkDcOfMatrix(); 376 sps.setScalingListPresentFlag(sps.getScalingList().checkDefaultScalingList()); 377 pps.setScalingListPresentFlag(false); 378 getTrQuant()->setScalingList(&(sps.getScalingList()), maxLog2TrDynamicRange, sps.getBitDepths()); 331 379 getTrQuant()->setUseScalingList(true); 332 380 } … … 346 394 for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep) 347 395 { 348 m_cSPS.getScalingList().checkPredMode( sizeId, listId );396 sps.getScalingList().checkPredMode( sizeId, listId ); 349 397 } 350 398 } … … 362 410 363 411 // get original YUV 364 xGetNewPicBuffer( pcPicCurr ); 412 413 xGetNewPicBuffer( pcPicCurr, getParameterSetId() ); 365 414 pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); 366 415 … … 431 480 TComPic* pcPicCurr = NULL; 432 481 433 xGetNewPicBuffer( pcPicCurr ); 482 Int ppsID=-1; // Use default PPS ID 483 if (getWCGChromaQPControl().isEnabled()) 484 { 485 ppsID=getdQPs()[ m_iPOCLast+1 ]; 486 } 487 xGetNewPicBuffer( pcPicCurr, ppsID ); 434 488 pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); 435 489 pcPicYuvTrueOrg->copyToPic( pcPicCurr->getPicYuvTrueOrg() ); … … 454 508 #if NH_MV 455 509 } 456 m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb(getLayerId(), false) ), rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, gopId);510 m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb(getLayerId(), false) ), rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, m_printMSSSIM, gopId); 457 511 458 512 if( gopId + 1 == m_cGOPEncoder.getGOPSize() ) … … 460 514 #else 461 515 // compress GOP 516 #if JVET_F0064_MSSSIM 517 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, m_printMSSSIM); 518 #else 462 519 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE); 520 #endif 463 521 #endif 464 522 if ( m_RCEnableRateControl ) … … 515 573 516 574 TComPic *pcField; 517 xGetNewPicBuffer( pcField );575 xGetNewPicBuffer( pcField, -1 ); 518 576 pcField->setReconMark (false); // where is this normally? 519 577 … … 536 594 537 595 pcField->getSlice(0)->setPOC( m_iPOCLast ); // superfluous? 596 #if !REDUCED_ENCODER_MEMORY 538 597 pcField->getPicYuvRec()->setBorderExtension(false);// where is this normally? 598 #endif 539 599 540 600 pcField->setTopField(isTopField); // interlaced requirement … … 570 630 { 571 631 // compress GOP 632 #if JVET_F0064_MSSSIM 633 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff, snrCSC, m_printFrameMSE, m_printMSSSIM); 634 #else 572 635 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff, snrCSC, m_printFrameMSE); 636 #endif 573 637 574 638 iNumEncoded += m_iNumPicRcvd; … … 590 654 \retval rpcPic obtained picture buffer 591 655 */ 592 Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic ) 593 { 656 Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic, Int ppsId ) 657 { 658 rpcPic=0; 659 660 #if NH_MV 661 const TComPPS &pps = m_activePps; 662 const TComSPS &sps = m_activeSps; 663 664 if ( ppsId > 0 ) 665 { 666 assert( pps.getPPSId() == ppsId ); 667 assert( sps.getSPSId() == pps.getSPSId() ); 668 } 669 #else 670 const TComSPS *pSPS=m_spsMap.getPS(pps.getSPSId()); 594 671 // At this point, the SPS and PPS can be considered activated - they are copied to the new TComPic. 672 const TComPPS *pPPS=(ppsId<0) ? m_ppsMap.getFirstPS() : m_ppsMap.getPS(ppsId); 673 assert (pPPS!=0); 674 const TComPPS &pps=*pPPS; 675 assert (pSPS!=0); 676 677 assert (pSPS!=0); 678 const TComSPS &sps=*pSPS; 679 680 #endif 681 595 682 596 683 #if NH_MV 597 684 TComList<TComPic*>& cListPic = *(m_ivPicLists->getSubDpb(getLayerId(), false) ); 598 685 TComSlice::sortPicList(cListPic); 686 // Infer the correct rep format 687 688 // As 599 689 #else 600 690 TComSlice::sortPicList(m_cListPic); … … 608 698 Int iSize = Int( cListPic.size() ); 609 699 #else 700 // use an entry in the buffered list if the maximum number that need buffering has been reached: 701 610 702 if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) 611 703 { … … 615 707 for ( Int i = 0; i < iSize; i++ ) 616 708 { 617 rpcPic = * (iterPic++);709 rpcPic = *iterPic; 618 710 if(rpcPic->getSlice(0)->isReferenced() == false) 619 711 { 620 712 break; 621 713 } 622 } 623 } 624 else 714 iterPic++; 715 } 716 // If PPS ID is the same, we will assume that it has not changed since it was last used 717 // and return the old object. 718 if (pps.getPPSId() == rpcPic->getPicSym()->getPPS().getPPSId()) 719 { 720 #if REDUCED_ENCODER_MEMORY 721 rpcPic->releaseAllReconstructionData(); 722 rpcPic->prepareForEncoderSourcePicYuv(); 723 #endif 724 } 725 else 726 { 727 // the IDs differ - free up an entry in the list, and then create a new one, as with the case where the max buffering state has not been reached. 728 delete rpcPic; 729 cListPic.erase(iterPic); 730 rpcPic=0; 731 } 732 } 733 734 if (rpcPic==0) 625 735 { 626 736 if ( getUseAdaptiveQP() ) 627 737 { 628 738 TEncPic* pcEPic = new TEncPic; 629 pcEPic->create( m_cSPS, m_cPPS, m_cPPS.getMaxCuDQPDepth()+1, false); 739 #if REDUCED_ENCODER_MEMORY 740 pcEPic->create( sps, pps, pps.getMaxCuDQPDepth()+1); 741 #else 742 pcEPic->create( sps, pps, pps.getMaxCuDQPDepth()+1, false); 743 #endif 630 744 rpcPic = pcEPic; 631 745 } … … 633 747 { 634 748 rpcPic = new TComPic; 635 rpcPic->create( m_cSPS, m_cPPS, false ); 749 #if REDUCED_ENCODER_MEMORY 750 rpcPic->create( sps, pps, true, false ); 751 #else 752 rpcPic->create( sps, pps, false ); 753 #endif 636 754 } 637 755 … … 648 766 649 767 rpcPic->getSlice(0)->setPOC( m_iPOCLast ); 768 #if !REDUCED_ENCODER_MEMORY 650 769 // mark it should be extended 651 770 rpcPic->getPicYuvRec()->setBorderExtension(false); … … 653 772 rpcPic->getPicYuvOrg()->setBorderExtension(false); 654 773 #endif 655 656 } 657 658 Void TEncTop::xInitVPS( )774 #endif 775 } 776 777 Void TEncTop::xInitVPS(TComVPS &vps, const TComSPS &sps) 659 778 { 660 779 // The SPS must have already been set up. … … 663 782 // Do initialization in TAppEncTop 664 783 #else 665 * m_cVPS.getPTL() = *m_cSPS.getPTL();666 m_cVPS.setMaxOpSets(1);667 m_cVPS.getTimingInfo()->setTimingInfoPresentFlag ( false );668 m_cVPS.setNumHrdParameters( 0 );669 670 m_cVPS.createHrdParamBuffer();671 for( UInt i = 0; i < m_cVPS.getNumHrdParameters(); i ++ )672 { 673 m_cVPS.setHrdOpSetIdx( 0, i );674 m_cVPS.setCprmsPresentFlag( false, i );784 *vps.getPTL() = *sps.getPTL(); 785 vps.setMaxOpSets(1); 786 vps.getTimingInfo()->setTimingInfoPresentFlag ( false ); 787 vps.setNumHrdParameters( 0 ); 788 789 vps.createHrdParamBuffer(); 790 for( UInt i = 0; i < vps.getNumHrdParameters(); i ++ ) 791 { 792 vps.setHrdOpSetIdx( 0, i ); 793 vps.setCprmsPresentFlag( false, i ); 675 794 // Set up HrdParameters here. 676 795 } … … 678 797 } 679 798 680 Void TEncTop::xInitSPS( )681 { 682 #if NH_MV 683 m_cSPS.setSPSId(getLayerIdInVps() );684 m_cSPS.setLayerId( getLayerId() );799 Void TEncTop::xInitSPS(TComSPS &sps) 800 { 801 #if NH_MV 802 //AOF( sps.getSPSId() == getLayerIdInVps() ); 803 sps.setLayerId( getLayerId() ); 685 804 // Code below needs to be moved to VPS 686 805 #endif 687 ProfileTierLevel& profileTierLevel = * m_cSPS.getPTL()->getGeneralPTL();806 ProfileTierLevel& profileTierLevel = *sps.getPTL()->getGeneralPTL(); 688 807 profileTierLevel.setLevelIdc(m_level); 689 808 profileTierLevel.setTierFlag(m_levelTier); … … 714 833 * that chooses the actual compatibility based upon options */ 715 834 #if NH_MV 716 m_cSPS.setUpdateRepFormatFlag ( false ); 717 Bool multiLayerExtensionFlag = ( getLayerId() > 0 ) && ( m_cVPS->getNumRefLayers( getLayerId() ) > 0 ); 835 sps.setUpdateRepFormatFlag ( false ); 718 836 719 m_cSPS.setSpsExtOrMaxSubLayersMinus1( multiLayerExtensionFlag ? 7 : m_maxTempLayer - 1 ); 837 Bool multiLayerExtensionFlag = ( getLayerId() > 0 && m_cVPS->getNumRefLayers( getLayerId() ) > 0 ); 838 sps.setSpsExtOrMaxSubLayersMinus1( multiLayerExtensionFlag ? 7 : m_maxTempLayer - 1 ); 720 839 if ( multiLayerExtensionFlag ) 721 840 { 722 m_cSPS.setSpsInferScalingListFlag ( true );723 m_cSPS.setSpsScalingListRefLayerId( m_cVPS->getIdRefLayer( getLayerId(), 0 ) );841 sps.setSpsInferScalingListFlag ( true ); 842 sps.setSpsScalingListRefLayerId( m_cVPS->getIdRefLayer( getLayerId(), 0 ) ); 724 843 #if NH_MV 725 844 if ( m_bUseDisparitySearchRangeRestriction ) 726 845 { 727 m_cSPS.setInterViewMvVertConstraintFlag ( true ) ;846 sps.setInterViewMvVertConstraintFlag ( true ) ; 728 847 } 729 848 #endif 730 849 } 731 m_cSPS.setSpsExtensionPresentFlag ( true );732 m_cSPS.setSpsMultilayerExtensionFlag ( true );850 sps.setSpsExtensionPresentFlag ( true ); 851 sps.setSpsMultilayerExtensionFlag ( true ); 733 852 #if NH_3D 734 m_cSPS.setSps3dExtensionFlag ( true );735 #endif 736 #endif 737 738 m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth );739 m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight );740 m_cSPS.setConformanceWindow ( m_conformanceWindow );741 m_cSPS.setMaxCUWidth ( m_maxCUWidth );742 m_cSPS.setMaxCUHeight ( m_maxCUHeight );743 m_cSPS.setMaxTotalCUDepth ( m_maxTotalCUDepth );853 sps.setSps3dExtensionFlag ( true ); 854 #endif 855 #endif 856 857 sps.setPicWidthInLumaSamples ( m_iSourceWidth ); 858 sps.setPicHeightInLumaSamples ( m_iSourceHeight ); 859 sps.setConformanceWindow ( m_conformanceWindow ); 860 sps.setMaxCUWidth ( m_maxCUWidth ); 861 sps.setMaxCUHeight ( m_maxCUHeight ); 862 sps.setMaxTotalCUDepth ( m_maxTotalCUDepth ); 744 863 #if NH_3D 745 864 assert( !getIsDepth() || m_chromaFormatIDC == CHROMA_400 ); 746 865 #endif 747 m_cSPS.setChromaFormatIdc( m_chromaFormatIDC);748 m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize);749 750 Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getLog2DiffMaxMinCodingBlockSize() );866 sps.setChromaFormatIdc( m_chromaFormatIDC); 867 sps.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize); 868 869 Int minCUSize = sps.getMaxCUWidth() >> ( sps.getLog2DiffMaxMinCodingBlockSize() ); 751 870 Int log2MinCUSize = 0; 752 871 while(minCUSize > 1) … … 756 875 } 757 876 758 m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize);759 760 m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize);761 m_cSPS.setUsePCM ( m_usePCM );762 m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize );763 764 m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize );765 m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize );766 m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter );767 m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra );768 769 m_cSPS.setTMVPFlagsPresent((getTMVPModeId() == 2 || getTMVPModeId() == 1));770 771 m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize );772 773 m_cSPS.setUseAMP ( m_useAMP );877 sps.setLog2MinCodingBlockSize(log2MinCUSize); 878 879 sps.setPCMLog2MinSize (m_uiPCMLog2MinSize); 880 sps.setUsePCM ( m_usePCM ); 881 sps.setPCMLog2MaxSize( m_pcmLog2MaxSize ); 882 883 sps.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); 884 sps.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize ); 885 sps.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter ); 886 sps.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra ); 887 888 sps.setSPSTemporalMVPEnabledFlag((getTMVPModeId() == 2 || getTMVPModeId() == 1)); 889 890 sps.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); 891 892 sps.setUseAMP ( m_useAMP ); 774 893 775 894 for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++) 776 895 { 777 m_cSPS.setBitDepth (ChannelType(channelType), m_bitDepth[channelType] );896 sps.setBitDepth (ChannelType(channelType), m_bitDepth[channelType] ); 778 897 #if O0043_BEST_EFFORT_DECODING 779 m_cSPS.setStreamBitDepth(ChannelType(channelType), m_bitDepth[channelType] ); 780 #endif 781 m_cSPS.setQpBDOffset (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8))); 782 m_cSPS.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType] ); 783 } 784 #if NH_MV 785 m_cSPS.inferRepFormat( m_cVPS, getLayerId(), true ); 786 #endif 787 m_cSPS.setUseSAO( m_bUseSAO ); 788 789 m_cSPS.setMaxTLayers( m_maxTempLayer ); 790 m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false ); 791 792 for (Int i = 0; i < min(m_cSPS.getMaxTLayers(),(UInt) MAX_TLAYER); i++ ) 793 { 794 m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); 795 m_cSPS.setNumReorderPics(m_numReorderPics[i], i); 898 sps.setStreamBitDepth(ChannelType(channelType), m_bitDepth[channelType] ); 899 #endif 900 sps.setQpBDOffset (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8))); 901 sps.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType] ); 902 } 903 sps.setUseSAO( m_bUseSAO ); 904 905 sps.setMaxTLayers( m_maxTempLayer ); 906 sps.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false ); 907 908 for (Int i = 0; i < min(sps.getMaxTLayers(),(UInt) MAX_TLAYER); i++ ) 909 { 910 sps.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); 911 sps.setNumReorderPics(m_numReorderPics[i], i); 796 912 } 797 913 #if NH_MV … … 804 920 if ( m_cVPS->getNecessaryLayerFlag( ols, is ) ) 805 921 { 806 m_cSPS.inferSpsMaxDecPicBufferingMinus1( m_cVPS, ols, targetDecLayerIdList[is], true );807 } 808 } 809 } 810 #endif 811 812 813 m_cSPS.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag );814 m_cSPS.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 );815 m_cSPS.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );816 m_cSPS.setVuiParametersPresentFlag(getVuiParametersPresentFlag());817 818 if ( m_cSPS.getVuiParametersPresentFlag())819 { 820 TComVUI* pcVUI = m_cSPS.getVuiParameters();922 sps.inferSpsMaxDecPicBufferingMinus1( m_cVPS, ols, targetDecLayerIdList[is], true ); 923 } 924 } 925 } 926 #endif 927 928 929 sps.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag ); 930 sps.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 ); 931 sps.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); 932 sps.setVuiParametersPresentFlag(getVuiParametersPresentFlag()); 933 934 if (sps.getVuiParametersPresentFlag()) 935 { 936 TComVUI* pcVUI = sps.getVuiParameters(); 821 937 pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag()); 822 938 pcVUI->setAspectRatioIdc(getAspectRatioIdc()); … … 855 971 pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical()); 856 972 } 857 m_cSPS.setNumLongTermRefPicSPS(NUM_LONG_TERM_REF_PIC_SPS);973 sps.setNumLongTermRefPicSPS(NUM_LONG_TERM_REF_PIC_SPS); 858 974 assert (NUM_LONG_TERM_REF_PIC_SPS <= MAX_NUM_LONG_TERM_REF_PICS); 859 975 for (Int k = 0; k < NUM_LONG_TERM_REF_PIC_SPS; k++) 860 976 { 861 m_cSPS.setLtRefPicPocLsbSps(k, 0); 862 m_cSPS.setUsedByCurrPicLtSPSFlag(k, 0); 863 } 864 865 #if U0132_TARGET_BITS_SATURATION 977 sps.setLtRefPicPocLsbSps(k, 0); 978 sps.setUsedByCurrPicLtSPSFlag(k, 0); 979 } 980 866 981 if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() || getCpbSaturationEnabled() ) 867 #else 868 if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() ) 869 #endif 870 { 871 xInitHrdParameters(); 982 { 983 xInitHrdParameters(sps); 872 984 } 873 985 if( getBufferingPeriodSEIEnabled() || getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() ) 874 986 { 875 m_cSPS.getVuiParameters()->setHrdParametersPresentFlag( true );987 sps.getVuiParameters()->setHrdParametersPresentFlag( true ); 876 988 } 877 989 878 990 // Set up SPS range extension settings 879 m_cSPS.getSpsRangeExtension().setTransformSkipRotationEnabledFlag(m_transformSkipRotationEnabledFlag);880 m_cSPS.getSpsRangeExtension().setTransformSkipContextEnabledFlag(m_transformSkipContextEnabledFlag);991 sps.getSpsRangeExtension().setTransformSkipRotationEnabledFlag(m_transformSkipRotationEnabledFlag); 992 sps.getSpsRangeExtension().setTransformSkipContextEnabledFlag(m_transformSkipContextEnabledFlag); 881 993 for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) 882 994 { 883 m_cSPS.getSpsRangeExtension().setRdpcmEnabledFlag(RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]); 884 } 885 m_cSPS.getSpsRangeExtension().setExtendedPrecisionProcessingFlag(m_extendedPrecisionProcessingFlag); 886 m_cSPS.getSpsRangeExtension().setIntraSmoothingDisabledFlag( m_intraSmoothingDisabledFlag ); 887 m_cSPS.getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag(m_highPrecisionOffsetsEnabledFlag); 888 m_cSPS.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag); 889 m_cSPS.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag); 890 #if NH_MV 891 m_cSPS.setSpsRangeExtensionsFlag( m_cSPS.getSpsRangeExtension().settingsDifferFromDefaults() ); 892 #endif 893 } 894 #if U0132_TARGET_BITS_SATURATION 995 sps.getSpsRangeExtension().setRdpcmEnabledFlag(RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]); 996 } 997 sps.getSpsRangeExtension().setExtendedPrecisionProcessingFlag(m_extendedPrecisionProcessingFlag); 998 sps.getSpsRangeExtension().setIntraSmoothingDisabledFlag( m_intraSmoothingDisabledFlag ); 999 sps.getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag(m_highPrecisionOffsetsEnabledFlag); 1000 sps.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag); 1001 sps.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag); 1002 #if NH_MV 1003 sps.setSpsRangeExtensionsFlag( sps.getSpsRangeExtension().settingsDifferFromDefaults() ); 1004 #endif 1005 #if NH_3D 1006 sps.setSps3dExtension( m_sps3dExtension ); 1007 #endif 1008 } 895 1009 // calculate scale value of bitrate and initial delay 896 1010 Int calcScale(Int x) 897 1011 { 1012 if (x==0) 1013 { 1014 return 0; 1015 } 898 1016 UInt iMask = 0xffffffff; 899 1017 Int ScaleValue = 32; … … 907 1025 return ScaleValue; 908 1026 } 909 #endif 910 Void TEncTop::xInitHrdParameters() 1027 Void TEncTop::xInitHrdParameters(TComSPS &sps) 911 1028 { 912 1029 Bool useSubCpbParams = (getSliceMode() > 0) || (getSliceSegmentMode() > 0); 913 1030 Int bitRate = getTargetBitrate(); 914 1031 Bool isRandomAccess = getIntraPeriod() > 0; 915 # if U0132_TARGET_BITS_SATURATION916 1032 Int cpbSize = getCpbSize(); 917 1033 1034 assert (cpbSize!=0); // CPB size may not be equal to zero. ToDo: have a better default and check for level constraints 918 1035 if( !getVuiParametersPresentFlag() && !getCpbSaturationEnabled() ) 919 #else920 if( !getVuiParametersPresentFlag() )921 #endif922 1036 { 923 1037 return; 924 1038 } 925 1039 926 TComVUI *vui = m_cSPS.getVuiParameters();1040 TComVUI *vui = sps.getVuiParameters(); 927 1041 TComHRD *hrd = vui->getHrdParameters(); 928 1042 … … 982 1096 } 983 1097 984 #if U0132_TARGET_BITS_SATURATION985 1098 if (calcScale(bitRate) <= 6) 986 1099 { … … 1000 1113 hrd->setCpbSizeScale(calcScale(cpbSize) - 4); 1001 1114 } 1002 #else1003 hrd->setBitRateScale( 4 ); // in units of 2^( 6 + 4 ) = 1,024 bps1004 hrd->setCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit1005 #endif1006 1115 1007 1116 hrd->setDuCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit … … 1036 1145 bitrateValue = bitRate / (1 << (6 + hrd->getBitRateScale()) ); // bitRate is in bits, so it needs to be scaled down 1037 1146 // CpbSize[ i ] = ( cpb_size_value_minus1[ i ] + 1 ) * 2^( 4 + cpb_size_scale ) 1038 #if U0132_TARGET_BITS_SATURATION1039 1147 cpbSizeValue = cpbSize / (1 << (4 + hrd->getCpbSizeScale()) ); // using bitRate results in 1 second CPB size 1040 #else1041 cpbSizeValue = bitRate / (1 << (4 + hrd->getCpbSizeScale()) ); // using bitRate results in 1 second CPB size1042 #endif1043 1044 1148 1045 1149 // DU CPB size could be smaller (i.e. bitrateValue / number of DUs), but we don't know … … 1066 1170 1067 1171 1068 Void TEncTop::xInitPPS() 1069 { 1070 #if NH_MV 1071 m_cPPS.setLayerId( getLayerId() ); 1172 Void TEncTop::xInitPPS(TComPPS &pps, const TComSPS &sps) const 1173 { 1174 1175 // pps ID already initialised. 1176 pps.setSPSId(sps.getSPSId()); 1177 1178 #if NH_MV 1179 AOF( pps.getPPSId() == getLayerIdInVps() ); 1180 pps.setLayerId( getLayerId() ); 1072 1181 #if NH_3D 1073 1182 // Check if this condition is still correct … … 1077 1186 #endif 1078 1187 { 1079 m_cPPS.setListsModificationPresentFlag( true ); 1080 } 1081 m_cPPS.setPPSId( getLayerIdInVps() ); 1082 m_cPPS.setSPSId( getLayerIdInVps() ); 1083 m_cPPS.setPpsMultilayerExtensionFlag ( true ); 1188 pps.setListsModificationPresentFlag( true ); 1189 } 1190 pps.setPpsMultilayerExtensionFlag ( true ); 1084 1191 #if NH_3D 1085 1192 // Might be used for DLT 1086 m_cPPS.setPps3dExtensionFlag ( getIsDepth() ); 1087 #endif 1088 #endif 1089 1090 #if NH_3D_DLT 1193 pps.setPps3dExtensionFlag ( getIsDepth() ); 1194 #endif 1195 #endif 1196 1197 #if NH_3D 1198 // This should be done in TEncAppTop 1199 TComDLT curDlt = m_cDLT; 1091 1200 // create mapping from depth layer indexes to layer ids 1092 1201 Int j=0; … … 1095 1204 Int layerId = getVPS()->getLayerIdInNuh(i); 1096 1205 if( getVPS()->getDepthId(layerId) ) 1097 m_cDLT.setDepthIdxToLayerId(j++, layerId);1098 } 1099 m_cPPS.setDLT( m_cDLT);1100 #endif 1101 1102 m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );1206 curDlt.setDepthIdxToLayerId(j++, layerId); 1207 } 1208 pps.setDLT( curDlt ); 1209 #endif 1210 1211 pps.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); 1103 1212 Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; 1104 1213 … … 1108 1217 } 1109 1218 1219 if ( getLumaLevelToDeltaQPMapping().isEnabled() ) 1220 { 1221 bUseDQP = true; 1222 } 1223 1110 1224 if (m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING) 1111 1225 { … … 1113 1227 } 1114 1228 1115 1116 1229 if ( m_RCEnableRateControl ) 1117 1230 { 1118 m_cPPS.setUseDQP(true);1119 m_cPPS.setMaxCuDQPDepth( 0 );1231 pps.setUseDQP(true); 1232 pps.setMaxCuDQPDepth( 0 ); 1120 1233 } 1121 1234 else if(bUseDQP) 1122 1235 { 1123 m_cPPS.setUseDQP(true);1124 m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth );1236 pps.setUseDQP(true); 1237 pps.setMaxCuDQPDepth( m_iMaxCuDQPDepth ); 1125 1238 } 1126 1239 else 1127 1240 { 1128 m_cPPS.setUseDQP(false);1129 m_cPPS.setMaxCuDQPDepth( 0 );1241 pps.setUseDQP(false); 1242 pps.setMaxCuDQPDepth( 0 ); 1130 1243 } 1131 1244 1132 1245 if ( m_diffCuChromaQpOffsetDepth >= 0 ) 1133 1246 { 1134 m_cPPS.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(m_diffCuChromaQpOffsetDepth);1135 m_cPPS.getPpsRangeExtension().clearChromaQpOffsetList();1136 m_cPPS.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6);1247 pps.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(m_diffCuChromaQpOffsetDepth); 1248 pps.getPpsRangeExtension().clearChromaQpOffsetList(); 1249 pps.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6); 1137 1250 /* todo, insert table entries from command line (NB, 0 should not be touched) */ 1138 1251 } 1139 1252 else 1140 1253 { 1141 m_cPPS.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(0); 1142 m_cPPS.getPpsRangeExtension().clearChromaQpOffsetList(); 1143 } 1144 m_cPPS.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag); 1145 m_cPPS.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA ]); 1146 m_cPPS.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]); 1147 1148 m_cPPS.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset ); 1149 m_cPPS.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset ); 1150 #if W0038_CQP_ADJ 1254 pps.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(0); 1255 pps.getPpsRangeExtension().clearChromaQpOffsetList(); 1256 } 1257 pps.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag); 1258 pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA ]); 1259 pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]); 1260 1261 if (getWCGChromaQPControl().isEnabled()) 1262 { 1263 const Int baseQp=m_iQP+pps.getPPSId(); 1264 const Double chromaQp = m_wcgChromaQpControl.chromaQpScale * baseQp + m_wcgChromaQpControl.chromaQpOffset; 1265 const Double dcbQP = m_wcgChromaQpControl.chromaCbQpScale * chromaQp; 1266 const Double dcrQP = m_wcgChromaQpControl.chromaCrQpScale * chromaQp; 1267 const Int cbQP =(Int)(dcbQP + ( dcbQP < 0 ? -0.5 : 0.5) ); 1268 const Int crQP =(Int)(dcrQP + ( dcrQP < 0 ? -0.5 : 0.5) ); 1269 pps.setQpOffset(COMPONENT_Cb, Clip3( -12, 12, min(0, cbQP) + m_chromaCbQpOffset )); 1270 pps.setQpOffset(COMPONENT_Cr, Clip3( -12, 12, min(0, crQP) + m_chromaCrQpOffset)); 1271 } 1272 else 1273 { 1274 pps.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset ); 1275 pps.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset ); 1276 } 1151 1277 Bool bChromaDeltaQPEnabled = false; 1152 1278 { … … 1164 1290 } 1165 1291 } 1166 m_cPPS.setSliceChromaQpFlag(bChromaDeltaQPEnabled);1167 #endif 1168 1169 m_cPPS.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag);1170 m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0));1171 m_cPPS.setUseWP( m_useWeightedPred );1172 m_cPPS.setWPBiPred( m_useWeightedBiPred);1173 m_cPPS.setOutputFlagPresentFlag( false ); 1174 #if NH_MV 1175 m_cPPS.setNumExtraSliceHeaderBits( 2 ); 1176 #endif 1177 m_cPPS.setSignHideFlag(getSignHideFlag()); 1292 pps.setSliceChromaQpFlag(bChromaDeltaQPEnabled); 1293 1294 pps.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag ); 1295 pps.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) ); 1296 pps.setUseWP( m_useWeightedPred ); 1297 pps.setWPBiPred( m_useWeightedBiPred ); 1298 pps.setOutputFlagPresentFlag( false ); 1299 #if NH_MV 1300 pps.setNumExtraSliceHeaderBits( 2 ); 1301 #endif 1302 pps.setSignDataHidingEnabledFlag(getSignDataHidingEnabledFlag()); 1303 1178 1304 if ( getDeblockingFilterMetric() ) 1179 1305 { 1180 m_cPPS.setDeblockingFilterOverrideEnabledFlag(true);1181 m_cPPS.setPicDisableDeblockingFilterFlag(false);1306 pps.setDeblockingFilterOverrideEnabledFlag(true); 1307 pps.setPPSDeblockingFilterDisabledFlag(false); 1182 1308 } 1183 1309 else 1184 1310 { 1185 m_cPPS.setDeblockingFilterOverrideEnabledFlag( !getLoopFilterOffsetInPPS() );1186 m_cPPS.setPicDisableDeblockingFilterFlag( getLoopFilterDisable() );1187 } 1188 1189 if (! m_cPPS.getPicDisableDeblockingFilterFlag())1190 { 1191 m_cPPS.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() );1192 m_cPPS.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() );1311 pps.setDeblockingFilterOverrideEnabledFlag( !getLoopFilterOffsetInPPS() ); 1312 pps.setPPSDeblockingFilterDisabledFlag( getLoopFilterDisable() ); 1313 } 1314 1315 if (! pps.getPPSDeblockingFilterDisabledFlag()) 1316 { 1317 pps.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() ); 1318 pps.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() ); 1193 1319 } 1194 1320 else 1195 1321 { 1196 m_cPPS.setDeblockingFilterBetaOffsetDiv2(0);1197 m_cPPS.setDeblockingFilterTcOffsetDiv2(0);1322 pps.setDeblockingFilterBetaOffsetDiv2(0); 1323 pps.setDeblockingFilterTcOffsetDiv2(0); 1198 1324 } 1199 1325 1200 1326 // deblockingFilterControlPresentFlag is true if any of the settings differ from the inferred values: 1201 const Bool deblockingFilterControlPresentFlag = m_cPPS.getDeblockingFilterOverrideEnabledFlag() ||1202 m_cPPS.getPicDisableDeblockingFilterFlag()||1203 m_cPPS.getDeblockingFilterBetaOffsetDiv2() != 0 ||1204 m_cPPS.getDeblockingFilterTcOffsetDiv2() != 0;1205 1206 m_cPPS.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag);1207 1208 m_cPPS.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 );1209 m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);1210 m_cPPS.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag );1327 const Bool deblockingFilterControlPresentFlag = pps.getDeblockingFilterOverrideEnabledFlag() || 1328 pps.getPPSDeblockingFilterDisabledFlag() || 1329 pps.getDeblockingFilterBetaOffsetDiv2() != 0 || 1330 pps.getDeblockingFilterTcOffsetDiv2() != 0; 1331 1332 pps.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag); 1333 1334 pps.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 ); 1335 pps.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); 1336 pps.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag ); 1211 1337 1212 1338 … … 1233 1359 } 1234 1360 assert(bestPos <= 15); 1235 m_cPPS.setNumRefIdxL0DefaultActive(bestPos);1236 m_cPPS.setNumRefIdxL1DefaultActive(bestPos);1237 m_cPPS.setTransquantBypassEnableFlag(getTransquantBypassEnableFlag());1238 m_cPPS.setUseTransformSkip( m_useTransformSkip );1239 m_cPPS.getPpsRangeExtension().setLog2MaxTransformSkipBlockSize( m_log2MaxTransformSkipBlockSize );1361 pps.setNumRefIdxL0DefaultActive(bestPos); 1362 pps.setNumRefIdxL1DefaultActive(bestPos); 1363 pps.setTransquantBypassEnabledFlag(getTransquantBypassEnabledFlag()); 1364 pps.setUseTransformSkip( m_useTransformSkip ); 1365 pps.getPpsRangeExtension().setLog2MaxTransformSkipBlockSize( m_log2MaxTransformSkipBlockSize ); 1240 1366 1241 1367 if (m_sliceSegmentMode != NO_SLICES) 1242 1368 { 1243 m_cPPS.setDependentSliceSegmentsEnabledFlag( true ); 1244 } 1369 pps.setDependentSliceSegmentsEnabledFlag( true ); 1370 } 1371 1372 xInitPPSforTiles(pps); 1245 1373 } 1246 1374 1247 1375 //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. 1248 Void TEncTop::xInitRPS( Bool isFieldCoding)1376 Void TEncTop::xInitRPS(TComSPS &sps, Bool isFieldCoding) 1249 1377 { 1250 1378 TComReferencePictureSet* rps; 1251 1379 1252 m_cSPS.createRPSList(getGOPSize() + m_extraRPSs + 1);1253 TComRPSList* rpsList = m_cSPS.getRPSList();1380 sps.createRPSList(getGOPSize() + m_extraRPSs + 1); 1381 TComRPSList* rpsList = sps.getRPSList(); 1254 1382 1255 1383 for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) 1256 1384 { 1257 GOPEntryge = getGOPEntry(i);1385 const GOPEntry &ge = getGOPEntry(i); 1258 1386 rps = rpsList->getReferencePictureSet(i); 1259 1387 rps->setNumberOfPictures(ge.m_numRefPics); … … 1480 1608 } 1481 1609 1482 Void TEncTop::xInitPPSforTiles() 1483 { 1484 m_cPPS.setTileUniformSpacingFlag( m_tileUniformSpacingFlag ); 1485 m_cPPS.setNumTileColumnsMinus1( m_iNumColumnsMinus1 ); 1486 m_cPPS.setNumTileRowsMinus1( m_iNumRowsMinus1 ); 1610 Void TEncTop::xInitPPSforTiles(TComPPS &pps) 1611 #if NH_MV 1612 const 1613 #endif 1614 { 1615 pps.setTileUniformSpacingFlag( m_tileUniformSpacingFlag ); 1616 pps.setNumTileColumnsMinus1( m_iNumColumnsMinus1 ); 1617 pps.setNumTileRowsMinus1( m_iNumRowsMinus1 ); 1487 1618 if( !m_tileUniformSpacingFlag ) 1488 1619 { 1489 m_cPPS.setTileColumnWidth( m_tileColumnWidth );1490 m_cPPS.setTileRowHeight( m_tileRowHeight );1491 } 1492 m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag );1620 pps.setTileColumnWidth( m_tileColumnWidth ); 1621 pps.setTileRowHeight( m_tileRowHeight ); 1622 } 1623 pps.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag ); 1493 1624 1494 1625 // # substreams is "per tile" when tiles are independent. … … 1557 1688 } 1558 1689 1690 #if JCTVC_Y0038_PARAMS 1691 #if NH_MV 1692 Void TEncTop::setParamSetChanged(Int id, Bool isPps ) 1693 { 1694 if ( isPps ) 1695 { 1696 m_ppsMap.setChangedFlag(id); 1697 } 1698 else 1699 { 1700 m_spsMap.setChangedFlag(id); 1701 } 1702 } 1703 #else 1704 1705 Void TEncTop::setParamSetChanged(Int spsId, Int ppsId) 1706 { 1707 m_ppsMap.setChangedFlag(ppsId); 1708 m_spsMap.setChangedFlag(spsId); 1709 } 1710 #endif 1711 #endif 1712 1713 Bool TEncTop::PPSNeedsWriting(Int ppsId) 1714 { 1715 Bool bChanged=m_ppsMap.getChangedFlag(ppsId); 1716 m_ppsMap.clearChangedFlag(ppsId); 1717 return bChanged; 1718 } 1719 1720 Bool TEncTop::SPSNeedsWriting(Int spsId) 1721 { 1722 Bool bChanged=m_spsMap.getChangedFlag(spsId); 1723 m_spsMap.clearChangedFlag(spsId); 1724 return bChanged; 1725 } 1726 1727 #if X0038_LAMBDA_FROM_QP_CAPABILITY 1728 Int TEncCfg::getQPForPicture(const UInt gopIndex, const TComSlice *pSlice) const 1729 { 1730 const Int lumaQpBDOffset = pSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); 1731 Int qp; 1732 1733 if (getCostMode()==COST_LOSSLESS_CODING) 1734 { 1735 qp=LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP; 1736 } 1737 else 1738 { 1739 const SliceType sliceType=pSlice->getSliceType(); 1740 1741 qp = getBaseQP(); 1742 1743 #if JVET_G0101_QP_SWITCHING 1744 // modify QP if a fractional QP was originally specified, cause dQPs to be 0 or 1. 1745 const Int* pdQPs = getdQPs(); 1746 if ( pdQPs ) 1747 { 1748 qp += pdQPs[ pSlice->getPOC() ]; 1749 } 1750 #endif 1751 1752 if(sliceType==I_SLICE) 1753 { 1754 qp += getIntraQPOffset(); 1755 } 1756 else 1757 { 1758 // Only adjust QP when not lossless 1759 if (!(( getMaxDeltaQP() == 0 ) && (!getLumaLevelToDeltaQPMapping().isEnabled()) && (qp == -lumaQpBDOffset ) && (pSlice->getPPS()->getTransquantBypassEnabledFlag()))) 1760 { 1761 const GOPEntry &gopEntry=getGOPEntry(gopIndex); 1762 // adjust QP according to the QP offset for the GOP entry. 1763 qp +=gopEntry.m_QPOffset; 1764 1765 // adjust QP according to QPOffsetModel for the GOP entry. 1766 Double dqpOffset=qp*gopEntry.m_QPOffsetModelScale+gopEntry.m_QPOffsetModelOffset+0.5; 1767 Int qpOffset = (Int)floor(Clip3<Double>(0.0, 3.0, dqpOffset)); 1768 qp += qpOffset ; 1769 } 1770 } 1771 1772 #if !JVET_G0101_QP_SWITCHING 1773 // modify QP if a fractional QP was originally specified, cause dQPs to be 0 or 1. 1774 const Int* pdQPs = getdQPs(); 1775 if ( pdQPs ) 1776 { 1777 qp += pdQPs[ pSlice->getPOC() ]; 1778 } 1779 #endif 1780 } 1781 qp = Clip3( -lumaQpBDOffset, MAX_QP, qp ); 1782 return qp; 1783 } 1784 #endif 1785 1786 1559 1787 #if NH_MV 1560 1788 Int TEncTop::getFrameId(Int iGOPid) … … 1583 1811 } 1584 1812 return pcPic; 1813 } 1814 1815 1816 Int TEncTop::xGetPsIdAndPsLayerId( ) 1817 { 1818 // LayerId of the parameter set and the Parameter set id are always equal in HTM 1819 return ( m_sendParameterSets ? ( getLayerId() == 0 ? 0 : 1 ) : getLayerId() ); 1585 1820 } 1586 1821 … … 1700 1935 } 1701 1936 } 1702 #endif 1937 1938 1939 #endif 1940 1703 1941 1704 1942 //! \}
Note: See TracChangeset for help on using the changeset viewer.