Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/TEncEntropy.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 * … … 37 37 38 38 #include "TEncEntropy.h" 39 #include "TLibCommon/ TypeDef.h"39 #include "TLibCommon/CommonDef.h" 40 40 #include "TLibCommon/TComSampleAdaptiveOffset.h" 41 #include "TLibCommon/TComTU.h" 42 43 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 44 #include "../TLibCommon/Debug.h" 45 static const Bool bDebugPredEnabled = DebugOptionList::DebugPred.getInt()!=0; 46 #endif 41 47 42 48 //! \ingroup TLibEncoder 43 49 //! \{ 44 50 45 Void TEncEntropy::setEntropyCoder ( TEncEntropyIf* e , TComSlice* pcSlice)51 Void TEncEntropy::setEntropyCoder ( TEncEntropyIf* e ) 46 52 { 47 53 m_pcEntropyCoderIf = e; 48 m_pcEntropyCoderIf->setSlice ( pcSlice );49 54 } 50 55 … … 63 68 { 64 69 m_pcEntropyCoderIf->codeTerminatingBit( uiIsLast ); 65 70 66 71 return; 67 72 } … … 72 77 } 73 78 74 Void TEncEntropy::encodePPS( TComPPS* pcPPS )79 Void TEncEntropy::encodePPS( const TComPPS* pcPPS ) 75 80 { 76 81 m_pcEntropyCoderIf->codePPS( pcPPS ); … … 78 83 } 79 84 80 Void TEncEntropy::encodeSPS( TComSPS* pcSPS )85 Void TEncEntropy::encodeSPS( const TComSPS* pcSPS ) 81 86 { 82 87 m_pcEntropyCoderIf->codeSPS( pcSPS ); … … 93 98 } 94 99 95 Void TEncEntropy::encodeVPS( TComVPS* pcVPS )100 Void TEncEntropy::encodeVPS( const TComVPS* pcVPS ) 96 101 { 97 102 m_pcEntropyCoderIf->codeVPS( pcVPS ); … … 111 116 m_pcEntropyCoderIf->codeSkipFlag( pcCU, uiAbsPartIdx ); 112 117 } 113 #if H_3D118 #if NH_3D_DIS 114 119 Void TEncEntropy::encodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 115 120 { 121 #if NH_3D_FIX_TICKET_98 122 if( !pcCU->getSlice()->getDepthIntraSkipFlag() ) 123 #else 116 124 if ( !pcCU->getSlice()->getIsDepth() ) 125 #endif 117 126 { 118 127 return; … … 125 134 } 126 135 #endif 127 /** encode merge flag 128 * \param pcCU 129 * \param uiAbsPartIdx 130 * \returns Void 131 */ 136 //! encode merge flag 132 137 Void TEncEntropy::encodeMergeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) 133 { 138 { 134 139 // at least one merge candidate exists 135 140 m_pcEntropyCoderIf->codeMergeFlag( pcCU, uiAbsPartIdx ); 136 141 } 137 142 138 /** encode merge index 139 * \param pcCU 140 * \param uiAbsPartIdx 141 * \param uiPUIdx 142 * \param bRD 143 * \returns Void 144 */ 143 //! encode merge index 145 144 Void TEncEntropy::encodeMergeIndex( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 146 145 { … … 153 152 } 154 153 155 #if H_3D_IC154 #if NH_3D_IC 156 155 Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 157 156 { 157 #if NH_3D_ARP 158 158 if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 ) 159 #else 160 if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() ) 161 #endif 159 162 { 160 163 return; … … 189 192 #endif 190 193 191 #if H_3D_ARP194 #if NH_3D_ARP 192 195 Void TEncEntropy::encodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx ) 193 196 { … … 208 211 #endif 209 212 210 /** encode prediction mode 211 * \param pcCU 212 * \param uiAbsPartIdx 213 * \param bRD 214 * \returns Void 215 */ 213 214 //! encode prediction mode 216 215 Void TEncEntropy::encodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 217 216 { … … 220 219 uiAbsPartIdx = 0; 221 220 } 221 222 222 if ( pcCU->getSlice()->isIntra() ) 223 223 { … … 228 228 } 229 229 230 // Split mode230 //! encode split flag 231 231 Void TEncEntropy::encodeSplitFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD ) 232 232 { … … 235 235 uiAbsPartIdx = 0; 236 236 } 237 237 238 m_pcEntropyCoderIf->codeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); 238 239 } 239 240 240 /** encode partition size 241 * \param pcCU 242 * \param uiAbsPartIdx 243 * \param uiDepth 244 * \param bRD 245 * \returns Void 246 */ 241 //! encode partition size 247 242 Void TEncEntropy::encodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD ) 248 243 { … … 251 246 uiAbsPartIdx = 0; 252 247 } 253 248 254 249 m_pcEntropyCoderIf->codePartSize( pcCU, uiAbsPartIdx, uiDepth ); 255 256 } 257 258 /** Encode I_PCM information. 259 * \param pcCU pointer to CU 260 * \param uiAbsPartIdx CU index 261 * \param bRD flag indicating estimation or encoding 262 * \returns Void 250 } 251 252 253 /** Encode I_PCM information. 254 * \param pcCU pointer to CU 255 * \param uiAbsPartIdx CU index 256 * \param bRD flag indicating estimation or encoding 263 257 */ 264 258 Void TEncEntropy::encodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) … … 270 264 return; 271 265 } 272 273 if( bRD ) 274 { 275 uiAbsPartIdx = 0; 276 } 277 266 267 if( bRD ) 268 { 269 uiAbsPartIdx = 0; 270 } 271 278 272 m_pcEntropyCoderIf->codeIPCMInfo ( pcCU, uiAbsPartIdx ); 279 } 280 281 #if H_3D_DISABLE_CHROMA 282 Void TEncEntropy::xEncodeTransform( TComDataCU* pcCU,UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Bool rd ) 283 #else 284 Void TEncEntropy::xEncodeTransform( TComDataCU* pcCU,UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP ) 285 #endif 286 { 287 273 274 } 275 276 Void TEncEntropy::xEncodeTransform( Bool& bCodeDQP, Bool& codeChromaQpAdj, TComTU &rTu ) 277 { 278 279 //pcCU, absPartIdxCU, uiAbsPartIdx, uiDepth+1, uiTrIdx+1, quadrant, 280 TComDataCU *pcCU=rTu.getCU(); 281 const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); 282 283 const UInt numValidComponent = pcCU->getPic()->getNumberValidComponents(); 284 const Bool bChroma = isChromaEnabled(pcCU->getPic()->getChromaFormat()); 285 const UInt uiTrIdx = rTu.GetTransformDepthRel(); 286 const UInt uiDepth = rTu.GetTransformDepthTotal(); 288 287 #if H_MV_ENC_DEC_TRAC 289 288 #if ENC_DEC_TRACE … … 292 291 293 292 DTRACE_TU_S("=========== transform_tree ===========\n") 294 DTRACE_TU("x0", uiLPelX) 295 DTRACE_TU("x1", uiTPelY) 296 DTRACE_TU("log2TrafoSize", g_uiMaxCUWidth>>uiDepth) 297 DTRACE_TU("trafoDepth" , uiDepth) 298 #endif 299 #endif 300 301 const UInt uiSubdiv = pcCU->getTransformIdx( uiAbsPartIdx ) + pcCU->getDepth( uiAbsPartIdx ) > uiDepth; 302 const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; 303 UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); 304 UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); 305 UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); 306 #if H_3D_DISABLE_CHROMA 307 if( !rd && pcCU->getSlice()->getSPS()->getChromaFormatIdc() == 0 ) 308 { 309 cbfU = 0; 310 cbfV = 0; 311 } 312 #endif 313 if(uiTrIdx==0) 314 { 315 m_bakAbsPartIdxCU = uiAbsPartIdx; 316 } 317 if( uiLog2TrafoSize == 2 ) 318 { 319 UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); 320 if( ( uiAbsPartIdx % partNum ) == 0 ) 321 { 322 m_uiBakAbsPartIdx = uiAbsPartIdx; 323 m_uiBakChromaOffset = offsetChroma; 324 } 325 else if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) 326 { 327 cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); 328 cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); 329 #if H_3D_DISABLE_CHROMA 330 if( !rd && pcCU->getSlice()->getSPS()->getChromaFormatIdc() == 0 ) 293 DTRACE_TU("x0", uiLPelX) 294 DTRACE_TU("x1", uiTPelY) 295 DTRACE_TU("log2TrafoSize", pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ) 296 DTRACE_TU("trafoDepth" , uiDepth) 297 #endif 298 #endif 299 300 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 301 const Bool bDebugRQT=pcCU->getSlice()->getFinalized() && DebugOptionList::DebugRQT.getInt()!=0; 302 if (bDebugRQT) 303 { 304 printf("x..codeTransform: offsetLuma=%d offsetChroma=%d absPartIdx=%d, uiDepth=%d\n width=%d, height=%d, uiTrIdx=%d, uiInnerQuadIdx=%d\n", 305 rTu.getCoefficientOffset(COMPONENT_Y), rTu.getCoefficientOffset(COMPONENT_Cb), uiAbsPartIdx, uiDepth, rTu.getRect(COMPONENT_Y).width, rTu.getRect(COMPONENT_Y).height, rTu.GetTransformDepthRel(), rTu.GetSectionNumber()); 306 } 307 #endif 308 const UInt uiSubdiv = pcCU->getTransformIdx( uiAbsPartIdx ) > uiTrIdx;// + pcCU->getDepth( uiAbsPartIdx ) > uiDepth; 309 const UInt uiLog2TrafoSize = rTu.GetLog2LumaTrSize(); 310 311 312 UInt cbf[MAX_NUM_COMPONENT] = {0,0,0}; 313 Bool bHaveACodedBlock = false; 314 Bool bHaveACodedChromaBlock = false; 315 316 for(UInt ch=0; ch<numValidComponent; ch++) 317 { 318 const ComponentID compID = ComponentID(ch); 319 320 cbf[compID] = pcCU->getCbf( uiAbsPartIdx, compID , uiTrIdx ); 321 322 if (cbf[ch] != 0) 323 { 324 bHaveACodedBlock = true; 325 if (isChroma(compID)) 331 326 { 332 cbfU = 0; 333 cbfV = 0; 327 bHaveACodedChromaBlock = true; 334 328 } 335 #endif 336 } 337 } 338 339 if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) 329 } 330 } 331 332 if( pcCU->isIntra(uiAbsPartIdx) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) 340 333 { 341 334 assert( uiSubdiv ); 342 335 } 343 else if( pcCU-> getPredictionMode(uiAbsPartIdx) == MODE_INTER&& (pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N) && uiDepth == pcCU->getDepth(uiAbsPartIdx) && (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) )336 else if( pcCU->isInter(uiAbsPartIdx) && (pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N) && uiDepth == pcCU->getDepth(uiAbsPartIdx) && (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) ) 344 337 { 345 338 if ( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) … … 372 365 const UInt uiTrDepthCurr = uiDepth - pcCU->getDepth( uiAbsPartIdx ); 373 366 const Bool bFirstCbfOfCU = uiTrDepthCurr == 0; 374 if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) 375 { 376 #if H_3D_DISABLE_CHROMA 377 if (pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 || rd) 378 { 379 if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ) 367 368 for(UInt ch=COMPONENT_Cb; ch<numValidComponent; ch++) 369 { 370 const ComponentID compID=ComponentID(ch); 371 if( bFirstCbfOfCU || rTu.ProcessingAllQuadrants(compID) ) 372 { 373 if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepthCurr - 1 ) ) 380 374 { 381 m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr);375 m_pcEntropyCoderIf->codeQtCbf( rTu, compID, (uiSubdiv == 0) ); 382 376 } 383 if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ) 384 { 385 m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ); 386 } 387 } 388 #else 389 if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ) 390 { 391 m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ); 392 } 393 if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ) 394 { 395 m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ); 396 } 397 #endif 398 } 399 else if( uiLog2TrafoSize == 2 ) 400 { 401 #if H_3D_DISABLE_CHROMA 402 if ( rd && pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 ) 403 { 404 assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ); 405 assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ); 406 } 407 #else 408 assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ); 409 assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ); 410 #endif 411 } 412 377 } 378 else 379 { 380 assert( pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepthCurr - 1 ) ); 381 } 382 } 383 413 384 if( uiSubdiv ) 414 385 { 415 UInt size; 416 width >>= 1; 417 height >>= 1; 418 size = width*height; 419 uiTrIdx++; 420 ++uiDepth; 421 const UInt partNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); 422 423 #if H_3D_DISABLE_CHROMA 424 xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, rd ); 425 426 uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); 427 xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ,rd ); 428 429 uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); 430 xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, rd ); 431 432 uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); 433 xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, rd ); 434 #else 435 xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); 436 437 uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); 438 xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); 439 440 uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); 441 xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); 442 443 uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); 444 xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); 445 #endif 386 TComTURecurse tuRecurseChild(rTu, true); 387 do 388 { 389 xEncodeTransform( bCodeDQP, codeChromaQpAdj, tuRecurseChild ); 390 } while (tuRecurseChild.nextSection(rTu)); 446 391 } 447 392 else … … 459 404 } 460 405 #endif 461 462 #if H_3D_DISABLE_CHROMA 463 Bool notcbfUV = !rd && pcCU->getSlice()->getSPS()->getChromaFormatIdc() == 0 ? 1 : ( !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) ; 464 if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && 465 uiDepth == pcCU->getDepth( uiAbsPartIdx ) && notcbfUV ) 466 #else 467 if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) 468 #endif 469 { 470 assert( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, 0 ) ); 406 if( !pcCU->isIntra(uiAbsPartIdx) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && (!bChroma || (!pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cb, 0 ) && !pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cr, 0 ) ) ) ) 407 { 408 assert( pcCU->getCbf( uiAbsPartIdx, COMPONENT_Y, 0 ) ); 471 409 // printf( "saved one bin! " ); 472 410 } 473 411 else 474 412 { 475 m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, pcCU->getTransformIdx( uiAbsPartIdx ) ); 476 } 477 478 479 if ( cbfY || cbfU || cbfV ) 480 { 481 // dQP: only for LCU once 413 m_pcEntropyCoderIf->codeQtCbf( rTu, COMPONENT_Y, true ); //luma CBF is always at the lowest level 414 } 415 416 if ( bHaveACodedBlock ) 417 { 418 // dQP: only for CTU once 482 419 if ( pcCU->getSlice()->getPPS()->getUseDQP() ) 483 420 { 484 421 if ( bCodeDQP ) 485 422 { 486 encodeQP( pcCU, m_bakAbsPartIdxCU);423 encodeQP( pcCU, rTu.GetAbsPartIdxCU() ); 487 424 bCodeDQP = false; 488 425 } 489 426 } 490 } 491 if( cbfY ) 492 { 493 Int trWidth = width; 494 Int trHeight = height; 495 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); 496 } 497 if( uiLog2TrafoSize > 2 ) 498 { 499 Int trWidth = width >> 1; 500 Int trHeight = height >> 1; 501 if( cbfU ) 427 428 if ( pcCU->getSlice()->getUseChromaQpAdj() ) 502 429 { 503 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); 504 } 505 if( cbfV ) 506 { 507 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); 508 } 509 } 510 else 511 { 512 UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); 513 if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) 514 { 515 Int trWidth = width; 516 Int trHeight = height; 517 if( cbfU ) 430 if ( bHaveACodedChromaBlock && codeChromaQpAdj && !pcCU->getCUTransquantBypass(rTu.GetAbsPartIdxCU()) ) 518 431 { 519 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); 520 } 521 if( cbfV ) 522 { 523 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); 432 encodeChromaQpAdjustment( pcCU, rTu.GetAbsPartIdxCU() ); 433 codeChromaQpAdj = false; 524 434 } 525 435 } 526 } 527 } 528 } 529 530 // Intra direction for Luma 436 437 const UInt numValidComp=pcCU->getPic()->getNumberValidComponents(); 438 439 for(UInt ch=COMPONENT_Y; ch<numValidComp; ch++) 440 { 441 const ComponentID compID=ComponentID(ch); 442 443 if (rTu.ProcessComponentSection(compID)) 444 { 445 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 446 if (bDebugRQT) 447 { 448 printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, rTu.getRect(compID).width, rTu.getRect(compID).height, 1); 449 } 450 #endif 451 452 if (rTu.getRect(compID).width != rTu.getRect(compID).height) 453 { 454 //code two sub-TUs 455 TComTURecurse subTUIterator(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); 456 457 do 458 { 459 const UChar subTUCBF = pcCU->getCbf(subTUIterator.GetAbsPartIdxTU(compID), compID, (uiTrIdx + 1)); 460 461 if (subTUCBF != 0) 462 { 463 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 464 if (bDebugRQT) 465 { 466 printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, subTUIterator.getRect(compID).width, subTUIterator.getRect(compID).height, 1); 467 } 468 #endif 469 m_pcEntropyCoderIf->codeCoeffNxN( subTUIterator, (pcCU->getCoeff(compID) + subTUIterator.getCoefficientOffset(compID)), compID ); 470 } 471 } 472 while (subTUIterator.nextSection(rTu)); 473 } 474 else 475 { 476 if (isChroma(compID) && (cbf[COMPONENT_Y] != 0)) 477 { 478 m_pcEntropyCoderIf->codeCrossComponentPrediction( rTu, compID ); 479 } 480 481 if (cbf[compID] != 0) 482 { 483 m_pcEntropyCoderIf->codeCoeffNxN( rTu, (pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID)), compID ); 484 } 485 } 486 } 487 } 488 } 489 } 490 } 491 492 493 //! encode intra direction for luma 531 494 Void TEncEntropy::encodeIntraDirModeLuma ( TComDataCU* pcCU, UInt absPartIdx, Bool isMultiplePU ) 532 495 { … … 534 497 } 535 498 536 // Intra direction for Chroma 537 Void TEncEntropy::encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 538 { 539 if( bRD ) 540 { 541 uiAbsPartIdx = 0; 542 } 543 499 500 //! encode intra direction for chroma 501 Void TEncEntropy::encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) 502 { 544 503 m_pcEntropyCoderIf->codeIntraDirChroma( pcCU, uiAbsPartIdx ); 545 } 546 547 Void TEncEntropy::encodePredInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 548 { 549 if( bRD ) 550 { 551 uiAbsPartIdx = 0; 552 } 504 505 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 506 if (bDebugPredEnabled && pcCU->getSlice()->getFinalized()) 507 { 508 UInt cdir=pcCU->getIntraDir(CHANNEL_TYPE_CHROMA, uiAbsPartIdx); 509 if (cdir==36) 510 { 511 cdir=pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx); 512 } 513 printf("coding chroma Intra dir: %d, uiAbsPartIdx: %d, luma dir: %d\n", cdir, uiAbsPartIdx, pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx)); 514 } 515 #endif 516 } 517 518 519 Void TEncEntropy::encodePredInfo( TComDataCU* pcCU, UInt uiAbsPartIdx ) 520 { 553 521 if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. 554 522 { 555 523 encodeIntraDirModeLuma ( pcCU, uiAbsPartIdx,true ); 556 #if H_3D_DIM_SDC 557 #if H_3D_DISABLE_CHROMA 558 if(!pcCU->getSDCFlag(uiAbsPartIdx) && ( pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 || bRD ) ) 559 #else 560 if(!pcCU->getSDCFlag(uiAbsPartIdx)) 561 #endif 562 #endif 563 encodeIntraDirModeChroma( pcCU, uiAbsPartIdx, bRD ); 524 525 if (pcCU->getPic()->getChromaFormat()!=CHROMA_400) 526 { 527 encodeIntraDirModeChroma( pcCU, uiAbsPartIdx ); 528 529 if (enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) && pcCU->getPartitionSize( uiAbsPartIdx )==SIZE_NxN) 530 { 531 UInt uiPartOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2; 532 encodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset ); 533 encodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*2 ); 534 encodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*3 ); 535 } 536 } 564 537 } 565 538 else // if it is Inter mode, encode motion vector and reference index 566 539 { 567 encodePUWise( pcCU, uiAbsPartIdx, bRD ); 568 } 569 } 570 571 /** encode motion information for every PU block 572 * \param pcCU 573 * \param uiAbsPartIdx 574 * \param bRD 575 * \returns Void 576 */ 577 Void TEncEntropy::encodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 578 { 579 if ( bRD ) 580 { 581 uiAbsPartIdx = 0; 582 } 583 540 encodePUWise( pcCU, uiAbsPartIdx ); 541 } 542 } 543 544 Void TEncEntropy::encodeCrossComponentPrediction( TComTU &rTu, ComponentID compID ) 545 { 546 m_pcEntropyCoderIf->codeCrossComponentPrediction( rTu, compID ); 547 } 548 549 //! encode motion information for every PU block 550 Void TEncEntropy::encodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx ) 551 { 552 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 553 const Bool bDebugPred = bDebugPredEnabled && pcCU->getSlice()->getFinalized(); 554 #endif 555 584 556 PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); 585 557 UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); 586 558 UInt uiDepth = pcCU->getDepth( uiAbsPartIdx ); 587 UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMax CUDepth() - uiDepth ) << 1 ) ) >> 4;559 UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4; 588 560 589 561 for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) … … 599 571 { 600 572 encodeMergeIndex( pcCU, uiSubPartIdx ); 573 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 574 if (bDebugPred) 575 { 576 std::cout << "Coded merge flag, CU absPartIdx: " << uiAbsPartIdx << " PU(" << uiPartIdx << ") absPartIdx: " << uiSubPartIdx; 577 std::cout << " merge index: " << (UInt)pcCU->getMergeIndex(uiSubPartIdx) << std::endl; 578 } 579 #endif 601 580 } 602 581 else … … 610 589 encodeMvdPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); 611 590 encodeMVPIdxPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); 591 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 592 if (bDebugPred) 593 { 594 std::cout << "refListIdx: " << uiRefListIdx << std::endl; 595 std::cout << "MVD horizontal: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getHor() << std::endl; 596 std::cout << "MVD vertical: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getVer() << std::endl; 597 std::cout << "MVPIdxPU: " << pcCU->getMVPIdx(RefPicList( uiRefListIdx ), uiSubPartIdx) << std::endl; 598 std::cout << "InterDir: " << (UInt)pcCU->getInterDir(uiSubPartIdx) << std::endl; 599 } 600 #endif 612 601 } 613 602 } … … 626 615 627 616 m_pcEntropyCoderIf->codeInterDir( pcCU, uiAbsPartIdx ); 617 628 618 return; 629 619 } 630 620 631 /** encode reference frame index for a PU block 632 * \param pcCU 633 * \param uiAbsPartIdx 634 * \param eRefList 635 * \returns Void 636 */ 621 //! encode reference frame index for a PU block 637 622 Void TEncEntropy::encodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) 638 623 { 639 assert( !pcCU->isIntra( uiAbsPartIdx ) ); 640 { 641 if ( ( pcCU->getSlice()->getNumRefIdx( eRefList ) == 1 ) ) 642 { 643 return; 644 } 645 646 if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) 647 { 648 m_pcEntropyCoderIf->codeRefFrmIdx( pcCU, uiAbsPartIdx, eRefList ); 649 } 624 assert( pcCU->isInter( uiAbsPartIdx ) ); 625 626 if ( ( pcCU->getSlice()->getNumRefIdx( eRefList ) == 1 ) ) 627 { 628 return; 629 } 630 631 if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) 632 { 633 m_pcEntropyCoderIf->codeRefFrmIdx( pcCU, uiAbsPartIdx, eRefList ); 650 634 } 651 635 … … 653 637 } 654 638 655 /** encode motion vector difference for a PU block 656 * \param pcCU 657 * \param uiAbsPartIdx 658 * \param eRefList 659 * \returns Void 660 */ 639 //! encode motion vector difference for a PU block 661 640 Void TEncEntropy::encodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) 662 641 { 663 assert( !pcCU->isIntra( uiAbsPartIdx ) );642 assert( pcCU->isInter( uiAbsPartIdx ) ); 664 643 665 644 if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) … … 680 659 } 681 660 682 Void TEncEntropy::encodeQtCbf( TCom DataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth)683 { 684 m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, eType, uiTrDepth);661 Void TEncEntropy::encodeQtCbf( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ) 662 { 663 m_pcEntropyCoderIf->codeQtCbf( rTu, compID, lowestLevel ); 685 664 } 686 665 … … 695 674 } 696 675 697 Void TEncEntropy::encodeQtCbfZero( TComDataCU* pcCU, TextType eType, UInt uiTrDepth ) 698 { 699 m_pcEntropyCoderIf->codeQtCbfZero( pcCU, eType, uiTrDepth ); 700 } 701 Void TEncEntropy::encodeQtRootCbfZero( TComDataCU* pcCU ) 702 { 703 m_pcEntropyCoderIf->codeQtRootCbfZero( pcCU ); 676 Void TEncEntropy::encodeQtCbfZero( TComTU &rTu, const ChannelType chType ) 677 { 678 m_pcEntropyCoderIf->codeQtCbfZero( rTu, chType ); 679 } 680 681 Void TEncEntropy::encodeQtRootCbfZero( ) 682 { 683 m_pcEntropyCoderIf->codeQtRootCbfZero( ); 704 684 } 705 685 … … 711 691 uiAbsPartIdx = 0; 712 692 } 713 693 714 694 if ( pcCU->getSlice()->getPPS()->getUseDQP() ) 715 695 { … … 718 698 } 719 699 700 //! encode chroma qp adjustment 701 Void TEncEntropy::encodeChromaQpAdjustment( TComDataCU* cu, UInt absPartIdx, Bool inRd ) 702 { 703 if( inRd ) 704 { 705 absPartIdx = 0; 706 } 707 708 m_pcEntropyCoderIf->codeChromaQpAdjustment( cu, absPartIdx ); 709 } 720 710 721 711 // texture 722 /** encode coefficients 723 * \param pcCU 724 * \param uiAbsPartIdx 725 * \param uiDepth 726 * \param uiWidth 727 * \param uiHeight 728 */ 729 #if H_3D_DISABLE_CHROMA 730 Void TEncEntropy::encodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP, Bool rd ) 731 #else 732 Void TEncEntropy::encodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) 733 #endif 734 { 735 UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); 736 UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; 737 UInt uiChromaOffset = uiLumaOffset>>2; 738 #if H_3D_DIM_SDC 712 713 //! encode coefficients 714 Void TEncEntropy::encodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& codeChromaQpAdj ) 715 { 716 717 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 718 const Bool bDebugRQT=pcCU->getSlice()->getFinalized() && DebugOptionList::DebugRQT.getInt()!=0; 719 #endif 720 721 #if NH_3D_SDC_INTRA 739 722 if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx ) ) 740 723 { 741 724 assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); 742 725 assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); 743 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); 744 #if H_3D_DISABLE_CHROMA 745 if (!pcCU->getSlice()->getIsDepth() ) 746 { 747 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); 748 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); 749 } 750 #else 751 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); 752 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); 753 #endif 754 } 755 756 726 assert( pcCU->getCbf(uiAbsPartIdx, COMPONENT_Y) == 1 ); 727 } 728 #endif 729 #if NH_3D_SDC_INTER 757 730 if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx ) ) 758 731 { … … 761 734 assert( pcCU->getSlice()->getIsDepth() ); 762 735 } 763 764 if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) ) 736 #endif 737 #if NH_3D 738 if( pcCU->getSlice()->getIsDepth() ) 739 { 740 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER 741 if( pcCU->getSDCFlag( uiAbsPartIdx ) ) 742 { 743 m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx ); 744 return; 745 } 746 #endif 747 #if NH_3D_DMM 748 if( pcCU->isIntra(uiAbsPartIdx) ) 765 749 { 766 750 Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1; 767 UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2; 768 769 if( !pcCU->getSDCFlag( uiAbsPartIdx ) ) 770 { 751 UInt uiPartOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2; 771 752 for( Int iPart = 0; iPart < iPartNum; iPart++ ) 772 753 { 773 if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE)754 if( isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx + uiPartOffset*iPart ) ) ) 774 755 { 775 756 m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart ); … … 777 758 } 778 759 } 760 #endif 761 } 762 #endif 763 764 if( pcCU->isIntra(uiAbsPartIdx) ) 765 { 766 #if !NH_MV 767 if (false) 768 { 769 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 770 DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" ) 771 DTRACE_CABAC_V( uiDepth ) 772 DTRACE_CABAC_T( "\n" ) 773 } 774 #endif 775 } 776 else 777 { 778 if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ) ) 779 { 780 m_pcEntropyCoderIf->codeQtRootCbf( pcCU, uiAbsPartIdx ); 781 } 782 if ( !pcCU->getQtRootCbf( uiAbsPartIdx ) ) 783 { 784 return; 785 } 786 } 787 788 TComTURecurse tuRecurse(pcCU, uiAbsPartIdx, uiDepth); 789 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 790 if (bDebugRQT) 791 { 792 printf("..codeCoeff: uiAbsPartIdx=%d, PU format=%d, 2Nx2N=%d, NxN=%d\n", uiAbsPartIdx, pcCU->getPartitionSize(uiAbsPartIdx), SIZE_2Nx2N, SIZE_NxN); 793 } 794 #endif 795 796 xEncodeTransform( bCodeDQP, codeChromaQpAdj, tuRecurse ); 797 } 798 799 Void TEncEntropy::encodeCoeffNxN( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID) 800 { 801 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC 802 Bool oldTraceFracBits = g_traceEncFracBits; 803 g_traceEncFracBits = false; 804 #endif 805 806 TComDataCU *pcCU = rTu.getCU(); 807 808 if (pcCU->getCbf(rTu.GetAbsPartIdxTU(), compID, rTu.GetTransformDepthRel()) != 0) 809 { 810 if (rTu.getRect(compID).width != rTu.getRect(compID).height) 811 { 812 //code two sub-TUs 813 TComTURecurse subTUIterator(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); 814 815 const UInt subTUSize = subTUIterator.getRect(compID).width * subTUIterator.getRect(compID).height; 816 817 do 818 { 819 const UChar subTUCBF = pcCU->getCbf(subTUIterator.GetAbsPartIdxTU(compID), compID, (subTUIterator.GetTransformDepthRel() + 1)); 820 821 if (subTUCBF != 0) 822 { 823 m_pcEntropyCoderIf->codeCoeffNxN( subTUIterator, (pcCoef + (subTUIterator.GetSectionNumber() * subTUSize)), compID); 824 } 825 } 826 while (subTUIterator.nextSection(rTu)); 827 } 779 828 else 780 829 { 781 m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx ); 782 return; 783 } 784 } 785 #endif 786 787 if( pcCU->isIntra(uiAbsPartIdx) ) 788 { 789 #if !H_MV 790 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 791 DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" ) 792 DTRACE_CABAC_V( uiDepth ) 793 DTRACE_CABAC_T( "\n" ) 794 #endif 795 } 796 else 797 { 798 if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ) ) 799 { 800 m_pcEntropyCoderIf->codeQtRootCbf( pcCU, uiAbsPartIdx ); 801 } 802 if ( !pcCU->getQtRootCbf( uiAbsPartIdx ) ) 803 { 804 return; 805 } 830 m_pcEntropyCoderIf->codeCoeffNxN(rTu, pcCoef, compID); 831 } 832 } 833 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC 834 g_traceEncFracBits = oldTraceFracBits; 835 #endif 836 } 837 838 Void TEncEntropy::estimateBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, const ChannelType chType) 839 { 840 const UInt heightAtEntropyCoding = (width != height) ? (height >> 1) : height; 841 842 m_pcEntropyCoderIf->estBit ( pcEstBitsSbac, width, heightAtEntropyCoding, chType ); 843 } 844 845 Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ) 846 { 847 Int count = 0; 848 849 for ( Int i = 0; i < uiSize; i++ ) 850 { 851 count += pcCoef[i] != 0; 852 } 853 854 return count; 855 } 856 857 #if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER 858 Void TEncEntropy::encodeDeltaDC ( TComDataCU* pcCU, UInt absPartIdx ) 859 { 860 m_pcEntropyCoderIf->codeDeltaDC( pcCU, absPartIdx ); 861 } 862 #endif 863 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER 864 Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 865 { 866 if( bRD ) 867 { 868 uiAbsPartIdx = 0; 806 869 } 807 870 808 #if H_3D_DISABLE_CHROMA809 xEncodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, rd);810 #else811 xEncodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP);812 #endif813 }814 815 Void TEncEntropy::encodeCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiTrWidth, UInt uiTrHeight, UInt uiDepth, TextType eType )816 {817 // This is for Transform unit processing. This may be used at mode selection stage for Inter.818 m_pcEntropyCoderIf->codeCoeffNxN( pcCU, pcCoeff, uiAbsPartIdx, uiTrWidth, uiTrHeight, uiDepth, eType );819 }820 821 Void TEncEntropy::estimateBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType)822 {823 eTType = eTType == TEXT_LUMA ? TEXT_LUMA : TEXT_CHROMA;824 825 m_pcEntropyCoderIf->estBit ( pcEstBitsSbac, width, height, eTType );826 }827 828 Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize )829 {830 Int count = 0;831 832 for ( Int i = 0; i < uiSize; i++ )833 {834 count += pcCoef[i] != 0;835 }836 837 return count;838 }839 840 /** encode quantization matrix841 * \param scalingList quantization matrix information842 */843 Void TEncEntropy::encodeScalingList( TComScalingList* scalingList )844 {845 m_pcEntropyCoderIf->codeScalingList( scalingList );846 }847 848 #if H_3D_INTER_SDC849 Void TEncEntropy::encodeDeltaDC ( TComDataCU* pcCU, UInt absPartIdx )850 {851 m_pcEntropyCoderIf->codeDeltaDC( pcCU, absPartIdx );852 }853 854 Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )855 {856 871 if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) || 857 872 ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) ) … … 865 880 } 866 881 867 assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) ); 868 869 if( bRD ) 870 { 871 uiAbsPartIdx = 0; 872 } 882 assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ); 873 883 874 884 m_pcEntropyCoderIf->codeSDCFlag( pcCU, uiAbsPartIdx ); … … 876 886 877 887 #endif 878 #if H_3D_DBBP888 #if NH_3D_DBBP 879 889 Void TEncEntropy::encodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 880 890 { 891 if( bRD ) 892 { 893 uiAbsPartIdx = 0; 894 } 895 881 896 if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && 882 897 ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || … … 885 900 pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() ) 886 901 { 887 if( bRD )888 {889 uiAbsPartIdx = 0;890 }891 902 m_pcEntropyCoderIf->codeDBBPFlag( pcCU, uiAbsPartIdx ); 892 903 } 893 904 } 894 905 #endif 906 895 907 //! \}
Note: See TracChangeset for help on using the changeset viewer.