Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncCu.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/TEncCu.cpp
r1196 r1313 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 40 40 #include "TEncCu.h" 41 41 #include "TEncAnalyze.h" 42 #include "TLibCommon/Debug.h" 42 43 43 44 #include <cmath> … … 45 46 using namespace std; 46 47 48 47 49 //! \ingroup TLibEncoder 48 50 //! \{ … … 53 55 54 56 /** 55 \param u iTotalDepth total number of allowable depth57 \param uhTotalDepth total number of allowable depth 56 58 \param uiMaxWidth largest CU width 57 59 \param uiMaxHeight largest CU height 60 \param chromaFormat chroma format 58 61 */ 59 Void TEncCu::create(UChar uhTotalDepth, UInt uiMaxWidth, UInt uiMaxHeight )62 Void TEncCu::create(UChar uhTotalDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormat) 60 63 { 61 64 Int i; 62 65 63 66 m_uhTotalDepth = uhTotalDepth + 1; 64 67 m_ppcBestCU = new TComDataCU*[m_uhTotalDepth-1]; 65 68 m_ppcTempCU = new TComDataCU*[m_uhTotalDepth-1]; 66 67 #if H_3D_ARP69 70 #if NH_3D_ARP 68 71 m_ppcWeightedTempCU = new TComDataCU*[m_uhTotalDepth-1]; 69 72 #endif … … 76 79 m_ppcRecoYuvTemp = new TComYuv*[m_uhTotalDepth-1]; 77 80 m_ppcOrigYuv = new TComYuv*[m_uhTotalDepth-1]; 78 #if H_3D_DBBP81 #if NH_3D_DBBP 79 82 m_ppcOrigYuvDBBP = new TComYuv*[m_uhTotalDepth-1]; 80 83 #endif 81 84 82 85 UInt uiNumPartitions; 83 86 for( i=0 ; i<m_uhTotalDepth-1 ; i++) … … 86 89 UInt uiWidth = uiMaxWidth >> i; 87 90 UInt uiHeight = uiMaxHeight >> i; 88 89 m_ppcBestCU[i] = new TComDataCU; m_ppcBestCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); 90 m_ppcTempCU[i] = new TComDataCU; m_ppcTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); 91 92 #if H_3D_ARP 93 m_ppcWeightedTempCU[i] = new TComDataCU; m_ppcWeightedTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); 91 92 m_ppcBestCU[i] = new TComDataCU; m_ppcBestCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); 93 m_ppcTempCU[i] = new TComDataCU; m_ppcTempCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); 94 #if NH_3D_ARP 95 m_ppcWeightedTempCU[i] = new TComDataCU; m_ppcWeightedTempCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); 94 96 #endif 95 97 96 m_ppcPredYuvBest[i] = new TComYuv; m_ppcPredYuvBest[i]->create(uiWidth, uiHeight); 97 m_ppcResiYuvBest[i] = new TComYuv; m_ppcResiYuvBest[i]->create(uiWidth, uiHeight); 98 m_ppcRecoYuvBest[i] = new TComYuv; m_ppcRecoYuvBest[i]->create(uiWidth, uiHeight); 99 100 m_ppcPredYuvTemp[i] = new TComYuv; m_ppcPredYuvTemp[i]->create(uiWidth, uiHeight); 101 m_ppcResiYuvTemp[i] = new TComYuv; m_ppcResiYuvTemp[i]->create(uiWidth, uiHeight); 102 m_ppcRecoYuvTemp[i] = new TComYuv; m_ppcRecoYuvTemp[i]->create(uiWidth, uiHeight); 103 104 m_ppcOrigYuv [i] = new TComYuv; m_ppcOrigYuv [i]->create(uiWidth, uiHeight); 105 #if H_3D_DBBP 106 m_ppcOrigYuvDBBP[i] = new TComYuv; m_ppcOrigYuvDBBP[i]->create(uiWidth, uiHeight); 107 #endif 108 } 109 110 m_bEncodeDQP = false; 98 m_ppcPredYuvBest[i] = new TComYuv; m_ppcPredYuvBest[i]->create(uiWidth, uiHeight, chromaFormat); 99 m_ppcResiYuvBest[i] = new TComYuv; m_ppcResiYuvBest[i]->create(uiWidth, uiHeight, chromaFormat); 100 m_ppcRecoYuvBest[i] = new TComYuv; m_ppcRecoYuvBest[i]->create(uiWidth, uiHeight, chromaFormat); 101 102 m_ppcPredYuvTemp[i] = new TComYuv; m_ppcPredYuvTemp[i]->create(uiWidth, uiHeight, chromaFormat); 103 m_ppcResiYuvTemp[i] = new TComYuv; m_ppcResiYuvTemp[i]->create(uiWidth, uiHeight, chromaFormat); 104 m_ppcRecoYuvTemp[i] = new TComYuv; m_ppcRecoYuvTemp[i]->create(uiWidth, uiHeight, chromaFormat); 105 106 m_ppcOrigYuv [i] = new TComYuv; m_ppcOrigYuv [i]->create(uiWidth, uiHeight, chromaFormat); 107 #if NH_3D_DBBP 108 m_ppcOrigYuvDBBP[i] = new TComYuv; m_ppcOrigYuvDBBP[i]->create(uiWidth, uiHeight, chromaFormat); 109 #endif 110 111 } 112 113 m_bEncodeDQP = false; 114 111 115 #if KWU_RC_MADPRED_E0227 112 116 m_LCUPredictionSAD = 0; … … 116 120 #endif 117 121 122 m_stillToCodeChromaQpOffsetFlag = false; 123 m_cuChromaQpOffsetIdxPlus1 = 0; 124 m_bFastDeltaQP = false; 125 118 126 // initialize partition order. 119 127 UInt* piTmp = &g_auiZscanToRaster[0]; 120 128 initZscanToRaster( m_uhTotalDepth, 1, 0, piTmp); 121 129 initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); 122 130 123 131 // initialize conversion matrix from partition index to pel 124 132 initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); … … 128 136 { 129 137 Int i; 130 138 131 139 for( i=0 ; i<m_uhTotalDepth-1 ; i++) 132 140 { … … 139 147 m_ppcTempCU[i]->destroy(); delete m_ppcTempCU[i]; m_ppcTempCU[i] = NULL; 140 148 } 141 #if H_3D_ARP149 #if NH_3D_ARP 142 150 if(m_ppcWeightedTempCU[i]) 143 151 { … … 173 181 m_ppcOrigYuv[i]->destroy(); delete m_ppcOrigYuv[i]; m_ppcOrigYuv[i] = NULL; 174 182 } 175 #if H_3D_DBBP183 #if NH_3D_DBBP 176 184 if(m_ppcOrigYuvDBBP[i]) 177 185 { … … 191 199 } 192 200 193 #if H_3D_ARP201 #if NH_3D_ARP 194 202 if(m_ppcWeightedTempCU) 195 203 { … … 233 241 m_ppcOrigYuv = NULL; 234 242 } 235 #if H_3D_DBBP243 #if NH_3D_DBBP 236 244 if(m_ppcOrigYuvDBBP) 237 245 { … … 249 257 m_pcPredSearch = pcEncTop->getPredSearch(); 250 258 m_pcTrQuant = pcEncTop->getTrQuant(); 251 m_pcBitCounter = pcEncTop->getBitCounter();252 259 m_pcRdCost = pcEncTop->getRdCost(); 253 260 254 261 m_pcEntropyCoder = pcEncTop->getEntropyCoder(); 255 m_pcCavlcCoder = pcEncTop->getCavlcCoder();256 m_pcSbacCoder = pcEncTop->getSbacCoder();257 262 m_pcBinCABAC = pcEncTop->getBinCABAC(); 258 259 m_pppcRDSbacCoder = pcEncTop->getRDSbacCoder();260 m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder();261 262 m_pcRateCtrl = pcEncTop->getRateCtrl();263 264 m_pppcRDSbacCoder = pcEncTop->getRDSbacCoder(); 265 m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder(); 266 267 m_pcRateCtrl = pcEncTop->getRateCtrl(); 263 268 } 264 269 … … 267 272 // ==================================================================================================================== 268 273 269 /** \param rpcCU pointer of CU data class 274 /** 275 \param pCtu pointer of CU data class 270 276 */ 271 Void TEncCu::compressC U( TComDataCU*& rpcCU)277 Void TEncCu::compressCtu( TComDataCU* pCtu ) 272 278 { 273 279 // initialize CU data 274 m_ppcBestCU[0]->initC U( rpcCU->getPic(), rpcCU->getAddr() );275 m_ppcTempCU[0]->initC U( rpcCU->getPic(), rpcCU->getAddr() );276 277 #if H_3D_DISABLE_CHROMA278 m_ppcWeightedTempCU[0]->initC U( rpcCU->getPic(), rpcCU->getAddr() );280 m_ppcBestCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() ); 281 m_ppcTempCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() ); 282 283 #if NH_3D_ARP 284 m_ppcWeightedTempCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() ); 279 285 #endif 280 286 … … 287 293 288 294 // analysis of CU 289 xCompressCU( m_ppcBestCU[0], m_ppcTempCU[0], 0 ); 295 DEBUG_STRING_NEW(sDebug) 296 297 xCompressCU( m_ppcBestCU[0], m_ppcTempCU[0], 0 DEBUG_STRING_PASS_INTO(sDebug) ); 298 DEBUG_STRING_OUTPUT(std::cout, sDebug) 290 299 291 300 #if ADAPTIVE_QP_SELECTION 292 301 if( m_pcEncCfg->getUseAdaptQpSelect() ) 293 302 { 294 if( rpcCU->getSlice()->getSliceType()!=I_SLICE) //IIII295 { 296 x LcuCollectARLStats( rpcCU);303 if(pCtu->getSlice()->getSliceType()!=I_SLICE) //IIII 304 { 305 xCtuCollectARLStats( pCtu ); 297 306 } 298 307 } 299 308 #endif 300 309 } 301 /** \param p cCUpointer of CU data class310 /** \param pCtu pointer of CU data class 302 311 */ 303 Void TEncCu::encodeC U ( TComDataCU* pcCU)312 Void TEncCu::encodeCtu ( TComDataCU* pCtu ) 304 313 { 305 if ( p cCU->getSlice()->getPPS()->getUseDQP() )314 if ( pCtu->getSlice()->getPPS()->getUseDQP() ) 306 315 { 307 316 setdQPFlag(true); 308 317 } 309 318 319 if ( pCtu->getSlice()->getUseChromaQpAdj() ) 320 { 321 setCodeChromaQpAdjFlag(true); 322 } 323 310 324 // Encode CU data 311 xEncodeCU( p cCU, 0, 0 );325 xEncodeCU( pCtu, 0, 0 ); 312 326 } 313 327 … … 315 329 // Protected member functions 316 330 // ==================================================================================================================== 317 /** Derive small set of test modes for AMP encoder speed-up 318 *\param rpcBestCU 319 *\param eParentPartSize 320 *\param bTestAMP_Hor 321 *\param bTestAMP_Ver 322 *\param bTestMergeAMP_Hor 323 *\param bTestMergeAMP_Ver 324 *\returns Void 325 */ 331 //! Derive small set of test modes for AMP encoder speed-up 326 332 #if AMP_ENC_SPEEDUP 327 333 #if AMP_MRG 328 Void TEncCu::deriveTestModeAMP (TComDataCU * &rpcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver)329 #else 330 Void TEncCu::deriveTestModeAMP (TComDataCU * &rpcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver)334 Void TEncCu::deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver) 335 #else 336 Void TEncCu::deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver) 331 337 #endif 332 338 { 333 if ( rpcBestCU->getPartitionSize(0) == SIZE_2NxN )339 if ( pcBestCU->getPartitionSize(0) == SIZE_2NxN ) 334 340 { 335 341 bTestAMP_Hor = true; 336 342 } 337 else if ( rpcBestCU->getPartitionSize(0) == SIZE_Nx2N )343 else if ( pcBestCU->getPartitionSize(0) == SIZE_Nx2N ) 338 344 { 339 345 bTestAMP_Ver = true; 340 346 } 341 else if ( rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N && rpcBestCU->getMergeFlag(0) == false && rpcBestCU->isSkipped(0) == false )342 { 343 bTestAMP_Hor = true; 344 bTestAMP_Ver = true; 347 else if ( pcBestCU->getPartitionSize(0) == SIZE_2Nx2N && pcBestCU->getMergeFlag(0) == false && pcBestCU->isSkipped(0) == false ) 348 { 349 bTestAMP_Hor = true; 350 bTestAMP_Ver = true; 345 351 } 346 352 347 353 #if AMP_MRG 348 //! Utilizing the partition size of parent PU 354 //! Utilizing the partition size of parent PU 349 355 if ( eParentPartSize >= SIZE_2NxnU && eParentPartSize <= SIZE_nRx2N ) 350 { 356 { 351 357 bTestMergeAMP_Hor = true; 352 358 bTestMergeAMP_Ver = true; 353 359 } 354 360 355 if ( eParentPartSize == SIZE_NONE) //! if parent is intra356 { 357 if ( rpcBestCU->getPartitionSize(0) == SIZE_2NxN )361 if ( eParentPartSize == NUMBER_OF_PART_SIZES ) //! if parent is intra 362 { 363 if ( pcBestCU->getPartitionSize(0) == SIZE_2NxN ) 358 364 { 359 365 bTestMergeAMP_Hor = true; 360 366 } 361 else if ( rpcBestCU->getPartitionSize(0) == SIZE_Nx2N )367 else if ( pcBestCU->getPartitionSize(0) == SIZE_Nx2N ) 362 368 { 363 369 bTestMergeAMP_Ver = true; … … 365 371 } 366 372 367 if ( rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N && rpcBestCU->isSkipped(0) == false )368 { 369 bTestMergeAMP_Hor = true; 370 bTestMergeAMP_Ver = true; 371 } 372 373 if ( rpcBestCU->getWidth(0) == 64 )374 { 373 if ( pcBestCU->getPartitionSize(0) == SIZE_2Nx2N && pcBestCU->isSkipped(0) == false ) 374 { 375 bTestMergeAMP_Hor = true; 376 bTestMergeAMP_Ver = true; 377 } 378 379 if ( pcBestCU->getWidth(0) == 64 ) 380 { 375 381 bTestAMP_Hor = false; 376 382 bTestAMP_Ver = false; 377 } 378 #else 379 //! Utilizing the partition size of parent PU 383 } 384 #else 385 //! Utilizing the partition size of parent PU 380 386 if ( eParentPartSize >= SIZE_2NxnU && eParentPartSize <= SIZE_nRx2N ) 381 { 387 { 382 388 bTestAMP_Hor = true; 383 389 bTestAMP_Ver = true; … … 385 391 386 392 if ( eParentPartSize == SIZE_2Nx2N ) 387 { 393 { 388 394 bTestAMP_Hor = false; 389 395 bTestAMP_Ver = false; 390 } 396 } 391 397 #endif 392 398 } 393 399 #endif 400 394 401 395 402 // ==================================================================================================================== 396 403 // Protected member functions 397 404 // ==================================================================================================================== 398 /** Compress a CU block recursively with enabling sub-LCU-level delta QP 399 *\param rpcBestCU 400 *\param rpcTempCU 401 *\param uiDepth 402 *\returns Void 403 * 404 *- for loop of QP value to compress the current CU with all possible QP 405 /** Compress a CU block recursively with enabling sub-CTU-level delta QP 406 * - for loop of QP value to compress the current CU with all possible QP 405 407 */ 406 408 #if AMP_ENC_SPEEDUP 407 Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth, PartSize eParentPartSize )408 #else 409 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 ) 410 412 #endif 411 413 { 412 414 TComPic* pcPic = rpcBestCU->getPic(); 413 414 #if H_3D_QTLPC 415 DEBUG_STRING_NEW(sDebug) 416 const TComPPS &pps=*(rpcTempCU->getSlice()->getPPS()); 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); 421 422 423 #if NH_3D_QTLPC 415 424 Bool bLimQtPredFalg = pcPic->getSlice(0)->getQtPredFlag(); 416 425 TComPic *pcTexture = rpcBestCU->getSlice()->getTexturePic(); … … 424 433 Bool bTryNx2N = true; 425 434 #endif 435 426 436 // get Original YUV data from picture 427 m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->get Addr(), rpcBestCU->getZorderIdxInCU() );428 429 #if H_3D_QTLPC437 m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getCtuRsAddr(), rpcBestCU->getZorderIdxInCtu() ); 438 439 #if NH_3D_QTLPC 430 440 Bool bTrySplit = true; 431 441 Bool bTrySplitDQP = true; 432 442 #endif 433 434 // variable for Early CU determination435 Bool bSubBranch = true;436 437 443 // variable for Cbf fast mode PU decision 438 444 Bool doNotBlockPu = true; 439 Bool earlyDetectionSkipMode = false;440 441 #if H_3D_VSP445 Bool earlyDetectionSkipMode = false; 446 447 #if NH_3D_NBDV 442 448 DisInfo DvInfo; 443 449 DvInfo.m_acNBDV.setZero(); 444 450 DvInfo.m_aVIdxCan = 0; 445 #if H_3D_NBDV_REF451 #if NH_3D_NBDV_REF 446 452 DvInfo.m_acDoNBDV.setZero(); 447 453 #endif 448 454 #endif 449 Bool bBoundary = false;450 UInt uiLPelX = rpcBestCU->getCUPelX();451 UInt uiRPelX = uiLPelX + rpcBestCU->getWidth(0) - 1;452 UInt uiTPelY = rpcBestCU->getCUPelY();453 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); 454 460 455 461 #if H_MV_ENC_DEC_TRAC … … 469 475 Bool isAddLowestQP = false; 470 476 471 if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) 477 const UInt numberValidComponents = rpcBestCU->getPic()->getNumberValidComponents(); 478 479 if( uiDepth <= pps.getMaxCuDQPDepth() ) 472 480 { 473 481 Int idQP = m_pcEncCfg->getMaxDeltaQP(); 474 iMinQP = Clip3( - rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP );475 iMaxQP = Clip3( - rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP );482 iMinQP = Clip3( -sps.getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQP-idQP ); 483 iMaxQP = Clip3( -sps.getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQP+idQP ); 476 484 } 477 485 else … … 486 494 iMaxQP = m_pcRateCtrl->getRCQP(); 487 495 } 496 488 497 // transquant-bypass (TQB) processing loop variable initialisation --- 489 498 490 499 const Int lowestQP = iMinQP; // For TQB, use this QP which is the lowest non TQB QP tested (rather than QP'=0) - that way delta QPs are smaller, and TQB can be tested at all CU levels. 491 500 492 if ( ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) )501 if ( (pps.getTransquantBypassEnableFlag()) ) 493 502 { 494 503 isAddLowestQP = true; // mark that the first iteration is to cost TQB mode. … … 500 509 } 501 510 502 #if H_3D_IC511 #if NH_3D_IC 503 512 Bool bICEnabled = rpcTempCU->getSlice()->getViewIndex() && ( rpcTempCU->getSlice()->getSliceType() == P_SLICE || rpcTempCU->getSlice()->getSliceType() == B_SLICE ) && !rpcTempCU->getSlice()->getIsDepth(); 504 513 bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC(); 505 514 #endif 506 // If slice start or slice end is within this cu... 515 507 516 TComSlice * pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx()); 508 Bool bSliceStart = pcSlice->getSliceSegmentCurStartCUAddr()>rpcTempCU->getSCUAddr()&&pcSlice->getSliceSegmentCurStartCUAddr()<rpcTempCU->getSCUAddr()+rpcTempCU->getTotalNumPart(); 509 Bool bSliceEnd = (pcSlice->getSliceSegmentCurEndCUAddr()>rpcTempCU->getSCUAddr()&&pcSlice->getSliceSegmentCurEndCUAddr()<rpcTempCU->getSCUAddr()+rpcTempCU->getTotalNumPart()); 510 Bool bInsidePicture = ( uiRPelX < rpcBestCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < rpcBestCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); 511 // We need to split, so don't try these modes. 512 if(!bSliceEnd && !bSliceStart && bInsidePicture ) 513 { 514 #if H_3D_FAST_TEXTURE_ENCODING 517 518 const Bool bBoundary = !( uiRPelX < sps.getPicWidthInLumaSamples() && uiBPelY < sps.getPicHeightInLumaSamples() ); 519 #if NH_3D_FAST_TEXTURE_ENCODING 515 520 Bool bIVFMerge = false; 516 521 Int iIVFMaxD = 0; 517 522 Bool bFMD = false; 518 #endif 523 Bool bSubBranch = true; 524 #endif 525 if ( !bBoundary ) 526 { 519 527 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 520 528 { … … 526 534 } 527 535 528 #if H_3D_QTLPC536 #if NH_3D_QTLPC 529 537 bTrySplit = true; 530 538 #endif 531 539 540 m_cuChromaQpOffsetIdxPlus1 = 0; 541 if (pcSlice->getUseChromaQpAdj()) 542 { 543 /* Pre-estimation of chroma QP based on input block activity may be performed 544 * here, using for example m_ppcOrigYuv[uiDepth] */ 545 /* To exercise the current code, the index used for adjustment is based on 546 * block position 547 */ 548 Int lgMinCuSize = sps.getLog2MinCodingBlockSize() + 549 std::max<Int>(0, sps.getLog2DiffMaxMinCodingBlockSize()-Int(pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth())); 550 m_cuChromaQpOffsetIdxPlus1 = ((uiLPelX >> lgMinCuSize) + (uiTPelY >> lgMinCuSize)) % (pps.getPpsRangeExtension().getChromaQpOffsetListLen() + 1); 551 } 552 532 553 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 533 #if H_3D_QTLPC554 #if NH_3D_QTLPC 534 555 //logic for setting bTrySplit using the partition information that is stored of the texture colocated CU 535 556 #if H_3D_FCO … … 539 560 #endif 540 561 { 541 TComDataCU* pcTextureCU = pcTexture->getC U( rpcBestCU->getAddr() ); //Corresponding texture LCU542 UInt uiCUIdx = rpcBestCU->getZorderIdxInC U();562 TComDataCU* pcTextureCU = pcTexture->getCtu( rpcBestCU->getCtuRsAddr() ); //Corresponding texture LCU 563 UInt uiCUIdx = rpcBestCU->getZorderIdxInCtu(); 543 564 assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); //Depth cannot be more partitioned than the texture. 544 565 if (pcTextureCU->getDepth(uiCUIdx) > uiDepth || pcTextureCU->getPartitionSize(uiCUIdx) == SIZE_NxN) //Texture was split. … … 568 589 #endif 569 590 570 #if H_3D_NBDV591 #if NH_3D_NBDV 571 592 if( rpcTempCU->getSlice()->getSliceType() != I_SLICE ) 572 593 { 573 #if H_3D_ARP && H_3D_IV_MERGE574 if( rpcTempCU->getSlice()->getIvResPredFlag() || rpcTempCU->getSlice()->getIvMvPredFlag() )594 #if NH_3D_ARP && NH_3D_IV_MERGE && NH_3D_VSP 595 if( rpcTempCU->getSlice()->getIvResPredFlag() || rpcTempCU->getSlice()->getIvMvPredFlag() || rpcTempCU->getSlice()->getViewSynthesisPredFlag() ) 575 596 #else 576 #if H_3D_ARP 577 if( rpcTempCU->getSlice()->getVPS()->getUseAdvRP(rpcTempCU->getSlice()->getLayerId()) ) 597 #if NH_3D_IV_MERGE && NH_3D_VSP 598 if( rpcTempCU->getSlice()->getIvMvPredFlag() || rpcTempCU->getSlice()->getViewSynthesisPredFlag() ) 599 #else 600 #if NH_3D_ARP && NH_3D_VSP 601 if( rpcTempCU->getSlice()->getIvResPredFlag() || rpcTempCU->getSlice()->getViewSynthesisPredFlag() ) 602 #else 603 #if NH_3D_VSP 604 if( rpcTempCU->getSlice()->getViewSynthesisPredFlag() ) 605 #else 606 #if NH_3D_ARP 607 if( rpcTempCU->getSlice()->getIvResPredFlag() ) 578 608 #else 579 609 #if H_3D_IV_MERGE 580 610 if( rpcTempCU->getSlice()->getVPS()->getIvMvPredFlag(rpcTempCU->getSlice()->getLayerId()) ) 581 611 #else 612 #if NH_3D_DBBP 613 if( rpcTempCU->getSlice()->getDepthBasedBlkPartFlag() ) 614 #else 582 615 if (0) 616 #endif 617 #endif 618 #endif 619 #endif 583 620 #endif 584 621 #endif … … 586 623 { 587 624 PartSize ePartTemp = rpcTempCU->getPartitionSize(0); 588 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );589 #if H_3D_IV_MERGE625 rpcTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth); 626 #if NH_3D_IV_MERGE 590 627 if (rpcTempCU->getSlice()->getIsDepth() ) 591 628 { … … 595 632 { 596 633 #endif 597 #if H_3D_NBDV_REF634 #if NH_3D_NBDV_REF 598 635 if( rpcTempCU->getSlice()->getDepthRefinementFlag() ) 599 636 { … … 605 642 rpcTempCU->getDisMvpCandNBDV(&DvInfo); 606 643 } 607 #if H_3D_IV_MERGE644 #if NH_3D_IV_MERGE 608 645 } 609 646 #endif … … 613 650 } 614 651 } 615 #if H_3D_FAST_TEXTURE_ENCODING652 #if NH_3D_FAST_TEXTURE_ENCODING 616 653 if(rpcTempCU->getSlice()->getViewIndex() && !rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getDefaultRefViewIdxAvailableFlag() ) 617 654 { … … 626 663 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) 627 664 { 628 #if H_3D_IC665 #if NH_3D_IC 629 666 for( UInt uiICId = 0; uiICId < ( bICEnabled ? 2 : 1 ); uiICId++ ) 630 667 { 631 668 Bool bICFlag = uiICId ? true : false; 632 669 #endif 633 634 635 636 #if H_3D_IC670 // 2Nx2N 671 if(m_pcEncCfg->getUseEarlySkipDetection()) 672 { 673 #if NH_3D_IC 637 674 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 638 675 #endif 639 #if H_3D_FAST_TEXTURE_ENCODING640 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD ); rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N641 #else 642 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N);643 644 #endif 645 #if H_3D_VSP646 647 #endif 648 649 650 #if H_3D_IC676 #if NH_3D_FAST_TEXTURE_ENCODING 677 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD ); rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N 678 #else 679 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug) ); 680 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N 681 #endif 682 #if NH_3D_VSP || NH_3D_DBBP 683 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 684 #endif 685 } 686 // SKIP 687 #if NH_3D_IC 651 688 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 652 689 #endif 653 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N654 #if H_3D_FAST_TEXTURE_ENCODING690 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU DEBUG_STRING_PASS_INTO(sDebug), &earlyDetectionSkipMode );//by Merge for inter_2Nx2N 691 #if NH_3D_FAST_TEXTURE_ENCODING 655 692 bFMD = bIVFMerge && rpcBestCU->isSkipped(0); 656 693 #endif 694 695 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 696 #if NH_3D_VSP || NH_3D_DBBP 697 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 698 #endif 699 700 if(!m_pcEncCfg->getUseEarlySkipDetection()) 701 { 702 // 2Nx2N, NxN 703 #if NH_3D_IC 704 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 705 #endif 706 #if NH_3D_FAST_TEXTURE_ENCODING 707 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD ); rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 708 #else 709 710 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug) ); 657 711 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 658 #if H_3D_VSP 712 #endif 713 #if NH_3D_VSP || NH_3D_DBBP 659 714 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 660 715 #endif 661 662 if(!m_pcEncCfg->getUseEarlySkipDetection()) 663 { 664 // 2Nx2N, NxN 665 #if H_3D_IC 666 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 667 #endif 668 #if H_3D_FAST_TEXTURE_ENCODING 669 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD ); rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 670 #else 671 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); 672 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 673 #endif 674 #if H_3D_VSP 675 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 676 #endif 677 678 #if H_3D_DBBP 716 #if NH_3D_DBBP 679 717 if( rpcTempCU->getSlice()->getDepthBasedBlkPartFlag() && rpcTempCU->getSlice()->getDefaultRefViewIdxAvailableFlag() ) 680 718 { 681 xCheckRDCostInterDBBP( rpcBestCU, rpcTempCU , false );719 xCheckRDCostInterDBBP( rpcBestCU, rpcTempCU DEBUG_STRING_PASS_INTO(sDebug), false ); 682 720 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 683 #if H_3D_VSP721 #if NH_3D_VSP || NH_3D_DBBP 684 722 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 685 723 #endif 686 724 } 687 725 #endif 688 if(m_pcEncCfg->getUseCbfFastMode()) 689 {690 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;691 }726 727 if(m_pcEncCfg->getUseCbfFastMode()) 728 { 729 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; 692 730 } 693 #if H_3D_IC694 731 } 732 #if NH_3D_IC 733 } 695 734 #endif 696 735 } 697 698 #if H_3D_QTLPC 736 #if NH_3D_QTLPC 699 737 if(depthMapDetect && !bIntraSliceDetect && !rapPic && ( m_pcEncCfg->getUseQTL() || bLimQtPredFalg )) 700 738 { … … 702 740 } 703 741 #endif 704 if ( bIsLosslessMode ) 742 743 if (bIsLosslessMode) // Restore loop variable if lossless mode was searched. 705 744 { 706 745 iQP = iMinQP; … … 715 754 } 716 755 #endif 717 #if H_3D_DIM_ENC756 #if NH_3D_ENC_DEPTH 718 757 if( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() ) 719 758 { … … 721 760 } 722 761 #endif 723 #if H_3D762 #if NH_3D_DIS 724 763 rpcTempCU->initEstData( uiDepth, iMinQP, isAddLowestQP ); 725 764 if( rpcBestCU->getSlice()->getDepthIntraSkipFlag() ) … … 733 772 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 734 773 { 735 const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP); 774 const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP); // If lossless, then iQP is irrelevant for subsequent modules. 736 775 737 776 if (bIsLosslessMode) … … 739 778 iQP = lowestQP; 740 779 } 780 741 781 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 742 782 … … 745 785 { 746 786 // 2Nx2N, NxN 747 if(!( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) )) 787 788 if(!( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) )) 789 { 790 if( uiDepth == sps.getLog2DiffMaxMinCodingBlockSize() && doNotBlockPu 791 #if NH_3D_QTLPC 792 && bTrySplit 793 #endif 794 ) 748 795 { 749 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu 750 #if H_3D_QTLPC 751 && bTrySplit 752 #endif 753 ) 754 { 755 #if H_3D_FAST_TEXTURE_ENCODING 756 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN, bFMD ); 757 #else 758 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 759 #endif 760 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 761 #if H_3D_VSP 762 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 763 #endif 764 } 796 #if NH_3D_FAST_TEXTURE_ENCODING 797 xCheckRDCostInter( rpcBestCU, rpcTempCU DEBUG_STRING_PASS_INTO(sDebug), SIZE_NxN, bFMD ); 798 #else 799 800 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN DEBUG_STRING_PASS_INTO(sDebug) ); 801 #endif 802 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 803 #if NH_3D_VSP || NH_3D_DBBP 804 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 805 #endif 806 765 807 } 766 767 // 2NxN, Nx2N 808 } 809 768 810 if(doNotBlockPu 769 #if H_3D_QTLPC811 #if NH_3D_QTLPC 770 812 && bTryNx2N 771 813 #endif 772 814 ) 773 815 { 774 #if H_3D_FAST_TEXTURE_ENCODING775 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N , bFMD );776 #else 777 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N );816 #if NH_3D_FAST_TEXTURE_ENCODING 817 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD ); 818 #else 819 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N DEBUG_STRING_PASS_INTO(sDebug) ); 778 820 #endif 779 821 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 780 #if H_3D_VSP822 #if NH_3D_VSP || NH_3D_DBBP 781 823 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 782 824 #endif 825 783 826 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) 784 827 { … … 787 830 } 788 831 if(doNotBlockPu 789 #if H_3D_QTLPC832 #if NH_3D_QTLPC 790 833 && bTry2NxN 791 834 #endif 792 835 ) 793 836 { 794 #if H_3D_FAST_TEXTURE_ENCODING 795 xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN, bFMD ); 796 #else 797 xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN ); 798 #endif 837 #if NH_3D_FAST_TEXTURE_ENCODING 838 xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN DEBUG_STRING_PASS_INTO(sDebug), bFMD ); 839 #else 840 841 xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN DEBUG_STRING_PASS_INTO(sDebug) ); 842 #endif 843 799 844 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 800 #if H_3D_VSP845 #if NH_3D_VSP || NH_3D_DBBP 801 846 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 802 847 #endif 848 803 849 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN) 804 850 { … … 807 853 } 808 854 809 #if 1810 855 //! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N) 811 if( pcPic->getSlice(0)->getSPS()->getAMPAcc(uiDepth) )856 if(sps.getUseAMP() && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) 812 857 { 813 #if AMP_ENC_SPEEDUP 858 #if AMP_ENC_SPEEDUP 814 859 Bool bTestAMP_Hor = false, bTestAMP_Ver = false; 815 860 … … 826 871 { 827 872 if(doNotBlockPu 828 #if H_3D_QTLPC873 #if NH_3D_QTLPC 829 874 && bTry2NxN 830 875 #endif 831 876 ) 832 877 { 833 #if H_3D_FAST_TEXTURE_ENCODING834 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU , bFMD );835 #else 836 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );878 #if NH_3D_FAST_TEXTURE_ENCODING 879 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU DEBUG_STRING_PASS_INTO(sDebug), bFMD ); 880 #else 881 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU DEBUG_STRING_PASS_INTO(sDebug) ); 837 882 #endif 838 883 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 839 #if H_3D_VSP884 #if NH_3D_VSP || NH_3D_DBBP 840 885 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 841 886 #endif … … 846 891 } 847 892 if(doNotBlockPu 848 #if H_3D_QTLPC893 #if NH_3D_QTLPC 849 894 && bTry2NxN 850 895 #endif 851 896 ) 852 897 { 853 #if H_3D_FAST_TEXTURE_ENCODING 854 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFMD ); 855 #else 856 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); 857 #endif 898 #if NH_3D_FAST_TEXTURE_ENCODING 899 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD DEBUG_STRING_PASS_INTO(sDebug), bFMD ); 900 #else 901 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD DEBUG_STRING_PASS_INTO(sDebug) ); 902 #endif 903 858 904 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 859 #if H_3D_VSP905 #if NH_3D_VSP || NH_3D_DBBP 860 906 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 861 907 #endif 908 862 909 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) 863 910 { … … 867 914 } 868 915 #if AMP_MRG 869 else if ( bTestMergeAMP_Hor ) 916 else if ( bTestMergeAMP_Hor ) 870 917 { 871 918 if(doNotBlockPu 872 #if H_3D_QTLPC919 #if NH_3D_QTLPC 873 920 && bTry2NxN 874 921 #endif 875 922 ) 876 923 { 877 #if H_3D_FAST_TEXTURE_ENCODING 878 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFMD, true ); 879 #else 880 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true ); 881 #endif 924 #if NH_3D_FAST_TEXTURE_ENCODING 925 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU DEBUG_STRING_PASS_INTO(sDebug), bFMD, true ); 926 #else 927 928 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU DEBUG_STRING_PASS_INTO(sDebug), true ); 929 #endif 930 882 931 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 883 #if H_3D_VSP932 #if NH_3D_VSP || NH_3D_DBBP 884 933 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 885 934 #endif … … 890 939 } 891 940 if(doNotBlockPu 892 #if H_3D_QTLPC941 #if NH_3D_QTLPC 893 942 && bTry2NxN 894 943 #endif 895 944 ) 896 945 { 897 #if H_3D_FAST_TEXTURE_ENCODING898 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD , bFMD, true );899 #else 900 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD , true );946 #if NH_3D_FAST_TEXTURE_ENCODING 947 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD DEBUG_STRING_PASS_INTO(sDebug), bFMD, true ); 948 #else 949 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD DEBUG_STRING_PASS_INTO(sDebug), true ); 901 950 #endif 902 951 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 903 #if H_3D_VSP952 #if NH_3D_VSP || NH_3D_DBBP 904 953 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 905 954 #endif 955 906 956 if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) 907 957 { … … 916 966 { 917 967 if(doNotBlockPu 918 #if H_3D_QTLPC968 #if NH_3D_QTLPC 919 969 && bTryNx2N 920 970 #endif 921 971 ) 922 972 { 923 #if H_3D_FAST_TEXTURE_ENCODING 924 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFMD ); 925 #else 926 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); 927 #endif 973 #if NH_3D_FAST_TEXTURE_ENCODING 974 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD ); 975 #else 976 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N DEBUG_STRING_PASS_INTO(sDebug) ); 977 #endif 978 928 979 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 929 #if H_3D_VSP980 #if NH_3D_VSP || NH_3D_DBBP 930 981 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 931 982 #endif … … 936 987 } 937 988 if(doNotBlockPu 938 #if H_3D_QTLPC989 #if NH_3D_QTLPC 939 990 && bTryNx2N 940 991 #endif 941 992 ) 942 993 { 943 #if H_3D_FAST_TEXTURE_ENCODING944 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N , bFMD );945 #else 946 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );994 #if NH_3D_FAST_TEXTURE_ENCODING 995 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD ); 996 #else 997 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N DEBUG_STRING_PASS_INTO(sDebug) ); 947 998 #endif 948 999 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 949 #if H_3D_VSP1000 #if NH_3D_VSP || NH_3D_DBBP 950 1001 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 951 1002 #endif … … 956 1007 { 957 1008 if(doNotBlockPu 958 #if H_3D_QTLPC1009 #if NH_3D_QTLPC 959 1010 && bTryNx2N 960 1011 #endif 961 1012 ) 962 1013 { 963 #if H_3D_FAST_TEXTURE_ENCODING964 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N , bFMD, true );965 #else 966 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N , true );1014 #if NH_3D_FAST_TEXTURE_ENCODING 1015 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD, true ); 1016 #else 1017 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N DEBUG_STRING_PASS_INTO(sDebug), true ); 967 1018 #endif 968 1019 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 969 #if H_3D_VSP1020 #if NH_3D_VSP || NH_3D_DBBP 970 1021 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 971 1022 #endif … … 976 1027 } 977 1028 if(doNotBlockPu 978 #if H_3D_QTLPC1029 #if NH_3D_QTLPC 979 1030 && bTryNx2N 980 1031 #endif 981 1032 ) 982 1033 { 983 #if H_3D_FAST_TEXTURE_ENCODING 984 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFMD, true ); 985 #else 986 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true ); 1034 #if NH_3D_FAST_TEXTURE_ENCODING 1035 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N DEBUG_STRING_PASS_INTO(sDebug), bFMD, true ); 1036 #else 1037 1038 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N DEBUG_STRING_PASS_INTO(sDebug), true ); 987 1039 #endif 988 1040 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 989 #if H_3D_VSP1041 #if NH_3D_VSP || NH_3D_DBBP 990 1042 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 991 1043 #endif 1044 992 1045 } 993 1046 } … … 995 1048 996 1049 #else 997 #if H_3D_QTLPC1050 #if NH_3D_QTLPC 998 1051 if (bTry2NxN) 999 1052 { 1000 1053 #endif 1001 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); 1002 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1003 #if H_3D_VSP 1004 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 1005 #endif 1006 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); 1007 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1008 #if H_3D_VSP 1009 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 1010 #endif 1011 #if H_3D_QTLPC 1054 1055 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); 1056 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1057 #if NH_3D_VSP || NH_3D_DBBP 1058 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 1059 #endif 1060 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); 1061 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1062 #if NH_3D_VSP || NH_3D_DBBP 1063 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 1064 #endif 1065 #if NH_3D_QTLPC 1012 1066 } 1013 1067 if (bTryNx2N) 1014 1068 { 1015 1069 #endif 1016 1017 1018 #if H_3D_VSP1019 1020 #endif 1021 1022 1023 #if H_3D_VSP1024 1025 #endif 1026 #if H_3D_QTLPC1070 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); 1071 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1072 #if NH_3D_VSP || NH_3D_DBBP 1073 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 1074 #endif 1075 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); 1076 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1077 #if NH_3D_VSP || NH_3D_DBBP 1078 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 1079 #endif 1080 #if NH_3D_QTLPC 1027 1081 } 1028 1082 #endif 1029 1083 1030 #endif 1031 } 1032 #endif 1084 1085 #endif 1086 } 1033 1087 } 1034 #if H_3D_FAST_TEXTURE_ENCODING1088 #if NH_3D_FAST_TEXTURE_ENCODING 1035 1089 if(!bFMD) 1036 1090 { 1037 1091 #endif 1092 1038 1093 // do normal intra modes 1039 1040 // speedup for inter frames 1041 if( rpcBestCU->getSlice()->getSliceType() == I_SLICE || 1042 rpcBestCU->getCbf( 0, TEXT_LUMA ) != 0 || 1043 rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0 || 1044 rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 1045 #if H_3D_DIM_ENC 1094 // speedup for inter frames 1095 Double intraCost = 0.0; 1096 1097 if((rpcBestCU->getSlice()->getSliceType() == I_SLICE) || 1098 ((!m_pcEncCfg->getDisableIntraPUsInInterSlices()) && ( // avoid very complex intra if it is unlikely 1099 (rpcBestCU->getCbf( 0, COMPONENT_Y ) != 0) || 1100 ((rpcBestCU->getCbf( 0, COMPONENT_Cb ) != 0) && (numberValidComponents > COMPONENT_Cb)) || 1101 ((rpcBestCU->getCbf( 0, COMPONENT_Cr ) != 0) && (numberValidComponents > COMPONENT_Cr)) 1102 #if NH_3D_ENC_DEPTH 1046 1103 || rpcBestCU->getSlice()->getIsDepth() 1047 1104 #endif 1048 ) // avoid very complex intra if it is unlikely1049 1050 #if H_3D_DIM1105 ))) 1106 { 1107 #if NH_3D_ENC_DEPTH 1051 1108 Bool bOnlyIVP = false; 1052 1109 Bool bUseIVP = true; 1053 if( rpcBestCU->getSlice()->getIsDepth() && !(rpcBestCU->getSlice()->isIRAP()) && 1054 rpcBestCU->getSlice()->getSliceType() != I_SLICE && 1055 rpcBestCU->getCbf( 0, TEXT_LUMA ) == 0 && 1056 rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) == 0 && 1057 rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) == 0 1058 ) 1110 if( (rpcBestCU->getSlice()->getSliceType() != I_SLICE) && 1111 !( (rpcBestCU->getCbf( 0, COMPONENT_Y ) != 0) || 1112 ((rpcBestCU->getCbf( 0, COMPONENT_Cb ) != 0) && (numberValidComponents > COMPONENT_Cb)) || 1113 ((rpcBestCU->getCbf( 0, COMPONENT_Cr ) != 0) && (numberValidComponents > COMPONENT_Cr)) ) && 1114 (rpcBestCU->getSlice()->getIsDepth() && !(rpcBestCU->getSlice()->isIRAP())) ) 1059 1115 { 1060 1116 bOnlyIVP = true; … … 1063 1119 if( bUseIVP ) 1064 1120 { 1065 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bOnlyIVP ); 1066 #else 1067 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); 1068 #endif 1069 1121 xCheckRDCostIntra( rpcBestCU, rpcTempCU, intraCost, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug), bOnlyIVP ); 1122 #else 1123 xCheckRDCostIntra( rpcBestCU, rpcTempCU, intraCost, SIZE_2Nx2N DEBUG_STRING_PASS_INTO(sDebug) ); 1124 #endif 1070 1125 #if KWU_RC_MADPRED_E0227 1071 1126 if ( uiDepth <= m_addSADDepth ) … … 1076 1131 #endif 1077 1132 1078 1079 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth)1080 1081 #if H_3D_QTLPC //Try IntraNxN1133 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1134 if( uiDepth == sps.getLog2DiffMaxMinCodingBlockSize() ) 1135 { 1136 #if NH_3D_QTLPC //Try IntraNxN 1082 1137 if(bTrySplit) 1083 1138 { 1084 1139 #endif 1085 if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) ) 1086 { 1087 #if H_3D_DIM 1088 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN, bOnlyIVP ); 1089 #else 1090 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN ); 1091 #endif 1092 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1093 } 1094 #if H_3D_QTLPC 1140 if( rpcTempCU->getWidth(0) > ( 1 << sps.getQuadtreeTULog2MinSize() ) ) 1141 { 1142 Double tmpIntraCost; 1143 #if NH_3D_ENC_DEPTH 1144 xCheckRDCostIntra( rpcBestCU, rpcTempCU, tmpIntraCost, SIZE_NxN DEBUG_STRING_PASS_INTO(sDebug), bOnlyIVP ); 1145 #else 1146 xCheckRDCostIntra( rpcBestCU, rpcTempCU, tmpIntraCost, SIZE_NxN DEBUG_STRING_PASS_INTO(sDebug) ); 1147 #endif 1148 1149 intraCost = std::min(intraCost, tmpIntraCost); 1150 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1151 } 1152 #if NH_3D_QTLPC 1095 1153 } 1096 1154 #endif 1097 }1098 #if H_3D1099 1155 } 1156 #if NH_3D_ENC_DEPTH 1157 } 1100 1158 #endif 1101 1159 } 1160 1102 1161 // test PCM 1103 if( pcPic->getSlice(0)->getSPS()->getUsePCM()1104 && rpcTempCU->getWidth(0) <= (1<< pcPic->getSlice(0)->getSPS()->getPCMLog2MaxSize())1105 && rpcTempCU->getWidth(0) >= (1<< pcPic->getSlice(0)->getSPS()->getPCMLog2MinSize()) )1162 if(sps.getUsePCM() 1163 && rpcTempCU->getWidth(0) <= (1<<sps.getPCMLog2MaxSize()) 1164 && rpcTempCU->getWidth(0) >= (1<<sps.getPCMLog2MinSize()) ) 1106 1165 { 1107 UInt uiRawBits = (2 * g_bitDepthY + g_bitDepthC) * rpcBestCU->getWidth(0) * rpcBestCU->getHeight(0) / 2;1166 UInt uiRawBits = getTotalBits(rpcBestCU->getWidth(0), rpcBestCU->getHeight(0), rpcBestCU->getPic()->getChromaFormat(), sps.getBitDepths().recon); 1108 1167 UInt uiBestBits = rpcBestCU->getTotalBits(); 1109 #if H_3D_VSO // M71110 Double dRDCostTemp = m_pcRdCost->getUse VSO() ? m_pcRdCost->calcRdCostVSO(uiRawBits, 0) : m_pcRdCost->calcRdCost(uiRawBits, 0);1168 #if NH_3D_VSO // M7 1169 Double dRDCostTemp = m_pcRdCost->getUseLambdaScaleVSO() ? m_pcRdCost->calcRdCostVSO(uiRawBits, 0) : m_pcRdCost->calcRdCost(uiRawBits, 0); 1111 1170 if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > dRDCostTemp )) 1112 1171 #else 1113 1172 if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > m_pcRdCost->calcRdCost(uiRawBits, 0))) 1114 1173 #endif 1174 1115 1175 { 1116 1176 xCheckIntraPCM (rpcBestCU, rpcTempCU); … … 1118 1178 } 1119 1179 } 1120 #if H_3D_FAST_TEXTURE_ENCODING1180 #if NH_3D_FAST_TEXTURE_ENCODING 1121 1181 } 1122 1182 #endif 1123 if (bIsLosslessMode) 1183 if (bIsLosslessMode) // Restore loop variable if lossless mode was searched. 1124 1184 { 1125 1185 iQP = iMinQP; … … 1128 1188 } 1129 1189 1130 m_pcEntropyCoder->resetBits(); 1131 m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true ); 1132 rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits 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 1133 1196 rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1134 #ifH_3D_VSO // M81197 #if NH_3D_VSO // M8 1135 1198 if ( m_pcRdCost->getUseVSO() ) 1199 { 1136 1200 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 1201 } 1137 1202 else 1138 1203 #endif 1139 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 1140 1141 // Early CU determination 1142 if( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->isSkipped(0) ) 1204 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 1205 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); 1206 } 1207 #if NH_3D_FAST_TEXTURE_ENCODING 1208 if(rpcBestCU->getSlice()->getViewIndex() && !rpcBestCU->getSlice()->getIsDepth() && (uiDepth >=iIVFMaxD) && rpcBestCU->isSkipped(0)) 1143 1209 { 1144 1210 bSubBranch = false; 1145 1211 } 1146 else 1147 { 1148 bSubBranch = true; 1149 } 1150 #if H_3D_FAST_TEXTURE_ENCODING 1151 if(rpcBestCU->getSlice()->getViewIndex() && !rpcBestCU->getSlice()->getIsDepth() && (uiDepth >=iIVFMaxD) && rpcBestCU->isSkipped(0)) 1152 { 1153 bSubBranch = false; 1154 } 1155 #endif 1156 } 1157 else if(!(bSliceEnd && bInsidePicture)) 1158 { 1159 bBoundary = true; 1160 } 1161 1162 // copy orginal YUV samples to PCM buffer 1163 if( rpcBestCU->isLosslessCoded(0) && (rpcBestCU->getIPCMFlag(0) == false)) 1212 #endif 1213 } 1214 1215 // copy original YUV samples to PCM buffer 1216 if( rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isLosslessCoded(0) && (rpcBestCU->getIPCMFlag(0) == false)) 1164 1217 { 1165 1218 xFillPCMBuffer(rpcBestCU, m_ppcOrigYuv[uiDepth]); 1166 1219 } 1167 if( (g_uiMaxCUWidth>>uiDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) 1220 1221 if( uiDepth == pps.getMaxCuDQPDepth() ) 1168 1222 { 1169 1223 Int idQP = m_pcEncCfg->getMaxDeltaQP(); 1170 iMinQP = Clip3( - rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP );1171 iMaxQP = Clip3( - rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP );1172 } 1173 else if( (g_uiMaxCUWidth>>uiDepth) > rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() )1224 iMinQP = Clip3( -sps.getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQP-idQP ); 1225 iMaxQP = Clip3( -sps.getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQP+idQP ); 1226 } 1227 else if( uiDepth < pps.getMaxCuDQPDepth() ) 1174 1228 { 1175 1229 iMinQP = iBaseQP; … … 1178 1232 else 1179 1233 { 1180 Int iStartQP; 1181 if( pcPic->getCU( rpcTempCU->getAddr() )->getSliceSegmentStartCU(rpcTempCU->getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr()) 1182 { 1183 iStartQP = rpcTempCU->getQP(0); 1184 } 1185 else 1186 { 1187 UInt uiCurSliceStartPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU() - rpcTempCU->getZorderIdxInCU(); 1188 iStartQP = rpcTempCU->getQP(uiCurSliceStartPartIdx); 1189 } 1234 const Int iStartQP = rpcTempCU->getQP(0); 1190 1235 iMinQP = iStartQP; 1191 1236 iMaxQP = iStartQP; 1192 1237 } 1238 1193 1239 if ( m_pcEncCfg->getUseRateCtrl() ) 1194 1240 { … … 1199 1245 if ( m_pcEncCfg->getCUTransquantBypassFlagForceValue() ) 1200 1246 { 1201 iMaxQP = iMinQP; // If all blocks are forced into using transquant bypass, do not loop here. 1202 } 1203 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 1204 { 1205 const Bool bIsLosslessMode = false; // False at this level. Next level down may set it to true. 1206 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1207 1247 iMaxQP = iMinQP; // If all TUs are forced into using transquant bypass, do not loop here. 1248 } 1249 #if NH_3D_FAST_TEXTURE_ENCODING 1250 bSubBranch = bSubBranch && (bBoundary || !( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isSkipped(0) )); 1251 #else 1252 const Bool bSubBranch = bBoundary || !( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isSkipped(0) ); 1253 #endif 1254 #if NH_3D_QTLPC 1255 if( bSubBranch && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() && (!getFastDeltaQp() || uiWidth > fastDeltaQPCuMaxSize || bBoundary) && bTrySplitDQP ) 1256 #else 1257 if( bSubBranch && uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() && (!getFastDeltaQp() || uiWidth > fastDeltaQPCuMaxSize || bBoundary)) 1258 #endif 1259 { 1208 1260 // further split 1209 #if H_3D_QTLPC 1210 if( bSubBranch && bTrySplitDQP && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )1211 #else 1212 if( bSubBranch && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) 1213 #endif 1214 { 1215 #if H_3D_VSO // M91261 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) 1262 { 1263 const Bool bIsLosslessMode = false; // False at this level. Next level down may set it to true. 1264 1265 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 1266 1267 #if NH_3D_VSO // M9 1216 1268 // reset Model 1217 1269 if( m_pcRdCost->getUseRenModel() ) 1218 1270 { 1219 UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth ();1220 UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight();1221 Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr(0 );1222 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();1223 m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth , uiHeight);1271 UInt uiWidthOy = m_ppcOrigYuv[uiDepth]->getWidth ( COMPONENT_Y ); 1272 UInt uiHeightOy = m_ppcOrigYuv[uiDepth]->getHeight( COMPONENT_Y ); 1273 Pel* piSrc = m_ppcOrigYuv[uiDepth]->getAddr ( COMPONENT_Y, 0 ); 1274 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride( COMPONENT_Y ); 1275 m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidthOy, uiHeightOy ); 1224 1276 } 1225 1277 #endif 1226 1227 1278 UChar uhNextDepth = uiDepth+1; 1228 1279 TComDataCU* pcSubBestPartCU = m_ppcBestCU[uhNextDepth]; 1229 1280 TComDataCU* pcSubTempPartCU = m_ppcTempCU[uhNextDepth]; 1230 1231 #if H_3D_DISABLE_CHROMA 1281 DEBUG_STRING_NEW(sTempDebug) 1282 1283 #if NH_3D_ARP 1232 1284 m_ppcWeightedTempCU[uhNextDepth]->setSlice( m_ppcWeightedTempCU[ uiDepth]->getSlice()); 1285 m_ppcWeightedTempCU[uhNextDepth]->setPic ( m_ppcWeightedTempCU[ uiDepth] ); 1233 1286 #endif 1234 1287 for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) … … 1237 1290 pcSubTempPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. 1238 1291 1239 Bool bInSlice = pcSubBestPartCU->getSCUAddr()+pcSubBestPartCU->getTotalNumPart()>pcSlice->getSliceSegmentCurStartCUAddr()&&pcSubBestPartCU->getSCUAddr()<pcSlice->getSliceSegmentCurEndCUAddr(); 1240 if(bInSlice && ( pcSubBestPartCU->getCUPelX() < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( pcSubBestPartCU->getCUPelY() < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 1292 if( ( pcSubBestPartCU->getCUPelX() < sps.getPicWidthInLumaSamples() ) && ( pcSubBestPartCU->getCUPelY() < sps.getPicHeightInLumaSamples() ) ) 1241 1293 { 1242 if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer 1243 { 1244 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 1245 } 1246 else 1247 { 1248 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 1249 } 1250 1251 #if AMP_ENC_SPEEDUP 1252 if ( rpcBestCU->isIntra(0) ) 1294 if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer 1253 1295 { 1254 xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth, SIZE_NONE);1296 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); 1255 1297 } 1256 1298 else 1257 1299 { 1258 xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth, rpcBestCU->getPartitionSize(0));1300 m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 1259 1301 } 1302 1303 #if AMP_ENC_SPEEDUP 1304 DEBUG_STRING_NEW(sChild) 1305 if ( !(rpcBestCU->getTotalCost()!=MAX_DOUBLE && rpcBestCU->isInter(0)) ) 1306 { 1307 xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth DEBUG_STRING_PASS_INTO(sChild), NUMBER_OF_PART_SIZES ); 1308 } 1309 else 1310 { 1311 1312 xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth DEBUG_STRING_PASS_INTO(sChild), rpcBestCU->getPartitionSize(0) ); 1313 } 1314 DEBUG_STRING_APPEND(sTempDebug, sChild) 1260 1315 #else 1261 1316 xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth ); … … 1265 1320 xCopyYuv2Tmp( pcSubBestPartCU->getTotalNumPart()*uiPartUnitIdx, uhNextDepth ); 1266 1321 } 1267 else if (bInSlice)1322 else 1268 1323 { 1269 1324 pcSubBestPartCU->copyToPic( uhNextDepth ); … … 1272 1327 } 1273 1328 1329 m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); 1274 1330 if( !bBoundary ) 1275 1331 { … … 1278 1334 1279 1335 rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits 1280 1281 1282 #if H_3D_VSO // M101336 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1337 } 1338 #if NH_3D_VSO // M10 1283 1339 if ( m_pcRdCost->getUseVSO() ) 1340 { 1284 1341 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1342 } 1285 1343 else 1286 1344 #endif 1287 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );1288 1289 if( (g_uiMaxCUWidth>>uiDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() && rpcTempCU->getSlice()->getPPS()->getUseDQP())1345 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1346 1347 if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP()) 1290 1348 { 1291 1349 Bool hasResidual = false; 1292 1350 for( UInt uiBlkIdx = 0; uiBlkIdx < rpcTempCU->getTotalNumPart(); uiBlkIdx ++) 1293 1351 { 1294 if( ( pcPic->getCU( rpcTempCU->getAddr() )->getSliceSegmentStartCU(uiBlkIdx+rpcTempCU->getZorderIdxInCU()) == rpcTempCU->getSlice()->getSliceSegmentCurStartCUAddr() ) && 1295 ( rpcTempCU->getCbf( uiBlkIdx, TEXT_LUMA ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_U ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_V ) ) ) 1352 if( ( rpcTempCU->getCbf(uiBlkIdx, COMPONENT_Y) 1353 || (rpcTempCU->getCbf(uiBlkIdx, COMPONENT_Cb) && (numberValidComponents > COMPONENT_Cb)) 1354 || (rpcTempCU->getCbf(uiBlkIdx, COMPONENT_Cr) && (numberValidComponents > COMPONENT_Cr)) ) ) 1296 1355 { 1297 1356 hasResidual = true; … … 1300 1359 } 1301 1360 1302 UInt uiTargetPartIdx;1303 if ( pcPic->getCU( rpcTempCU->getAddr() )->getSliceSegmentStartCU(rpcTempCU->getZorderIdxInCU()) != pcSlice->getSliceSegmentCurStartCUAddr() )1304 {1305 uiTargetPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU() - rpcTempCU->getZorderIdxInCU();1306 }1307 else1308 {1309 uiTargetPartIdx = 0;1310 }1311 1361 if ( hasResidual ) 1312 1362 { 1313 #if !RDO_WITHOUT_DQP_BITS1314 1363 m_pcEntropyCoder->resetBits(); 1315 m_pcEntropyCoder->encodeQP( rpcTempCU, uiTargetPartIdx, false );1364 m_pcEntropyCoder->encodeQP( rpcTempCU, 0, false ); 1316 1365 rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits 1317 1318 #if H_3D_VSO // M111366 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1367 #if NH_3D_VSO // M11 1319 1368 if ( m_pcRdCost->getUseLambdaScaleVSO()) 1369 { 1320 1370 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1371 } 1321 1372 else 1322 1373 #endif 1323 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1324 #endif 1374 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1325 1375 1326 1376 Bool foundNonZeroCbf = false; 1327 rpcTempCU->setQPSubCUs( rpcTempCU->getRefQP( uiTargetPartIdx ), rpcTempCU, 0, uiDepth, foundNonZeroCbf );1377 rpcTempCU->setQPSubCUs( rpcTempCU->getRefQP( 0 ), 0, uiDepth, foundNonZeroCbf ); 1328 1378 assert( foundNonZeroCbf ); 1329 1379 } 1330 1380 else 1331 1381 { 1332 rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( uiTargetPartIdx), 0, uiDepth ); // set QP to default QP1382 rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( 0 ), 0, uiDepth ); // set QP to default QP 1333 1383 } 1334 1384 } 1335 1385 1336 m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 1337 Bool isEndOfSlice = rpcBestCU->getSlice()->getSliceMode()==FIXED_NUMBER_OF_BYTES 1338 && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceArgument()<<3); 1339 Bool isEndOfSliceSegment = rpcBestCU->getSlice()->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES 1340 && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceSegmentArgument()<<3); 1341 if(isEndOfSlice||isEndOfSliceSegment) 1386 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 1387 1388 // If the configuration being tested exceeds the maximum number of bytes for a slice / slice-segment, then 1389 // a proper RD evaluation cannot be performed. Therefore, termination of the 1390 // slice/slice-segment must be made prior to this CTU. 1391 // This can be achieved by forcing the decision to be that of the rpcTempCU. 1392 // The exception is each slice / slice-segment must have at least one CTU. 1393 if (rpcBestCU->getTotalCost()!=MAX_DOUBLE) 1342 1394 { 1343 rpcBestCU->getTotalCost()=rpcTempCU->getTotalCost()+1; 1395 const Bool isEndOfSlice = pcSlice->getSliceMode()==FIXED_NUMBER_OF_BYTES 1396 && ((pcSlice->getSliceBits()+rpcBestCU->getTotalBits())>pcSlice->getSliceArgument()<<3) 1397 && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceCurStartCtuTsAddr()) 1398 && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()); 1399 const Bool isEndOfSliceSegment = pcSlice->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES 1400 && ((pcSlice->getSliceSegmentBits()+rpcBestCU->getTotalBits()) > pcSlice->getSliceSegmentArgument()<<3) 1401 && rpcBestCU->getCtuRsAddr() != pcPic->getPicSym()->getCtuTsToRsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()); 1402 // Do not need to check slice condition for slice-segment since a slice-segment is a subset of a slice. 1403 if(isEndOfSlice||isEndOfSliceSegment) 1404 { 1405 rpcBestCU->getTotalCost()=MAX_DOUBLE; 1406 } 1344 1407 } 1345 xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth); // RD compare current larger prediction 1346 } // with sub partitioned prediction. 1347 } 1348 1349 #if H_3D_VSO // M12 1408 1409 xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTempDebug) DEBUG_STRING_PASS_INTO(false) ); // RD compare current larger prediction 1410 // with sub partitioned prediction. 1411 } 1412 } 1413 #if NH_3D_VSO // M12 1350 1414 if( m_pcRdCost->getUseRenModel() ) 1351 1415 { 1352 UInt uiWidth = m_ppcRecoYuvBest[uiDepth]->getWidth ( ); 1353 UInt uiHeight = m_ppcRecoYuvBest[uiDepth]->getHeight ( ); 1354 Pel* piSrc = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 ); 1355 UInt uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride ( ); 1356 m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 1357 } 1358 #endif 1416 UInt uiWidthRy = m_ppcRecoYuvBest[uiDepth]->getWidth ( COMPONENT_Y ); 1417 UInt uiHeightRy = m_ppcRecoYuvBest[uiDepth]->getHeight ( COMPONENT_Y ); 1418 Pel* piSrc = m_ppcRecoYuvBest[uiDepth]->getAddr ( COMPONENT_Y, 0 ); 1419 UInt uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride ( COMPONENT_Y ); 1420 m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidthRy, uiHeightRy ); 1421 } 1422 #endif 1423 1424 DEBUG_STRING_APPEND(sDebug_, sDebug); 1425 1359 1426 rpcBestCU->copyToPic(uiDepth); // Copy Best data to Picture for next partition prediction. 1360 1427 1361 xCopyYuv2Pic( rpcBestCU->getPic(), rpcBestCU->get Addr(), rpcBestCU->getZorderIdxInCU(), uiDepth, uiDepth, rpcBestCU, uiLPelX, uiTPelY); // Copy Yuv data to picture Yuv1362 if ( bBoundary ||(bSliceEnd && bInsidePicture))1428 xCopyYuv2Pic( rpcBestCU->getPic(), rpcBestCU->getCtuRsAddr(), rpcBestCU->getZorderIdxInCtu(), uiDepth, uiDepth ); // Copy Yuv data to picture Yuv 1429 if (bBoundary) 1363 1430 { 1364 1431 return; … … 1367 1434 // Assert if Best prediction mode is NONE 1368 1435 // Selected mode's RD-cost must be not MAX_DOUBLE. 1369 assert( rpcBestCU->getPartitionSize ( 0 ) != SIZE_NONE);1370 assert( rpcBestCU->getPredictionMode( 0 ) != MODE_NONE);1371 assert( rpcBestCU->getTotalCost ( ) != MAX_DOUBLE );1436 assert( rpcBestCU->getPartitionSize ( 0 ) != NUMBER_OF_PART_SIZES ); 1437 assert( rpcBestCU->getPredictionMode( 0 ) != NUMBER_OF_PREDICTION_MODES ); 1438 assert( rpcBestCU->getTotalCost ( ) != MAX_DOUBLE ); 1372 1439 } 1373 1440 … … 1375 1442 * \param pcCU 1376 1443 * \param uiAbsPartIdx 1377 * \param uiDepth 1444 * \param uiDepth 1378 1445 * \returns Void 1379 1446 */ 1380 Void TEncCu::finishCU( TComDataCU* pcCU, UInt uiAbsPartIdx , UInt uiDepth)1447 Void TEncCu::finishCU( TComDataCU* pcCU, UInt uiAbsPartIdx ) 1381 1448 { 1382 1449 TComPic* pcPic = pcCU->getPic(); … … 1384 1451 1385 1452 //Calculate end address 1386 UInt uiCUAddr = pcCU->getSCUAddr()+uiAbsPartIdx; 1387 1388 UInt uiInternalAddress = pcPic->getPicSym()->getPicSCUAddr(pcSlice->getSliceSegmentCurEndCUAddr()-1) % pcPic->getNumPartInCU(); 1389 UInt uiExternalAddress = pcPic->getPicSym()->getPicSCUAddr(pcSlice->getSliceSegmentCurEndCUAddr()-1) / pcPic->getNumPartInCU(); 1390 UInt uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; 1391 UInt uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; 1392 UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); 1393 UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); 1394 while(uiPosX>=uiWidth||uiPosY>=uiHeight) 1395 { 1396 uiInternalAddress--; 1397 uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; 1398 uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; 1399 } 1400 uiInternalAddress++; 1401 if(uiInternalAddress==pcCU->getPic()->getNumPartInCU()) 1402 { 1403 uiInternalAddress = 0; 1404 uiExternalAddress = pcPic->getPicSym()->getCUOrderMap(pcPic->getPicSym()->getInverseCUOrderMap(uiExternalAddress)+1); 1405 } 1406 UInt uiRealEndAddress = pcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*pcPic->getNumPartInCU()+uiInternalAddress); 1407 1408 // Encode slice finish 1409 Bool bTerminateSlice = false; 1410 if (uiCUAddr+(pcCU->getPic()->getNumPartInCU()>>(uiDepth<<1)) == uiRealEndAddress) 1411 { 1412 bTerminateSlice = true; 1413 } 1414 UInt uiGranularityWidth = g_uiMaxCUWidth; 1415 uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1416 uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1417 Bool granularityBoundary=((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) 1418 &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)); 1419 1420 if(granularityBoundary) 1453 const Int currentCTUTsAddr = pcPic->getPicSym()->getCtuRsToTsAddrMap(pcCU->getCtuRsAddr()); 1454 const Bool isLastSubCUOfCtu = pcCU->isLastSubCUOfCtu(uiAbsPartIdx); 1455 if ( isLastSubCUOfCtu ) 1421 1456 { 1422 1457 // The 1-terminating bit is added to all streams, so don't add it here when it's 1. 1423 if (!bTerminateSlice) 1424 m_pcEntropyCoder->encodeTerminatingBit( bTerminateSlice ? 1 : 0 ); 1425 } 1426 1427 Int numberOfWrittenBits = 0; 1428 if (m_pcBitCounter) 1429 { 1430 numberOfWrittenBits = m_pcEntropyCoder->getNumberOfWrittenBits(); 1431 } 1432 1433 // Calculate slice end IF this CU puts us over slice bit size. 1434 UInt iGranularitySize = pcCU->getPic()->getNumPartInCU(); 1435 Int iGranularityEnd = ((pcCU->getSCUAddr()+uiAbsPartIdx)/iGranularitySize)*iGranularitySize; 1436 if(iGranularityEnd<=pcSlice->getSliceSegmentCurStartCUAddr()) 1437 { 1438 iGranularityEnd+=max(iGranularitySize,(pcCU->getPic()->getNumPartInCU()>>(uiDepth<<1))); 1439 } 1440 // Set slice end parameter 1441 if(pcSlice->getSliceMode()==FIXED_NUMBER_OF_BYTES&&!pcSlice->getFinalized()&&pcSlice->getSliceBits()+numberOfWrittenBits>pcSlice->getSliceArgument()<<3) 1442 { 1443 pcSlice->setSliceSegmentCurEndCUAddr(iGranularityEnd); 1444 pcSlice->setSliceCurEndCUAddr(iGranularityEnd); 1445 return; 1446 } 1447 // Set dependent slice end parameter 1448 if(pcSlice->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES&&!pcSlice->getFinalized()&&pcSlice->getSliceSegmentBits()+numberOfWrittenBits > pcSlice->getSliceSegmentArgument()<<3) 1449 { 1450 pcSlice->setSliceSegmentCurEndCUAddr(iGranularityEnd); 1451 return; 1452 } 1453 if(granularityBoundary) 1454 { 1455 pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + numberOfWrittenBits) ); 1456 pcSlice->setSliceSegmentBits(pcSlice->getSliceSegmentBits()+numberOfWrittenBits); 1457 if (m_pcBitCounter) 1458 { 1459 m_pcEntropyCoder->resetBits(); 1458 // i.e. when the slice segment CurEnd CTU address is the current CTU address+1. 1459 if (pcSlice->getSliceSegmentCurEndCtuTsAddr() != currentCTUTsAddr+1) 1460 { 1461 m_pcEntropyCoder->encodeTerminatingBit( 0 ); 1460 1462 } 1461 1463 } … … 1488 1490 iQpOffset = Int(floor( dQpOffset + 0.49999 )); 1489 1491 } 1490 return Clip3(-pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQp+iQpOffset ); 1492 1493 return Clip3(-pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQp+iQpOffset ); 1491 1494 } 1492 1495 … … 1494 1497 * \param pcCU 1495 1498 * \param uiAbsPartIdx 1496 * \param uiDepth 1499 * \param uiDepth 1497 1500 * \returns Void 1498 1501 */ 1499 1502 Void TEncCu::xEncodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 1500 1503 { 1501 TComPic* pcPic = pcCU->getPic(); 1502 1503 Bool bBoundary = false; 1504 UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1505 UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; 1506 UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1507 UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; 1508 1504 TComPic *const pcPic = pcCU->getPic(); 1505 TComSlice *const pcSlice = pcCU->getSlice(); 1506 const TComSPS &sps =*(pcSlice->getSPS()); 1507 const TComPPS &pps =*(pcSlice->getPPS()); 1508 1509 const UInt maxCUWidth = sps.getMaxCUWidth(); 1510 const UInt maxCUHeight = sps.getMaxCUHeight(); 1511 1512 Bool bBoundary = false; 1513 UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1514 const UInt uiRPelX = uiLPelX + (maxCUWidth>>uiDepth) - 1; 1515 UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1516 const UInt uiBPelY = uiTPelY + (maxCUHeight>>uiDepth) - 1; 1517 1509 1518 #if H_MV_ENC_DEC_TRAC 1510 1519 DTRACE_CU_S("=========== coding_quadtree ===========\n") 1511 1520 DTRACE_CU("x0", uiLPelX) 1512 1521 DTRACE_CU("x1", uiTPelY) 1513 DTRACE_CU("log2CbSize", g_uiMaxCUWidth>>uiDepth)1522 DTRACE_CU("log2CbSize", maxCUWidth>>uiDepth ) 1514 1523 DTRACE_CU("cqtDepth" , uiDepth) 1515 1524 #endif 1516 1525 1517 TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); 1518 // If slice start is within this cu... 1519 Bool bSliceStart = pcSlice->getSliceSegmentCurStartCUAddr() > pcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && 1520 pcSlice->getSliceSegmentCurStartCUAddr() < pcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcPic->getNumPartInCU() >> (uiDepth<<1) ); 1521 // We need to split, so don't try these modes. 1522 if(!bSliceStart&&( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 1526 if( ( uiRPelX < sps.getPicWidthInLumaSamples() ) && ( uiBPelY < sps.getPicHeightInLumaSamples() ) ) 1523 1527 { 1524 1528 m_pcEntropyCoder->encodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); … … 1528 1532 bBoundary = true; 1529 1533 } 1530 1531 if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < (g_uiMaxCUDepth-g_uiAddCUDepth) ) ) || bBoundary )1532 { 1533 UInt uiQNumParts = ( pcPic->getNumPart InCU() >> (uiDepth<<1) )>>2;1534 if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())1534 1535 if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary ) 1536 { 1537 UInt uiQNumParts = ( pcPic->getNumPartitionsInCtu() >> (uiDepth<<1) )>>2; 1538 if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP()) 1535 1539 { 1536 1540 setdQPFlag(true); 1537 1541 } 1542 1543 if( uiDepth == pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcSlice->getUseChromaQpAdj()) 1544 { 1545 setCodeChromaQpAdjFlag(true); 1546 } 1547 1538 1548 for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx+=uiQNumParts ) 1539 1549 { 1540 1550 uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1541 1551 uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1542 Bool bInSlice = pcCU->getSCUAddr()+uiAbsPartIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurEndCUAddr(); 1543 if(bInSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 1552 if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) 1544 1553 { 1545 1554 xEncodeCU( pcCU, uiAbsPartIdx, uiDepth+1 ); … … 1548 1557 return; 1549 1558 } 1550 1559 1551 1560 #if H_MV_ENC_DEC_TRAC 1552 1561 DTRACE_CU_S("=========== coding_unit ===========\n") 1553 1562 #endif 1554 1563 1555 if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) 1564 1565 if( uiDepth <= pps.getMaxCuDQPDepth() && pps.getUseDQP()) 1556 1566 { 1557 1567 setdQPFlag(true); 1558 1568 } 1559 if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) 1569 1570 if( uiDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcSlice->getUseChromaQpAdj()) 1571 { 1572 setCodeChromaQpAdjFlag(true); 1573 } 1574 1575 if (pps.getTransquantBypassEnableFlag()) 1560 1576 { 1561 1577 m_pcEntropyCoder->encodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx ); 1562 1578 } 1563 if( !pcCU->getSlice()->isIntra() ) 1579 1580 if( !pcSlice->isIntra() ) 1564 1581 { 1565 1582 m_pcEntropyCoder->encodeSkipFlag( pcCU, uiAbsPartIdx ); 1566 1583 } 1567 1584 1568 1585 if( pcCU->isSkipped( uiAbsPartIdx ) ) 1569 1586 { … … 1573 1590 DTRACE_PU("x1", uiTPelY) 1574 1591 #endif 1592 1575 1593 m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx ); 1576 #if H_3D_ARP1594 #if NH_3D_ARP 1577 1595 m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx ); 1578 1596 #endif 1579 #if H_3D_IC1597 #if NH_3D_IC 1580 1598 m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx ); 1581 1599 #endif 1582 finishCU(pcCU,uiAbsPartIdx,uiDepth); 1600 1601 finishCU(pcCU,uiAbsPartIdx); 1583 1602 return; 1584 1603 } 1585 #if H_3D 1604 1605 #if NH_3D_DIS 1586 1606 m_pcEntropyCoder->encodeDIS( pcCU, uiAbsPartIdx ); 1587 1607 if(!pcCU->getDISFlag(uiAbsPartIdx)) 1588 1608 { 1589 1609 #endif 1590 1591 1610 m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx ); 1592 1593 1611 m_pcEntropyCoder->encodePartSize( pcCU, uiAbsPartIdx, uiDepth ); 1594 1612 1595 1613 if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) 1596 1614 { 1597 1615 m_pcEntropyCoder->encodeIPCMInfo( pcCU, uiAbsPartIdx ); 1616 1598 1617 if(pcCU->getIPCMFlag(uiAbsPartIdx)) 1599 1618 { 1600 #if H_3D_DIM_SDC1601 m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx , false);1619 #if NH_3D_SDC_INTRA 1620 m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx ); 1602 1621 #endif 1622 1603 1623 // Encode slice finish 1604 finishCU(pcCU,uiAbsPartIdx ,uiDepth);1624 finishCU(pcCU,uiAbsPartIdx); 1605 1625 return; 1606 1626 } … … 1609 1629 // prediction Info ( Intra : direction mode, Inter : Mv, reference idx ) 1610 1630 m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx ); 1611 #if H_3D1631 #if NH_3D_DBBP 1612 1632 m_pcEntropyCoder->encodeDBBPFlag( pcCU, uiAbsPartIdx ); 1613 1633 #endif 1614 #if H_3D_DIM_SDC1615 m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx , false);1634 #if NH_3D_SDC_INTRA 1635 m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx ); 1616 1636 #endif 1617 #if H_3D_ARP1637 #if NH_3D_ARP 1618 1638 m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx ); 1619 1639 #endif 1620 #if H_3D_IC1640 #if NH_3D_IC 1621 1641 m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx ); 1622 1642 #endif 1643 1623 1644 // Encode Coefficients 1624 1645 Bool bCodeDQP = getdQPFlag(); 1625 #if H_3D_DISABLE_CHROMA 1626 m_pcEntropyCoder->encodeCoeff( pcCU, uiAbsPartIdx, uiDepth, pcCU->getWidth (uiAbsPartIdx), pcCU->getHeight(uiAbsPartIdx), bCodeDQP, false ); 1627 #else 1628 m_pcEntropyCoder->encodeCoeff( pcCU, uiAbsPartIdx, uiDepth, pcCU->getWidth (uiAbsPartIdx), pcCU->getHeight(uiAbsPartIdx), bCodeDQP ); 1629 #endif 1646 Bool codeChromaQpAdj = getCodeChromaQpAdjFlag(); 1647 m_pcEntropyCoder->encodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, codeChromaQpAdj ); 1648 setCodeChromaQpAdjFlag( codeChromaQpAdj ); 1630 1649 setdQPFlag( bCodeDQP ); 1631 #if H_3D 1632 } 1633 #endif 1650 #if NH_3D_DIS 1651 } 1652 #endif 1653 1654 1634 1655 // --- write terminating bit --- 1635 finishCU(pcCU,uiAbsPartIdx ,uiDepth);1656 finishCU(pcCU,uiAbsPartIdx); 1636 1657 } 1637 1658 1638 Int xCalcHADs8x8_ISlice(Pel *piOrg, Int iStrideOrg) 1659 Int xCalcHADs8x8_ISlice(Pel *piOrg, Int iStrideOrg) 1639 1660 { 1640 1661 Int k, i, j, jj; … … 1651 1672 diff[k+6] = piOrg[6] ; 1652 1673 diff[k+7] = piOrg[7] ; 1653 1674 1654 1675 piOrg += iStrideOrg; 1655 1676 } 1656 1677 1657 1678 //horizontal 1658 1679 for (j=0; j < 8; j++) … … 1667 1688 m2[j][6] = diff[jj+2] - diff[jj+6]; 1668 1689 m2[j][7] = diff[jj+3] - diff[jj+7]; 1669 1690 1670 1691 m1[j][0] = m2[j][0] + m2[j][2]; 1671 1692 m1[j][1] = m2[j][1] + m2[j][3]; … … 1676 1697 m1[j][6] = m2[j][4] - m2[j][6]; 1677 1698 m1[j][7] = m2[j][5] - m2[j][7]; 1678 1699 1679 1700 m2[j][0] = m1[j][0] + m1[j][1]; 1680 1701 m2[j][1] = m1[j][0] - m1[j][1]; … … 1686 1707 m2[j][7] = m1[j][6] - m1[j][7]; 1687 1708 } 1688 1709 1689 1710 //vertical 1690 1711 for (i=0; i < 8; i++) … … 1698 1719 m3[6][i] = m2[2][i] - m2[6][i]; 1699 1720 m3[7][i] = m2[3][i] - m2[7][i]; 1700 1721 1701 1722 m1[0][i] = m3[0][i] + m3[2][i]; 1702 1723 m1[1][i] = m3[1][i] + m3[3][i]; … … 1707 1728 m1[6][i] = m3[4][i] - m3[6][i]; 1708 1729 m1[7][i] = m3[5][i] - m3[7][i]; 1709 1730 1710 1731 m2[0][i] = m1[0][i] + m1[1][i]; 1711 1732 m2[1][i] = m1[0][i] - m1[1][i]; … … 1717 1738 m2[7][i] = m1[6][i] - m1[7][i]; 1718 1739 } 1719 1740 1720 1741 for (i = 0; i < 8; i++) 1721 1742 { … … 1730 1751 } 1731 1752 1732 Int TEncCu::update LCUDataISlice(TComDataCU* pcCU, Int LCUIdx, Int width, Int height)1753 Int TEncCu::updateCtuDataISlice(TComDataCU* pCtu, Int width, Int height) 1733 1754 { 1734 Int xBl, yBl; 1755 Int xBl, yBl; 1735 1756 const Int iBlkSize = 8; 1736 1757 1737 Pel* pOrgInit = p cCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);1738 Int iStrideOrig = p cCU->getPic()->getPicYuvOrg()->getStride();1758 Pel* pOrgInit = pCtu->getPic()->getPicYuvOrg()->getAddr(COMPONENT_Y, pCtu->getCtuRsAddr(), 0); 1759 Int iStrideOrig = pCtu->getPic()->getPicYuvOrg()->getStride(COMPONENT_Y); 1739 1760 Pel *pOrg; 1740 1761 … … 1744 1765 for ( xBl=0; (xBl+iBlkSize)<=width; xBl+= iBlkSize) 1745 1766 { 1746 pOrg = pOrgInit + iStrideOrig*yBl + xBl; 1767 pOrg = pOrgInit + iStrideOrig*yBl + xBl; 1747 1768 iSumHad += xCalcHADs8x8_ISlice(pOrg, iStrideOrig); 1748 1769 } … … 1754 1775 * \param rpcBestCU 1755 1776 * \param rpcTempCU 1756 * \ returns Void1777 * \param earlyDetectionSkipMode 1757 1778 */ 1758 Void TEncCu::xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU , Bool *earlyDetectionSkipMode )1779 Void TEncCu::xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU DEBUG_STRING_FN_DECLARE(sDebug), Bool *earlyDetectionSkipMode ) 1759 1780 { 1760 1781 assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE ); 1761 #if H_3D_IV_MERGE 1782 if(getFastDeltaQp()) 1783 { 1784 return; // never check merge in fast deltaqp mode 1785 } 1786 1787 D_PRINT_INC_INDENT( g_traceModeCheck, "xCheckRDCostMerge2Nx2N" ); 1788 1789 #if NH_3D_MLC 1762 1790 TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists 1763 1791 UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; … … 1774 1802 } 1775 1803 UChar uhDepth = rpcTempCU->getDepth( 0 ); 1776 #if H_3D_IC1804 #if NH_3D_IC 1777 1805 Bool bICFlag = rpcTempCU->getICFlag( 0 ); 1778 1806 #endif 1779 #if H_3D_VSO // M1 //necessary here?1807 #if NH_3D_VSO // M1 //necessary here? 1780 1808 if( m_pcRdCost->getUseRenModel() ) 1781 1809 { 1782 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( );1783 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( );1784 Pel* piSrc = m_ppcOrigYuv[uhDepth]->get LumaAddr();1785 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( );1810 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( COMPONENT_Y ); 1811 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( COMPONENT_Y ); 1812 Pel* piSrc = m_ppcOrigYuv[uhDepth]->getAddr ( COMPONENT_Y ); 1813 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( COMPONENT_Y ); 1786 1814 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 1787 1815 } 1788 1816 #endif 1789 1817 1790 #if H_3D_ARP1818 #if NH_3D_ARP 1791 1819 DisInfo cOrigDisInfo = rpcTempCU->getDvInfo(0); 1792 1820 #else 1793 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level 1794 #endif 1795 1796 #if H_3D_VSP 1797 #if !H_3D_ARP 1821 #endif 1822 1823 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to CTU level 1824 1825 #if NH_3D_SPIVMP 1826 Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; 1827 memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); 1828 TComMvField* pcMvFieldSP; 1829 UChar* puhInterDirSP; 1830 pcMvFieldSP = new TComMvField[rpcTempCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2]; 1831 puhInterDirSP = new UChar[rpcTempCU->getPic()->getPicSym()->getNumPartitionsInCtu()]; 1832 #endif 1833 1834 #if NH_3D_VSP 1835 #if !NH_3D_ARP 1798 1836 Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; 1799 1837 memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); 1800 InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; 1801 rpcTempCU->m_bAvailableFlagA1 = 0; 1802 rpcTempCU->m_bAvailableFlagB1 = 0; 1803 rpcTempCU->m_bAvailableFlagB0 = 0; 1804 rpcTempCU->m_bAvailableFlagA0 = 0; 1805 rpcTempCU->m_bAvailableFlagB2 = 0; 1838 #if NH_3D_MLC 1839 rpcTempCU->initAvailableFlags(); 1840 #endif 1806 1841 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); 1807 rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo, numValidMergeCand ); 1808 #endif 1809 #else 1810 #if H_3D 1811 rpcTempCU->m_bAvailableFlagA1 = 0; 1812 rpcTempCU->m_bAvailableFlagB1 = 0; 1813 rpcTempCU->m_bAvailableFlagB0 = 0; 1814 rpcTempCU->m_bAvailableFlagA0 = 0; 1815 rpcTempCU->m_bAvailableFlagB2 = 0; 1816 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); 1817 rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); 1818 #else 1842 #if NH_3D_MLC 1843 rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours 1844 #if NH_3D_SPIVMP 1845 , pcMvFieldSP, puhInterDirSP 1846 #endif 1847 , numValidMergeCand 1848 ); 1849 1850 rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag 1851 #if NH_3D_SPIVMP 1852 , bSPIVMPFlag 1853 #endif 1854 , numValidMergeCand 1855 ); 1856 #endif 1857 #endif 1858 #else 1859 #if NH_3D_MLC 1860 rpcTempCU->initAvailableFlags(); 1861 #endif 1819 1862 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); 1820 #endif 1821 #endif 1822 1823 #if H_3D_IV_MERGE 1863 #if NH_3D_MLC 1864 rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours 1865 #if H_3D_SPIVMP 1866 , pcMvFieldSP, puhInterDirSP 1867 #endif 1868 , numValidMergeCand 1869 ); 1870 #if NH_3D_MLC 1871 rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours 1872 #if H_3D_SPIVMP 1873 , bSPIVMPFlag 1874 #endif 1875 , numValidMergeCand 1876 ); 1877 #endif 1878 #endif 1879 #endif 1880 1881 #if NH_3D_MLC 1824 1882 Int mergeCandBuffer[MRG_MAX_NUM_CANDS_MEM]; 1825 1883 #else 1826 1884 Int mergeCandBuffer[MRG_MAX_NUM_CANDS]; 1827 1885 #endif 1828 #if H_3D_ARP1829 for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )1830 #else 1831 for( UInt ui = 0; ui < numValidMergeCand; ++ui )1886 #if NH_3D_MLC 1887 for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui ) 1888 #else 1889 for( UInt ui = 0; ui < numValidMergeCand; ++ui ) 1832 1890 #endif 1833 1891 { … … 1842 1900 iteration = 1; 1843 1901 } 1844 else 1902 else 1845 1903 { 1846 1904 iteration = 2; 1847 1905 } 1848 1849 #if H_3D_ARP 1906 DEBUG_STRING_NEW(bestStr) 1907 1908 #if NH_3D_ARP 1850 1909 Int nARPWMax = rpcTempCU->getSlice()->getARPStepNum() - 1; 1910 #if NH_3D_IC 1851 1911 if( nARPWMax < 0 || bICFlag ) 1912 #else 1913 if( nARPWMax < 0 ) 1914 #endif 1852 1915 { 1853 1916 nARPWMax = 0; … … 1855 1918 for( Int nARPW=nARPWMax; nARPW >= 0 ; nARPW-- ) 1856 1919 { 1920 #if NH_3D 1921 #if DEBUG_STRING 1922 bestStr.clear(); 1923 #endif 1924 #endif 1925 #if NH_3D_IV_MERGE 1857 1926 memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS_MEM*sizeof(Int) ); 1927 #else 1928 memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS * sizeof(Int) ); 1929 #endif 1858 1930 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level 1859 1931 rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth ); 1860 #if H_3D_IC1932 #if NH_3D_IC 1861 1933 rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth ); 1862 1934 #endif 1863 1935 rpcTempCU->getDvInfo(0) = cOrigDisInfo; 1864 rpcTempCU->setDvInfoSubParts(cOrigDisInfo, 0, 0, uhDepth ); 1936 rpcTempCU->setDvInfoSubParts(cOrigDisInfo, 0, uhDepth ); 1937 #if NH_3D_VSP 1865 1938 Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; 1866 1939 memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); 1867 #if H_3D_SPIVMP 1868 Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; 1869 memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); 1870 TComMvField* pcMvFieldSP; 1871 UChar* puhInterDirSP; 1872 pcMvFieldSP = new TComMvField[rpcTempCU->getPic()->getPicSym()->getNumPartition()*2]; 1873 puhInterDirSP = new UChar[rpcTempCU->getPic()->getPicSym()->getNumPartition()]; 1874 #endif 1875 #if H_3D 1940 #endif 1941 #if NH_3D 1942 #if NH_3D_MLC 1876 1943 rpcTempCU->initAvailableFlags(); 1944 #endif 1877 1945 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); 1878 1946 rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours 1879 #if H_3D_SPIVMP1947 #if NH_3D_SPIVMP 1880 1948 , pcMvFieldSP, puhInterDirSP 1881 1949 #endif … … 1883 1951 ); 1884 1952 1885 rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag 1886 #if H_3D_SPIVMP 1953 rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours 1954 #if NH_3D_VSP 1955 , vspFlag 1956 #endif 1957 #if NH_3D_SPIVMP 1887 1958 , bSPIVMPFlag 1888 1959 #endif … … 1891 1962 1892 1963 #else 1893 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,numValidMergeCand );1964 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); 1894 1965 #endif 1895 1966 … … 1899 1970 for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual ) 1900 1971 { 1972 D_PRINT_INC_INDENT ( g_traceModeCheck, "uiNoResidual: " + n2s( uiNoResidual) ); 1973 1901 1974 for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand ) 1902 { 1903 #if H_3D_IC1975 { 1976 #if NH_3D_IC 1904 1977 if( rpcTempCU->getSlice()->getApplyIC() && rpcTempCU->getSlice()->getIcSkipParseFlag() ) 1905 1978 { … … 1910 1983 } 1911 1984 #endif 1985 D_PRINT_INC_INDENT ( g_traceModeCheck, "uiMergeCand: "+ n2s(uiMergeCand) ); 1986 1912 1987 if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1)) 1913 1988 { 1914 1989 if( !(bestIsSkip && uiNoResidual == 0) ) 1915 1990 { 1991 DEBUG_STRING_NEW(tmpStr) 1916 1992 // set MC parameters 1917 rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth ); // interprets depth relative to LCU level 1918 rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag, 0, uhDepth ); 1919 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level 1920 #if H_3D_IC 1993 rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth ); // interprets depth relative to CTU level 1994 #if NH_3D_IC 1921 1995 rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth ); 1922 1996 #endif 1923 #if H_3D_ARP 1997 rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag, 0, uhDepth ); 1998 rpcTempCU->setChromaQpAdjSubParts( bTransquantBypassFlag ? 0 : m_cuChromaQpOffsetIdxPlus1, 0, uhDepth ); 1999 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to CTU level 2000 rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to CTU level 2001 rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to CTU level 2002 #if NH_3D_ARP 1924 2003 rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth ); 1925 2004 #endif 1926 rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level 1927 rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to LCU level 1928 #if H_3D_VSP 2005 2006 #if NH_3D_VSP 1929 2007 rpcTempCU->setVSPFlagSubParts( vspFlag[uiMergeCand], 0, 0, uhDepth ); 1930 2008 #endif 1931 #if H_3D_SPIVMP2009 #if NH_3D_SPIVMP 1932 2010 rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth); 1933 2011 if (bSPIVMPFlag[uiMergeCand]) … … 1948 2026 else 1949 2027 #endif 1950 #if H_3D_VSP1951 2028 { 2029 #if NH_3D_VSP 1952 2030 if ( vspFlag[uiMergeCand] ) 1953 2031 { … … 1979 2057 { 1980 2058 #endif 1981 rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level1982 1983 1984 #if H_3D_VSP2059 rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to CTU level 2060 rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level 2061 rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level 2062 #if NH_3D_VSP 1985 2063 } 2064 #endif 1986 2065 } 1987 #endif1988 2066 // do MC 1989 2067 m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); 1990 2068 // estimate residual and encode everything 1991 #if H_3D_VSO //M22069 #if NH_3D_VSO //M2 1992 2070 if( m_pcRdCost->getUseRenModel() ) 1993 2071 { //Reset 1994 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( );1995 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight ( );1996 Pel* piSrc = m_ppcOrigYuv[uhDepth]->get LumaAddr ();1997 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride ( );2072 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( COMPONENT_Y ); 2073 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight ( COMPONENT_Y ); 2074 Pel* piSrc = m_ppcOrigYuv[uhDepth]->getAddr ( COMPONENT_Y ); 2075 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride ( COMPONENT_Y ); 1998 2076 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 1999 2077 } 2000 2078 #endif 2001 2079 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, 2002 m_ppcOrigYuv [uhDepth], 2003 m_ppcPredYuvTemp[uhDepth], 2004 m_ppcResiYuvTemp[uhDepth], 2005 m_ppcResiYuvBest[uhDepth], 2006 m_ppcRecoYuvTemp[uhDepth], 2007 (uiNoResidual? true:false)); 2008 2009 2010 if ( uiNoResidual == 0 && rpcTempCU->getQtRootCbf(0) == 0 ) 2080 m_ppcOrigYuv [uhDepth], 2081 m_ppcPredYuvTemp[uhDepth], 2082 m_ppcResiYuvTemp[uhDepth], 2083 m_ppcResiYuvBest[uhDepth], 2084 m_ppcRecoYuvTemp[uhDepth], 2085 (uiNoResidual != 0) DEBUG_STRING_PASS_INTO(tmpStr) ); 2086 2087 #if DEBUG_STRING 2088 DebugInterPredResiReco(tmpStr, *(m_ppcPredYuvTemp[uhDepth]), *(m_ppcResiYuvBest[uhDepth]), *(m_ppcRecoYuvTemp[uhDepth]), DebugStringGetPredModeMask(rpcTempCU->getPredictionMode(0))); 2089 #endif 2090 2091 if ((uiNoResidual == 0) && (rpcTempCU->getQtRootCbf(0) == 0)) 2011 2092 { 2012 2093 // If no residual when allowing for one, then set mark to not try case where residual is forced to 0 2013 2094 mergeCandBuffer[uiMergeCand] = 1; 2014 2095 } 2015 2016 rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth ); 2017 #if H_3D 2096 #if NH_3D_DIS 2018 2097 rpcTempCU->setDISFlagSubParts( false, 0, uhDepth ); 2019 2098 #endif 2020 #if H_3D_VSP // possible bug fix2099 #if NH_3D_VSP 2021 2100 if( rpcTempCU->getSkipFlag(0) ) 2022 2101 { … … 2024 2103 } 2025 2104 #endif 2026 #if H_3D_INTER_SDC2105 #if NH_3D_SDC_INTER 2027 2106 TComDataCU *rpcTempCUPre = rpcTempCU; 2028 2107 #endif 2029 2108 Int orgQP = rpcTempCU->getQP( 0 ); 2030 2109 xCheckDQP( rpcTempCU ); 2031 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth );2032 #if H_3D_INTER_SDC2110 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(bestStr) DEBUG_STRING_PASS_INTO(tmpStr)); 2111 #if NH_3D_SDC_INTER 2033 2112 if( rpcTempCU->getSlice()->getInterSdcFlag() && !uiNoResidual ) 2034 2113 { … … 2057 2136 } 2058 2137 rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth ); 2059 #if H_3D2138 #if NH_3D_DIS 2060 2139 rpcTempCU->setDISFlagSubParts( false, 0, uhDepth ); 2061 2140 #endif 2062 2141 rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth ); 2063 rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth );2064 #if H_3D_VSO //M22142 rpcTempCU->setCbfSubParts( 1, COMPONENT_Y, 0, uhDepth ); 2143 #if NH_3D_VSO //M2 2065 2144 if( m_pcRdCost->getUseRenModel() ) 2066 2145 { //Reset 2067 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( );2068 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight ( );2069 Pel* piSrc = m_ppcOrigYuv[uhDepth]->get LumaAddr ();2070 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride ( );2146 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( COMPONENT_Y ); 2147 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight ( COMPONENT_Y ); 2148 Pel* piSrc = m_ppcOrigYuv[uhDepth]->getAddr ( COMPONENT_Y ); 2149 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride ( COMPONENT_Y ); 2071 2150 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2072 2151 } … … 2098 2177 } 2099 2178 #endif 2179 2100 2180 rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag ); 2101 2181 2102 2182 if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip ) 2103 2183 { 2104 #if H_3D_INTER_SDC2184 #if NH_3D_SDC_INTER 2105 2185 if( rpcTempCU->getSlice()->getInterSdcFlag() ) 2106 2186 { … … 2110 2190 { 2111 2191 #endif 2112 2113 #if H_3D_INTER_SDC2192 bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0; 2193 #if NH_3D_SDC_INTER 2114 2194 } 2115 2195 #endif … … 2117 2197 } 2118 2198 } 2199 D_DEC_INDENT( g_traceModeCheck ); 2119 2200 } 2120 2201 … … 2127 2208 *earlyDetectionSkipMode = true; 2128 2209 } 2129 else 2210 else if(m_pcEncCfg->getFastSearch() != SELECTIVE) 2130 2211 { 2131 2212 Int absoulte_MV=0; … … 2148 2229 } 2149 2230 } 2150 } 2151 #if H_3D_SPIVMP 2231 D_DEC_INDENT( g_traceModeCheck ); 2232 } 2233 DEBUG_STRING_APPEND(sDebug, bestStr) 2234 #if NH_3D_ARP 2235 } 2236 #endif 2237 #if NH_3D_SPIVMP 2152 2238 delete[] pcMvFieldSP; 2153 2239 delete[] puhInterDirSP; 2154 2240 #endif 2155 #if H_3D_ARP 2156 } 2157 #endif 2241 D_DEC_INDENT( g_traceModeCheck ); 2158 2242 } 2159 2243 2160 2244 2161 2245 #if AMP_MRG 2162 #if H_3D_FAST_TEXTURE_ENCODING2163 Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize , Bool bFMD, Bool bUseMRG)2164 #else 2165 Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize , Bool bUseMRG)2246 #if NH_3D_FAST_TEXTURE_ENCODING 2247 Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug), Bool bFMD, Bool bUseMRG) 2248 #else 2249 Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize DEBUG_STRING_FN_DECLARE(sDebug), Bool bUseMRG) 2166 2250 #endif 2167 2251 #else … … 2169 2253 #endif 2170 2254 { 2171 #if H_3D 2255 DEBUG_STRING_NEW(sTest) 2256 2257 if(getFastDeltaQp()) 2258 { 2259 const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS()); 2260 const UInt fastDeltaQPCuMaxSize = Clip3(sps.getMaxCUHeight()>>(sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u); 2261 if(ePartSize != SIZE_2Nx2N || rpcTempCU->getWidth( 0 ) > fastDeltaQPCuMaxSize) 2262 { 2263 return; // only check necessary 2Nx2N Inter in fast deltaqp mode 2264 } 2265 } 2266 2267 D_PRINT_INC_INDENT(g_traceModeCheck, "xCheckRDCostInter; ePartSize:" + n2s( ePartSize) ); 2268 2269 2270 // prior to this, rpcTempCU will have just been reset using rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); 2271 #if NH_3D_ARP 2172 2272 const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0); 2173 2273 #endif 2174 #if H_3D_FAST_TEXTURE_ENCODING2274 #if NH_3D_FAST_TEXTURE_ENCODING 2175 2275 if(!(bFMD && (ePartSize == SIZE_2Nx2N))) //have motion estimation or merge check 2176 2276 { 2177 2277 #endif 2178 2179 #if H_3D_ARP2278 UChar uhDepth = rpcTempCU->getDepth( 0 ); 2279 #if NH_3D_ARP 2180 2280 Bool bFirstTime = true; 2181 2281 Int nARPWMax = rpcTempCU->getSlice()->getARPStepNum() - 1; 2282 #if NH_3D_IC 2182 2283 if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N || rpcTempCU->getICFlag(0) ) 2284 #else 2285 if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N ) 2286 #endif 2183 2287 { 2184 2288 nARPWMax = 0; … … 2187 2291 for( Int nARPW = 0; nARPW <= nARPWMax; nARPW++ ) 2188 2292 { 2293 #if DEBUG_STRING && H_MV_ENC_DEC_TRAC 2294 sTest.clear(); 2295 #endif 2296 2189 2297 if( !bFirstTime && rpcTempCU->getSlice()->getIvResPredFlag() ) 2190 2298 { … … 2192 2300 } 2193 2301 #endif 2194 #if H_3D_VSO // M32302 #if NH_3D_VSO // M3 2195 2303 if( m_pcRdCost->getUseRenModel() ) 2196 2304 { 2197 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( );2198 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( );2199 Pel* piSrc = m_ppcOrigYuv[uhDepth]->get LumaAddr();2200 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( );2305 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( COMPONENT_Y ); 2306 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( COMPONENT_Y ); 2307 Pel* piSrc = m_ppcOrigYuv[uhDepth]->getAddr ( COMPONENT_Y ); 2308 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( COMPONENT_Y ); 2201 2309 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2202 2310 } 2203 2311 #endif 2204 2205 rpcTempCU->setDepthSubParts( uhDepth, 0 ); 2206 2207 rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth ); 2208 #if H_3D 2312 #if NH_3D_DIS 2209 2313 rpcTempCU->setDISFlagSubParts( false, 0, uhDepth ); 2210 2314 #endif 2211 rpcTempCU->setPartSizeSubParts ( ePartSize, 0, uhDepth ); 2212 rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); 2213 #if H_3D_ARP 2315 rpcTempCU->setPartSizeSubParts ( ePartSize, 0, uhDepth ); 2316 rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); 2317 rpcTempCU->setChromaQpAdjSubParts( rpcTempCU->getCUTransquantBypass(0) ? 0 : m_cuChromaQpOffsetIdxPlus1, 0, uhDepth ); 2318 #if NH_3D_ARP 2214 2319 rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth ); 2215 2320 #endif 2216 #if H_3D_ARP2321 #if NH_3D_ARP 2217 2322 if( bFirstTime == false && nARPWMax ) 2218 2323 { … … 2227 2332 #endif 2228 2333 #if AMP_MRG 2229 rpcTempCU->setMergeAMP (true); 2230 #if H_3D_FAST_TEXTURE_ENCODING 2231 m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bFMD, false, bUseMRG ); 2232 #else 2233 m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG ); 2234 #endif 2235 #else 2236 m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] ); 2237 #endif 2238 #if H_3D_ARP 2334 rpcTempCU->setMergeAMP (true); 2335 #if NH_3D_FAST_TEXTURE_ENCODING 2336 m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] DEBUG_STRING_PASS_INTO(sTest), bFMD, false, bUseMRG ); 2337 #else 2338 m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] DEBUG_STRING_PASS_INTO(sTest), false, bUseMRG ); 2339 #endif 2340 2341 #else 2342 m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] ); 2343 #endif 2344 #if NH_3D_ARP 2239 2345 if( nARPWMax ) 2240 2346 { … … 2245 2351 2246 2352 #if AMP_MRG 2247 if ( !rpcTempCU->getMergeAMP() ) 2248 { 2249 #if H_3D_ARP 2250 if( nARPWMax ) 2251 { 2252 continue; 2253 } 2254 else 2255 #endif 2256 return; 2257 } 2258 #endif 2259 2353 if ( !rpcTempCU->getMergeAMP() ) 2354 { 2355 #if NH_3D_ARP 2356 if( nARPWMax ) 2357 { 2358 continue; 2359 } 2360 else 2361 #endif 2362 { 2363 D_DEC_INDENT( g_traceModeCheck ); 2364 return; 2365 } 2366 } 2367 #endif 2260 2368 #if KWU_RC_MADPRED_E0227 2261 2369 if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth ) … … 2267 2375 } 2268 2376 #endif 2269 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false ); 2270 #if H_3D_VSP // possible bug fix 2271 if( rpcTempCU->getQtRootCbf(0)==0 ) 2272 { 2273 rpcTempCU->setTrIdxSubParts(0, 0, uhDepth); 2274 } 2275 #endif 2276 #if H_3D_VSO // M4 2277 if( m_pcRdCost->getUseLambdaScaleVSO() ) 2278 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2279 else 2280 #endif 2281 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2282 #if H_3D_INTER_SDC 2377 2378 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false DEBUG_STRING_PASS_INTO(sTest) ); 2379 #if NH_3D_VSP 2380 if( rpcTempCU->getQtRootCbf(0)==0 ) 2381 { 2382 rpcTempCU->setTrIdxSubParts(0, 0, uhDepth); 2383 } 2384 #endif 2385 #if NH_3D_VSO // M4 2386 if( m_pcRdCost->getUseLambdaScaleVSO() ) 2387 { 2388 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2389 } 2390 else 2391 #endif 2392 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2393 2394 #if DEBUG_STRING 2395 DebugInterPredResiReco(sTest, *(m_ppcPredYuvTemp[uhDepth]), *(m_ppcResiYuvBest[uhDepth]), *(m_ppcRecoYuvTemp[uhDepth]), DebugStringGetPredModeMask(rpcTempCU->getPredictionMode(0))); 2396 #endif 2397 #if NH_3D_SDC_INTER 2283 2398 TComDataCU *rpcTempCUPre = rpcTempCU; 2284 2399 #endif 2285 xCheckDQP( rpcTempCU ); 2286 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); 2287 #if H_3D_INTER_SDC 2400 2401 xCheckDQP( rpcTempCU ); 2402 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest)); 2403 #if NH_3D_SDC_INTER 2288 2404 if( rpcTempCU->getSlice()->getInterSdcFlag() && ePartSize == SIZE_2Nx2N) 2289 2405 { … … 2314 2430 } 2315 2431 rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth ); 2316 #if H_3D2432 #if NH_3D_DIS 2317 2433 rpcTempCU->setDISFlagSubParts( false, 0, uhDepth ); 2318 2434 #endif 2319 2435 rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth ); 2320 rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth );2321 #if H_3D_VSO // M32436 rpcTempCU->setCbfSubParts( 1, COMPONENT_Y, 0, uhDepth ); 2437 #if NH_3D_VSO // M3 2322 2438 if( m_pcRdCost->getUseRenModel() ) 2323 2439 { 2324 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( );2325 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( );2326 Pel* piSrc = m_ppcOrigYuv[uhDepth]->get LumaAddr();2327 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( );2440 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( COMPONENT_Y ); 2441 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( COMPONENT_Y ); 2442 Pel* piSrc = m_ppcOrigYuv[uhDepth]->getAddr ( COMPONENT_Y ); 2443 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( COMPONENT_Y ); 2328 2444 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2329 2445 } … … 2357 2473 } 2358 2474 #endif 2359 #if H_3D_ARP 2360 } 2361 #endif 2362 #if H_3D_FAST_TEXTURE_ENCODING 2363 } 2364 #endif 2475 #if NH_3D_ARP 2476 } 2477 #endif 2478 #if NH_3D_FAST_TEXTURE_ENCODING 2479 } 2480 #endif 2481 D_DEC_INDENT( g_traceModeCheck ); 2365 2482 } 2366 2483 2367 #if H_3D_DBBP2484 #if NH_3D_DBBP 2368 2485 Void TEncCu::xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment ) 2369 2486 { 2370 UInt uiWidth = pOrigYuv->getWidth ( 2371 UInt uiHeight = pOrigYuv->getHeight( 2372 Pel* piSrc = pOrigYuv->get LumaAddr();2373 UInt uiSrcStride = pOrigYuv->getStride( );2374 Pel* piDst = pOrigYuvTemp->get LumaAddr();2375 UInt uiDstStride = pOrigYuvTemp->getStride( );2487 UInt uiWidth = pOrigYuv->getWidth (COMPONENT_Y); 2488 UInt uiHeight = pOrigYuv->getHeight(COMPONENT_Y); 2489 Pel* piSrc = pOrigYuv->getAddr(COMPONENT_Y); 2490 UInt uiSrcStride = pOrigYuv->getStride(COMPONENT_Y); 2491 Pel* piDst = pOrigYuvTemp->getAddr(COMPONENT_Y); 2492 UInt uiDstStride = pOrigYuvTemp->getStride(COMPONENT_Y); 2376 2493 2377 2494 UInt uiMaskStride= MAX_CU_SIZE; … … 2398 2515 2399 2516 // now invalidate chroma 2400 Pel* piSrcU = pOrigYuv->get CbAddr();2401 Pel* piSrcV = pOrigYuv->get CrAddr();2402 UInt uiSrcStrideC = pOrigYuv->get CStride();2403 Pel* piDstU = pOrigYuvTemp->get CbAddr();2404 Pel* piDstV = pOrigYuvTemp->get CrAddr();2405 UInt uiDstStrideC = pOrigYuvTemp->get CStride();2517 Pel* piSrcU = pOrigYuv->getAddr(COMPONENT_Cb); 2518 Pel* piSrcV = pOrigYuv->getAddr(COMPONENT_Cr); 2519 UInt uiSrcStrideC = pOrigYuv->getStride(COMPONENT_Cb); 2520 Pel* piDstU = pOrigYuvTemp->getAddr(COMPONENT_Cb); 2521 Pel* piDstV = pOrigYuvTemp->getAddr(COMPONENT_Cr); 2522 UInt uiDstStrideC = pOrigYuvTemp->getStride(COMPONENT_Cb); 2406 2523 pMask = pMaskStart; 2407 2524 … … 2424 2541 } 2425 2542 } 2426 2427 Void TEncCu::xCheckRDCostDIS( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize ) 2543 #endif 2544 2545 #if NH_3D_DBBP 2546 Void TEncCu::xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU DEBUG_STRING_FN_DECLARE(sDebug), Bool bUseMRG ) 2428 2547 { 2429 UInt uiDepth = rpcTempCU->getDepth( 0 ); 2430 if( !rpcBestCU->getSlice()->getIsDepth() || (eSize != SIZE_2Nx2N)) 2431 { 2432 return; 2433 } 2434 2435 #if H_3D_VSO // M5 2436 if( m_pcRdCost->getUseRenModel() ) 2437 { 2438 UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth (); 2439 UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight (); 2440 Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr(); 2441 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride (); 2442 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2443 } 2444 #endif 2445 2446 rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth ); 2447 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); 2448 rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); 2449 rpcTempCU->setCUTransquantBypassSubParts( rpcTempCU->getCUTransquantBypass(0), 0, uiDepth ); 2450 2451 rpcTempCU->setTrIdxSubParts(0, 0, uiDepth); 2452 rpcTempCU->setCbfSubParts(0, 1, 1, 0, uiDepth); 2453 rpcTempCU->setDISFlagSubParts(true, 0, uiDepth); 2454 rpcTempCU->setLumaIntraDirSubParts (DC_IDX, 0, uiDepth); 2455 #if H_3D_DIM_SDC 2456 rpcTempCU->setSDCFlagSubParts( false, 0, uiDepth); 2457 #endif 2458 2459 UInt uiPreCalcDistC; 2460 m_pcPredSearch ->estIntraPredDIS ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, false ); 2461 2462 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC 2463 Int oldTraceCopyBack = g_traceCopyBack; 2464 g_traceCopyBack = false; 2465 #endif 2466 m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() ); 2467 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC 2468 g_traceCopyBack = oldTraceCopyBack; 2469 #endif 2470 2471 2472 m_pcEntropyCoder->resetBits(); 2473 if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) 2474 { 2475 m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0, true ); 2476 } 2477 m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); 2478 m_pcEntropyCoder->encodeDIS( rpcTempCU, 0, true ); 2479 2480 2481 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 2482 2483 rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); 2484 rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 2485 2486 2487 #if H_3D_VSO // M6 2488 if( m_pcRdCost->getUseLambdaScaleVSO()) 2489 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2490 else 2491 #endif 2492 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2493 2494 2495 xCheckDQP( rpcTempCU ); 2496 xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth); 2497 } 2498 2499 Void TEncCu::xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bUseMRG ) 2500 { 2548 DEBUG_STRING_NEW(sTest) 2501 2549 AOF( !rpcTempCU->getSlice()->getIsDepth() ); 2502 2550 2503 2551 UChar uhDepth = rpcTempCU->getDepth( 0 ); 2504 2552 2505 #if H_3D_VSO2553 #if NH_3D_VSO 2506 2554 if( m_pcRdCost->getUseRenModel() ) 2507 2555 { 2508 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( );2509 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( );2510 Pel* piSrc = m_ppcOrigYuv[uhDepth]->get LumaAddr();2511 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( );2556 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( COMPONENT_Y ); 2557 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( COMPONENT_Y ); 2558 Pel* piSrc = m_ppcOrigYuv[uhDepth]->getAddr ( COMPONENT_Y ); 2559 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride( COMPONENT_Y ); 2512 2560 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2513 2561 } … … 2518 2566 AOF( uiWidth == uiHeight ); 2519 2567 2520 #if H_3D_DBBP 2521 // Is this correct here, was under the macro SEC_DBBP_DISALLOW_8x8_I0078, however the function is related to Single Depth Mode 2568 #if NH_3D_DBBP 2522 2569 if(uiWidth <= 8) 2523 2570 { … … 2570 2617 rpcTempCU->getDBBPTmpData()->eVirtualPartSize = eVirtualPartSize; 2571 2618 rpcTempCU->getDBBPTmpData()->uiVirtualPartIndex = uiSegment; 2572 m_pcPredSearch->predInterSearch( rpcTempCU, m_ppcOrigYuvDBBP[uhDepth], apPredYuv[uiSegment], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth] , false, false, bUseMRG );2619 m_pcPredSearch->predInterSearch( rpcTempCU, m_ppcOrigYuvDBBP[uhDepth], apPredYuv[uiSegment], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth] DEBUG_STRING_PASS_INTO(sTest), false, bUseMRG ); 2573 2620 m_pcRdCost->setUseMask(false); 2574 2621 … … 2579 2626 pDBBPTmpData->auhMergeIndex[uiSegment] = rpcTempCU->getMergeIndex(0); 2580 2627 2628 #if NH_3D_VSP 2581 2629 AOF( rpcTempCU->getSPIVMPFlag(0) == false ); 2582 2630 AOF( rpcTempCU->getVSPFlag(0) == 0 ); 2631 #endif 2583 2632 2584 2633 for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) … … 2599 2648 rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); 2600 2649 2601 UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( rpcTempCU->getSlice()->getSPS()->getMax CUDepth() - uhDepth ) << 1 ) ) >> 4;2650 UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( rpcTempCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uhDepth ) << 1 ) ) >> 4; 2602 2651 for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) 2603 2652 { … … 2625 2674 2626 2675 // reconstruct final prediction signal by combining both segments 2627 m_pcPredSearch->combineSegmentsWithMask(apPredYuv, m_ppcPredYuvTemp[uhDepth], pMask, uiWidth, uiHeight, 0, eVirtualPartSize); 2628 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false ); 2676 Int bitDepthY = rpcTempCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA); 2677 m_pcPredSearch->combineSegmentsWithMask(apPredYuv, m_ppcPredYuvTemp[uhDepth], pMask, uiWidth, uiHeight, 0, eVirtualPartSize, bitDepthY); 2678 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false DEBUG_STRING_PASS_INTO(sTest) ); 2629 2679 2630 2680 xCheckDQP( rpcTempCU ); 2631 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth );2681 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest) ); 2632 2682 } 2633 2683 #endif 2634 2635 #if H_3D_DIM 2636 Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize, Bool bOnlyIVP ) 2637 #else 2638 Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize ) 2639 #endif 2684 #if NH_3D_DIS 2685 Void TEncCu::xCheckRDCostDIS( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize ) 2640 2686 { 2641 UInt uiDepth = rpcTempCU->getDepth( 0 ); 2642 #if H_3D_VSO // M5 2687 UInt uiDepth = rpcTempCU->getDepth( 0 ); 2688 if( !rpcBestCU->getSlice()->getIsDepth() || (eSize != SIZE_2Nx2N)) 2689 { 2690 return; 2691 } 2692 2693 D_PRINT_INC_INDENT(g_traceModeCheck, "xCheckRDCostDIS" ); 2694 2695 #if NH_3D_VSO // M5 2643 2696 if( m_pcRdCost->getUseRenModel() ) 2644 2697 { 2645 UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth ( );2646 UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight ( );2647 Pel* piSrc = m_ppcOrigYuv[uiDepth]->get LumaAddr();2648 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride ( );2698 UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth ( COMPONENT_Y ); 2699 UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight ( COMPONENT_Y ); 2700 Pel* piSrc = m_ppcOrigYuv[uiDepth]->getAddr ( COMPONENT_Y ); 2701 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride ( COMPONENT_Y ); 2649 2702 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2650 2703 } … … 2652 2705 2653 2706 rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth ); 2654 #if H_3D 2707 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); 2708 rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); 2709 rpcTempCU->setCUTransquantBypassSubParts( rpcTempCU->getCUTransquantBypass(0), 0, uiDepth ); 2710 2711 rpcTempCU->setTrIdxSubParts(0, 0, uiDepth); 2712 rpcTempCU->setCbfSubParts(0, COMPONENT_Y, 0, uiDepth); 2713 rpcTempCU->setDISFlagSubParts(true, 0, uiDepth); 2714 rpcTempCU->setIntraDirSubParts(CHANNEL_TYPE_LUMA, DC_IDX, 0, uiDepth); 2715 #if NH_3D_SDC_INTRA 2716 rpcTempCU->setSDCFlagSubParts( false, 0, uiDepth); 2717 #endif 2718 2719 UInt uiPreCalcDistC; 2720 m_pcPredSearch ->estIntraPredDIS ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, false ); 2721 2722 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC 2723 Int oldTraceCopyBack = g_traceCopyBack; 2724 g_traceCopyBack = false; 2725 #endif 2726 m_ppcRecoYuvTemp[uiDepth]->copyToPicComponent(COMPONENT_Y, rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getCtuRsAddr(), rpcTempCU->getZorderIdxInCtu() ); 2727 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC 2728 g_traceCopyBack = oldTraceCopyBack; 2729 #endif 2730 2731 m_pcEntropyCoder->resetBits(); 2732 if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) 2733 { 2734 m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0, true ); 2735 } 2736 m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); 2737 m_pcEntropyCoder->encodeDIS( rpcTempCU, 0, true ); 2738 2739 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 2740 2741 rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); 2742 rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 2743 2744 #if NH_3D_VSO // M6 2745 if( m_pcRdCost->getUseLambdaScaleVSO()) 2746 { 2747 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2748 } 2749 else 2750 #endif 2751 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2752 2753 xCheckDQP( rpcTempCU ); 2754 xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest) ); 2755 D_DEC_INDENT( g_traceModeCheck ); 2756 } 2757 #endif 2758 Void TEncCu::xCheckRDCostIntra( TComDataCU *&rpcBestCU, 2759 TComDataCU *&rpcTempCU, 2760 Double &cost, 2761 PartSize eSize 2762 DEBUG_STRING_FN_DECLARE(sDebug) 2763 #if NH_3D_ENC_DEPTH 2764 , Bool bOnlyIVP 2765 #endif 2766 ) 2767 { 2768 DEBUG_STRING_NEW(sTest) 2769 2770 if(getFastDeltaQp()) 2771 { 2772 const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS()); 2773 const UInt fastDeltaQPCuMaxSize = Clip3(sps.getMaxCUHeight()>>(sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u); 2774 if(rpcTempCU->getWidth( 0 ) > fastDeltaQPCuMaxSize) 2775 { 2776 return; // only check necessary 2Nx2N Intra in fast deltaqp mode 2777 } 2778 } 2779 D_PRINT_INC_INDENT (g_traceModeCheck, "xCheckRDCostIntra; eSize: " + n2s(eSize) ); 2780 2781 UInt uiDepth = rpcTempCU->getDepth( 0 ); 2782 #if NH_3D_VSO // M5 2783 if( m_pcRdCost->getUseRenModel() ) 2784 { 2785 UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth ( COMPONENT_Y ); 2786 UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight ( COMPONENT_Y ); 2787 Pel* piSrc = m_ppcOrigYuv[uiDepth]->getAddr ( COMPONENT_Y ); 2788 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride ( COMPONENT_Y ); 2789 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2790 } 2791 #endif 2792 2793 rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth ); 2794 #if NH_3D_DIS 2655 2795 rpcTempCU->setDISFlagSubParts( false, 0, uiDepth ); 2656 2796 #endif 2797 2798 2657 2799 rpcTempCU->setPartSizeSubParts( eSize, 0, uiDepth ); 2658 2800 rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); 2801 rpcTempCU->setChromaQpAdjSubParts( rpcTempCU->getCUTransquantBypass(0) ? 0 : m_cuChromaQpOffsetIdxPlus1, 0, uiDepth ); 2802 2803 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE]; 2804 2805 m_pcPredSearch->estIntraPredLumaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], resiLuma DEBUG_STRING_PASS_INTO(sTest) 2806 #if NH_3D_ENC_DEPTH 2807 , bOnlyIVP 2808 #endif 2809 ); 2810 2811 m_ppcRecoYuvTemp[uiDepth]->copyToPicComponent(COMPONENT_Y, rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getCtuRsAddr(), rpcTempCU->getZorderIdxInCtu() ); 2812 2813 if (rpcBestCU->getPic()->getChromaFormat()!=CHROMA_400) 2814 { 2815 m_pcPredSearch->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], resiLuma DEBUG_STRING_PASS_INTO(sTest) ); 2816 } 2659 2817 2660 Bool bSeparateLumaChroma = true; // choose estimation mode 2661 UInt uiPreCalcDistC = 0; 2662 if( !bSeparateLumaChroma ) 2663 { 2664 m_pcPredSearch->preestChromaPredMode( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth] ); 2665 } 2666 #if H_3D_DIM 2667 m_pcPredSearch ->estIntraPredQT ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, bSeparateLumaChroma, bOnlyIVP ); 2668 #else 2669 m_pcPredSearch ->estIntraPredQT ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, bSeparateLumaChroma ); 2670 #endif 2671 m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() ); 2672 2673 #if H_3D_DIM_SDC 2674 if( !rpcTempCU->getSDCFlag( 0 ) ) 2675 #endif 2676 m_pcPredSearch ->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC ); 2677 2818 #if NH_3D_SDC_INTRA 2819 if( rpcTempCU->getSDCFlag( 0 ) ) 2820 { 2821 assert( rpcTempCU->getTransformIdx(0) == 0 ); 2822 assert( rpcTempCU->getCbf(0, COMPONENT_Y) == 1 ); 2823 } 2824 #endif 2825 2678 2826 m_pcEntropyCoder->resetBits(); 2827 2679 2828 if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) 2680 2829 { 2681 2830 m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0, true ); 2682 2831 } 2683 m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); 2684 #if H_3D 2832 #if NH_3D_DIS && !NH_3D_DIS_FIX 2685 2833 m_pcEntropyCoder->encodeDIS( rpcTempCU, 0, true ); 2686 2834 if(!rpcTempCU->getDISFlag(0)) 2687 2835 { 2688 2836 #endif 2689 m_pcEntropyCoder->encodePredMode( rpcTempCU, 0, true ); 2690 m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true ); 2691 m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0, true ); 2692 m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true ); 2693 #if H_3D_DIM_SDC 2837 m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); 2838 #if NH_3D_DIS_FIX 2839 m_pcEntropyCoder->encodeDIS( rpcTempCU, 0, true ); 2840 if(!rpcTempCU->getDISFlag(0)) 2841 { 2842 #endif 2843 m_pcEntropyCoder->encodePredMode( rpcTempCU, 0, true ); 2844 m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true ); 2845 m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0 ); 2846 m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true ); 2847 #if NH_3D_SDC_INTRA 2694 2848 m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true ); 2695 2849 #endif 2696 2850 2697 // Encode Coefficients 2698 Bool bCodeDQP = getdQPFlag(); 2699 #if H_3D_DISABLE_CHROMA 2700 m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP, true ); 2701 #else 2702 m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP ); 2703 #endif 2704 setdQPFlag( bCodeDQP ); 2705 #if H_3D 2851 // Encode Coefficients 2852 Bool bCodeDQP = getdQPFlag(); 2853 Bool codeChromaQpAdjFlag = getCodeChromaQpAdjFlag(); 2854 m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, bCodeDQP, codeChromaQpAdjFlag ); 2855 setCodeChromaQpAdjFlag( codeChromaQpAdjFlag ); 2856 setdQPFlag( bCodeDQP ); 2857 #if NH_3D_DIS 2706 2858 } 2707 2859 #endif 2708 2860 m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); 2709 2861 2710 2862 rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); 2711 2863 rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 2712 #if H_3D_VSO // M62864 #if NH_3D_VSO // M6 2713 2865 if( m_pcRdCost->getUseLambdaScaleVSO()) 2866 { 2714 2867 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2868 } 2715 2869 else 2716 2870 #endif 2717 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );2718 2871 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2872 2719 2873 xCheckDQP( rpcTempCU ); 2720 xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth); 2721 } 2722 2723 /** Check R-D costs for a CU with PCM mode. 2874 2875 cost = rpcTempCU->getTotalCost(); 2876 2877 xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest)); 2878 2879 D_DEC_INDENT( g_traceModeCheck ); 2880 } 2881 2882 2883 /** Check R-D costs for a CU with PCM mode. 2724 2884 * \param rpcBestCU pointer to best mode CU data structure 2725 2885 * \param rpcTempCU pointer to testing mode CU data structure 2726 2886 * \returns Void 2727 * 2887 * 2728 2888 * \note Current PCM implementation encodes sample values in a lossless way. The distortion of PCM mode CUs are zero. PCM mode is selected if the best mode yields bits greater than that of PCM mode. 2729 2889 */ 2730 2890 Void TEncCu::xCheckIntraPCM( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ) 2731 2891 { 2892 if(getFastDeltaQp()) 2893 { 2894 const TComSPS &sps=*(rpcTempCU->getSlice()->getSPS()); 2895 const UInt fastDeltaQPCuMaxPCMSize = Clip3((UInt)1<<sps.getPCMLog2MinSize(), (UInt)1<<sps.getPCMLog2MaxSize(), 32u); 2896 if (rpcTempCU->getWidth( 0 ) > fastDeltaQPCuMaxPCMSize) 2897 { 2898 return; // only check necessary PCM in fast deltaqp mode 2899 } 2900 } 2901 2732 2902 UInt uiDepth = rpcTempCU->getDepth( 0 ); 2733 2903 2904 #if NH_3D_VSO // VERY NEW 2905 if( m_pcRdCost->getUseRenModel() ) 2906 { 2907 UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth ( COMPONENT_Y ); 2908 UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight ( COMPONENT_Y ); 2909 Pel* piSrc = m_ppcOrigYuv[uiDepth]->getAddr ( COMPONENT_Y ); 2910 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride ( COMPONENT_Y ); 2911 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2912 } 2913 #endif 2914 2734 2915 rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth ); 2735 #if H_3D2916 #if NH_3D_DIS 2736 2917 rpcTempCU->setDISFlagSubParts( false, 0, uiDepth ); 2737 2918 #endif … … 2741 2922 rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); 2742 2923 rpcTempCU->setTrIdxSubParts ( 0, 0, uiDepth ); 2924 rpcTempCU->setChromaQpAdjSubParts( rpcTempCU->getCUTransquantBypass(0) ? 0 : m_cuChromaQpOffsetIdxPlus1, 0, uiDepth ); 2743 2925 2744 2926 m_pcPredSearch->IPCMSearch( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth]); … … 2747 2929 2748 2930 m_pcEntropyCoder->resetBits(); 2931 2749 2932 if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) 2750 2933 { 2751 2934 m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0, true ); 2752 2935 } 2936 2753 2937 m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); 2754 #if H_3D2938 #if NH_3D_DIS 2755 2939 m_pcEntropyCoder->encodeDIS( rpcTempCU, 0, true ); 2756 2940 #endif … … 2758 2942 m_pcEntropyCoder->encodePartSize ( rpcTempCU, 0, uiDepth, true ); 2759 2943 m_pcEntropyCoder->encodeIPCMInfo ( rpcTempCU, 0, true ); 2760 #if H_3D_DIM_SDC2944 #if NH_3D_SDC_INTRA 2761 2945 m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true ); 2762 2946 #endif … … 2764 2948 2765 2949 rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); 2766 2767 #if H_3D_VSO // M442950 rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 2951 #if NH_3D_VSO // M44 2768 2952 if ( m_pcRdCost->getUseVSO() ) 2953 { 2769 2954 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2955 } 2770 2956 else 2771 2957 #endif 2772 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );2958 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2773 2959 2774 2960 xCheckDQP( rpcTempCU ); 2775 xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth ); 2961 DEBUG_STRING_NEW(a) 2962 DEBUG_STRING_NEW(b) 2963 xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth DEBUG_STRING_PASS_INTO(a) DEBUG_STRING_PASS_INTO(b)); 2776 2964 } 2777 2965 … … 2779 2967 * \param rpcBestCU 2780 2968 * \param rpcTempCU 2781 * \ returns Void2969 * \param uiDepth 2782 2970 */ 2783 Void TEncCu::xCheckBestMode( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth )2971 Void TEncCu::xCheckBestMode( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth DEBUG_STRING_FN_DECLARE(sParent) DEBUG_STRING_FN_DECLARE(sTest) DEBUG_STRING_PASS_INTO(Bool bAddSizeInfo) ) 2784 2972 { 2785 2973 if( rpcTempCU->getTotalCost() < rpcBestCU->getTotalCost() ) … … 2805 2993 2806 2994 // store temp best CI for next CU coding 2807 m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); 2995 m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); 2996 2997 2998 #if DEBUG_STRING 2999 DEBUG_STRING_SWAP(sParent, sTest) 3000 const PredMode predMode=rpcBestCU->getPredictionMode(0); 3001 if ((DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode)) && bAddSizeInfo) 3002 { 3003 std::stringstream ss(stringstream::out); 3004 ss <<"###: " << (predMode==MODE_INTRA?"Intra ":"Inter ") << partSizeToString[rpcBestCU->getPartitionSize(0)] << " CU at " << rpcBestCU->getCUPelX() << ", " << rpcBestCU->getCUPelY() << " width=" << UInt(rpcBestCU->getWidth(0)) << std::endl; 3005 sParent+=ss.str(); 3006 } 3007 #endif 2808 3008 } 2809 3009 } … … 2813 3013 UInt uiDepth = pcCU->getDepth( 0 ); 2814 3014 2815 if( pcCU->getSlice()->getPPS()->getUseDQP() && (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() )2816 {2817 if ( pcCU->getCbf( 0, TEXT_LUMA, 0 ) || pcCU->getCbf( 0, TEXT_CHROMA_U, 0 ) || pcCU->getCbf( 0, TEXT_CHROMA_V, 0 ) )2818 {2819 #if !RDO_WITHOUT_DQP_BITS 3015 const TComPPS &pps = *(pcCU->getSlice()->getPPS()); 3016 if ( pps.getUseDQP() && uiDepth <= pps.getMaxCuDQPDepth() ) 3017 { 3018 if ( pcCU->getQtRootCbf( 0) ) 3019 { 2820 3020 m_pcEntropyCoder->resetBits(); 2821 3021 m_pcEntropyCoder->encodeQP( pcCU, 0, false ); 2822 3022 pcCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits 2823 2824 #if H_3D_VSO // M453023 pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 3024 #if NH_3D_VSO // M45 2825 3025 if ( m_pcRdCost->getUseVSO() ) 3026 { 2826 3027 pcCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); 3028 } 2827 3029 else 2828 3030 #endif 2829 pcCU->getTotalCost() = m_pcRdCost->calcRdCost( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); 2830 #endif 3031 pcCU->getTotalCost() = m_pcRdCost->calcRdCost( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); 2831 3032 } 2832 3033 else … … 2845 3046 } 2846 3047 } 2847 Void TEncCu::xCopyYuv2Pic(TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth , TComDataCU* pcCU, UInt uiLPelX, UInt uiTPelY)3048 Void TEncCu::xCopyYuv2Pic(TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth ) 2848 3049 { 2849 UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; 2850 UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; 2851 TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); 2852 Bool bSliceStart = pcSlice->getSliceSegmentCurStartCUAddr() > rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && 2853 pcSlice->getSliceSegmentCurStartCUAddr() < rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) ); 2854 Bool bSliceEnd = pcSlice->getSliceSegmentCurEndCUAddr() > rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && 2855 pcSlice->getSliceSegmentCurEndCUAddr() < rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) ); 2856 if(!bSliceEnd && !bSliceStart && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 2857 { 2858 UInt uiAbsPartIdxInRaster = g_auiZscanToRaster[uiAbsPartIdx]; 2859 UInt uiSrcBlkWidth = rpcPic->getNumPartInWidth() >> (uiSrcDepth); 2860 UInt uiBlkWidth = rpcPic->getNumPartInWidth() >> (uiDepth); 2861 UInt uiPartIdxX = ( ( uiAbsPartIdxInRaster % rpcPic->getNumPartInWidth() ) % uiSrcBlkWidth) / uiBlkWidth; 2862 UInt uiPartIdxY = ( ( uiAbsPartIdxInRaster / rpcPic->getNumPartInWidth() ) % uiSrcBlkWidth) / uiBlkWidth; 2863 UInt uiPartIdx = uiPartIdxY * ( uiSrcBlkWidth / uiBlkWidth ) + uiPartIdxX; 2864 m_ppcRecoYuvBest[uiSrcDepth]->copyToPicYuv( rpcPic->getPicYuvRec (), uiCUAddr, uiAbsPartIdx, uiDepth - uiSrcDepth, uiPartIdx); 2865 } 2866 else 2867 { 2868 UInt uiQNumParts = ( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) )>>2; 2869 2870 for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx+=uiQNumParts ) 2871 { 2872 UInt uiSubCULPelX = uiLPelX + ( g_uiMaxCUWidth >>(uiDepth+1) )*( uiPartUnitIdx & 1 ); 2873 UInt uiSubCUTPelY = uiTPelY + ( g_uiMaxCUHeight>>(uiDepth+1) )*( uiPartUnitIdx >> 1 ); 2874 2875 Bool bInSlice = rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+uiQNumParts > pcSlice->getSliceSegmentCurStartCUAddr() && 2876 rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx < pcSlice->getSliceSegmentCurEndCUAddr(); 2877 if(bInSlice&&( uiSubCULPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiSubCUTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 2878 { 2879 xCopyYuv2Pic( rpcPic, uiCUAddr, uiAbsPartIdx, uiDepth+1, uiSrcDepth, pcCU, uiSubCULPelX, uiSubCUTPelY ); // Copy Yuv data to picture Yuv 2880 } 2881 } 2882 } 3050 UInt uiAbsPartIdxInRaster = g_auiZscanToRaster[uiAbsPartIdx]; 3051 UInt uiSrcBlkWidth = rpcPic->getNumPartInCtuWidth() >> (uiSrcDepth); 3052 UInt uiBlkWidth = rpcPic->getNumPartInCtuWidth() >> (uiDepth); 3053 UInt uiPartIdxX = ( ( uiAbsPartIdxInRaster % rpcPic->getNumPartInCtuWidth() ) % uiSrcBlkWidth) / uiBlkWidth; 3054 UInt uiPartIdxY = ( ( uiAbsPartIdxInRaster / rpcPic->getNumPartInCtuWidth() ) % uiSrcBlkWidth) / uiBlkWidth; 3055 UInt uiPartIdx = uiPartIdxY * ( uiSrcBlkWidth / uiBlkWidth ) + uiPartIdxX; 3056 m_ppcRecoYuvBest[uiSrcDepth]->copyToPicYuv( rpcPic->getPicYuvRec (), uiCUAddr, uiAbsPartIdx, uiDepth - uiSrcDepth, uiPartIdx); 3057 3058 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC 3059 Bool oldtraceCopyBack = g_traceCopyBack; 3060 g_traceCopyBack = false; 3061 #endif 3062 m_ppcPredYuvBest[uiSrcDepth]->copyToPicYuv( rpcPic->getPicYuvPred (), uiCUAddr, uiAbsPartIdx, uiDepth - uiSrcDepth, uiPartIdx); 3063 3064 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC 3065 g_traceCopyBack = oldtraceCopyBack; 3066 #endif 2883 3067 } 2884 3068 … … 2887 3071 UInt uiCurrDepth = uiNextDepth - 1; 2888 3072 m_ppcRecoYuvBest[uiNextDepth]->copyToPartYuv( m_ppcRecoYuvTemp[uiCurrDepth], uiPartUnitIdx ); 3073 m_ppcPredYuvBest[uiNextDepth]->copyToPartYuv( m_ppcPredYuvBest[uiCurrDepth], uiPartUnitIdx); 2889 3074 } 2890 3075 2891 /** Function for filling the PCM buffer of a CU using its original sample array 2892 * \param pcCU pointer to current CU 2893 * \param pcOrgYuv pointer to original sample array 2894 * \returns Void 3076 /** Function for filling the PCM buffer of a CU using its original sample array 3077 * \param pCU pointer to current CU 3078 * \param pOrgYuv pointer to original sample array 2895 3079 */ 2896 Void TEncCu::xFillPCMBuffer ( TComDataCU* &pCU, TComYuv* pOrgYuv )3080 Void TEncCu::xFillPCMBuffer ( TComDataCU* pCU, TComYuv* pOrgYuv ) 2897 3081 { 2898 2899 UInt width = pCU->getWidth(0); 2900 UInt height = pCU->getHeight(0); 2901 2902 Pel* pSrcY = pOrgYuv->getLumaAddr(0, width); 2903 Pel* pDstY = pCU->getPCMSampleY(); 2904 UInt srcStride = pOrgYuv->getStride(); 2905 2906 for(Int y = 0; y < height; y++ ) 2907 { 2908 for(Int x = 0; x < width; x++ ) 2909 { 2910 pDstY[x] = pSrcY[x]; 2911 } 2912 pDstY += width; 2913 pSrcY += srcStride; 2914 } 2915 2916 Pel* pSrcCb = pOrgYuv->getCbAddr(); 2917 Pel* pSrcCr = pOrgYuv->getCrAddr();; 2918 2919 Pel* pDstCb = pCU->getPCMSampleCb(); 2920 Pel* pDstCr = pCU->getPCMSampleCr();; 2921 2922 UInt srcStrideC = pOrgYuv->getCStride(); 2923 UInt heightC = height >> 1; 2924 UInt widthC = width >> 1; 2925 2926 for(Int y = 0; y < heightC; y++ ) 2927 { 2928 for(Int x = 0; x < widthC; x++ ) 2929 { 2930 pDstCb[x] = pSrcCb[x]; 2931 pDstCr[x] = pSrcCr[x]; 2932 } 2933 pDstCb += widthC; 2934 pDstCr += widthC; 2935 pSrcCb += srcStrideC; 2936 pSrcCr += srcStrideC; 3082 const ChromaFormat format = pCU->getPic()->getChromaFormat(); 3083 const UInt numberValidComponents = getNumberValidComponents(format); 3084 for (UInt componentIndex = 0; componentIndex < numberValidComponents; componentIndex++) 3085 { 3086 const ComponentID component = ComponentID(componentIndex); 3087 3088 const UInt width = pCU->getWidth(0) >> getComponentScaleX(component, format); 3089 const UInt height = pCU->getHeight(0) >> getComponentScaleY(component, format); 3090 3091 Pel *source = pOrgYuv->getAddr(component, 0, width); 3092 Pel *destination = pCU->getPCMSample(component); 3093 3094 const UInt sourceStride = pOrgYuv->getStride(component); 3095 3096 for (Int line = 0; line < height; line++) 3097 { 3098 for (Int column = 0; column < width; column++) 3099 { 3100 destination[column] = source[column]; 3101 } 3102 3103 source += sourceStride; 3104 destination += width; 3105 } 2937 3106 } 2938 3107 } … … 2941 3110 /** Collect ARL statistics from one block 2942 3111 */ 2943 Int TEncCu::xTuCollectARLStats(TCoeff* rpcCoeff, Int* rpcArlCoeff, Int NumCoeffInCU, Double* cSum, UInt* numSamples )3112 Int TEncCu::xTuCollectARLStats(TCoeff* rpcCoeff, TCoeff* rpcArlCoeff, Int NumCoeffInCU, Double* cSum, UInt* numSamples ) 2944 3113 { 2945 3114 for( Int n = 0; n < NumCoeffInCU; n++ ) 2946 3115 { 2947 Intu = abs( rpcCoeff[ n ] );2948 Intabsc = rpcArlCoeff[ n ];3116 TCoeff u = abs( rpcCoeff[ n ] ); 3117 TCoeff absc = rpcArlCoeff[ n ]; 2949 3118 2950 3119 if( u != 0 ) … … 2955 3124 numSamples[ u ]++; 2956 3125 } 2957 else 3126 else 2958 3127 { 2959 3128 cSum[ LEVEL_RANGE ] += ( Double )absc - ( Double )( u << ARL_C_PRECISION ); … … 2966 3135 } 2967 3136 2968 /** Collect ARL statistics from one LCU 2969 * \param pcCU 2970 */ 2971 Void TEncCu::xLcuCollectARLStats(TComDataCU* rpcCU ) 3137 //! Collect ARL statistics from one CTU 3138 Void TEncCu::xCtuCollectARLStats(TComDataCU* pCtu ) 2972 3139 { 2973 Double cSum[ LEVEL_RANGE + 1 ]; //: the sum of DCT coefficients corresponding to datatype and quantization output 2974 UInt numSamples[ LEVEL_RANGE + 1 ]; //: the number of coefficients corresponding to datatype and quantization output 2975 2976 TCoeff* pCoeffY = rpcCU->getCoeffY(); 2977 Int* pArlCoeffY = rpcCU->getArlCoeffY(); 2978 2979 UInt uiMinCUWidth = g_uiMaxCUWidth >> g_uiMaxCUDepth; 2980 UInt uiMinNumCoeffInCU = 1 << uiMinCUWidth; 3140 Double cSum[ LEVEL_RANGE + 1 ]; //: the sum of DCT coefficients corresponding to data type and quantization output 3141 UInt numSamples[ LEVEL_RANGE + 1 ]; //: the number of coefficients corresponding to data type and quantization output 3142 3143 TCoeff* pCoeffY = pCtu->getCoeff(COMPONENT_Y); 3144 TCoeff* pArlCoeffY = pCtu->getArlCoeff(COMPONENT_Y); 3145 const TComSPS &sps = *(pCtu->getSlice()->getSPS()); 3146 3147 const UInt uiMinCUWidth = sps.getMaxCUWidth() >> sps.getMaxTotalCUDepth(); // NOTE: ed - this is not the minimum CU width. It is the square-root of the number of coefficients per part. 3148 const UInt uiMinNumCoeffInCU = 1 << uiMinCUWidth; // NOTE: ed - what is this? 2981 3149 2982 3150 memset( cSum, 0, sizeof( Double )*(LEVEL_RANGE+1) ); … … 2984 3152 2985 3153 // Collect stats to cSum[][] and numSamples[][] 2986 for(Int i = 0; i < rpcCU->getTotalNumPart(); i ++ ) 2987 { 2988 UInt uiTrIdx = rpcCU->getTransformIdx(i); 2989 2990 if(rpcCU->getPredictionMode(i) == MODE_INTER) 2991 if( rpcCU->getCbf( i, TEXT_LUMA, uiTrIdx ) ) 3154 for(Int i = 0; i < pCtu->getTotalNumPart(); i ++ ) 3155 { 3156 UInt uiTrIdx = pCtu->getTransformIdx(i); 3157 3158 if(pCtu->isInter(i) && pCtu->getCbf( i, COMPONENT_Y, uiTrIdx ) ) 2992 3159 { 2993 3160 xTuCollectARLStats(pCoeffY, pArlCoeffY, uiMinNumCoeffInCU, cSum, numSamples); 2994 3161 }//Note that only InterY is processed. QP rounding is based on InterY data only. 2995 3162 2996 3163 pCoeffY += uiMinNumCoeffInCU; 2997 3164 pArlCoeffY += uiMinNumCoeffInCU; … … 3007 3174 } 3008 3175 #endif 3176 3009 3177 //! \}
Note: See TracChangeset for help on using the changeset viewer.