Changeset 177 in 3DVCSoftware for branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder
- Timestamp:
- 10 Nov 2012, 19:05:41 (14 years ago)
- Location:
- branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder
- Files:
-
- 11 edited
-
TEncCavlc.cpp (modified) (2 diffs)
-
TEncCavlc.h (modified) (1 diff)
-
TEncCfg.h (modified) (3 diffs)
-
TEncCu.cpp (modified) (2 diffs)
-
TEncEntropy.cpp (modified) (6 diffs)
-
TEncEntropy.h (modified) (2 diffs)
-
TEncSbac.cpp (modified) (6 diffs)
-
TEncSbac.h (modified) (2 diffs)
-
TEncSearch.cpp (modified) (14 diffs)
-
TEncSearch.h (modified) (1 diff)
-
TEncTop.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCavlc.cpp
r152 r177 644 644 } 645 645 #endif 646 647 #if RWTH_SDC_DLT_B0036 648 if( bIsDepth ) 649 { 650 WRITE_FLAG( pcSPS->getUseDLT() ? 1 : 0, "use_dlt_flag" ); 651 if( pcSPS->getUseDLT() ) 652 { 653 // code mapping 654 xWriteUvlc ( pcSPS->getNumDepthValues() ); 655 for(UInt i=0; i<pcSPS->getNumDepthValues(); i++) 656 { 657 xWriteUvlc( pcSPS->idx2DepthValue(i) ); 658 } 659 } 660 } 661 #endif 646 662 647 663 if( pcSPS->getViewId() || pcSPS->isDepth() ) … … 2066 2082 return true; 2067 2083 } 2084 2085 #if RWTH_SDC_DLT_B0036 2086 Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2087 { 2088 assert(0); 2089 } 2090 2091 Void TEncCavlc::codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) 2092 { 2093 assert(0); 2094 } 2095 2096 Void TEncCavlc::codeSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2097 { 2098 assert(0); 2099 } 2100 #endif 2068 2101 //! \} -
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCavlc.h
r152 r177 223 223 Void codeDFFlag ( UInt uiCode, const Char *pSymbolName ); 224 224 Void codeDFSvlc ( Int iCode, const Char *pSymbolName ); 225 226 #if RWTH_SDC_DLT_B0036 227 Void codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 228 Void codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ); 229 Void codeSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 230 #endif 225 231 226 232 }; -
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCfg.h
r152 r177 250 250 Bool m_bUseMVI; 251 251 #endif 252 #if RWTH_SDC_DLT_B0036 253 Bool m_bUseDLT; 254 Bool m_bUseSDC; 255 #endif 252 256 253 257 Int* m_aidQP; … … 690 694 #if HHI_MPI 691 695 Void setUseMVI ( Bool bVal ) {m_bUseMVI = bVal;} 696 #endif 697 #if RWTH_SDC_DLT_B0036 698 Void setUseDLT ( Bool b ) { m_bUseDLT = b; } 699 Void setUseSDC ( Bool b ) { m_bUseSDC = b; } 692 700 #endif 693 701 Void setUseSAO ( Bool bVal ) {m_bUseSAO = bVal;} … … 830 838 Bool getUseDMM() { return m_bUseDMM; } 831 839 #endif 840 841 #if RWTH_SDC_DLT_B0036 842 Bool getUseDLT() { return m_bUseDLT; } 843 Bool getUseSDC() { return m_bUseSDC; } 844 #endif 832 845 833 846 #if OL_DEPTHLIMIT_A0044 -
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCu.cpp
r161 r177 2308 2308 // do MC 2309 2309 #if HHI_INTERVIEW_SKIP 2310 if ( (uiNoResidual == 0) || bSkipRes ){ 2311 #else 2312 if ( uiNoResidual == 0 ){ 2313 #endif 2310 if ( (uiNoResidual == 0) || bSkipRes ) 2311 #else 2312 if ( uiNoResidual == 0 ) 2313 #endif 2314 { 2314 2315 m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); 2315 2316 // save pred adress … … 2541 2542 m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() ); 2542 2543 2544 #if RWTH_SDC_DLT_B0036 2545 if( !rpcTempCU->getSDCFlag( 0 ) ) 2546 #endif 2543 2547 m_pcPredSearch ->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC ); 2544 2548 -
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncEntropy.cpp
r152 r177 905 905 #endif 906 906 907 #if !RWTH_SDC_DLT_B0036 907 908 if ( pcCU->getSlice()->isIntra() ) 908 909 { 909 910 return; 910 911 } 912 #endif 911 913 912 914 m_pcEntropyCoderIf->codePredMode( pcCU, uiAbsPartIdx ); 915 916 #if RWTH_SDC_DLT_B0036 917 // if B-Slice, code SDC flag later 918 if( !pcCU->getSlice()->isInterB() && pcCU->getSlice()->getSPS()->isDepth() && pcCU->isIntra(uiAbsPartIdx) ) 919 { 920 // encode SDC flag 921 encodeSDCFlag(pcCU, uiAbsPartIdx, bRD); 922 } 923 #endif 913 924 } 914 925 … … 955 966 } 956 967 #endif 968 #if RWTH_SDC_DLT_B0036 969 if( !pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSDCFlag(uiAbsPartIdx) ) 970 { 971 assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); 972 return; 973 } 974 #endif 975 957 976 m_pcEntropyCoderIf->codePartSize( pcCU, uiAbsPartIdx, uiDepth ); 977 978 #if RWTH_SDC_DLT_B0036 979 // code SDC flag now! 980 if( pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSlice()->getSPS()->isDepth() ) 981 { 982 // encode SDC flag 983 encodeSDCFlag(pcCU, uiAbsPartIdx, bRD); 984 985 if( pcCU->getSDCFlag(uiAbsPartIdx) ) 986 { 987 // part size is also known for SDC intra 988 assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); 989 } 990 } 991 #endif 958 992 } 959 993 … … 972 1006 return; 973 1007 } 1008 1009 #if RWTH_SDC_DLT_B0036 1010 if( pcCU->getSDCFlag(uiAbsPartIdx) ) 1011 { 1012 return; 1013 } 1014 #endif 974 1015 975 1016 if( bRD ) … … 1307 1348 } 1308 1349 1350 #if RWTH_SDC_DLT_B0036 1351 if( pcCU->getSDCFlag(uiAbsPartIdx) ) 1352 { 1353 encodeSDCPredMode(pcCU, uiAbsPartIdx, bRD); 1354 return; 1355 } 1356 #endif 1357 1309 1358 PartSize eSize = pcCU->getPartitionSize( uiAbsPartIdx ); 1310 1359 … … 1636 1685 UInt uiLumaTrMode, uiChromaTrMode; 1637 1686 pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode ); 1687 1688 #if RWTH_SDC_DLT_B0036 1689 if( pcCU->getSDCFlag( uiAbsPartIdx ) ) 1690 { 1691 assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); 1692 assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); 1693 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); 1694 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); 1695 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); 1696 1697 encodeSDCResidualData(pcCU, uiAbsPartIdx); 1698 return; 1699 } 1700 #endif 1638 1701 1639 1702 if( pcCU->isIntra(uiAbsPartIdx) ) … … 2009 2072 } 2010 2073 2074 #if RWTH_SDC_DLT_B0036 2075 Void TEncEntropy::encodeSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 2076 { 2077 assert( pcCU->getSlice()->getSPS()->isDepth() ); 2078 2079 if( bRD ) 2080 uiAbsPartIdx = 0; 2081 2082 m_pcEntropyCoderIf->codeSDCPredMode(pcCU, uiAbsPartIdx); 2083 } 2084 2085 Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 2086 { 2087 assert( pcCU->getSlice()->getSPS()->isDepth() ); 2088 2089 if( bRD ) 2090 uiAbsPartIdx = 0; 2091 2092 m_pcEntropyCoderIf->codeSDCFlag(pcCU, uiAbsPartIdx); 2093 } 2094 2095 Void TEncEntropy::encodeSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 2096 { 2097 assert( pcCU->getSlice()->getSPS()->isDepth() ); 2098 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); 2099 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); 2100 assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); 2101 assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); 2102 2103 if( bRD ) 2104 uiAbsPartIdx = 0; 2105 2106 // number of segments depends on prediction mode for INTRA 2107 UInt uiNumSegments = 2; 2108 UInt uiLumaPredMode = pcCU->getLumaIntraDir( uiAbsPartIdx ); 2109 if( uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX ) 2110 uiNumSegments = 1; 2111 2112 // encode residual data for each segment 2113 for( UInt uiSeg = 0; uiSeg < uiNumSegments; uiSeg++ ) 2114 m_pcEntropyCoderIf->codeSDCResidualData(pcCU, uiAbsPartIdx, uiSeg); 2115 } 2116 #endif 2117 2011 2118 //! \} -
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncEntropy.h
r152 r177 128 128 virtual Void codePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; 129 129 130 #if RWTH_SDC_DLT_B0036 131 virtual Void codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; 132 virtual Void codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) = 0; 133 virtual Void codeSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; 134 #endif 135 130 136 #if BURST_IPCM 131 137 virtual Void codeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) = 0; … … 302 308 Void encodeScalingList ( TComScalingList* scalingList ); 303 309 Void encodeDFParams (TComAPS* pcAPS); 310 311 #if RWTH_SDC_DLT_B0036 312 Void encodeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); 313 Void encodeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); 314 Void encodeSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); 315 #endif 304 316 305 317 private: -
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSbac.cpp
r156 r177 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 //! \{ … … 114 119 , m_cEdgeIntraDeltaDCSCModel ( 1, 1, NUM_EDGE_INTRA_DELTA_DC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 115 120 #endif 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) 116 128 #endif 117 129 { … … 199 211 #endif 200 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 ); 219 #endif 201 220 202 221 // new structure … … 353 372 m_cDmmDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_DATA ); 354 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 355 381 356 382 m_pcBinIf->start(); … … 750 776 Void TEncSbac::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) 751 777 { 778 #if RWTH_SDC_DLT_B0036 779 if ( pcCU->getSlice()->isIntra() ) 780 { 781 assert( pcCU->isIntra(uiAbsPartIdx) ); 782 return; 783 } 784 #endif 785 752 786 // get context function is here 753 787 Int iPredMode = pcCU->getPredictionMode( uiAbsPartIdx ); … … 2678 2712 } 2679 2713 #endif 2714 2715 #if RWTH_SDC_DLT_B0036 2716 Void TEncSbac::codeSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2717 { 2718 assert( pcCU->getSlice()->getSPS()->isDepth() ); 2719 assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); 2720 assert( pcCU->getSDCFlag(uiAbsPartIdx) ); 2721 2722 UInt uiPredMode = pcCU->getLumaIntraDir(uiAbsPartIdx); 2723 UInt uiCtx = 0; 2724 2725 UInt uiMPModeIdx = 0; 2726 2727 for(Int i=0; i<RWTH_SDC_NUM_PRED_MODES-1; i++) 2728 { 2729 UInt uiBit = (uiPredMode == g_auiSDCPredModes[uiMPModeIdx]) ? 1 : 0; 2730 m_pcBinIf->encodeBin( uiBit, m_cSDCPredModeSCModel.get( 0, i, uiCtx ) ); 2731 2732 // if mode is most probable mode, we are done here 2733 if ( uiBit == 1 ) 2734 break; 2735 2736 // else: get next most probable pred mode 2737 uiMPModeIdx = (uiMPModeIdx+1)%RWTH_SDC_NUM_PRED_MODES; 2738 } 2739 2740 #if HHI_DMM_WEDGE_INTRA 2741 if( uiPredMode == DMM_WEDGE_FULL_IDX ) { xCodeWedgeFullInfo ( pcCU, uiAbsPartIdx ); } 2742 if( uiPredMode == DMM_WEDGE_PREDDIR_IDX ) { xCodeWedgePredDirInfo ( pcCU, uiAbsPartIdx ); } 2743 #endif 2744 2745 AOF(uiPredMode == g_auiSDCPredModes[uiMPModeIdx]); 2746 } 2747 2748 Void TEncSbac::codeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2749 { 2750 // get context function is here 2751 UInt uiSymbol = pcCU->getSDCFlag( uiAbsPartIdx ) ? 1 : 0; 2752 UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx ); 2753 m_pcBinIf->encodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) ); 2754 2755 } 2756 2757 Void TEncSbac::codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) 2758 { 2759 assert( pcCU->getSlice()->getSPS()->isDepth() ); 2760 assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); 2761 assert( pcCU->getSDCFlag(uiAbsPartIdx) ); 2762 assert( uiSegment < 2 ); 2763 2764 Pel segmentDCOffset = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); 2765 2766 UInt uiResidual = segmentDCOffset == 0 ? 0 : 1; 2767 UInt uiSign = segmentDCOffset < 0 ? 1 : 0; 2768 UInt uiAbsIdx = abs(segmentDCOffset); 2769 UInt uiBit = 0; 2770 2771 UInt uiMaxResidualBits = GetBitsPerDepthValue(); 2772 assert( uiMaxResidualBits <= g_uiBitDepth ); 2773 2774 // residual flag 2775 m_pcBinIf->encodeBin( uiResidual, m_cSDCResidualFlagSCModel.get( 0, uiSegment, 0 ) ); //TODO depthmap: more sophisticated context selection 2776 2777 if (uiResidual) 2778 { 2779 // encode sign bit of residual 2780 m_pcBinIf->encodeBin( uiSign, m_cSDCResidualSignFlagSCModel.get( 0, uiSegment, 0 ) ); //TODO depthmap: more sophisticated context selection 2781 2782 assert(uiAbsIdx < GetNumDepthValues()); 2783 2784 // encode residual magnitude 2785 uiAbsIdx -= 1; 2786 for (Int i=0; i<uiMaxResidualBits; i++) 2787 { 2788 uiBit = (uiAbsIdx & (1<<i))>>i; 2789 2790 m_pcBinIf->encodeBin( uiBit, m_cSDCResidualSCModel.get( 0, uiSegment, i ) ); //TODO depthmap: more sophisticated context selection 2791 } 2792 2793 } 2794 } 2795 #endif 2680 2796 //! \} -
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSbac.h
r152 r177 145 145 #endif 146 146 Void codeScalingList ( TComScalingList* scalingList ){ assert (0); return;}; 147 148 #if RWTH_SDC_DLT_B0036 149 Void codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 150 Void codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ); 151 Void codeSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 152 #endif 147 153 148 154 private: … … 322 328 #endif 323 329 #endif 330 331 #if RWTH_SDC_DLT_B0036 332 ContextModel3DBuffer m_cSDCFlagSCModel; 333 334 ContextModel3DBuffer m_cSDCResidualFlagSCModel; 335 ContextModel3DBuffer m_cSDCResidualSignFlagSCModel; 336 ContextModel3DBuffer m_cSDCResidualSCModel; 337 338 ContextModel3DBuffer m_cSDCPredModeSCModel; 339 #endif 324 340 }; 325 341 -
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSearch.cpp
r158 r177 42 42 #include <math.h> 43 43 44 #if RWTH_SDC_DLT_B0036 45 #define GetDepthValue2Idx(val) (pcCU->getSlice()->getSPS()->depthValue2idx(val)) 46 #define GetIdx2DepthValue(val) (pcCU->getSlice()->getSPS()->idx2DepthValue(val)) 47 #endif 48 44 49 //! \ingroup TLibEncoder 45 50 //! \{ … … 195 200 const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + 1; 196 201 for( Int iNum = 0; iNum < iNumAMVPCands+1; iNum++) 197 {198 202 for( Int iIdx = 0; iIdx < iNumAMVPCands; iIdx++) 199 203 #else 200 204 for( Int iNum = 0; iNum < AMVP_MAX_NUM_CANDS+1; iNum++) 201 {202 205 for( Int iIdx = 0; iIdx < AMVP_MAX_NUM_CANDS; iIdx++) 203 206 #endif … … 208 211 m_auiMVPIdxCost[iIdx][iNum] = MAX_INT; 209 212 } 210 }211 213 212 214 initTempBuff(); … … 1599 1601 } 1600 1602 1603 #if RWTH_SDC_DLT_B0036 1604 Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bResidual ) 1605 { 1606 UInt uiLumaPredMode = pcCU ->getLumaIntraDir( uiAbsPartIdx ); 1607 UInt uiWidth = pcCU ->getWidth ( 0 ); 1608 UInt uiHeight = pcCU ->getHeight ( 0 ); 1609 UInt uiStride = pcOrgYuv ->getStride (); 1610 Pel* piOrg = pcOrgYuv ->getLumaAddr( uiAbsPartIdx ); 1611 Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); 1612 Pel* piReco = pcPredYuv->getLumaAddr( uiAbsPartIdx ); 1613 1614 UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; 1615 Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); 1616 UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); 1617 1618 AOF( uiWidth == uiHeight ); 1619 AOF( uiAbsPartIdx == 0 ); 1620 AOF( pcCU->getSDCAvailable(uiAbsPartIdx) ); 1621 AOF( pcCU->getSDCFlag(uiAbsPartIdx) ); 1622 1623 //===== init availability pattern ===== 1624 Bool bAboveAvail = false; 1625 Bool bLeftAvail = false; 1626 pcCU->getPattern()->initPattern ( pcCU, 0, uiAbsPartIdx ); 1627 pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail ); 1628 1629 //===== get prediction signal ===== 1630 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 1631 if( uiLumaPredMode >= NUM_INTRA_MODE ) 1632 { 1633 predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, true ); 1634 } 1635 else 1636 { 1637 #endif 1638 predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); 1639 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 1640 } 1641 #endif 1642 1643 // number of segments depends on prediction mode 1644 UInt uiNumSegments = 1; 1645 Bool* pbMask = NULL; 1646 UInt uiMaskStride = 0; 1647 1648 //if( uiLumaPredMode == DMM_WEDGE_FULL_IDX || uiLumaPredMode == DMM_WEDGE_PREDDIR_IDX ) 1649 if( 0 ) 1650 { 1651 Int uiTabIdx = (uiLumaPredMode == DMM_WEDGE_FULL_IDX)?pcCU->getWedgeFullTabIdx(uiAbsPartIdx):pcCU->getWedgePredDirTabIdx(uiAbsPartIdx); 1652 1653 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])]; 1654 TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx )); 1655 1656 uiNumSegments = 2; 1657 pbMask = pcWedgelet->getPattern(); 1658 uiMaskStride = pcWedgelet->getStride(); 1659 } 1660 1661 // get DC prediction for each segment 1662 Pel apDCPredValues[2]; 1663 xAnalyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride ); 1664 1665 // get original DC for each segment 1666 Pel apDCOrigValues[2]; 1667 xAnalyzeSegmentsSDC(piOrg, uiStride, uiWidth, apDCOrigValues, uiNumSegments, pbMask, uiMaskStride ); 1668 1669 for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) 1670 { 1671 // remap reconstructed value to valid depth values 1672 Pel pDCRec = bResidual?apDCOrigValues[uiSegment]:apDCPredValues[uiSegment]; 1673 1674 // get residual (idx) 1675 Pel pResidualIdx = GetDepthValue2Idx( pDCRec ) - GetDepthValue2Idx( apDCPredValues[uiSegment] ); 1676 1677 // save SDC DC offset 1678 pcCU->setSDCSegmentDCOffset(pResidualIdx, uiSegment, uiAbsPartIdx); 1679 } 1680 1681 // reconstruct residual based on mask + DC residuals 1682 Pel apDCResiValues[2]; 1683 Pel apDCRecoValues[2]; 1684 for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) 1685 { 1686 Pel pPredIdx = GetDepthValue2Idx( apDCPredValues[uiSegment] ); 1687 Pel pResiIdx = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); 1688 Pel pRecoValue = GetIdx2DepthValue( pPredIdx + pResiIdx ); 1689 1690 apDCRecoValues[uiSegment] = pRecoValue; 1691 apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; 1692 } 1693 1694 //===== reconstruction ===== 1695 Bool* pMask = pbMask; 1696 Pel* pPred = piPred; 1697 Pel* pReco = piReco; 1698 Pel* pRecIPred = piRecIPred; 1699 1700 for( UInt uiY = 0; uiY < uiHeight; uiY++ ) 1701 { 1702 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 1703 { 1704 UChar ucSegment = pMask?(UChar)pMask[uiX]:0; 1705 assert( ucSegment < uiNumSegments ); 1706 1707 Pel pPredVal= apDCPredValues[ucSegment]; 1708 Pel pResiDC = apDCResiValues[ucSegment]; 1709 1710 pReco [ uiX ] = Clip( pPredVal + pResiDC ); 1711 pRecIPred[ uiX ] = pReco[ uiX ]; 1712 } 1713 pPred += uiStride; 1714 pReco += uiStride; 1715 pRecIPred += uiRecIPredStride; 1716 pMask += uiMaskStride; 1717 } 1718 1719 // clear UV 1720 UInt uiStrideC = pcPredYuv->getCStride(); 1721 Pel *pRecCb = pcPredYuv->getCbAddr(); 1722 Pel *pRecCr = pcPredYuv->getCrAddr(); 1723 1724 for (Int y=0; y<uiHeight/2; y++) 1725 { 1726 for (Int x=0; x<uiWidth/2; x++) 1727 { 1728 pRecCb[x] = (Pel)(128<<g_uiBitIncrement); 1729 pRecCr[x] = (Pel)(128<<g_uiBitIncrement); 1730 } 1731 1732 pRecCb += uiStrideC; 1733 pRecCr += uiStrideC; 1734 } 1735 1736 //===== determine distortion ===== 1737 #if HHI_VSO 1738 if ( m_pcRdCost->getUseVSO() ) 1739 { 1740 ruiDist = m_pcRdCost->getDistVS ( pcCU, uiAbsPartIdx, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, false, 0 ); 1741 } 1742 else 1743 #endif 1744 { 1745 ruiDist = m_pcRdCost->getDistPart( piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight ); 1746 } 1747 1748 //----- determine rate and r-d cost ----- 1749 m_pcEntropyCoder->resetBits(); 1750 1751 // encode reduced intra header 1752 m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true ); 1753 m_pcEntropyCoder->encodePredMode( pcCU, 0, true ); 1754 1755 // encode pred direction + residual data 1756 m_pcEntropyCoder->encodePredInfo( pcCU, 0, true ); 1757 1758 UInt uiBits = m_pcEntropyCoder->getNumberOfWrittenBits(); 1759 1760 #if HHI_VSO 1761 if ( m_pcRdCost->getUseLambdaScaleVSO()) 1762 { 1763 dRDCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist ); 1764 } 1765 else 1766 #endif 1767 { 1768 dRDCost = m_pcRdCost->calcRdCost( uiBits, ruiDist ); 1769 } 1770 } 1771 #endif 1601 1772 1602 1773 Void … … 2107 2278 UInt uiBestPUDistC = 0; 2108 2279 Double dBestPUCost = MAX_DOUBLE; 2280 #if RWTH_SDC_DLT_B0036 2281 Bool bBestUseSDC = false; 2282 Pel apBestDCOffsets[2] = {0,0}; 2283 #endif 2109 2284 for( UInt uiMode = 0; uiMode < numModesForFullRD; uiMode++ ) 2110 2285 { … … 2127 2302 continue; 2128 2303 } 2304 #endif 2305 2306 #if RWTH_SDC_DLT_B0036 2307 UInt uiUseSDC = ( m_pcEncCfg->getUseSDC() && pcCU->getPartitionSize(uiPartOffset) == SIZE_2Nx2N )?1:0; 2308 2309 for( UInt uiSDC=0; uiSDC<=uiUseSDC; uiSDC++ ) 2310 { 2311 for( UInt uiRes = 0; uiRes<=uiUseSDC; uiRes++ ) 2312 { 2129 2313 #endif 2130 2314 … … 2150 2334 } 2151 2335 #endif 2152 2336 #if RWTH_SDC_DLT_B0036 2337 // last check: if not available for current intra prediction mode, don't try 2338 if( uiSDC == 1 && !pcCU->getSDCAvailable(uiPartOffset) ) 2339 continue; 2340 2341 pcCU->setSDCFlagSubParts( uiSDC == 1, uiPartOffset, 0, uiDepth + uiInitTrDepth ); 2342 2343 if(uiSDC == 1) 2344 { 2345 pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth); 2346 pcCU->setCbfSubParts(1, 1, 1, uiPartOffset, uiDepth + uiInitTrDepth); 2347 2348 // start encoding with SDC 2349 xIntraCodingSDC(pcCU, uiPartOffset, pcOrgYuv, pcPredYuv, uiPUDistY, dPUCost, (uiRes==1)); 2350 } 2351 else 2352 { 2353 #endif 2153 2354 #if HHI_RQT_INTRA_SPEEDUP 2154 2355 #if LG_ZEROINTRADEPTHRESI_M26039 … … 2159 2360 #else 2160 2361 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost ); 2362 #endif 2363 #if RWTH_SDC_DLT_B0036 2364 } 2161 2365 #endif 2162 2366 … … 2172 2376 uiBestPUDistC = uiPUDistC; 2173 2377 dBestPUCost = dPUCost; 2378 2379 #if RWTH_SDC_DLT_B0036 2380 if( uiSDC == 1 ) 2381 { 2382 bBestUseSDC = true; 2383 2384 // copy reconstruction 2385 pcPredYuv->copyPartToPartYuv(pcRecoYuv, uiPartOffset, uiWidth, uiHeight); 2386 2387 // copy DC values 2388 apBestDCOffsets[0] = pcCU->getSDCSegmentDCOffset(0, uiPartOffset); 2389 apBestDCOffsets[1] = pcCU->getSDCSegmentDCOffset(1, uiPartOffset); 2390 } 2391 else 2392 { 2393 bBestUseSDC = false; 2394 #endif 2395 2396 xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv ); 2397 2398 UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth(0) + uiInitTrDepth ) << 1 ); 2399 ::memcpy( m_puhQTTempTrIdx, pcCU->getTransformIdx() + uiPartOffset, uiQPartNum * sizeof( UChar ) ); 2400 ::memcpy( m_puhQTTempCbf[0], pcCU->getCbf( TEXT_LUMA ) + uiPartOffset, uiQPartNum * sizeof( UChar ) ); 2401 ::memcpy( m_puhQTTempCbf[1], pcCU->getCbf( TEXT_CHROMA_U ) + uiPartOffset, uiQPartNum * sizeof( UChar ) ); 2402 ::memcpy( m_puhQTTempCbf[2], pcCU->getCbf( TEXT_CHROMA_V ) + uiPartOffset, uiQPartNum * sizeof( UChar ) ); 2403 #if RWTH_SDC_DLT_B0036 2404 } 2405 #endif 2406 } 2407 #if HHI_RQT_INTRA_SPEEDUP_MOD 2408 else if( dPUCost < dSecondBestPUCost ) 2409 { 2410 uiSecondBestMode = uiOrgMode; 2411 dSecondBestPUCost = dPUCost; 2412 } 2413 #endif 2414 #if LG_ZEROINTRADEPTHRESI_M26039 2415 } 2416 #endif 2417 #if RWTH_SDC_DLT_B0036 2418 } // SDC residual loop 2419 } // SDC loop 2420 #endif 2421 } // Mode loop 2422 2423 #if HHI_RQT_INTRA_SPEEDUP 2424 #if HHI_RQT_INTRA_SPEEDUP_MOD 2425 for( UInt ui =0; ui < 2; ++ui ) 2426 #endif 2427 { 2428 #if HHI_RQT_INTRA_SPEEDUP_MOD 2429 UInt uiOrgMode = ui ? uiSecondBestMode : uiBestPUMode; 2430 if( uiOrgMode == MAX_UINT ) 2431 { 2432 break; 2433 } 2434 #else 2435 UInt uiOrgMode = uiBestPUMode; 2436 #endif 2437 2438 pcCU->setLumaIntraDirSubParts ( uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth ); 2439 2440 // set context models 2441 if( m_bUseSBACRD ) 2442 { 2443 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 2444 } 2445 2446 // determine residual for partition 2447 Dist uiPUDistY = 0; 2448 Dist uiPUDistC = 0; 2449 Double dPUCost = 0.0; 2450 2451 #if HHI_VSO 2452 // reset Model 2453 if( m_pcRdCost->getUseRenModel() ) 2454 { 2455 m_pcRdCost->setRenModelData( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight ); 2456 } 2457 #endif 2458 2459 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, false, dPUCost ); 2460 2461 // check r-d cost 2462 if( dPUCost < dBestPUCost ) 2463 { 2464 uiBestPUMode = uiOrgMode; 2465 uiBestPUDistY = uiPUDistY; 2466 uiBestPUDistC = uiPUDistC; 2467 dBestPUCost = dPUCost; 2468 #if RWTH_SDC_DLT_B0036 2469 bBestUseSDC = false; 2470 #endif 2174 2471 2175 2472 xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv ); … … 2182 2479 2183 2480 } 2184 #if HHI_RQT_INTRA_SPEEDUP_MOD2185 else if( dPUCost < dSecondBestPUCost )2186 {2187 uiSecondBestMode = uiOrgMode;2188 dSecondBestPUCost = dPUCost;2189 }2190 #endif2191 #if LG_ZEROINTRADEPTHRESI_M260392192 }2193 #endif2194 } // Mode loop2195 2196 #if HHI_RQT_INTRA_SPEEDUP2197 #if HHI_RQT_INTRA_SPEEDUP_MOD2198 for( UInt ui =0; ui < 2; ++ui )2199 #endif2200 {2201 #if HHI_RQT_INTRA_SPEEDUP_MOD2202 UInt uiOrgMode = ui ? uiSecondBestMode : uiBestPUMode;2203 if( uiOrgMode == MAX_UINT )2204 {2205 break;2206 }2207 #else2208 UInt uiOrgMode = uiBestPUMode;2209 #endif2210 2211 pcCU->setLumaIntraDirSubParts ( uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );2212 2213 // set context models2214 if( m_bUseSBACRD )2215 {2216 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );2217 }2218 2219 // determine residual for partition2220 Dist uiPUDistY = 0;2221 Dist uiPUDistC = 0;2222 Double dPUCost = 0.0;2223 2224 #if HHI_VSO2225 // reset Model2226 if( m_pcRdCost->getUseRenModel() )2227 {2228 m_pcRdCost->setRenModelData( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight );2229 }2230 #endif2231 2232 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, false, dPUCost );2233 2234 // check r-d cost2235 if( dPUCost < dBestPUCost )2236 {2237 uiBestPUMode = uiOrgMode;2238 uiBestPUDistY = uiPUDistY;2239 uiBestPUDistC = uiPUDistC;2240 dBestPUCost = dPUCost;2241 2242 xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv );2243 2244 UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth(0) + uiInitTrDepth ) << 1 );2245 ::memcpy( m_puhQTTempTrIdx, pcCU->getTransformIdx() + uiPartOffset, uiQPartNum * sizeof( UChar ) );2246 ::memcpy( m_puhQTTempCbf[0], pcCU->getCbf( TEXT_LUMA ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );2247 ::memcpy( m_puhQTTempCbf[1], pcCU->getCbf( TEXT_CHROMA_U ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );2248 ::memcpy( m_puhQTTempCbf[2], pcCU->getCbf( TEXT_CHROMA_V ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );2249 2250 }2251 2481 } // Mode loop 2252 2482 #endif … … 2255 2485 uiOverallDistY += uiBestPUDistY; 2256 2486 uiOverallDistC += uiBestPUDistC; 2487 2488 #if RWTH_SDC_DLT_B0036 2489 if( bBestUseSDC ) 2490 { 2491 pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth); 2492 pcCU->setCbfSubParts(1, 1, 1, uiPartOffset, uiDepth + uiInitTrDepth); 2493 2494 //=== copy best DC segment values back to CU ==== 2495 pcCU->setSDCSegmentDCOffset(apBestDCOffsets[0], 0, uiPartOffset); 2496 pcCU->setSDCSegmentDCOffset(apBestDCOffsets[1], 1, uiPartOffset); 2497 } 2498 else 2499 { 2500 #endif 2257 2501 2258 2502 //--- update transform index and cbf --- … … 2262 2506 ::memcpy( pcCU->getCbf( TEXT_CHROMA_U ) + uiPartOffset, m_puhQTTempCbf[1], uiQPartNum * sizeof( UChar ) ); 2263 2507 ::memcpy( pcCU->getCbf( TEXT_CHROMA_V ) + uiPartOffset, m_puhQTTempCbf[2], uiQPartNum * sizeof( UChar ) ); 2508 #if RWTH_SDC_DLT_B0036 2509 } 2510 #endif 2264 2511 2265 2512 //--- set reconstruction for next intra prediction blocks --- … … 2332 2579 //=== update PU data ==== 2333 2580 pcCU->setLumaIntraDirSubParts ( uiBestPUMode, uiPartOffset, uiDepth + uiInitTrDepth ); 2581 #if RWTH_SDC_DLT_B0036 2582 pcCU->setSDCFlagSubParts ( bBestUseSDC, uiPartOffset, 0, uiDepth + uiInitTrDepth ); 2583 #endif 2334 2584 pcCU->copyToPic ( uiDepth, uiPU, uiInitTrDepth ); 2335 2585 } // PU loop … … 7817 8067 #endif 7818 8068 #endif 8069 8070 #if RWTH_SDC_DLT_B0036 8071 Void TEncSearch::xAnalyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride ) 8072 { 8073 Int iSumDepth[uiNumSegments]; 8074 memset(iSumDepth, 0, sizeof(Int)*uiNumSegments); 8075 Int iSumPix[uiNumSegments]; 8076 memset(iSumPix, 0, sizeof(Int)*uiNumSegments); 8077 8078 for (Int y=0; y<uiSize; y++) 8079 { 8080 for (Int x=0; x<uiSize; x++) 8081 { 8082 UChar ucSegment = pMask?(UChar)pMask[x]:0; 8083 assert( ucSegment < uiNumSegments ); 8084 8085 iSumDepth[ucSegment] += pOrig[x]; 8086 iSumPix[ucSegment] += 1; 8087 } 8088 8089 pOrig += uiStride; 8090 pMask += uiMaskStride; 8091 } 8092 8093 // compute mean for each segment 8094 for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ ) 8095 { 8096 if( iSumPix[ucSeg] > 0 ) 8097 rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg]; 8098 else 8099 rpSegMeans[ucSeg] = 0; // this happens for zero-segments 8100 } 8101 } 8102 #endif 7819 8103 7820 8104 //! \} -
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSearch.h
r158 r177 307 307 UInt uiAbsPartIdx, 308 308 TComYuv* pcRecoYuv ); 309 310 #if RWTH_SDC_DLT_B0036 311 Void xAnalyzeSegmentsSDC ( Pel* pOrig, 312 UInt uiStride, 313 UInt uiSize, 314 Pel* rpSegMeans, 315 UInt uiNumSegments, 316 Bool* pMask, 317 UInt uiMaskStride ); 318 319 Void xIntraCodingSDC ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bResidual ); 320 #endif 309 321 310 322 // ------------------------------------------------------------------------------------------------------------------- -
branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncTop.cpp
r121 r177 648 648 #endif 649 649 650 #if RWTH_SDC_DLT_B0036 651 m_cSPS.setUseDLT ( m_bUseDLT ); 652 #endif 653 650 654 m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); 651 655 m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize );
Note: See TracChangeset for help on using the changeset viewer.