Changeset 1287 in 3DVCSoftware for branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncCu.cpp
- Timestamp:
- 20 Jul 2015, 14:13:33 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncCu.cpp
r1285 r1287 122 122 m_stillToCodeChromaQpOffsetFlag = false; 123 123 m_cuChromaQpOffsetIdxPlus1 = 0; 124 m_bFastDeltaQP = false; 124 125 125 126 // initialize partition order. … … 406 407 */ 407 408 #if AMP_ENC_SPEEDUP 408 Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth DEBUG_STRING_FN_DECLARE(sDebug_), PartSize eParentPartSize )409 #else 410 Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth )409 Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth DEBUG_STRING_FN_DECLARE(sDebug_), PartSize eParentPartSize ) 410 #else 411 Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth ) 411 412 #endif 412 413 { … … 415 416 const TComPPS &pps=*(rpcTempCU->getSlice()->getPPS()); 416 417 const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS()); 418 419 // These are only used if getFastDeltaQp() is true 420 const UInt fastDeltaQPCuMaxSize = Clip3(sps.getMaxCUHeight()>>sps.getLog2DiffMaxMinCodingBlockSize(), sps.getMaxCUHeight(), 32u); 417 421 418 422 … … 437 441 Bool bTrySplitDQP = true; 438 442 #endif 439 440 // variable for Early CU determination441 Bool bSubBranch = true;442 443 443 // variable for Cbf fast mode PU decision 444 444 Bool doNotBlockPu = true; … … 453 453 #endif 454 454 #endif 455 Bool bBoundary = false;456 UInt uiLPelX = rpcBestCU->getCUPelX();457 UInt uiRPelX = uiLPelX + rpcBestCU->getWidth(0) - 1;458 UInt uiTPelY = rpcBestCU->getCUPelY();459 UInt uiBPelY = uiTPelY + rpcBestCU->getHeight(0) - 1;455 const UInt uiLPelX = rpcBestCU->getCUPelX(); 456 const UInt uiRPelX = uiLPelX + rpcBestCU->getWidth(0) - 1; 457 const UInt uiTPelY = rpcBestCU->getCUPelY(); 458 const UInt uiBPelY = uiTPelY + rpcBestCU->getHeight(0) - 1; 459 const UInt uiWidth = rpcBestCU->getWidth(0); 460 460 461 461 #if H_MV_ENC_DEC_TRAC … … 515 515 516 516 TComSlice * pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx()); 517 // We need to split, so don't try these modes. 518 if ( ( uiRPelX < sps.getPicWidthInLumaSamples() ) && 519 ( uiBPelY < sps.getPicHeightInLumaSamples() ) ) 517 518 const Bool bBoundary = !( uiRPelX < sps.getPicWidthInLumaSamples() && uiBPelY < sps.getPicHeightInLumaSamples() ); 519 520 if ( !bBoundary ) 520 521 { 521 522 #if H_3D_FAST_TEXTURE_ENCODING … … 1187 1188 } 1188 1189 1189 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); 1190 m_pcEntropyCoder->resetBits(); 1191 m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true ); 1192 rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits 1193 rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1190 if( rpcBestCU->getTotalCost()!=MAX_DOUBLE ) 1191 { 1192 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); 1193 m_pcEntropyCoder->resetBits(); 1194 m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true ); 1195 rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits 1196 rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1194 1197 #if NH_3D_VSO // M8 1195 1198 if ( m_pcRdCost->getUseVSO() ) … … 1200 1203 #endif 1201 1204 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 1202 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); 1203 1204 // Early CU determination 1205 if( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->isSkipped(0) ) 1206 { 1207 bSubBranch = false; 1208 } 1209 else 1210 { 1211 bSubBranch = true; 1205 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); 1212 1206 } 1213 1207 #if H_3D_FAST_TEXTURE_ENCODING … … 1218 1212 #endif 1219 1213 } 1220 else 1221 { 1222 bBoundary = true; 1223 } 1224 1225 // copy orginal YUV samples to PCM buffer 1226 if( rpcBestCU->isLosslessCoded(0) && (rpcBestCU->getIPCMFlag(0) == false)) 1214 1215 // copy original YUV samples to PCM buffer 1216 if( rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isLosslessCoded(0) && (rpcBestCU->getIPCMFlag(0) == false)) 1227 1217 { 1228 1218 xFillPCMBuffer(rpcBestCU, m_ppcOrigYuv[uiDepth]); … … 1258 1248 } 1259 1249 1260 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 1261 { 1262 const Bool bIsLosslessMode = false; // False at this level. Next level down may set it to true. 1263 1264 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1265 1250 const Bool bSubBranch = bBoundary || !( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isSkipped(0) ); 1251 #if NH_3D_QTLPC 1252 if( bSubBranch && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() && (!getFastDeltaQp() || uiWidth > fastDeltaQPCuMaxSize || bBoundary) && bTrySplitDQP ) 1253 #else 1254 if( bSubBranch && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() && (!getFastDeltaQp() || uiWidth > fastDeltaQPCuMaxSize || bBoundary)) 1255 #endif 1256 { 1266 1257 // further split 1267 #if NH_3D_QTLPC 1268 1269 if( bSubBranch && bTrySplitDQP && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) 1270 #else 1271 if( bSubBranch && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) 1272 #endif 1273 { 1258 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 1259 { 1260 const Bool bIsLosslessMode = false; // False at this level. Next level down may set it to true. 1261 1262 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1263 1274 1264 #if NH_3D_VSO // M9 1275 1265 // reset Model … … 1310 1300 #if AMP_ENC_SPEEDUP 1311 1301 DEBUG_STRING_NEW(sChild) 1312 if ( ! rpcBestCU->isInter(0) )1302 if ( !(rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isInter(0)) ) 1313 1303 { 1314 1304 xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth DEBUG_STRING_PASS_INTO(sChild), NUMBER_OF_PART_SIZES ); … … 1366 1356 } 1367 1357 1368 UInt uiTargetPartIdx = 0;1369 1358 if ( hasResidual ) 1370 1359 { 1371 1360 m_pcEntropyCoder->resetBits(); 1372 m_pcEntropyCoder->encodeQP( rpcTempCU, uiTargetPartIdx, false );1361 m_pcEntropyCoder->encodeQP( rpcTempCU, 0, false ); 1373 1362 rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits 1374 1363 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); … … 1383 1372 1384 1373 Bool foundNonZeroCbf = false; 1385 rpcTempCU->setQPSubCUs( rpcTempCU->getRefQP( uiTargetPartIdx), 0, uiDepth, foundNonZeroCbf );1374 rpcTempCU->setQPSubCUs( rpcTempCU->getRefQP( 0 ), 0, uiDepth, foundNonZeroCbf ); 1386 1375 assert( foundNonZeroCbf ); 1387 1376 } 1388 1377 else 1389 1378 { 1390 rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( uiTargetPartIdx), 0, uiDepth ); // set QP to default QP1379 rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( 0 ), 0, uiDepth ); // set QP to default QP 1391 1380 } 1392 1381 } … … 1399 1388 // This can be achieved by forcing the decision to be that of the rpcTempCU. 1400 1389 // The exception is each slice / slice-segment must have at least one CTU. 1401 const Bool isEndOfSlice = pcSlice->getSliceMode()==FIXED_NUMBER_OF_BYTES 1402 && ((pcSlice->getSliceBits()+rpcBestCU->getTotalBits())>pcSlice->getSliceArgument()<<3) 1403 && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceCurStartCtuTsAddr()) 1404 && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()); 1405 const Bool isEndOfSliceSegment = pcSlice->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES 1406 && ((pcSlice->getSliceSegmentBits()+rpcBestCU->getTotalBits()) > pcSlice->getSliceSegmentArgument()<<3) 1407 && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()); 1408 // Do not need to check slice condition for slice-segment since a slice-segment is a subset of a slice. 1409 if(isEndOfSlice||isEndOfSliceSegment) 1390 if (rpcBestCU->getTotalCost()!=MAX_DOUBLE) 1410 1391 { 1411 rpcBestCU->getTotalCost()=MAX_DOUBLE; 1392 const Bool isEndOfSlice = pcSlice->getSliceMode()==FIXED_NUMBER_OF_BYTES 1393 && ((pcSlice->getSliceBits()+rpcBestCU->getTotalBits())>pcSlice->getSliceArgument()<<3) 1394 && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceCurStartCtuTsAddr()) 1395 && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()); 1396 const Bool isEndOfSliceSegment = pcSlice->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES 1397 && ((pcSlice->getSliceSegmentBits()+rpcBestCU->getTotalBits()) > pcSlice->getSliceSegmentArgument()<<3) 1398 && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()); 1399 // Do not need to check slice condition for slice-segment since a slice-segment is a subset of a slice. 1400 if(isEndOfSlice||isEndOfSliceSegment) 1401 { 1402 rpcBestCU->getTotalCost()=MAX_DOUBLE; 1403 } 1412 1404 } 1413 1405 1414 1406 xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTempDebug) DEBUG_STRING_PASS_INTO(false) ); // RD compare current larger prediction 1415 // with sub partitioned prediction.1407 // with sub partitioned prediction. 1416 1408 } 1417 1409 } … … 1785 1777 { 1786 1778 assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE ); 1779 if(getFastDeltaQp()) 1780 { 1781 return; // never check merge in fast deltaqp mode 1782 } 1787 1783 #if NH_3D_MLC 1788 1784 TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists … … 2247 2243 DEBUG_STRING_NEW(sTest) 2248 2244 2245 if(getFastDeltaQp()) 2246 { 2247 const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS()); 2248 const UInt fastDeltaQPCuMaxSize = Clip3(sps.getMaxCUHeight()>>(sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u); 2249 if(ePartSize != SIZE_2Nx2N || rpcTempCU->getWidth( 0 ) > fastDeltaQPCuMaxSize) 2250 { 2251 return; // only check necessary 2Nx2N Inter in fast deltaqp mode 2252 } 2253 } 2254 2249 2255 // prior to this, rpcTempCU will have just been reset using rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 2250 2256 #if H_3D || NH_3D_ARP … … 2740 2746 DEBUG_STRING_NEW(sTest) 2741 2747 2748 if(getFastDeltaQp()) 2749 { 2750 const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS()); 2751 const UInt fastDeltaQPCuMaxSize = Clip3(sps.getMaxCUHeight()>>(sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u); 2752 if(rpcTempCU->getWidth( 0 ) > fastDeltaQPCuMaxSize) 2753 { 2754 return; // only check necessary 2Nx2N Intra in fast deltaqp mode 2755 } 2756 } 2757 2742 2758 UInt uiDepth = rpcTempCU->getDepth( 0 ); 2743 2759 #if NH_3D_VSO // M5 … … 2844 2860 Void TEncCu::xCheckIntraPCM( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ) 2845 2861 { 2862 if(getFastDeltaQp()) 2863 { 2864 const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS()); 2865 const UInt fastDeltaQPCuMaxPCMSize = Clip3((UInt)1<<sps.getPCMLog2MinSize(), (UInt)1<<sps.getPCMLog2MaxSize(), 32u); 2866 if (rpcTempCU->getWidth( 0 ) > fastDeltaQPCuMaxPCMSize) 2867 { 2868 return; // only check necessary PCM in fast deltaqp mode 2869 } 2870 } 2871 2846 2872 UInt uiDepth = rpcTempCU->getDepth( 0 ); 2847 2873
Note: See TracChangeset for help on using the changeset viewer.