Ticket #186: EntropySliceMode2.patch
File EntropySliceMode2.patch, 11.6 KB (added by rickard, 13 years ago) |
---|
-
source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp
142 142 m_uiBitsToFollow = 0; 143 143 m_uiByte = 0; 144 144 m_uiBitsLeft = 9; 145 #if FINE_GRANULARITY_SLICES 146 if (m_bBinCountingEnabled) 147 { 148 m_uiBinsCoded=0; 149 } 150 #endif 145 151 } 146 152 147 153 UInt -
source/Lib/TLibEncoder/TEncCu.cpp
746 746 #if FINE_GRANULARITY_SLICES 747 747 if(m_pcEncCfg->getUseSBACRD()) 748 748 { 749 rpc BestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();749 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 750 750 } 751 751 #endif 752 752 } … … 790 790 #if FINE_GRANULARITY_SLICES 791 791 if(m_pcEncCfg->getUseSBACRD()) 792 792 { 793 rpc BestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();793 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 794 794 } 795 795 #endif 796 796 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); … … 836 836 Bool bEntropyLimit=false; 837 837 Bool bSliceLimit=false; 838 838 bSliceLimit=rpcBestCU->getSlice()->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&&(rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceArgument()<<3); 839 if(rpcBestCU->getSlice()->get SliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&m_pcEncCfg->getUseSBACRD())839 if(rpcBestCU->getSlice()->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&m_pcEncCfg->getUseSBACRD()) 840 840 { 841 841 if(rpcBestCU->getTotalBins()>rpcBestCU->getSlice()->getEntropySliceArgument()) 842 842 { 843 843 bEntropyLimit=true; 844 844 } 845 845 } 846 else if(rpcBestCU->getSlice()->get SliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE)846 else if(rpcBestCU->getSlice()->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE) 847 847 { 848 848 if(rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getEntropySliceArgument()) 849 849 { … … 940 940 UInt uiGranularityWidth = g_uiMaxCUWidth>>(pcSlice->getPPS()->getSliceGranularity()); 941 941 uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 942 942 uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 943 if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) 944 &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight))) 943 Bool granularityBoundary=((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) 944 &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)); 945 if(granularityBoundary) 945 946 { 946 947 m_pcEntropyCoder->encodeTerminatingBit( bTerminateSlice ? 1 : 0 ); 947 948 } … … 971 972 if(pcSlice->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&!pcSlice->getFinalized()&&pcSlice->getEntropySliceCounter()+uiBinsCoded>pcSlice->getEntropySliceArgument()) 972 973 { 973 974 pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd); 975 return; 974 976 } 975 977 } 976 978 else … … 978 980 if(pcSlice->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&!pcSlice->getFinalized()&&pcSlice->getEntropySliceCounter()+m_pcBitCounter->getNumberOfWrittenBits()>pcSlice->getEntropySliceArgument()) 979 981 { 980 982 pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd); 983 return; 981 984 } 982 985 } 986 if(granularityBoundary) 987 { 988 pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + m_pcBitCounter->getNumberOfWrittenBits()) ); 989 if(m_pcEncCfg->getUseSBACRD()) 990 { 991 TEncBinCABAC *pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf(); 992 pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+pppcRDSbacCoder->getBinsCoded()); 993 pppcRDSbacCoder->setBinsCoded( 0 ); 994 } 995 else 996 { 997 pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+m_pcBitCounter->getNumberOfWrittenBits()); 998 } 999 m_pcBitCounter->resetBits(); 1000 } 983 1001 } 984 1002 #endif 985 1003 /** encode a CU block recursively … … 1194 1212 #if FINE_GRANULARITY_SLICES 1195 1213 if(m_pcEncCfg->getUseSBACRD()) 1196 1214 { 1197 rpc BestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();1215 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1198 1216 } 1199 1217 #endif 1200 1218 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); … … 1315 1333 #if FINE_GRANULARITY_SLICES 1316 1334 if(m_pcEncCfg->getUseSBACRD()) 1317 1335 { 1318 rpc BestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();1336 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1319 1337 } 1320 1338 #endif 1321 1339 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); … … 1380 1398 #if FINE_GRANULARITY_SLICES 1381 1399 if(m_pcEncCfg->getUseSBACRD()) 1382 1400 { 1383 rpc BestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();1401 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1384 1402 } 1385 1403 #endif 1386 1404 } … … 1439 1457 #if FINE_GRANULARITY_SLICES 1440 1458 if(m_pcEncCfg->getUseSBACRD()) 1441 1459 { 1442 rpc BestCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();1460 rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1443 1461 } 1444 1462 #endif 1445 1463 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); … … 1455 1473 #if FINE_GRANULARITY_SLICES 1456 1474 if(m_pcEncCfg->getUseSBACRD()) 1457 1475 { 1458 rpc BestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();1476 rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1459 1477 } 1460 1478 #endif 1461 1479 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); … … 1506 1524 #if FINE_GRANULARITY_SLICES 1507 1525 if(m_pcEncCfg->getUseSBACRD()) 1508 1526 { 1509 rpc BestCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();1527 rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); 1510 1528 } 1511 1529 #endif 1512 1530 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); -
source/Lib/TLibEncoder/TEncSlice.cpp
560 560 // set go-on entropy coder 561 561 m_pcEntropyCoder->setEntropyCoder ( m_pcRDGoOnSbacCoder, pcSlice ); 562 562 m_pcEntropyCoder->setBitstream ( m_pcBitCounter ); 563 563 #if FINE_GRANULARITY_SLICES 564 ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true); 565 #endif 564 566 // run CU encoder 565 567 m_pcCuEncoder->compressCU( pcCU ); 566 568 … … 570 572 pppcRDSbacCoder->setBinCountingEnableFlag( true ); 571 573 #if FINE_GRANULARITY_SLICES 572 574 m_pcBitCounter->resetBits(); 575 pppcRDSbacCoder->setBinsCoded( 0 ); 573 576 #endif 574 577 #if SUB_LCU_DQP 575 578 // restore last QP … … 579 582 580 583 pppcRDSbacCoder->setBinCountingEnableFlag( false ); 581 584 #if FINE_GRANULARITY_SLICES 582 pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + m_pcBitCounter->getNumberOfWrittenBits()) ); 583 if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() ) ) > m_pcCfg->getSliceArgument()<<3) 585 if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() + m_pcBitCounter->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3) 584 586 { 585 587 #else 586 588 uiBitsCoded += m_pcBitCounter->getNumberOfWrittenBits(); … … 597 599 break; 598 600 } 599 601 #if FINE_GRANULARITY_SLICES 600 pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+pppcRDSbacCoder->getBinsCoded()); 601 if (m_pcCfg->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE && pcSlice->getEntropySliceCounter() > m_pcCfg->getEntropySliceArgument()&&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getEntropySliceCurEndCUAddr()) 602 if (m_pcCfg->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE && pcSlice->getEntropySliceCounter()+pppcRDSbacCoder->getBinsCoded() > m_pcCfg->getEntropySliceArgument()&&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getEntropySliceCurEndCUAddr()) 602 603 { 603 604 #else 604 605 … … 612 613 uiCUAddr = uiCUAddr + 1; 613 614 } 614 615 #endif 616 #if !FINE_GRANULARITY_SLICES 617 uiBitsCoded -= m_pcBitCounter->getNumberOfWrittenBits(); 618 #endif 615 619 pcSlice->setNextEntropySlice( true ); 616 620 break; 617 621 } … … 628 632 m_pcCuEncoder->encodeCU( pcCU ); 629 633 630 634 #if FINE_GRANULARITY_SLICES 631 pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + m_pcBitCounter->getNumberOfWrittenBits()) ); 632 if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() ) ) > m_pcCfg->getSliceArgument()<<3) 635 if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits()+ m_pcBitCounter->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3) 633 636 { 634 637 #else 635 638 uiBitsCoded += m_pcBitCounter->getNumberOfWrittenBits(); … … 646 649 break; 647 650 } 648 651 #if FINE_GRANULARITY_SLICES 649 pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+m_pcBitCounter->getNumberOfWrittenBits()); 650 if (m_pcCfg->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE && pcSlice->getEntropySliceCounter() > m_pcCfg->getEntropySliceArgument()&&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getEntropySliceCurEndCUAddr()) 652 if (m_pcCfg->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE && pcSlice->getEntropySliceCounter()+ m_pcBitCounter->getNumberOfWrittenBits()> m_pcCfg->getEntropySliceArgument()&&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getEntropySliceCurEndCUAddr()) 651 653 { 652 654 653 655 #else … … 660 662 uiCUAddr = uiCUAddr + 1; 661 663 } 662 664 #endif 665 666 #if !FINE_GRANULARITY_SLICES 667 uiBitsCoded -= m_pcBitCounter->getNumberOfWrittenBits(); 668 #endif 663 669 pcSlice->setNextEntropySlice( true ); 664 670 break; 665 671 }