Changeset 189 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncSbac.cpp
- Timestamp:
- 18 Nov 2012, 22:11:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/TEncSbac.cpp
r116 r189 42 42 #include <algorithm> 43 43 44 #if RWTH_SDC_DLT_B0036 45 #define GetNumDepthValues() (pcCU->getSlice()->getSPS()->getNumDepthValues()) 46 #define GetBitsPerDepthValue() (pcCU->getSlice()->getSPS()->getBitsPerDepthValue()) 47 #endif 48 44 49 //! \ingroup TLibEncoder 45 50 //! \{ … … 60 65 , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels ) 61 66 , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 67 #if LGE_ILLUCOMP_B0045 68 , m_cCUICFlagSCModel ( 1, 1, NUM_IC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 69 #endif 62 70 , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) 63 71 , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 106 114 , m_cDmmDataSCModel ( 1, 1, NUM_DMM_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 107 115 #endif 108 #if LGE_EDGE_INTRA 116 #if LGE_EDGE_INTRA_A0070 109 117 , m_cEdgeIntraSCModel ( 1, 1, NUM_EDGE_INTRA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 110 118 #if LGE_EDGE_INTRA_DELTA_DC … … 112 120 #endif 113 121 #endif 122 #if RWTH_SDC_DLT_B0036 123 , m_cSDCFlagSCModel ( 1, 1, SDC_NUM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 124 , m_cSDCResidualFlagSCModel ( 1, 2, SDC_NUM_RESIDUAL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 125 , m_cSDCResidualSignFlagSCModel ( 1, 2, SDC_NUM_SIGN_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 126 , m_cSDCResidualSCModel ( 1, 2, SDC_NUM_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) 127 , m_cSDCPredModeSCModel ( 1, 3, SDC_NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 128 #endif 114 129 { 115 130 assert( m_numContextModels <= MAX_NUM_CTX_MOD ); … … 141 156 142 157 m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG ); 158 #if LGE_ILLUCOMP_B0045 159 m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG ); 160 #endif 143 161 m_cCUAlfCtrlFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_CTRL_FLAG ); 144 162 m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT); … … 187 205 m_cDmmDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_DATA ); 188 206 #endif 189 #if LGE_EDGE_INTRA 207 #if LGE_EDGE_INTRA_A0070 190 208 m_cEdgeIntraSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA ); 191 209 #if LGE_EDGE_INTRA_DELTA_DC 192 210 m_cEdgeIntraDeltaDCSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA_DELTA_DC ); 193 211 #endif 212 #endif 213 #if RWTH_SDC_DLT_B0036 214 m_cSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG ); 215 m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); 216 m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL ); 217 m_cSDCResidualSignFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_SIGN_FLAG ); 218 m_cSDCPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_PRED_MODE ); 194 219 #endif 195 220 … … 224 249 curCost = m_cCUSplitFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SPLIT_FLAG ); 225 250 curCost += m_cCUSkipFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_SKIP_FLAG ); 251 #if LGE_ILLUCOMP_B0045 252 curCost += m_cCUICFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_IC_FLAG ); 253 #endif 226 254 curCost += m_cCUAlfCtrlFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_ALF_CTRL_FLAG ); 227 255 curCost += m_cCUMergeFlagExtSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT); … … 279 307 } 280 308 281 #if CABAC_INIT_FLAG && POZNAN_CABAC_INIT_FLAG_FIX309 #if CABAC_INIT_FLAG && FIX_POZNAN_CABAC_INIT_FLAG 282 310 m_pcSlice->getPPS()->setEncPrevPOC( m_pcSlice->getPOC() ); 283 311 #endif … … 295 323 296 324 m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG ); 325 #if LGE_ILLUCOMP_B0045 326 m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG ); 327 #endif 297 328 m_cCUAlfCtrlFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ALF_CTRL_FLAG ); 298 329 m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT); … … 341 372 m_cDmmDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_DATA ); 342 373 #endif 374 #if RWTH_SDC_DLT_B0036 375 m_cSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG ); 376 m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); 377 m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL ); 378 m_cSDCResidualSignFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_SIGN_FLAG ); 379 m_cSDCPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_PRED_MODE ); 380 #endif 343 381 344 382 m_pcBinIf->start(); … … 580 618 { 581 619 PartSize eSize = pcCU->getPartitionSize( uiAbsPartIdx ); 582 #if OL_DEPTHLIMIT_A0044 583 UInt uiSymbol; 584 #endif 620 621 #if OL_QTLIMIT_PREDCODING_B0068 622 TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); 623 TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); 624 Bool bDepthMapDetect = (pcTexture != NULL); 625 Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); 626 627 if(bDepthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC() && pcCU->getPic()->getReduceBitsFlag()) 628 { 629 TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); 630 UInt uiCUIdx = (pcCU->getZorderIdxInCU() == 0) ? uiAbsPartIdx : pcCU->getZorderIdxInCU(); 631 assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); 632 if (pcTextureCU->getDepth(uiCUIdx) == uiDepth && pcTextureCU->getPartitionSize( uiCUIdx ) != SIZE_NxN) 633 { 634 assert( eSize == SIZE_2Nx2N ); 635 return; 636 } 637 } 638 #endif 639 585 640 if ( pcCU->isIntra( uiAbsPartIdx ) ) 586 641 { … … 588 643 { 589 644 m_pcBinIf->encodeBin( eSize == SIZE_2Nx2N? 1 : 0, m_cCUPartSizeSCModel.get( 0, 0, 0 ) ); 590 #if OL_DEPTHLIMIT_A0044 591 if(pcCU->getPartDumpFlag()) 592 { 593 uiSymbol = (UInt)(eSize == SIZE_2Nx2N? 1 : 0); 594 pcCU->updatePartInfo(uiSymbol?0:1,uiDepth); //0 for 2Nx2N and 1 for NxN 595 pcCU->incrementPartInfo(); 596 } 597 #endif 598 } 599 #if OL_DEPTHLIMIT_A0044 600 if(pcCU->getPartDumpFlag() && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth && !pcCU->getSlice()->isIntra()) 601 { 602 pcCU->updatePartInfo(0,uiDepth); //0 for 2Nx2N and 1 for NxN 603 pcCU->incrementPartInfo(); 604 } 605 #endif 645 } 606 646 return; 607 647 } … … 612 652 { 613 653 m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) ); 614 #if OL_DEPTHLIMIT_A0044615 if(pcCU->getPartDumpFlag())616 {617 pcCU->updatePartInfo(0,uiDepth); //0 for 2Nx2N618 pcCU->incrementPartInfo();619 }620 #endif621 654 break; 622 655 } … … 648 681 } 649 682 } 650 #if OL_DEPTHLIMIT_A0044651 if(pcCU->getPartDumpFlag())652 {653 pcCU->updatePartInfo(2,uiDepth); //2 for 2NxN654 pcCU->incrementPartInfo();655 }656 #endif657 683 break; 658 684 } … … 688 714 } 689 715 } 690 #if OL_DEPTHLIMIT_A0044691 if(pcCU->getPartDumpFlag())692 {693 pcCU->updatePartInfo(3,uiDepth); //3 for Nx2N694 pcCU->incrementPartInfo();695 }696 #endif697 716 break; 698 717 } … … 704 723 m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) ); 705 724 m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 2) ); 706 #if OL_DEPTHLIMIT_A0044707 if(pcCU->getPartDumpFlag())708 {709 pcCU->updatePartInfo(1,uiDepth); //2Nx2N here since we disable NxN in Inter710 pcCU->incrementPartInfo();711 }712 #endif713 }714 else715 {716 #if OL_DEPTHLIMIT_A0044717 if(pcCU->getPartDumpFlag())718 {719 pcCU->updatePartInfo(0,uiDepth); //2Nx2N here since we disable NxN in Inter720 pcCU->incrementPartInfo();721 }722 #endif723 725 } 724 726 break; … … 738 740 Void TEncSbac::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) 739 741 { 742 #if RWTH_SDC_DLT_B0036 743 if ( pcCU->getSlice()->isIntra() ) 744 { 745 assert( pcCU->isIntra(uiAbsPartIdx) ); 746 return; 747 } 748 #endif 749 740 750 // get context function is here 741 751 Int iPredMode = pcCU->getPredictionMode( uiAbsPartIdx ); … … 786 796 } 787 797 798 #if LGE_ILLUCOMP_B0045 799 /** code Illumination Compensation flag 800 * \param pcCU 801 * \param uiAbsPartIdx 802 * \returns Void 803 */ 804 Void TEncSbac::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) 805 { 806 // get context function is here 807 UInt uiSymbol = pcCU->getICFlag( uiAbsPartIdx ) ? 1 : 0; 808 UInt uiCtxIC = pcCU->getCtxICFlag( uiAbsPartIdx ) ; 809 m_pcBinIf->encodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, uiCtxIC ) ); 810 DTRACE_CABAC_VL( g_nSymbolCounter++ ); 811 DTRACE_CABAC_T( "\tICFlag" ); 812 DTRACE_CABAC_T( "\tuiCtxIC: "); 813 DTRACE_CABAC_V( uiCtxIC ); 814 DTRACE_CABAC_T( "\tuiSymbol: "); 815 DTRACE_CABAC_V( uiSymbol ); 816 DTRACE_CABAC_T( "\n"); 817 } 818 #endif 819 788 820 /** code merge flag 789 821 * \param pcCU … … 883 915 884 916 assert( uiCtx < 3 ); 917 918 #if OL_QTLIMIT_PREDCODING_B0068 919 Bool bCodeSplitFlag = true; 920 921 TComSPS *sps = pcCU->getPic()->getSlice(0)->getSPS(); 922 TComPic *pcTexture = pcCU->getSlice()->getTexturePic(); 923 Bool bDepthMapDetect = (pcTexture != NULL); 924 Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE); 925 926 if(bDepthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC() && pcCU->getPic()->getReduceBitsFlag()) 927 { 928 TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr()); 929 UInt uiCUIdx = (pcCU->getZorderIdxInCU() == 0) ? uiAbsPartIdx : pcCU->getZorderIdxInCU(); 930 assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); 931 bCodeSplitFlag = (pcTextureCU->getDepth(uiCUIdx) > uiDepth); 932 } 933 934 if(!bCodeSplitFlag) 935 { 936 assert(uiCurrSplitFlag == 0); 937 return; 938 } 939 #endif 940 885 941 m_pcBinIf->encodeBin( uiCurrSplitFlag, m_cCUSplitFlagSCModel.get( 0, 0, uiCtx ) ); 886 #if OL_DEPTHLIMIT_A0044887 if(pcCU->getPartDumpFlag())888 {889 if(pcCU->getSlice()->isIntra() || (!pcCU->getSlice()->isIntra() && uiCurrSplitFlag!=0))890 {891 pcCU->updatePartInfo(uiCurrSplitFlag,uiDepth);892 pcCU->incrementPartInfo();893 }894 }895 #endif896 942 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 897 943 DTRACE_CABAC_T( "\tSplitFlag\n" ) … … 911 957 } 912 958 913 #if LGE_EDGE_INTRA 959 #if LGE_EDGE_INTRA_A0070 914 960 Void TEncSbac::xCodeEdgeIntraInfo( TComDataCU* pcCU, UInt uiPartIdx ) 915 961 { … … 992 1038 if( pcCU->getSlice()->getSPS()->getUseDMM() && pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE ) 993 1039 { 994 #if LGE_EDGE_INTRA 1040 #if LGE_EDGE_INTRA_A0070 995 1041 m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX, m_cDmmFlagSCModel.get(0, 0, 0) ); 996 1042 #else … … 998 1044 #endif 999 1045 } 1000 #if LGE_EDGE_INTRA 1046 #if LGE_EDGE_INTRA_A0070 1001 1047 if( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX ) 1002 1048 #else … … 1035 1081 } 1036 1082 else 1037 #if LGE_EDGE_INTRA 1083 #if LGE_EDGE_INTRA_A0070 1038 1084 if ( uiDir >= EDGE_INTRA_IDX) 1039 1085 { … … 1070 1116 Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); 1071 1117 #endif 1072 #if LGE_EDGE_INTRA 1118 #if LGE_EDGE_INTRA_A0070 1073 1119 Bool bCodeEdgeIntra = false; 1074 1120 if( pcCU->getSlice()->getSPS()->isDepth() ) … … 1136 1182 #if LOGI_INTRA_NAME_3MPM 1137 1183 m_pcBinIf->encodeBinsEP( uiDir, 5 ); 1138 #if LGE_EDGE_INTRA 1184 #if LGE_EDGE_INTRA_A0070 1139 1185 if (bCodeEdgeIntra) 1140 1186 if (uiDir == 31) m_pcBinIf->encodeBinsEP(0,1); … … 2478 2524 } 2479 2525 2480 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC)2526 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA_A0070 && LGE_EDGE_INTRA_DELTA_DC) 2481 2527 Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel ) 2482 2528 { … … 2644 2690 } 2645 2691 #endif 2692 2693 #if RWTH_SDC_DLT_B0036 2694 Void TEncSbac::codeSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2695 { 2696 assert( pcCU->getSlice()->getSPS()->isDepth() ); 2697 assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); 2698 assert( pcCU->getSDCFlag(uiAbsPartIdx) ); 2699 2700 UInt uiPredMode = pcCU->getLumaIntraDir(uiAbsPartIdx); 2701 UInt uiCtx = 0; 2702 2703 UInt uiMPModeIdx = 0; 2704 2705 for(Int i=0; i<RWTH_SDC_NUM_PRED_MODES-1; i++) 2706 { 2707 UInt uiBit = (uiPredMode == g_auiSDCPredModes[uiMPModeIdx]) ? 1 : 0; 2708 m_pcBinIf->encodeBin( uiBit, m_cSDCPredModeSCModel.get( 0, i, uiCtx ) ); 2709 2710 // if mode is most probable mode, we are done here 2711 if ( uiBit == 1 ) 2712 break; 2713 2714 // else: get next most probable pred mode 2715 uiMPModeIdx = (uiMPModeIdx+1)%RWTH_SDC_NUM_PRED_MODES; 2716 } 2717 2718 #if HHI_DMM_WEDGE_INTRA 2719 if( uiPredMode == DMM_WEDGE_FULL_IDX ) { xCodeWedgeFullInfo ( pcCU, uiAbsPartIdx ); } 2720 if( uiPredMode == DMM_WEDGE_PREDDIR_IDX ) { xCodeWedgePredDirInfo ( pcCU, uiAbsPartIdx ); } 2721 #endif 2722 2723 AOF(uiPredMode == g_auiSDCPredModes[uiMPModeIdx]); 2724 } 2725 2726 Void TEncSbac::codeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2727 { 2728 // get context function is here 2729 UInt uiSymbol = pcCU->getSDCFlag( uiAbsPartIdx ) ? 1 : 0; 2730 UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx ); 2731 m_pcBinIf->encodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) ); 2732 2733 } 2734 2735 Void TEncSbac::codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) 2736 { 2737 assert( pcCU->getSlice()->getSPS()->isDepth() ); 2738 assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); 2739 assert( pcCU->getSDCFlag(uiAbsPartIdx) ); 2740 assert( uiSegment < 2 ); 2741 2742 Pel segmentDCOffset = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); 2743 2744 UInt uiResidual = segmentDCOffset == 0 ? 0 : 1; 2745 UInt uiSign = segmentDCOffset < 0 ? 1 : 0; 2746 UInt uiAbsIdx = abs(segmentDCOffset); 2747 UInt uiBit = 0; 2748 2749 UInt uiMaxResidualBits = GetBitsPerDepthValue(); 2750 assert( uiMaxResidualBits <= g_uiBitDepth ); 2751 2752 // residual flag 2753 m_pcBinIf->encodeBin( uiResidual, m_cSDCResidualFlagSCModel.get( 0, uiSegment, 0 ) ); //TODO depthmap: more sophisticated context selection 2754 2755 if (uiResidual) 2756 { 2757 // encode sign bit of residual 2758 m_pcBinIf->encodeBin( uiSign, m_cSDCResidualSignFlagSCModel.get( 0, uiSegment, 0 ) ); //TODO depthmap: more sophisticated context selection 2759 2760 assert(uiAbsIdx < GetNumDepthValues()); 2761 2762 // encode residual magnitude 2763 uiAbsIdx -= 1; 2764 for (Int i=0; i<uiMaxResidualBits; i++) 2765 { 2766 uiBit = (uiAbsIdx & (1<<i))>>i; 2767 2768 m_pcBinIf->encodeBin( uiBit, m_cSDCResidualSCModel.get( 0, uiSegment, i ) ); //TODO depthmap: more sophisticated context selection 2769 } 2770 2771 } 2772 } 2773 #endif 2646 2774 //! \}
Note: See TracChangeset for help on using the changeset viewer.