Changeset 282 in SHVCSoftware for branches/SHM-2.1-dev/source/Lib/TLibEncoder
- Timestamp:
- 11 Jun 2013, 02:30:21 (12 years ago)
- Location:
- branches/SHM-2.1-dev/source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-2.1-dev/source
- Property svn:mergeinfo changed
/branches/SHM-2.1-multilayers-dev/source (added) merged: 253-257,259-275,277-280
- Property svn:mergeinfo changed
-
branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
r258 r282 1067 1067 if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 1068 1068 { 1069 WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1"); 1069 WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1"); 1070 1070 } 1071 1071 for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) -
branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCfg.h
r212 r282 145 145 Int m_numDirectRefLayers; 146 146 Int m_refLayerId[MAX_VPS_LAYER_ID_PLUS1]; 147 148 Int m_numActiveRefLayers; 149 Int m_predLayerId[MAX_VPS_LAYER_ID_PLUS1]; 147 150 #endif 148 151 //======= Transform ============= … … 405 408 Int getRefLayerId (Int i) { return m_refLayerId[i]; } 406 409 Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } 410 411 Int getNumActiveRefLayers () { return m_numActiveRefLayers; } 412 Void setNumActiveRefLayers (Int num) { m_numActiveRefLayers = num; } 413 414 Int getPredLayerId (Int i) { return m_predLayerId[i]; } 415 Void setPredLayerId (Int i, Int refLayerId) { m_predLayerId[i] = refLayerId; } 407 416 #endif 408 417 //======== Transform ============= -
branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCu.cpp
r191 r282 108 108 // initialize conversion matrix from partition index to pel 109 109 initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); 110 110 111 } 111 112 … … 455 456 { 456 457 #if (ENCODER_FAST_MODE) 457 bool testInter = true;458 Bool testInter = true; 458 459 if (rpcBestCU->getLayerId() > 0) 459 460 { 460 if (rpcBestCU->getSlice()->getBaseColPic()->getSlice(0)->getSliceType() == I_SLICE) 461 { 462 testInter = false; 463 } 464 461 if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx()) 462 testInter = false; 463 if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx()) 464 testInter = false; 465 465 } 466 466 #endif … … 767 767 } 768 768 #endif 769 770 769 #if (ENCODER_FAST_MODE) 771 if(pcPic->getLayerId() > 0) 772 { 773 xCheckRDCostILRUni( rpcBestCU, rpcTempCU); 774 rpcTempCU->initEstData( uiDepth, iQP ); 775 } 770 if(pcPic->getLayerId() > 0) 771 { 772 for(Int refLayer = 0; refLayer < pcSlice->getActiveNumILRRefIdx(); refLayer++) 773 { 774 xCheckRDCostILRUni( rpcBestCU, rpcTempCU, pcSlice->getInterLayerPredLayerIdc(refLayer)); 775 rpcTempCU->initEstData( uiDepth, iQP ); 776 } 777 } 776 778 #endif 777 779 … … 1812 1814 } 1813 1815 #endif 1814 1815 1816 #if (ENCODER_FAST_MODE) 1816 Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU )1817 Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt refLayerId) 1817 1818 { 1818 1819 UChar uhDepth = rpcTempCU->getDepth( 0 ); 1819 1820 1820 rpcTempCU->setDepthSubParts( uhDepth, 0 ); 1821 1822 1821 #if SKIP_FLAG 1823 1822 rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth ); 1824 1823 #endif 1825 1826 1824 rpcTempCU->setPartSizeSubParts ( SIZE_2Nx2N, 0, uhDepth ); //2Nx2N 1827 1825 rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); 1828 1826 rpcTempCU->setCUTransquantBypassSubParts ( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth ); 1829 1830 Bool exitILR = m_pcPredSearch->predInterSearchILRUni( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] ); 1831 1827 Bool exitILR = m_pcPredSearch->predInterSearchILRUni( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], refLayerId ); 1832 1828 if(!exitILR) 1833 1829 { 1834 return; 1835 } 1836 1830 return; 1831 } 1837 1832 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false ); 1838 1839 1833 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1840 1841 1834 xCheckDQP( rpcTempCU ); 1842 1835 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); 1843 1844 1836 return; 1845 1837 } 1846 1838 #endif 1847 1848 1849 1839 //! \} -
branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCu.h
r191 r282 158 158 #endif 159 159 #if ENCODER_FAST_MODE 160 Void xCheckRDCostILRUni ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU 160 Void xCheckRDCostILRUni ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId); 161 161 #endif 162 162 Void xCheckDQP ( TComDataCU* pcCU ); -
branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r251 r282 535 535 if (m_layerId > 0) 536 536 { 537 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 538 { 539 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 537 540 #if VPS_EXTN_DIRECT_REF_LAYERS 538 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(m_layerId-1)->getListPic();539 #else 540 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic();541 #endif 542 pcSlice->setBaseColPic (*cListPic, m_layerId);543 541 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(refLayerIdc)->getListPic(); 542 #else 543 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic(); 544 #endif 545 pcSlice->setBaseColPic( *cListPic, refLayerIdc ); 546 544 547 #if SIMPLIFIED_MV_POS_SCALING 545 548 #if SCALED_REF_LAYER_OFFSETS 546 const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow(); 547 548 Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth(); 549 Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight(); 550 551 Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); 552 Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); 553 #else 554 const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow(); 555 const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow(); 556 557 Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); 558 Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); 559 560 Int widthEL = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); 561 Int heightEL = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); 562 #endif 563 g_mvScalingFactor[m_layerId][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); 564 g_mvScalingFactor[m_layerId][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); 565 566 g_posScalingFactor[m_layerId][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; 567 g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; 568 #endif 569 570 #if ZERO_NUM_DIRECT_LAYERS 571 if( pcSlice->getActiveNumILRRefIdx() ) 572 #endif 573 { 549 const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow(); 550 551 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); 552 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(); 553 554 Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); 555 Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); 556 #else 557 const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getConformanceWindow(); 558 const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow(); 559 560 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); 561 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); 562 563 Int widthEL = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); 564 Int heightEL = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); 565 #endif 566 g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); 567 g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); 568 569 g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; 570 g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; 571 #endif 572 574 573 #if SVC_UPSAMPLING 575 if ( pcPic->isSpatialEnhLayer())574 if( pcPic->isSpatialEnhLayer(refLayerIdc)) 576 575 { 577 576 #if SCALED_REF_LAYER_OFFSETS 578 m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );579 #else 580 m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );577 m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() ); 578 #else 579 m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec() ); 581 580 #endif 582 581 } 583 582 else 584 583 { 585 pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() );586 } 587 pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() );584 pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); 585 } 586 pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); 588 587 #endif 589 588 } … … 595 594 { 596 595 #if IDR_ALIGNMENT 597 if( pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 598 { 599 pcSlice->setNalUnitType(pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType()); 596 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic(); 597 TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() ); 598 if( picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 599 { 600 pcSlice->setNalUnitType(picLayer0->getSlice(0)->getNalUnitType()); 600 601 } 601 602 else … … 935 936 { 936 937 pcSlice->getSPS()->setTMVPFlagsPresent(1); 938 #if SVC_EXTENSION 939 if( pcSlice->getIdrPicFlag() ) 940 { 941 pcSlice->setEnableTMVPFlag(0); 942 } 943 else 944 #endif 937 945 pcSlice->setEnableTMVPFlag(1); 938 946 } -
branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSearch.cpp
r212 r282 3287 3287 #endif 3288 3288 3289 #if (ENCODER_FAST_MODE)3290 Bool testILR;3291 #endif3292 3293 3289 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 3294 3290 … … 3312 3308 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 3313 3309 3314 #if (ENCODER_FAST_MODE)3315 if (pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1)3316 {3317 testILR = false;3318 }3319 else3320 {3321 testILR = true;3322 }3323 #endif3324 3325 3310 for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ ) 3326 3311 { 3327 3312 #if (ENCODER_FAST_MODE) 3328 3313 TComPic* pcPic = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp ); 3329 if( !testILR &&pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) )3314 if( pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) ) 3330 3315 { 3331 3316 continue; … … 6305 6290 6306 6291 #if ENCODER_FAST_MODE 6307 Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv )6292 Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId ) 6308 6293 { 6309 rpcPredYuv->clear(); 6310 rpcRecoYuv->clear(); 6311 6312 Int iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2; 6313 6314 TComMv cMv[2]; 6315 TComMv cMvPred[2][33]; 6316 TComMv cMvTemp[2][33]; 6317 TComMv TempMv; 6318 6319 Int iRefIdx[2]={0,0}; 6320 6321 Int aaiMvpIdx[2][33]; 6322 Int aaiMvpNum[2][33]; 6323 6324 UInt uiMbBits[3] = {1, 1, 0}; 6325 UInt uiLastMode = 0; 6326 6327 UInt uiCost[2] = { MAX_UINT, MAX_UINT }; //uni, rdCost 6328 UInt uiCostTemp; 6329 UInt biPDistTemp = MAX_INT; 6330 UInt uiBitsTemp; 6331 6332 PartSize ePartSize = pcCU->getPartitionSize( 0 ); //2Nx2N 6333 Int iPartIdx = 0; //one PU in CU 6334 UInt uiPartAddr; 6335 Int iRoiWidth, iRoiHeight; 6336 6337 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 6338 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 6339 6340 for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++) //list 6341 { 6342 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 6343 6344 Int iRefIdxTemp = -1; 6345 Bool foundILR = false; 6346 for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ ) 6347 { 6348 if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) ) 6349 { 6350 iRefIdxTemp = refIdx; 6351 foundILR = true; 6352 break; 6353 } 6354 } 6355 6356 if(!foundILR) //no ILR in eRefPiclist 6357 { 6358 continue; 6359 } 6360 6361 uiBitsTemp = uiMbBits[iRefList]; 6362 if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 ) 6363 { 6364 uiBitsTemp += iRefIdxTemp+1; 6365 if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--; 6366 } 6367 6368 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp); 6369 aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr); 6370 aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr); 6371 6372 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; 6373 6374 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp ); 6375 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); 6376 6377 if( uiCostTemp < uiCost[iRefList] ) 6378 { 6379 uiCost[iRefList] = uiCostTemp; 6380 6381 cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp]; 6382 iRefIdx[iRefList] = iRefIdxTemp; 6383 6384 pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6385 pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6386 } 6387 } 6388 6389 if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT ) //no ILR in both list0 and list1 6390 { 6391 return false; 6392 } 6393 6394 // Clear Motion Field 6395 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6396 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6397 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6398 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6399 6400 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6401 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6402 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6403 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6404 6405 if( uiCost[0] <= uiCost[1] ) //list0 ILR 6406 { 6407 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6408 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6409 6410 TempMv = cMv[0] - cMvPred[0][iRefIdx[0]]; 6411 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6412 6413 pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6414 6415 pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6416 pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6417 } 6418 else if( uiCost[1] < uiCost[0] ) //list1 ILR 6419 { 6420 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6421 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6422 6423 TempMv = cMv[1] - cMvPred[1][iRefIdx[1]]; 6424 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6425 6426 pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6427 6428 pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6429 pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6430 } 6431 else 6432 { 6433 assert(0); 6434 } 6435 6436 pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 6437 6438 motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx ); 6439 6440 setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X ); 6441 6442 return true; 6294 rpcPredYuv->clear(); 6295 rpcRecoYuv->clear(); 6296 6297 Int iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2; 6298 6299 TComMv cMv[2]; 6300 TComMv cMvPred[2][33]; 6301 TComMv cMvTemp[2][33]; 6302 TComMv TempMv; 6303 6304 Int iRefIdx[2]={0,0}; 6305 6306 Int aaiMvpIdx[2][33]; 6307 Int aaiMvpNum[2][33]; 6308 6309 UInt uiMbBits[3] = {1, 1, 0}; 6310 UInt uiLastMode = 0; 6311 6312 UInt uiCost[2] = { MAX_UINT, MAX_UINT }; //uni, rdCost 6313 UInt uiCostTemp; 6314 UInt biPDistTemp = MAX_INT; 6315 UInt uiBitsTemp; 6316 6317 PartSize ePartSize = pcCU->getPartitionSize( 0 ); //2Nx2N 6318 Int iPartIdx = 0; //one PU in CU 6319 UInt uiPartAddr; 6320 Int iRoiWidth, iRoiHeight; 6321 Bool bILRSearched = false; 6322 6323 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 6324 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 6325 6326 for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++) //list 6327 { 6328 if(bILRSearched) 6329 continue; 6330 6331 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 6332 6333 Int iRefIdxTemp = -1; 6334 Bool foundILR = false; 6335 6336 for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ ) 6337 { 6338 if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) && pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->getLayerId() == refLayerId ) 6339 { 6340 iRefIdxTemp = refIdx; 6341 foundILR = true; 6342 bILRSearched = true; 6343 break; 6344 } 6345 } 6346 6347 if(!foundILR) //no ILR in eRefPiclist 6348 { 6349 continue; 6350 } 6351 6352 uiBitsTemp = uiMbBits[iRefList]; 6353 if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 ) 6354 { 6355 uiBitsTemp += iRefIdxTemp+1; 6356 if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--; 6357 } 6358 6359 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp); 6360 aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr); 6361 aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr); 6362 6363 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; 6364 6365 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp ); 6366 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); 6367 6368 if( uiCostTemp < uiCost[iRefList] ) 6369 { 6370 uiCost[iRefList] = uiCostTemp; 6371 6372 cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp]; 6373 iRefIdx[iRefList] = iRefIdxTemp; 6374 6375 pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6376 pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6377 } 6378 } 6379 6380 if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT ) //no ILR in both list0 and list1 6381 { 6382 return false; 6383 } 6384 6385 // Clear Motion Field 6386 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6387 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6388 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6389 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6390 6391 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6392 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6393 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6394 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6395 6396 if( uiCost[0] <= uiCost[1] ) //list0 ILR 6397 { 6398 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6399 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6400 6401 TempMv = cMv[0] - cMvPred[0][iRefIdx[0]]; 6402 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6403 6404 pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6405 6406 pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6407 pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6408 } 6409 else if( uiCost[1] < uiCost[0] ) //list1 ILR 6410 { 6411 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6412 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6413 6414 TempMv = cMv[1] - cMvPred[1][iRefIdx[1]]; 6415 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6416 6417 pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6418 6419 pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6420 pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6421 } 6422 else 6423 { 6424 assert(0); 6425 } 6426 6427 pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 6428 6429 motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx ); 6430 setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X ); 6431 6432 return true; 6443 6433 } 6444 6445 6446 6434 #endif 6447 6435 -
branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSearch.h
r191 r282 216 216 217 217 #if (ENCODER_FAST_MODE) 218 Bool predInterSearchILRUni ( TComDataCU* pcCU, 219 TComYuv* pcOrgYuv, 220 TComYuv*& rpcPredYuv, 221 TComYuv*& rpcResiYuv, 222 TComYuv*& rpcRecoYuv 223 ); 224 218 Bool predInterSearchILRUni ( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId ); 225 219 #endif 226 220 -
branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp
r258 r282 493 493 if( rpcSlice->getNumILRRefIdx() > 0 ) 494 494 { 495 rpcSlice->setActiveNumILRRefIdx( rpcSlice->getNumILRRefIdx() );495 rpcSlice->setActiveNumILRRefIdx( m_ppcTEncTop[layerId]->getNumActiveRefLayers() ); 496 496 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 497 497 { 498 rpcSlice->setInterLayerPredLayerIdc( i, i);498 rpcSlice->setInterLayerPredLayerIdc( m_ppcTEncTop[layerId]->getPredLayerId(i), i ); 499 499 } 500 500 rpcSlice->setInterLayerPredEnabledFlag(1); … … 995 995 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 996 996 pcCU->initCU( rpcPic, uiCUAddr ); 997 #if SVC_EXTENSION998 pcCU->setLayerId(m_pcCfg->getLayerId());999 #endif1000 997 1001 998 #if !RATE_CONTROL_LAMBDA_DOMAIN -
branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncTop.cpp
r250 r282 507 507 if(m_layerId > 0) 508 508 { 509 for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) 510 { 511 const Window scalEL = getSPS()->getScaledRefLayerWindow(); 512 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); 513 509 514 #if VPS_EXTN_DIRECT_REF_LAYERS 510 TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( m_layerId - 1 ); 511 #else 512 TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); 513 #endif 514 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() ) 515 { 516 pcEPic->setSpatialEnhLayerFlag( true ); 517 518 //only for scalable extension 519 assert( m_cVPS.getScalabilityMask(1) == true ); 515 TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i ); 516 #else 517 TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); 518 #endif 519 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets ) 520 { 521 pcEPic->setSpatialEnhLayerFlag( i, true ); 522 523 //only for scalable extension 524 assert( m_cVPS.getScalabilityMask(1) == true ); 525 } 520 526 } 521 527 } … … 538 544 if(m_layerId > 0) 539 545 { 546 for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) 547 { 548 const Window scalEL = getSPS()->getScaledRefLayerWindow(); 549 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); 550 540 551 #if VPS_EXTN_DIRECT_REF_LAYERS 541 TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( m_layerId - 1 ); 542 #else 543 TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); 544 #endif 545 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() ) 546 { 547 rpcPic->setSpatialEnhLayerFlag( true ); 548 549 //only for scalable extension 550 assert( m_cVPS.getScalabilityMask(1) == true ); 552 TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i ); 553 #else 554 TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); 555 #endif 556 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets ) 557 { 558 rpcPic->setSpatialEnhLayerFlag( i, true ); 559 560 //only for scalable extension 561 assert( m_cVPS.getScalabilityMask(1) == true ); 562 } 551 563 } 552 564 } … … 1210 1222 } 1211 1223 1212 // currently only one reference layer is supported 1213 assert( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() == 1 ); 1214 1215 return (TEncTop *)getLayerEnc( getVPS()->getRefLayerId( m_layerId, refLayerIdc ) ); 1224 return (TEncTop *)getLayerEnc( m_cVPS.getRefLayerId( m_layerId, refLayerIdc ) ); 1216 1225 } 1217 1226 #endif … … 1235 1244 if (m_cIlpPic[0] == NULL) 1236 1245 { 1237 for (Int j=0; j <1/*MAX_NUM_REF*/; j++)1246 for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] 1238 1247 { 1239 1248 m_cIlpPic[j] = new TComPic; … … 1254 1263 Void TEncTop::setILRPic(TComPic *pcPic) 1255 1264 { 1256 if(m_cIlpPic[0]) 1257 { 1258 m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec()); 1259 m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC()); 1260 m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId 1261 m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false); 1262 m_cIlpPic[0]->getPicYuvRec()->extendPicBorder(); 1265 for( Int i = 0; i < pcPic->getSlice(0)->getActiveNumILRRefIdx(); i++ ) 1266 { 1267 Int refLayerIdc = pcPic->getSlice(0)->getInterLayerPredLayerIdc(i); 1268 1269 if(m_cIlpPic[refLayerIdc]) 1270 { 1271 m_cIlpPic[refLayerIdc]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(refLayerIdc), m_cIlpPic[refLayerIdc]->getPicYuvRec()); 1272 m_cIlpPic[refLayerIdc]->getSlice(0)->setPOC(pcPic->getPOC()); 1273 m_cIlpPic[refLayerIdc]->setLayerId(pcPic->getSlice(0)->getBaseColPic(refLayerIdc)->getLayerId()); //set reference layerId 1274 m_cIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension(false); 1275 m_cIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); 1276 } 1263 1277 } 1264 1278 }
Note: See TracChangeset for help on using the changeset viewer.