Changeset 540 in SHVCSoftware for trunk/source/Lib/TLibEncoder/TEncSlice.cpp
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/SHM-4.1-dev (added) merged: 501-539 /trunk merged: 499
- Property svn:mergeinfo changed
-
trunk/source
- Property svn:mergeinfo changed
/branches/SHM-4.1-dev/source (added) merged: 502-522,524-533,535,537-539
- Property svn:mergeinfo changed
-
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r494 r540 295 295 dQP += pdQPs[ rpcSlice->getPOC() ]; 296 296 } 297 #if !RATE_CONTROL_LAMBDA_DOMAIN298 if ( m_pcCfg->getUseRateCtrl())299 {300 dQP = m_pcRateCtrl->getFrameQP(rpcSlice->isReferenced(), rpcSlice->getPOC());301 }302 #endif303 297 // ------------------------------------------------------------------------------------------------------------------ 304 298 // Lambda computation … … 386 380 // store lambda 387 381 m_pcRdCost ->setLambda( dLambda ); 388 #if WEIGHTED_CHROMA_DISTORTION389 382 // for RDO 390 383 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 391 Double weight = 1.0;384 Double weight[2] = { 1.0, 1.0 }; 392 385 Int qpc; 393 386 Int chromaQPOffset; … … 395 388 chromaQPOffset = rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb(); 396 389 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 397 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset398 m_pcRdCost->setCbDistortionWeight(weight );390 weight[0] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 391 m_pcRdCost->setCbDistortionWeight(weight[0]); 399 392 400 393 chromaQPOffset = rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr(); 401 394 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 402 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 395 weight[1] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 396 m_pcRdCost->setCrDistortionWeight(weight[1]); 397 403 398 #if JCTVC_M0259_LAMBDAREFINEMENT 404 399 if( rpcSlice->getLayerId() > 0 && m_ppcTEncTop[layerId]->getNumActiveRefLayers() && m_pcCfg->getGOPSize() >= 8 && rpcSlice->isIntra() == false && depth == 0 ) 405 400 { 406 401 dLambda *= 1.1; 407 weight *= 1.15; 408 } 409 #endif 410 m_pcRdCost->setCrDistortionWeight(weight); 411 #endif 412 402 weight[1] *= 1.15; 403 weight[0] *= 1.15; 404 405 m_pcRdCost ->setLambda( dLambda ); 406 m_pcRdCost->setCbDistortionWeight(weight[0]); 407 m_pcRdCost->setCrDistortionWeight(weight[1]); 408 } 409 #endif 410 411 const Double lambdaArray[3] = {dLambda, (dLambda / weight[0]), (dLambda / weight[1])}; 412 413 413 #if RDOQ_CHROMA_LAMBDA 414 414 // for RDOQ 415 m_pcTrQuant->setLambda ( dLambda, dLambda / weight);415 m_pcTrQuant->setLambdas( lambdaArray ); 416 416 #else 417 417 m_pcTrQuant->setLambda( dLambda ); 418 418 #endif 419 419 420 #if SAO_CHROMA_LAMBDA421 420 // For SAO 422 rpcSlice ->setLambda( dLambda, dLambda / weight ); 423 #else 424 rpcSlice ->setLambda( dLambda ); 425 #endif 421 rpcSlice->setLambdas( lambdaArray ); 426 422 427 423 #if HB_LAMBDA_FOR_LDC … … 430 426 431 427 #if SVC_EXTENSION 432 if( m_pcCfg->getLayerId() > 0)428 if( m_pcCfg->getLayerId() > 0 && m_pcCfg->getNumActiveRefLayers() > 0 ) 433 429 { 434 430 eSliceType=B_SLICE; … … 500 496 501 497 pcPic->setTLayer( m_pcCfg->getGOPEntry(iGOPid).m_temporalId ); 502 503 498 if(eSliceType==I_SLICE) 504 499 { … … 517 512 rpcSlice->setSliceSegmentArgument ( m_pcCfg->getSliceSegmentArgument() ); 518 513 rpcSlice->setMaxNumMergeCand ( m_pcCfg->getMaxNumMergeCand() ); 514 #if HIGHER_LAYER_IRAP_SKIP_FLAG 515 if (m_pcCfg->getSkipPictureAtArcSwitch() && m_pcCfg->getAdaptiveResolutionChange() > 0 && rpcSlice->getLayerId() == 1 && rpcSlice->getPOC() == m_pcCfg->getAdaptiveResolutionChange()) 516 { 517 rpcSlice->setMaxNumMergeCand ( 1 ); 518 } 519 #endif 519 520 xStoreWPparam( pPPS->getUseWP(), pPPS->getWPBiPred() ); 520 521 … … 546 547 } 547 548 548 #if RATE_CONTROL_LAMBDA_DOMAIN549 549 Void TEncSlice::resetQP( TComPic* pic, Int sliceQP, Double lambda ) 550 550 { … … 555 555 slice->setSliceQpBase ( sliceQP ); 556 556 m_pcRdCost ->setLambda( lambda ); 557 #if WEIGHTED_CHROMA_DISTORTION558 557 // for RDO 559 558 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 560 Double weight ;559 Double weight[2] = { 1.0, 1.0 }; 561 560 Int qpc; 562 561 Int chromaQPOffset; … … 564 563 chromaQPOffset = slice->getPPS()->getChromaCbQpOffset() + slice->getSliceQpDeltaCb(); 565 564 qpc = Clip3( 0, 57, sliceQP + chromaQPOffset); 566 weight = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset567 m_pcRdCost->setCbDistortionWeight(weight );565 weight[0] = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 566 m_pcRdCost->setCbDistortionWeight(weight[0]); 568 567 569 568 chromaQPOffset = slice->getPPS()->getChromaCrQpOffset() + slice->getSliceQpDeltaCr(); 570 569 qpc = Clip3( 0, 57, sliceQP + chromaQPOffset); 571 weight = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 572 m_pcRdCost->setCrDistortionWeight(weight); 573 #endif 570 weight[1] = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 571 m_pcRdCost->setCrDistortionWeight(weight[1]); 572 573 const Double lambdaArray[3] = {lambda, (lambda / weight[0]), (lambda / weight[1])}; 574 574 575 575 #if RDOQ_CHROMA_LAMBDA 576 576 // for RDOQ 577 m_pcTrQuant->setLambda ( lambda, lambda / weight);577 m_pcTrQuant->setLambdas( lambdaArray ); 578 578 #else 579 579 m_pcTrQuant->setLambda( lambda ); 580 580 #endif 581 581 582 #if SAO_CHROMA_LAMBDA583 582 // For SAO 584 slice ->setLambda( lambda, lambda / weight ); 585 #else 586 slice ->setLambda( lambda ); 587 #endif 583 slice->setLambdas( lambdaArray ); 588 584 } 589 #else590 /**591 - lambda re-computation based on rate control QP592 */593 Void TEncSlice::xLamdaRecalculation(Int changeQP, Int idGOP, Int depth, SliceType eSliceType, TComSPS* pcSPS, TComSlice* pcSlice)594 {595 Int qp;596 Double recalQP= (Double)changeQP;597 Double origQP = (Double)recalQP;598 Double lambda;599 600 // pre-compute lambda and QP values for all possible QP candidates601 for ( Int deltqQpIdx = 0; deltqQpIdx < 2 * m_pcCfg->getDeltaQpRD() + 1; deltqQpIdx++ )602 {603 // compute QP value604 recalQP = origQP + ((deltqQpIdx+1)>>1)*(deltqQpIdx%2 ? -1 : 1);605 606 // compute lambda value607 Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 );608 Int SHIFT_QP = 12;609 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames );610 #if FULL_NBIT611 Int bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8);612 #else613 Int bitdepth_luma_qp_scale = 0;614 #endif615 Double qp_temp = (Double) recalQP + bitdepth_luma_qp_scale - SHIFT_QP;616 #if FULL_NBIT617 Double qp_temp_orig = (Double) recalQP - SHIFT_QP;618 #endif619 // Case #1: I or P-slices (key-frame)620 Double dQPFactor = m_pcCfg->getGOPEntry(idGOP).m_QPFactor;621 if ( eSliceType==I_SLICE )622 {623 dQPFactor=0.57*dLambda_scale;624 }625 lambda = dQPFactor*pow( 2.0, qp_temp/3.0 );626 627 if ( depth>0 )628 {629 #if FULL_NBIT630 lambda *= Clip3( 2.00, 4.00, (qp_temp_orig / 6.0) ); // (j == B_SLICE && p_cur_frm->layer != 0 )631 #else632 lambda *= Clip3( 2.00, 4.00, (qp_temp / 6.0) ); // (j == B_SLICE && p_cur_frm->layer != 0 )633 #endif634 }635 636 // if hadamard is used in ME process637 if ( !m_pcCfg->getUseHADME() )638 {639 lambda *= 0.95;640 }641 642 #if REPN_FORMAT_IN_VPS643 qp = max( -pcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( recalQP + 0.5 ) ) );644 #else645 qp = max( -pcSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( recalQP + 0.5 ) ) );646 #endif647 648 m_pdRdPicLambda[deltqQpIdx] = lambda;649 m_pdRdPicQp [deltqQpIdx] = recalQP;650 m_piRdPicQp [deltqQpIdx] = qp;651 }652 653 // obtain dQP = 0 case654 lambda = m_pdRdPicLambda[0];655 recalQP = m_pdRdPicQp [0];656 qp = m_piRdPicQp [0];657 658 if( pcSlice->getSliceType( ) != I_SLICE )659 {660 lambda *= m_pcCfg->getLambdaModifier( depth );661 }662 663 // store lambda664 m_pcRdCost ->setLambda( lambda );665 #if WEIGHTED_CHROMA_DISTORTION666 // for RDO667 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma.668 Double weight = 1.0;669 Int qpc;670 Int chromaQPOffset;671 672 chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb();673 qpc = Clip3( 0, 57, qp + chromaQPOffset);674 weight = pow( 2.0, (qp-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset675 m_pcRdCost->setCbDistortionWeight(weight);676 677 chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr();678 qpc = Clip3( 0, 57, qp + chromaQPOffset);679 weight = pow( 2.0, (qp-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset680 m_pcRdCost->setCrDistortionWeight(weight);681 #endif682 683 #if RDOQ_CHROMA_LAMBDA684 // for RDOQ685 m_pcTrQuant->setLambda( lambda, lambda / weight );686 #else687 m_pcTrQuant->setLambda( lambda );688 #endif689 690 #if SAO_CHROMA_LAMBDA691 // For SAO692 pcSlice ->setLambda( lambda, lambda / weight );693 #else694 pcSlice ->setLambda( lambda );695 #endif696 }697 #endif698 585 // ==================================================================================================================== 699 586 // Public member functions … … 735 622 } 736 623 737 #if RATE_CONTROL_LAMBDA_DOMAIN738 624 if ( m_pcCfg->getUseRateCtrl() ) 739 625 { … … 741 627 assert(0); 742 628 } 743 #endif744 629 745 630 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); … … 773 658 #endif 774 659 m_pcRdCost ->setLambda ( m_pdRdPicLambda[uiQpIdx] ); 775 #if WEIGHTED_CHROMA_DISTORTION776 660 // for RDO 777 661 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 778 662 Int iQP = m_piRdPicQp [uiQpIdx]; 779 Double weight = 1.0;663 Double weight[2] = { 1.0, 1.0 }; 780 664 Int qpc; 781 665 Int chromaQPOffset; … … 783 667 chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb(); 784 668 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 785 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset786 m_pcRdCost->setCbDistortionWeight(weight );669 weight[0] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 670 m_pcRdCost->setCbDistortionWeight(weight[0]); 787 671 788 672 chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr(); 789 673 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 790 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset791 m_pcRdCost->setCrDistortionWeight(weight );792 #endif 793 674 weight[1] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 675 m_pcRdCost->setCrDistortionWeight(weight[1]); 676 677 const Double lambdaArray[3] = {m_pdRdPicLambda[uiQpIdx], (m_pdRdPicLambda[uiQpIdx] / weight[0]), (m_pdRdPicLambda[uiQpIdx] / weight[1])}; 794 678 #if RDOQ_CHROMA_LAMBDA 795 679 // for RDOQ 796 m_pcTrQuant ->setLambda( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight);680 m_pcTrQuant->setLambdas( lambdaArray ); 797 681 #else 798 682 m_pcTrQuant ->setLambda ( m_pdRdPicLambda[uiQpIdx] ); 799 683 #endif 800 #if SAO_CHROMA_LAMBDA801 684 // For SAO 802 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight ); 803 #else 804 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdx] ); 805 #endif 685 pcSlice->setLambdas( lambdaArray ); 806 686 807 687 // try compress … … 830 710 #endif 831 711 m_pcRdCost ->setLambda ( m_pdRdPicLambda[uiQpIdxBest] ); 832 #if WEIGHTED_CHROMA_DISTORTION833 712 // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma. 834 713 Int iQP = m_piRdPicQp [uiQpIdxBest]; 835 Double weight = 1.0;714 Double weight[2] = { 1.0, 1.0 }; 836 715 Int qpc; 837 716 Int chromaQPOffset; … … 839 718 chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb(); 840 719 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 841 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset842 m_pcRdCost->setCbDistortionWeight(weight );720 weight[0] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 721 m_pcRdCost->setCbDistortionWeight(weight[0]); 843 722 844 723 chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr(); 845 724 qpc = Clip3( 0, 57, iQP + chromaQPOffset); 846 weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset847 m_pcRdCost->setCrDistortionWeight(weight );848 #endif 849 725 weight[1] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset 726 m_pcRdCost->setCrDistortionWeight(weight[1]); 727 728 const Double lambdaArray[3] = {m_pdRdPicLambda[uiQpIdxBest], (m_pdRdPicLambda[uiQpIdxBest] / weight[0]), (m_pdRdPicLambda[uiQpIdxBest] / weight[1])}; 850 729 #if RDOQ_CHROMA_LAMBDA 851 730 // for RDOQ 852 m_pcTrQuant ->setLambda( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight);731 m_pcTrQuant->setLambdas( lambdaArray ); 853 732 #else 854 733 m_pcTrQuant ->setLambda ( m_pdRdPicLambda[uiQpIdxBest] ); 855 734 #endif 856 #if SAO_CHROMA_LAMBDA857 735 // For SAO 858 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight ); 859 #else 860 pcSlice ->setLambda ( m_pdRdPicLambda[uiQpIdxBest] ); 861 #endif 736 pcSlice->setLambdas( lambdaArray ); 862 737 } 863 738 864 739 /** \param rpcPic picture class 865 740 */ 866 #if RATE_CONTROL_INTRA867 741 Void TEncSlice::calCostSliceI(TComPic*& rpcPic) 868 742 { … … 903 777 m_pcRateCtrl->getRCPic()->setTotalIntraCost(iSumHadSlice); 904 778 } 905 #endif906 779 907 780 Void TEncSlice::compressSlice( TComPic*& rpcPic ) … … 1031 904 UInt uiTileStartLCU = 0; 1032 905 UInt uiTileLCUX = 0; 1033 1034 906 Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag(); 1035 907 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); … … 1080 952 pcCU->initCU( rpcPic, uiCUAddr ); 1081 953 1082 #if !RATE_CONTROL_LAMBDA_DOMAIN1083 if(m_pcCfg->getUseRateCtrl())1084 {1085 if(m_pcRateCtrl->calculateUnitQP())1086 {1087 xLamdaRecalculation(m_pcRateCtrl->getUnitQP(), m_pcRateCtrl->getGOPId(), pcSlice->getDepth(), pcSlice->getSliceType(), pcSlice->getSPS(), pcSlice );1088 }1089 }1090 #endif1091 954 // inherit from TR if necessary, select substream to use. 1092 955 if( m_pcCfg->getUseSBACRD() ) … … 1163 1026 ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true); 1164 1027 1165 #if RATE_CONTROL_LAMBDA_DOMAIN1166 1028 Double oldLambda = m_pcRdCost->getLambda(); 1167 1029 if ( m_pcCfg->getUseRateCtrl() ) … … 1171 1033 Double bpp = -1.0; 1172 1034 1173 #if M0036_RC_IMPROVEMENT1174 1035 if ( ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE && m_pcCfg->getForceIntraQP() ) || !m_pcCfg->getLCULevelRC() ) 1175 #else1176 if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE || !m_pcCfg->getLCULevelRC() )1177 #endif1178 1036 { 1179 1037 estQP = pcSlice->getSliceQp(); … … 1181 1039 else 1182 1040 { 1183 #if RATE_CONTROL_INTRA1184 1041 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType()); 1185 1042 if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE) … … 1192 1049 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() ); 1193 1050 } 1194 #else1195 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp();1196 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );1197 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() );1198 #endif1199 1051 1200 1052 #if REPN_FORMAT_IN_VPS … … 1205 1057 1206 1058 m_pcRdCost->setLambda(estLambda); 1207 #if M0036_RC_IMPROVEMENT1208 1059 #if RDOQ_CHROMA_LAMBDA 1209 1060 // set lambda for RDOQ 1210 1061 Double weight=m_pcRdCost->getChromaWeight(); 1211 m_pcTrQuant->setLambda( estLambda, estLambda / weight ); 1062 const Double lambdaArray[3] = { estLambda, (estLambda / weight), (estLambda / weight) }; 1063 m_pcTrQuant->setLambdas( lambdaArray ); 1212 1064 #else 1213 1065 m_pcTrQuant->setLambda( estLambda ); 1214 #endif1215 1066 #endif 1216 1067 } … … 1219 1070 pcCU->getSlice()->setSliceQpBase( estQP ); 1220 1071 } 1221 #endif1222 1072 1223 1073 // run CU encoder 1224 1074 m_pcCuEncoder->compressCU( pcCU ); 1225 1226 #if !TICKET_1090_FIX1227 #if RATE_CONTROL_LAMBDA_DOMAIN1228 if ( m_pcCfg->getUseRateCtrl() )1229 {1230 #if !M0036_RC_IMPROVEMENT1231 UInt SAD = m_pcCuEncoder->getLCUPredictionSAD();1232 #if REPN_FORMAT_IN_VPS1233 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );1234 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->>getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );1235 #else1236 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );1237 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );1238 #endif1239 Double MAD = (Double)SAD / (Double)(height * width);1240 MAD = MAD * MAD;1241 ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;1242 #endif1243 1244 Int actualQP = g_RCInvalidQPValue;1245 Double actualLambda = m_pcRdCost->getLambda();1246 Int actualBits = pcCU->getTotalBits();1247 Int numberOfEffectivePixels = 0;1248 for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ )1249 {1250 if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) )1251 {1252 numberOfEffectivePixels = numberOfEffectivePixels + 16;1253 break;1254 }1255 }1256 1257 if ( numberOfEffectivePixels == 0 )1258 {1259 actualQP = g_RCInvalidQPValue;1260 }1261 else1262 {1263 actualQP = pcCU->getQP( 0 );1264 }1265 m_pcRdCost->setLambda(oldLambda);1266 #if RATE_CONTROL_INTRA1267 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,1268 pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );1269 #else1270 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() );1271 #endif1272 }1273 #endif1274 #endif1275 1075 1276 1076 // restore entropy coder to an initial stage … … 1306 1106 } 1307 1107 1308 #if TICKET_1090_FIX1309 #if RATE_CONTROL_LAMBDA_DOMAIN1310 1108 if ( m_pcCfg->getUseRateCtrl() ) 1311 1109 { 1312 #if !M0036_RC_IMPROVEMENT1313 UInt SAD = m_pcCuEncoder->getLCUPredictionSAD();1314 #if REPN_FORMAT_IN_VPS1315 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );1316 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );1317 #else1318 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );1319 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );1320 #endif1321 Double MAD = (Double)SAD / (Double)(height * width);1322 MAD = MAD * MAD;1323 ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;1324 #endif1325 1110 1326 1111 Int actualQP = g_RCInvalidQPValue; … … 1347 1132 m_pcRdCost->setLambda(oldLambda); 1348 1133 1349 #if RATE_CONTROL_INTRA1350 1134 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, 1351 1135 pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() ); 1352 #else 1353 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() ); 1354 #endif 1355 } 1356 #endif 1357 #endif 1136 } 1358 1137 } 1359 1138 // other case: encodeCU is not called … … 1377 1156 m_dPicRdCost += pcCU->getTotalCost(); 1378 1157 m_uiPicDist += pcCU->getTotalDistortion(); 1379 #if !RATE_CONTROL_LAMBDA_DOMAIN1380 if(m_pcCfg->getUseRateCtrl())1381 {1382 m_pcRateCtrl->updateLCUData(pcCU, pcCU->getTotalBits(), pcCU->getQP(0));1383 m_pcRateCtrl->updataRCUnitStatus();1384 }1385 #endif1386 1158 } 1387 1159 if ((pcSlice->getPPS()->getNumSubstreams() > 1) && !depSliceSegmentsEnabled) … … 1398 1170 } 1399 1171 xRestoreWPparam( pcSlice ); 1400 #if !RATE_CONTROL_LAMBDA_DOMAIN1401 if(m_pcCfg->getUseRateCtrl())1402 {1403 m_pcRateCtrl->updateFrameData(m_uiPicTotalBits);1404 }1405 #endif1406 1172 } 1407 1173 … … 1603 1369 1604 1370 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 1371 #if HM_CLEANUP_SAO 1372 if ( pcSlice->getSPS()->getUseSAO() ) 1373 { 1374 if (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) 1375 { 1376 SAOBlkParam& saoblkParam = (rpcPic->getPicSym()->getSAOBlkParam())[uiCUAddr]; 1377 Bool sliceEnabled[NUM_SAO_COMPONENTS]; 1378 sliceEnabled[SAO_Y] = pcSlice->getSaoEnabledFlag(); 1379 sliceEnabled[SAO_Cb]= sliceEnabled[SAO_Cr]= pcSlice->getSaoEnabledFlagChroma(); 1380 1381 Bool leftMergeAvail = false; 1382 Bool aboveMergeAvail= false; 1383 //merge left condition 1384 Int rx = (uiCUAddr % uiWidthInLCUs); 1385 if(rx > 0) 1386 { 1387 leftMergeAvail = rpcPic->getSAOMergeAvailability(uiCUAddr, uiCUAddr-1); 1388 } 1389 1390 //merge up condition 1391 Int ry = (uiCUAddr / uiWidthInLCUs); 1392 if(ry > 0) 1393 { 1394 aboveMergeAvail = rpcPic->getSAOMergeAvailability(uiCUAddr, uiCUAddr-uiWidthInLCUs); 1395 } 1396 1397 m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam,sliceEnabled, leftMergeAvail, aboveMergeAvail); 1398 } 1399 } 1400 #else 1605 1401 if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) ) 1606 1402 { … … 1685 1481 } 1686 1482 } 1483 #endif 1484 1687 1485 #if ENC_DEC_TRACE 1688 1486 g_bJustDoIt = g_bEncDecTraceEnable;
Note: See TracChangeset for help on using the changeset viewer.