Changeset 100 in 3DVCSoftware for trunk/source/Lib/TLibEncoder
- Timestamp:
- 9 Aug 2012, 12:53:16 (13 years ago)
- Location:
- trunk/source/Lib/TLibEncoder
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r77 r100 378 378 Void TEncCavlc::codeVPS( TComVPS* pcVPS ) 379 379 { 380 380 WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" ); 381 381 WRITE_CODE( pcVPS->getMaxLayers() - 1, 5, "max_layers_minus1" ); 382 382 WRITE_FLAG( pcVPS->getTemporalNestingFlag() - 1, "temporal_id_nesting_flag" ); … … 775 775 { 776 776 WRITE_CODE( (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()), pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); 777 #if HHI_FIX778 777 if( pcSlice->getPOC() == 0 && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV ) 779 778 { … … 848 847 } 849 848 if( pcSlice->getPOC() != 0 ) 850 #else851 if( pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV )852 #endif853 849 { 854 850 TComReferencePictureSet* rps = pcSlice->getRPS(); -
trunk/source/Lib/TLibEncoder/TEncCfg.h
r77 r100 205 205 UInt m_uiVSOMode; 206 206 #endif 207 #if SAIT_VSO_EST_A0033 208 Bool m_bUseEstimatedVSD; 209 Double m_dDispCoeff; 210 #endif 211 207 212 208 213 //====== Tool list ======== … … 568 573 #endif 569 574 575 #if SAIT_VSO_EST_A0033 576 Void setUseEstimatedVSD ( Bool b ) { m_bUseEstimatedVSD = b; } 577 Void setDispCoeff ( Double d ) { m_dDispCoeff = d; } 578 #endif 579 570 580 Void setUseFastEnc ( Bool b ) { m_bUseFastEnc = b; } 571 581 Void setUseEarlyCU ( Bool b ) { m_bUseEarlyCU = b; } … … 608 618 Bool getUseVSO () { return m_bUseVSO; } 609 619 #endif 620 #if SAIT_VSO_EST_A0033 621 Bool getUseEstimatedVSD () { return m_bUseEstimatedVSD; } 622 Double getDispCoeff () { return m_dDispCoeff; } 623 #endif 624 610 625 Bool getUseFastEnc () { return m_bUseFastEnc; } 611 626 Bool getUseEarlyCU () { return m_bUseEarlyCU; } -
trunk/source/Lib/TLibEncoder/TEncCu.cpp
r81 r100 1156 1156 if( m_pcRdCost->getUseRenModel() ) 1157 1157 { 1158 #if HHI_FIX1159 1158 UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth ( ); 1160 1159 UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight( ); … … 1162 1161 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride(); 1163 1162 m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 1164 #else1165 UInt uiWidth = m_ppcBestCU[uiDepth]->getWidth ( 0 );1166 UInt uiHeight = m_ppcBestCU[uiDepth]->getHeight( 0 );1167 Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr( 0 );1168 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();1169 m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );1170 #endif1171 1163 } 1172 1164 #endif … … 1212 1204 1213 1205 #if HHI_VSO 1206 #if HHI_VSO_SET_OPTIM 1207 #else 1214 1208 if( m_pcRdCost->getUseRenModel() ) // necessary ?? 1215 1209 { 1216 #if HHI_FIX1217 1210 UInt uiWidth = m_ppcRecoYuvBest[uhNextDepth]->getWidth ( ); 1218 1211 UInt uiHeight = m_ppcRecoYuvBest[uhNextDepth]->getHeight ( ); … … 1220 1213 UInt uiSrcStride = m_ppcRecoYuvBest[uhNextDepth]->getStride ( ); 1221 1214 m_pcRdCost->setRenModelData( pcSubBestPartCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 1222 #else 1223 UInt uiWidth = pcSubBestPartCU->getWidth ( 0 ); 1224 UInt uiHeight = pcSubBestPartCU->getHeight( 0 ); 1225 Pel* piSrc = m_ppcRecoYuvBest[pcSubBestPartCU->getDepth(0)]->getLumaAddr( 0 ); 1226 UInt uiSrcStride = m_ppcRecoYuvBest[pcSubBestPartCU->getDepth(0)]->getStride(); 1227 m_pcRdCost->setRenModelData( pcSubBestPartCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 1228 #endif 1229 } 1215 } 1216 #endif 1230 1217 #endif 1231 1218 } … … 1369 1356 if( m_pcRdCost->getUseRenModel() ) 1370 1357 { 1371 #if HHI_FIX1372 1358 UInt uiWidth = m_ppcRecoYuvBest[uiDepth]->getWidth ( ); 1373 1359 UInt uiHeight = m_ppcRecoYuvBest[uiDepth]->getHeight ( ); … … 1375 1361 UInt uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride ( ); 1376 1362 m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 1377 #else1378 UInt uiWidth = rpcBestCU->getWidth ( 0 );1379 UInt uiHeight = rpcBestCU->getHeight( 0 );1380 Pel* piSrc = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 );1381 UInt uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride();1382 m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );1383 #endif1384 1363 } 1385 1364 #endif … … 1747 1726 if( m_pcRdCost->getUseRenModel() ) 1748 1727 { 1749 #if HHI_FIX1750 1728 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( ); 1751 1729 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( ); … … 1753 1731 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride(); 1754 1732 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 1755 #else1756 UInt uiWidth = rpcTempCU->getWidth ( 0 );1757 UInt uiHeight = rpcTempCU->getHeight( 0 );1758 Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( );1759 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();1760 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );1761 #endif1762 1733 } 1763 1734 #endif … … 1851 1822 if( m_pcRdCost->getUseRenModel() ) 1852 1823 { //Reset 1853 #if HHI_FIX1854 1824 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth (); 1855 1825 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight (); … … 1857 1827 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride (); 1858 1828 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 1859 #else1860 UInt uiWidth = rpcTempCU->getWidth ( 0 );1861 UInt uiHeight = rpcTempCU->getHeight( 0 );1862 Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( );1863 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();1864 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );1865 #endif1866 1829 } 1867 1830 #endif … … 1927 1890 if( m_pcRdCost->getUseRenModel() ) 1928 1891 { 1929 #if HHI_FIX1930 1892 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( ); 1931 1893 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( ); … … 1933 1895 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride(); 1934 1896 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 1935 #else1936 UInt uiWidth = rpcTempCU->getWidth ( 0 );1937 UInt uiHeight = rpcTempCU->getHeight( 0 );1938 Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( );1939 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();1940 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );1941 #endif1942 1897 } 1943 1898 #endif … … 2046 2001 if( m_pcRdCost->getUseRenModel() ) 2047 2002 { 2048 #if HHI_FIX2049 2003 UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth (); 2050 2004 UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight (); … … 2052 2006 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride (); 2053 2007 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2054 #else2055 UInt uiWidth = rpcTempCU->getWidth ( 0 );2056 UInt uiHeight = rpcTempCU->getHeight( 0 );2057 Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr( );2058 UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride();2059 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );2060 #endif2061 2008 } 2062 2009 #endif … … 2557 2504 if( m_pcRdCost->getUseRenModel() && !bRecursiveCall) 2558 2505 { 2559 #if HHI_FIX2560 2506 UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth (); 2561 2507 UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight (); … … 2563 2509 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride (); 2564 2510 m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2565 #else2566 UInt uiWidth = m_ppcTempCU [uhDepth]->getWidth ( 0 );2567 UInt uiHeight = m_ppcTempCU [uhDepth]->getHeight( 0 );2568 Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( 0 );2569 UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();2570 m_pcRdCost->setRenModelData( m_ppcTempCU[uhDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight );2571 #endif2572 2511 } 2573 2512 #endif … … 2717 2656 if( !bSplit && bRecursiveCall && m_pcRdCost->getUseRenModel() ) 2718 2657 { 2719 #if HHI_FIX2720 2658 UInt uiWidth = m_ppcRecoYuvBest[uhDepth]->getWidth ( ); 2721 2659 UInt uiHeight = m_ppcRecoYuvBest[uhDepth]->getHeight ( ); … … 2723 2661 Pel* piSrc = m_ppcRecoYuvBest[uhDepth]->getLumaAddr( 0 ); 2724 2662 m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); 2725 #else2726 UInt uiWidth = rpcBestCU->getWidth ( 0 );2727 UInt uiHeight = rpcBestCU->getHeight( 0 );2728 Pel* piSrc = m_ppcRecoYuvBest[uhDepth]->getLumaAddr( 0 );2729 UInt uiSrcStride = m_ppcRecoYuvBest[uhDepth]->getStride();2730 m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );2731 #endif2732 2663 } 2733 2664 #endif -
trunk/source/Lib/TLibEncoder/TEncEntropy.h
r77 r100 77 77 78 78 #if VIDYO_VPS_INTEGRATION 79 80 #endif 81 79 virtual Void codeVPS ( TComVPS* pcVPS ) = 0; 80 #endif 81 82 82 #if HHI_MPI 83 83 virtual Void codeSPS ( TComSPS* pcSPS, Bool bIsDepth ) = 0; … … 234 234 public: 235 235 #if VIDYO_VPS_INTEGRATION 236 236 Void encodeVPS ( TComVPS* pcVPS); 237 237 #endif 238 238 // SPS -
trunk/source/Lib/TLibEncoder/TEncGOP.cpp
r77 r100 436 436 Bool bUseVSO = m_pcEncTop->getUseVSO(); 437 437 m_pcRdCost->setUseVSO( bUseVSO ); 438 #if SAIT_VSO_EST_A0033 439 m_pcRdCost->setUseEstimatedVSD( m_pcEncTop->getUseEstimatedVSD() ); 440 #endif 438 441 439 442 if ( bUseVSO ) … … 445 448 #endif 446 449 450 #if HHI_VSO_SPEEDUP_A033 451 #else 447 452 if ( iVSOMode == 4 ) 448 453 { … … 453 458 AOT(true); 454 459 } 460 #endif 461 462 #if SAIT_VSO_EST_A0033 463 m_pcRdCost->setVideoRecPicYuv( m_pcEncTop->getEncTop()->xGetPicYuvFromViewTemp( pcSlice->getViewId(), pcSlice->getPOC(), false, true ) ); 464 m_pcRdCost->setDepthPicYuv ( m_pcEncTop->getEncTop()->xGetPicYuvFromViewTemp( pcSlice->getViewId(), pcSlice->getPOC(), true, false ) ); 465 #endif 466 467 455 468 } 456 469 #endif … … 691 704 // init view component and predict virtual depth map 692 705 m_pcDepthMapGenerator->initViewComponent( pcPic ); 706 #if !QC_MULTI_DIS_CAN 693 707 m_pcDepthMapGenerator->predictDepthMap ( pcPic ); 708 #endif 694 709 #endif 695 710 #if HHI_INTER_VIEW_MOTION_PRED … … 758 773 #endif 759 774 #if DEPTH_MAP_GENERATION 775 #if !QC_MULTI_DIS_CAN 760 776 // update virtual depth map 761 777 m_pcDepthMapGenerator->updateDepthMap( pcPic ); 778 #endif 762 779 #endif 763 780 … … 2475 2492 if( hasModification ) 2476 2493 { 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2494 Int temporalRefIdx = 0; 2495 for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++ ) 2496 { 2497 if( tempListEntryL0[i] >= 0 ) 2498 { 2499 refPicListModification->setRefPicSetIdxL0( i, tempListEntryL0[i] ); 2500 } 2501 else 2502 { 2503 refPicListModification->setRefPicSetIdxL0( i, temporalRefIdx ); 2504 temporalRefIdx++; 2505 } 2506 } 2507 } 2491 2508 else 2492 2509 { … … 2520 2537 if( hasModification ) 2521 2538 { 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2539 Int temporalRefIdx = 0; 2540 for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++ ) 2541 { 2542 if( tempListEntryL1[i] >= 0 ) 2543 { 2544 refPicListModification->setRefPicSetIdxL1( i, tempListEntryL1[i] ); 2545 } 2546 else 2547 { 2548 refPicListModification->setRefPicSetIdxL1( i, temporalRefIdx ); 2549 temporalRefIdx++; 2550 } 2551 } 2535 2552 } 2536 2553 else -
trunk/source/Lib/TLibEncoder/TEncGOP.h
r56 r100 137 137 138 138 Void preLoopFilterPicAll ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits ); 139 #if HHI_VSO_SPEEDUP_A033 140 TEncTop* getEncTop() { return m_pcEncTop; } 141 #endif 139 142 140 143 TEncSlice* getSliceEncoder() { return m_pcSliceEncoder; } -
trunk/source/Lib/TLibEncoder/TEncSbac.cpp
r77 r100 106 106 , m_cDmmDataSCModel ( 1, 1, NUM_DMM_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 107 107 #endif 108 #if LGE_EDGE_INTRA 109 , m_cEdgeIntraSCModel ( 1, 1, NUM_EDGE_INTRA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 110 #if LGE_EDGE_INTRA_DELTA_DC 111 , m_cEdgeIntraDeltaDCSCModel ( 1, 1, NUM_EDGE_INTRA_DELTA_DC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 112 #endif 113 #endif 108 114 { 109 115 assert( m_numContextModels <= MAX_NUM_CTX_MOD ); … … 181 187 m_cDmmDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_DATA ); 182 188 #endif 189 #if LGE_EDGE_INTRA 190 m_cEdgeIntraSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA ); 191 #if LGE_EDGE_INTRA_DELTA_DC 192 m_cEdgeIntraDeltaDCSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA_DELTA_DC ); 193 #endif 194 #endif 183 195 184 196 // new structure … … 345 357 Void TEncSbac::codeVPS( TComVPS* pcVPS ) 346 358 { 347 359 assert (0); 348 360 return; 349 361 } … … 828 840 DTRACE_CABAC_T( "\n" ) 829 841 } 842 843 #if LGE_EDGE_INTRA 844 Void TEncSbac::xCodeEdgeIntraInfo( TComDataCU* pcCU, UInt uiPartIdx ) 845 { 846 UInt uiDepth = pcCU->getDepth( uiPartIdx ) + (pcCU->getPartitionSize( uiPartIdx ) == SIZE_NxN ? 1 : 0); 847 UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiPartIdx ); 848 UChar* pucSymbolList = pcCU->getEdgeCode( uiPartIdx ); 849 UChar ucEdgeNumber = pcCU->getEdgeNumber( uiPartIdx ); 850 Bool bLeft = pcCU->getEdgeLeftFirst( uiPartIdx ); 851 UChar ucStart = pcCU->getEdgeStartPos( uiPartIdx ); 852 UInt uiSymbol; 853 854 // 1. Top(0) or Left(1) 855 uiSymbol = (bLeft == false) ? 0 : 1; 856 m_pcBinIf->encodeBinEP( uiSymbol ); 857 858 // 2. Start position (lowest bit first) 859 uiSymbol = ucStart; 860 for( UInt ui = 6; ui > uiDepth; ui-- ) // 64(0)->6, 32(1)->5, 16(2)->4, 8(3)->3, 4(4)->2 861 { 862 m_pcBinIf->encodeBinEP( uiSymbol & 0x1 ); 863 uiSymbol >>= 1; 864 } 865 866 // 3. Number of edges 867 uiSymbol = ucEdgeNumber > 0 ? ucEdgeNumber - 1 : 0; 868 for( UInt ui = 7; ui > uiDepth; ui-- ) // 64(0)->7, 32(1)->6, 16(2)->5, 8(3)->4, 4(4)->3 869 { 870 m_pcBinIf->encodeBinEP( uiSymbol & 0x1 ); 871 uiSymbol >>= 1; 872 } 873 874 if(uiSymbol != 0) 875 { 876 printf(" ucEdgeNumber %d at depth %d\n",ucEdgeNumber, uiDepth); 877 assert(false); 878 } 879 880 // 4. Edges 881 for( Int iPtr2 = 0; iPtr2 < ucEdgeNumber; iPtr2++ ) 882 { 883 UInt uiReorderSymbol = pucSymbolList[iPtr2]; 884 885 //printf ("Ptr = %d, Symbol = %d\n", iPtr2, uiSymbol); 886 887 // Left-friendly direction (Top start) 888 // 0 ( 0deg) => 0 889 // 1 ( 45deg) => 10 890 // 2 ( -45deg) => 110 891 // 3 ( 90deg) => 1110 892 // 4 ( -90deg) => 11110 893 // 5 ( 135deg) => 111110 894 // 6 (-135deg) => 111111 895 // Right-friendly direction (Left start) 896 // 0 ( 0deg) => 0 897 // 2 ( -45deg) => 10 898 // 1 ( 45deg) => 110 899 // 4 ( -90deg) => 1110 900 // 3 ( 90deg) => 11110 901 // 6 (-135deg) => 111110 902 // 5 ( 135deg) => 111111 903 904 // refer to a paper "An efficient chain code with Huffman coding" 905 906 for( UInt ui = 0; ui < uiReorderSymbol; ui++ ) 907 { 908 m_pcBinIf->encodeBin( 1, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) ); 909 } 910 911 if( uiReorderSymbol != 6 ) 912 m_pcBinIf->encodeBin( 0, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) ); 913 } 914 } 915 #endif 916 830 917 Void TEncSbac::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) 831 918 { … … 835 922 if( pcCU->getSlice()->getSPS()->getUseDMM() && pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE ) 836 923 { 924 #if LGE_EDGE_INTRA 925 m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX, m_cDmmFlagSCModel.get(0, 0, 0) ); 926 #else 837 927 m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE, m_cDmmFlagSCModel.get(0, 0, 0) ); 838 } 928 #endif 929 } 930 #if LGE_EDGE_INTRA 931 if( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX ) 932 #else 839 933 if( uiDir >= NUM_INTRA_MODE ) 934 #endif 840 935 { 841 936 assert( pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE ); … … 870 965 } 871 966 else 967 #if LGE_EDGE_INTRA 968 if ( uiDir >= EDGE_INTRA_IDX) 969 { 970 m_pcBinIf->encodeBin( 0, m_cCUIntraPredSCModel.get( 0, 0, 0 ) ); 971 m_pcBinIf->encodeBinsEP( 63, 6 ); 972 xCodeEdgeIntraInfo( pcCU, uiAbsPartIdx ); 973 #if LGE_EDGE_INTRA_DELTA_DC 974 m_pcBinIf->encodeBin( (uiDir == EDGE_INTRA_DELTA_IDX), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) ); 975 if( uiDir == EDGE_INTRA_DELTA_IDX ) 976 { 977 Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx ); 978 Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx ); 979 980 xWriteExGolombLevel( UInt( abs( iDeltaDC0 ) ), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); 981 if ( iDeltaDC0 != 0 ) 982 { 983 UInt uiSign = iDeltaDC0 > 0 ? 0 : 1; 984 m_pcBinIf->encodeBinEP( uiSign ); 985 } 986 xWriteExGolombLevel( UInt( abs( iDeltaDC1 ) ), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); 987 if ( iDeltaDC1 != 0 ) 988 { 989 UInt uiSign = iDeltaDC1 > 0 ? 0 : 1; 990 m_pcBinIf->encodeBinEP( uiSign ); 991 } 992 } 993 #endif 994 } 995 else 996 #endif // LGE_EDGE_INTRA 872 997 { 873 998 #endif 874 999 #if !LOGI_INTRA_NAME_3MPM 875 1000 Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); 1001 #endif 1002 #if LGE_EDGE_INTRA 1003 Bool bCodeEdgeIntra = false; 1004 if( pcCU->getSlice()->getSPS()->isDepth() ) 1005 { 1006 UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0); 1007 if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE ) 1008 bCodeEdgeIntra = true; 1009 } 876 1010 #endif 877 1011 … … 932 1066 #if LOGI_INTRA_NAME_3MPM 933 1067 m_pcBinIf->encodeBinsEP( uiDir, 5 ); 1068 #if LGE_EDGE_INTRA 1069 if (bCodeEdgeIntra) 1070 if (uiDir == 31) m_pcBinIf->encodeBinsEP(0,1); 1071 #endif 934 1072 #else 935 1073 if ( uiDir < 31 ) … … 2270 2408 } 2271 2409 2272 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 2410 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC) 2273 2411 Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel ) 2274 2412 { -
trunk/source/Lib/TLibEncoder/TEncSbac.h
r77 r100 101 101 Void codeVPS ( TComVPS* pcVPS ); 102 102 #endif 103 103 104 104 #if HHI_MPI 105 105 Void codeSPS ( TComSPS* pcSPS, Bool bIsDepth ); … … 174 174 Void xCodeWedgePredTexDeltaInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 175 175 Void xCodeContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx ); 176 #endif 177 #if LGE_EDGE_INTRA 178 Void xCodeEdgeIntraInfo( TComDataCU* pcCU, UInt uiPartIdx ); 176 179 #endif 177 180 … … 307 310 ContextModel3DBuffer m_cDmmDataSCModel; 308 311 #endif 312 #if LGE_EDGE_INTRA 313 ContextModel3DBuffer m_cEdgeIntraSCModel; 314 #if LGE_EDGE_INTRA_DELTA_DC 315 ContextModel3DBuffer m_cEdgeIntraDeltaDCSCModel; 316 #endif 317 #endif 309 318 }; 310 319 -
trunk/source/Lib/TLibEncoder/TEncSearch.cpp
r81 r100 304 304 // motion cost 305 305 uiSad += m_pcRdCost->getCost( iSearchX, iSearchY ); 306 #if HHI_FIX 306 307 307 // regularization cost 308 308 if( m_pcRdCost->useMultiviewReg() ) … … 310 310 uiSad += m_pcRdCost->getMultiviewRegCost( iSearchX, iSearchY ); 311 311 } 312 #endif313 312 if( uiSad < rcStruct.uiBestSad ) 314 313 { … … 957 956 TComYuv* pcPredYuv, 958 957 TComYuv* pcResiYuv, 959 Dist& ruiDist ) 958 Dist& ruiDist 959 #if LG_ZEROINTRADEPTHRESI_M26039 960 ,Bool bZeroResi 961 #endif 962 ) 960 963 { 961 964 UInt uiLumaPredMode = pcCU ->getLumaIntraDir ( uiAbsPartIdx ); … … 989 992 pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail ); 990 993 994 #if LGE_EDGE_INTRA 995 if( uiLumaPredMode >= EDGE_INTRA_IDX ) 996 { 997 #if LGE_EDGE_INTRA_DELTA_DC 998 if( uiLumaPredMode == EDGE_INTRA_DELTA_IDX ) 999 xAssignEdgeIntraDeltaDCs( pcCU, uiAbsPartIdx, piOrg, uiStride, piPred, uiWidth, uiHeight ); 1000 #endif 1001 1002 predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride 1003 #if LGE_EDGE_INTRA_DELTA_DC 1004 , uiLumaPredMode == EDGE_INTRA_DELTA_IDX 1005 #endif 1006 ); 1007 } 1008 else 1009 #endif 1010 991 1011 //===== get prediction signal ===== 992 1012 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX … … 1020 1040 } 1021 1041 } 1042 #if LG_ZEROINTRADEPTHRESI_M26039 1043 if(bZeroResi) 1044 { 1045 Pel* pResi = piResi; 1046 1047 for( UInt uiY = 0; uiY < uiHeight; uiY++ ) 1048 { 1049 memset( pResi, 0, sizeof( Pel ) * uiWidth ); 1050 pResi += uiStride; 1051 } 1052 } 1053 #endif 1022 1054 1023 1055 //===== transform and quantization ===== … … 1311 1343 Bool bCheckFirst, 1312 1344 #endif 1313 Double& dRDCost ) 1345 Double& dRDCost 1346 #if LG_ZEROINTRADEPTHRESI_M26039 1347 ,Bool bZeroResi 1348 #endif 1349 ) 1314 1350 { 1315 1351 UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; … … 1326 1362 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 1327 1363 if( pcCU->getLumaIntraDir( uiAbsPartIdx ) >= NUM_INTRA_MODE ) 1364 { 1365 bCheckSplit = false; 1366 } 1367 #endif 1368 #if LGE_EDGE_INTRA 1369 if( pcCU->getLumaIntraDir( uiAbsPartIdx ) >= EDGE_INTRA_IDX ) 1328 1370 { 1329 1371 bCheckSplit = false; … … 1346 1388 //----- code luma block with given intra prediction mode and store Cbf----- 1347 1389 dSingleCost = 0.0; 1390 #if LG_ZEROINTRADEPTHRESI_M26039 1391 xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY, bZeroResi ); 1392 #else 1348 1393 xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY ); 1394 #endif 1349 1395 if( bCheckSplit ) 1350 1396 { … … 1808 1854 Int numModesForFullRD = g_aucIntraModeNumFast[ uiWidthBit ]; 1809 1855 1856 #if LGE_EDGE_INTRA 1857 Bool bTestEdgeIntra = false; 1858 if ( m_pcEncCfg->isDepthCoder() && uiWidth >= LGE_EDGE_INTRA_MIN_SIZE && uiWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiWidth == uiHeight ) 1859 { 1860 bTestEdgeIntra = true; 1861 1862 Bool bEdgeExist; 1863 1864 bEdgeExist = xEdgePartition( pcCU, uiPartOffset, pcCU->getPartitionSize(0) == SIZE_NxN ); 1865 1866 if( !bEdgeExist ) 1867 bTestEdgeIntra = false; 1868 } 1869 #endif 1870 1810 1871 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 1811 1872 Bool bTestDmm = ( m_pcEncCfg->getUseDMM() ); … … 1828 1889 1829 1890 predIntraLumaAng( pcCU->getPattern(), uiMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); 1830 1891 1831 1892 // use hadamard transform here 1832 Dist uiSad;1893 Dist uiSad; 1833 1894 #if HHI_VSO 1834 if ( m_pcRdCost->getUseVSO() ) 1835 { 1836 Bool bSad = !m_pcRdCost->getUseRenModel(); 1837 uiSad = m_pcRdCost->getDistVS(pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, bSad, 0 ); 1838 } 1839 else 1840 #endif 1841 { 1842 uiSad = (Dist) m_pcRdCost->calcHAD( piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight ); 1843 } 1844 1895 if ( m_pcRdCost->getUseVSO() ) 1896 { 1897 #if SAIT_VSO_EST_A0033 1898 if ( m_pcRdCost->getUseEstimatedVSD() ) 1899 { 1900 TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv(); 1901 TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv(); 1902 1903 uiSad = (Dist) ( m_pcRdCost->getDistPart( piPred, uiStride, piOrg, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset), pcVirRec->getStride(), uiWidth, uiHeight ) ); 1904 } 1905 else 1906 #endif 1907 { 1908 Bool bSad = !m_pcRdCost->getUseRenModel(); 1909 uiSad = m_pcRdCost->getDistVS(pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, bSad, 0 ); 1910 } 1911 1912 } 1913 else 1914 #endif 1915 { 1916 uiSad = (Dist) m_pcRdCost->calcHAD( piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight ); 1917 } 1918 1845 1919 UInt iModeBits = xModeBitsIntra( pcCU, uiMode, uiPU, uiPartOffset, uiDepth, uiInitTrDepth ); 1846 1920 1847 Double dLambda;1921 Double dLambda; 1848 1922 #if HHI_VSO 1849 if ( m_pcRdCost->getUseLambdaScaleVSO() ) 1850 { 1851 dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : m_pcRdCost->getSqrtLambdaVSO(); 1852 //GT: Sad is SSE for VSO4 1853 } 1854 else 1855 { 1923 if ( m_pcRdCost->getUseLambdaScaleVSO() ) 1924 { 1925 dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : m_pcRdCost->getSqrtLambdaVSO(); 1926 //GT: Sad is SSE for VSO4 1927 } 1928 else 1929 { 1930 dLambda = m_pcRdCost->getSqrtLambda(); 1931 } 1932 #else 1856 1933 dLambda = m_pcRdCost->getSqrtLambda(); 1857 } 1858 #else 1859 dLambda = m_pcRdCost->getSqrtLambda(); 1860 #endif 1861 1862 Double cost = (Double)uiSad + (Double)iModeBits * dLambda; 1863 1934 #endif 1935 1936 Double cost = (Double)uiSad + (Double)iModeBits * dLambda; 1937 1864 1938 CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList ); 1865 1939 1866 1940 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 1867 1941 if( bTestDmm ) bTestDmm = uiSad ? true : false; 1942 #endif 1943 #if LGE_EDGE_INTRA 1944 if ( bTestEdgeIntra ) bTestEdgeIntra = uiSad ? true : false; 1868 1945 #endif 1869 1946 } … … 1974 2051 } 1975 2052 #endif 2053 #if LGE_EDGE_INTRA 2054 if( bTestEdgeIntra ) 2055 { 2056 uiRdModeList[ numModesForFullRD++ ] = EDGE_INTRA_IDX; 2057 #if LGE_EDGE_INTRA_DELTA_DC 2058 uiRdModeList[ numModesForFullRD++ ] = EDGE_INTRA_DELTA_IDX; 2059 #endif 2060 } 2061 #endif 1976 2062 1977 2063 //===== check modes (using r-d costs) ===== … … 1987 2073 for( UInt uiMode = 0; uiMode < numModesForFullRD; uiMode++ ) 1988 2074 { 2075 #if LG_ZEROINTRADEPTHRESI_M26039 2076 Bool bAllowZeroResi = pcCU->getSlice()->getIsDepth() && (pcCU->getSlice()->getPOC()%pcCU->getPic()->getIntraPeriod());// && (uiMode < NUM_INTRA_MODE); 2077 for(UInt uiCnt = 0; uiCnt < (bAllowZeroResi ? 2 : 1); uiCnt++) 2078 { 2079 Bool bZeroResi = uiCnt ? true : false; 2080 #endif 1989 2081 // set luma prediction mode 1990 2082 UInt uiOrgMode = uiRdModeList[uiMode]; 1991 2083 1992 2084 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 1993 if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight ) ) 2085 if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight ) 2086 #if LGE_EDGE_INTRA 2087 && uiOrgMode < EDGE_INTRA_IDX 2088 #endif 2089 ) 1994 2090 { 1995 2091 continue; … … 2020 2116 2021 2117 #if HHI_RQT_INTRA_SPEEDUP 2118 #if LG_ZEROINTRADEPTHRESI_M26039 2119 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost, bZeroResi ); 2120 #else 2022 2121 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost ); 2122 #endif 2023 2123 #else 2024 2124 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost ); … … 2052 2152 dSecondBestPUCost = dPUCost; 2053 2153 } 2154 #endif 2155 #if LG_ZEROINTRADEPTHRESI_M26039 2156 } 2054 2157 #endif 2055 2158 } // Mode loop … … 2579 2682 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx ); 2580 2683 #if LG_RESTRICTEDRESPRED_M24766 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2684 Int iAddResiShift; 2685 UInt uiPartAddr; 2686 Int iRoiWidth, iRoiHeight; 2687 2688 pcCU->getPartIndexAndSize( iPUIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 2689 iAddResiShift = pcCU->getResiPredMode(uiPartAddr); 2690 iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1 - iAddResiShift : -1); 2691 2692 if( pcCU->getResPredFlag( 0 )) 2693 { // subtract residual prediction from original in motion search 2694 if(iLastAddResiShift != iAddResiShift) 2695 { 2696 //add subtracted residual last time 2697 if(iLastAddResiShift >= 0) 2698 { 2699 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift; 2700 pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 2701 } 2702 //subtract residual 2703 if(iAddResiShift >= 0) 2704 { 2705 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift; 2706 pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true ); 2707 } 2708 iLastAddResiShift = iAddResiShift; 2709 } 2710 } 2608 2711 #endif 2609 2712 xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() ); … … 2631 2734 if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0) 2632 2735 { 2633 2634 2736 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift; 2737 pcYuvOrg->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 2635 2738 } 2636 2739 #endif … … 2755 2858 UInt uiBitsTempL0[MAX_NUM_REF]; 2756 2859 #if LG_RESTRICTEDRESPRED_M24766 2757 2860 Int iPUResiPredShift[4] = {0, 0, 0, 0}; 2758 2861 #endif 2759 2862 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); … … 2773 2876 #endif 2774 2877 #if LG_RESTRICTEDRESPRED_M24766 2775 2878 Bool bLastResiFlag = false; 2776 2879 #endif 2777 2880 // Uni-directional prediction … … 2783 2886 { 2784 2887 #if LG_RESTRICTEDRESPRED_M24766 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2888 if( pcCU->getResPredFlag( 0 )) 2889 { 2890 if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp)) 2891 { // subtract residual prediction from original in motion search 2892 if(!bLastResiFlag) 2893 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true ); 2894 bLastResiFlag = true; 2895 } 2896 else 2897 { 2898 if(bLastResiFlag) 2899 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 2900 bLastResiFlag = false; 2901 } 2902 } 2800 2903 #endif 2801 2904 uiBitsTemp = uiMbBits[iRefList]; … … 2963 3066 } 2964 3067 #if LG_RESTRICTEDRESPRED_M24766 2965 2966 2967 2968 3068 if( pcCU->getResPredFlag( 0 ) && bLastResiFlag) 3069 { // subtract residual prediction from original in motion search 3070 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 3071 } 2969 3072 #endif 2970 3073 // Bi-directional prediction … … 2972 3075 { 2973 3076 #if LG_RESTRICTEDRESPRED_M24766 2974 3077 Int iLastAddResiShift = -1000; 2975 3078 #endif 2976 3079 cMvBi[0] = cMv[0]; cMvBi[1] = cMv[1]; … … 3077 3180 #endif 3078 3181 #if LG_RESTRICTEDRESPRED_M24766 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3182 Int iAddResiShift = -1, iPredFrom = 0; 3183 Int iBestRefIdx = pcCU->getCUMvField(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0)->getRefIdx(uiPartAddr); 3184 3185 iPredFrom = iBestRefIdx >= 0 ? 3 : 1; 3186 if(iBestRefIdx >= 0 && pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0, iBestRefIdx)) 3187 iAddResiShift++; 3188 if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp)) 3189 iAddResiShift++; 3190 iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || iPredFrom != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1); 3191 3192 if( pcCU->getResPredFlag( 0 ) ) 3193 { 3194 if(iLastAddResiShift != iAddResiShift) 3195 { 3196 //add substracted residual last time 3197 if(iLastAddResiShift >= 0 ) 3198 { 3199 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift; 3200 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 3201 } 3202 //substract residual 3203 if(iAddResiShift >= 0) 3204 { 3205 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift; 3206 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true ); 3207 } 3208 iLastAddResiShift = iAddResiShift; 3209 } 3210 } 3108 3211 #endif 3109 3212 // call ME … … 3162 3265 } // for loop-iter 3163 3266 #if LG_RESTRICTEDRESPRED_M24766 3164 3165 3166 3167 3168 3267 if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0) 3268 { 3269 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift; 3270 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 3271 } 3169 3272 #endif 3170 3273 } // if (B_SLICE) … … 3375 3478 { 3376 3479 #if LG_RESTRICTEDRESPRED_M24766 3377 3378 3379 3380 3381 3382 3383 3480 Int iAddResiShift = pcCU->getResiPredMode(uiPartAddr); 3481 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = \ 3482 (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3)? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1); 3483 if(pcCU->getResPredFlag(0) && iAddResiShift >= 0) 3484 { 3485 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true); 3486 } 3384 3487 #endif 3385 3488 xGetInterPredictionError( pcCU, pcOrgYuv, iPartIdx, uiMEError, m_pcEncCfg->getUseHADME() ); 3386 3489 uiMECost = uiMEError + m_pcRdCost->getCost( uiMEBits ); 3387 3490 #if LG_RESTRICTEDRESPRED_M24766 3388 3389 3390 3391 3491 if(pcCU->getResPredFlag(0) && iAddResiShift >= 0) 3492 { 3493 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 3494 } 3392 3495 #endif 3393 3496 } … … 3871 3974 else 3872 3975 { 3873 #if HHI_FIX3874 3976 rcMv = ( m_pcRdCost->useMultiviewReg() ? m_pcRdCost->getMultiviewOrgMvPred() : *pcMvPred ); 3875 #else3876 rcMv = *pcMvPred;3877 #endif3878 3977 xPatternSearchFast ( pcCU, pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost ); 3879 3978 } … … 3977 4076 uiSad += m_pcRdCost->getCost( x, y ); 3978 4077 3979 #if HHI_FIX3980 4078 // regularization cost 3981 4079 if( m_pcRdCost->useMultiviewReg() ) … … 3983 4081 uiSad += m_pcRdCost->getMultiviewRegCost( x, y ); 3984 4082 } 3985 #endif3986 4083 3987 4084 if ( uiSad < uiSadBest ) … … 4281 4378 { 4282 4379 #if LG_RESTRICTEDRESPRED_M24766 4283 4284 4380 pcCU->getPUResiPredShift(iPUResiPredShift, 0); 4381 rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd, uiWidth, uiHeight ); 4285 4382 #else 4286 4383 rpcYuvRec->add( rpcYuvResPrd, uiWidth, uiHeight ); … … 4294 4391 { 4295 4392 uiDistortion = m_pcRdCost->getDistVS( pcCU, 0, rpcYuvRec->getLumaAddr(), rpcYuvRec->getStride(), pcYuvOrg->getLumaAddr(), pcYuvOrg->getStride(), uiWidth, uiHeight , false, 0 ); 4296 4393 } 4297 4394 else 4298 4395 { … … 4349 4446 pcCU->setTrIdxSubParts( 0, 0, pcCU->getDepth(0) ); 4350 4447 4448 4351 4449 #if HHI_VSO // necessary? 4352 4450 // set Model 4451 #if SAIT_VSO_EST_A0033 4452 if( !m_pcRdCost->getUseEstimatedVSD()&& m_pcRdCost->getUseRenModel() ) 4453 #else 4353 4454 if( m_pcRdCost->getUseRenModel() ) 4455 #endif 4354 4456 { 4355 4457 Pel* piSrc = rpcYuvRec->getLumaAddr(); … … 4395 4497 { 4396 4498 #if LG_RESTRICTEDRESPRED_M24766 4397 4398 4499 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0; 4500 rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), pcYuvOrg, pcYuvPred, 0, uiWidth ); 4399 4501 #else 4400 4502 rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth ); … … 4405 4507 { 4406 4508 #if LG_RESTRICTEDRESPRED_M24766 4407 4408 4509 pcCU->getPUResiPredShift(iPUResiPredShift, 0); 4510 rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResi, rpcYuvResPrd, 0, uiWidth ); 4409 4511 #else 4410 4512 rpcYuvResi->subtract( rpcYuvResi, rpcYuvResPrd, 0, uiWidth ); … … 4579 4681 } 4580 4682 4683 4581 4684 #if HHI_VSO 4582 // GT: reset Model, only fordQP necessary?? 4685 #if SAIT_VSO_EST_A0033 4686 if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() ) 4687 #else 4583 4688 if( m_pcRdCost->getUseRenModel() ) 4689 #endif 4584 4690 { 4585 4691 Pel* piSrc = pcYuvOrg->getLumaAddr(); … … 4624 4730 pcYuvPred->copyToPartYuv( rpcYuvRec, 0 ); 4625 4731 #if LG_RESTRICTEDRESPRED_M24766 4626 4627 4628 4732 pcCU->getPUResiPredShift(iPUResiPredShift, 0); 4733 rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd, uiWidth, uiHeight ); 4734 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0; 4629 4735 rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResiBest, uiWidth, uiHeight ); 4630 4736 #else … … 4685 4791 4686 4792 // set Model 4793 4687 4794 #if HHI_VSO // necessary?? 4795 #if SAIT_VSO_EST_A0033 4796 if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() ) 4797 #else 4688 4798 if( m_pcRdCost->getUseRenModel() ) 4799 #endif 4689 4800 { 4690 4801 Pel* piSrc = rpcYuvRec->getLumaAddr(); … … 4693 4804 } 4694 4805 #endif 4695 4696 4806 } 4697 4807 … … 4869 4979 if ( m_pcRdCost->getUseVSO() ) 4870 4980 { 4871 uiDistY = m_pcRdCost->getDistVS ( pcCU, uiAbsPartIdx, pcPred->getLumaAddr( uiAbsPartIdx ), pcPred->getStride(), pcOrg->getLumaAddr( uiAbsPartIdx), pcOrg->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false, 0 ); // initialized with zero residual distortion 4981 #if SAIT_VSO_EST_A0033 4982 if( m_pcRdCost->getUseEstimatedVSD() ) 4983 { 4984 TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv(); 4985 TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv(); 4986 uiDistY = m_pcRdCost->getDistPart( m_pTempPel, 1<< uiLog2TrSize, pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(), pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPartIdx), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPartIdx), pcVirRec->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize ); 4987 } 4988 else 4989 #endif 4990 { 4991 uiDistY = m_pcRdCost->getDistVS ( pcCU, uiAbsPartIdx, pcPred->getLumaAddr( uiAbsPartIdx ), pcPred->getStride(), pcOrg->getLumaAddr( uiAbsPartIdx), pcOrg->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false, 0 ); // initialized with zero residual distortion 4992 } 4872 4993 } 4873 4994 else … … 4880 5001 #endif 4881 5002 } 4882 4883 5003 4884 5004 if ( puiZeroDist ) … … 4909 5029 if ( m_pcRdCost->getUseVSO() ) 4910 5030 { 4911 static int iCount = 1; 4912 iCount++; 4913 m_cYuvRecTemp.addClipPartLuma( &m_pcQTTempTComYuv[uiQTTempAccessLayer], pcPred, uiAbsPartIdx, 1<< uiLog2TrSize ); 4914 uiNonzeroDistY = m_pcRdCost->getDistVS( pcCU, uiAbsPartIdx, m_cYuvRecTemp.getLumaAddr(uiAbsPartIdx), m_cYuvRecTemp.getStride(), 4915 pcOrg->getLumaAddr( uiAbsPartIdx ), pcOrg->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false, 0 ); 5031 #if SAIT_VSO_EST_A0033 5032 if ( m_pcRdCost->getUseEstimatedVSD() ) 5033 { 5034 TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv(); 5035 TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv(); 5036 uiNonzeroDistY = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( uiAbsPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(), pcResi->getLumaAddr( uiAbsPartIdx ), pcResi->getStride(), pcVirRec->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiAbsPartIdx ), pcVirOrg->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiAbsPartIdx ), pcVirRec->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize ); 5037 } 5038 else 5039 #endif 5040 { 5041 m_cYuvRecTemp.addClipPartLuma( &m_pcQTTempTComYuv[uiQTTempAccessLayer], pcPred, uiAbsPartIdx, 1<< uiLog2TrSize ); 5042 uiNonzeroDistY = m_pcRdCost->getDistVS( pcCU, uiAbsPartIdx, m_cYuvRecTemp.getLumaAddr(uiAbsPartIdx), m_cYuvRecTemp.getStride(), 5043 pcOrg->getLumaAddr( uiAbsPartIdx ), pcOrg->getStride(), 1<< uiLog2TrSize, 1<< uiLog2TrSize, false, 0 ); 5044 } 4916 5045 } 4917 5046 else … … 5307 5436 } 5308 5437 5438 5309 5439 #if HHI_VSO 5440 #if SAIT_VSO_EST_A0033 5441 if( m_pcRdCost->getUseRenModel() && !m_pcRdCost->getUseEstimatedVSD() ) 5442 #else 5310 5443 if ( m_pcRdCost->getUseRenModel() ) //Only done if not split ( see return above ) 5444 #endif 5311 5445 { 5312 5446 UInt uiWidth = 1<< uiLog2TrSize; … … 5977 6111 5978 6112 assignWedgeDCs2Pred( pcWedgelet, piPredic, uiStride, iTestDC1, iTestDC2 ); 5979 5980 Dist uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, 0 ); 6113 6114 Dist uiActDist = RDO_DIST_MAX; 6115 #if SAIT_VSO_EST_A0033 6116 if ( m_pcRdCost->getUseEstimatedVSD() ) 6117 { 6118 TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv(); 6119 TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv(); 6120 uiActDist = m_pcRdCost->getDistPart( piPredic, uiStride, piOrig, uiStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight ); 6121 } 6122 else 6123 #else 6124 { 6125 uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, 0 ); 6126 } 6127 #endif 6128 5981 6129 if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 5982 6130 { … … 6078 6226 if( m_pcRdCost->getUseVSO() ) 6079 6227 { 6080 uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 ); 6228 #if SAIT_VSO_EST_A0033 6229 if ( m_pcRdCost->getUseEstimatedVSD() ) 6230 { 6231 TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv(); 6232 TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv(); 6233 uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight ); 6234 } 6235 else 6236 #endif 6237 { 6238 uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 ); 6239 } 6081 6240 } 6082 6241 else … … 6133 6292 if( m_pcRdCost->getUseVSO() ) 6134 6293 { 6135 uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 ); 6294 #if SAIT_VSO_EST_A0033 6295 if ( m_pcRdCost->getUseEstimatedVSD() ) 6296 { 6297 TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv(); 6298 TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv(); 6299 uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPtIdx), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiAbsPtIdx), pcVirRec->getStride(), uiWidth, uiHeight ); 6300 } 6301 else 6302 #endif 6303 { 6304 uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 ); 6305 } 6136 6306 } 6137 6307 else … … 6207 6377 } 6208 6378 #endif 6379 6380 #if LGE_EDGE_INTRA 6381 Bool TEncSearch::xCheckTerminatedEdge( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight ) 6382 { 6383 if( (iY % 2) == 0 ) // vertical edge 6384 { 6385 Bool bTopConnected = false; 6386 Bool bBottomConnected = false; 6387 6388 if( iY != 0 ) 6389 { 6390 if( pbEdge[ iX + (iY - 2) * 2 * iWidth ] ) 6391 bTopConnected = true; 6392 if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] ) 6393 bTopConnected = true; 6394 if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] ) 6395 bTopConnected = true; 6396 } 6397 else 6398 { 6399 bTopConnected = true; 6400 } 6401 6402 6403 if( iY != 2 * iHeight - 2 ) 6404 { 6405 if( pbEdge[ iX + (iY + 2) * 2 * iWidth ] ) 6406 bBottomConnected = true; 6407 if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] ) 6408 bBottomConnected = true; 6409 if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] ) 6410 bBottomConnected = true; 6411 } 6412 else 6413 { 6414 bBottomConnected = true; 6415 } 6416 6417 6418 if( bTopConnected && bBottomConnected ) 6419 { 6420 return true; 6421 } 6422 else 6423 { 6424 return false; 6425 } 6426 } 6427 else 6428 { 6429 Bool bLeftConnected = false; 6430 Bool bRightConnected = false; 6431 6432 if( iX != 0 ) 6433 { 6434 if( pbEdge[ (iX - 2) + iY * 2 * iWidth ] ) 6435 bLeftConnected = true; 6436 if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] ) 6437 bLeftConnected = true; 6438 if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] ) 6439 bLeftConnected = true; 6440 } 6441 else 6442 { 6443 bLeftConnected = true; 6444 } 6445 6446 if( iX != 2 * iWidth - 2 ) 6447 { 6448 if( pbEdge[ (iX + 2) + iY * 2 * iWidth ] ) 6449 bRightConnected = true; 6450 if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] ) 6451 bRightConnected = true; 6452 if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] ) 6453 bRightConnected = true; 6454 } 6455 else 6456 { 6457 bRightConnected = true; 6458 } 6459 6460 6461 if( bLeftConnected && bRightConnected ) 6462 { 6463 return true; 6464 } 6465 else 6466 { 6467 return false; 6468 } 6469 } 6470 } 6471 6472 #if LGE_EDGE_INTRA_PIXEL_DIFFERENCE 6473 Bool TEncSearch::xEdgePartition( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 ) 6474 { 6475 Pel* pcOrgY = pcCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr()); 6476 UInt uiStride = pcCU->getPic()->getPicYuvOrg()->getStride(); 6477 Int iWidth = pcCU->getWidth(uiPartIdx) >> (bPU4x4 ? 1 : 0); 6478 Int iHeight = pcCU->getHeight(uiPartIdx) >> (bPU4x4 ? 1 : 0); 6479 Bool* pbEdge = (Bool*) xMalloc( Bool, iWidth * iHeight * 4 ); 6480 6481 { 6482 UInt uiOffsetX = 0; 6483 UInt uiOffsetY = 0; 6484 UInt uiAbsPartIdx = pcCU->getZorderIdxInCU() + uiPartIdx; 6485 6486 uiOffsetX = (uiAbsPartIdx & 0x1) | 6487 ((uiAbsPartIdx & 0x4) >> 1) | 6488 ((uiAbsPartIdx & 0x10) >> 2) | 6489 ((uiAbsPartIdx & 0x40) >> 3); 6490 uiOffsetY = ((uiAbsPartIdx & 0x2) >> 1) | 6491 ((uiAbsPartIdx & 0x8) >> 2) | 6492 ((uiAbsPartIdx & 0x20) >> 3) | 6493 ((uiAbsPartIdx & 0x80) >> 4); 6494 uiOffsetX *= 4; 6495 uiOffsetY *= 4; 6496 pcOrgY += (uiOffsetX + uiOffsetY * uiStride); 6497 6498 } 6499 6500 Short* psDiffX = new Short[ iWidth * iHeight ]; 6501 Short* psDiffY = new Short[ iWidth * iHeight ]; 6502 Bool* pbEdgeX = new Bool [ iWidth * iHeight ]; 6503 Bool* pbEdgeY = new Bool [ iWidth * iHeight ]; 6504 6505 // Find Horizontal Gradient & Edge Detection ((x+1, y) - (x,y)) 6506 for( Int y=0; y<iHeight; y++ ) 6507 { 6508 Short* psDiffXPtr = &psDiffX[ y * iHeight ]; 6509 Bool* pbEdgeXPtr = &pbEdgeX[ y * iHeight ]; 6510 for(Int x=0; x<iWidth-1; x++ ) 6511 { 6512 *psDiffXPtr = pcOrgY[ x+1 + y*uiStride ] - pcOrgY[ x + y*uiStride ]; 6513 if(*psDiffXPtr >= LGE_EDGE_INTRA_THRESHOLD || *psDiffXPtr <= (-1)*LGE_EDGE_INTRA_THRESHOLD) 6514 { 6515 *pbEdgeXPtr = true; 6516 } 6517 else 6518 { 6519 *pbEdgeXPtr = false; 6520 } 6521 6522 psDiffXPtr++; 6523 pbEdgeXPtr++; 6524 } 6525 } 6526 6527 // Find Vertical Gradient & Edge Detection((x,y+1) - (x,y)) 6528 for( Int y=0; y<iHeight-1; y++ ) 6529 { 6530 Short* psDiffYPtr = &psDiffY[ y * iHeight ]; 6531 Bool* pbEdgeYPtr = &pbEdgeY[ y * iHeight ]; 6532 for(Int x=0; x<iWidth; x++ ) 6533 { 6534 *psDiffYPtr = pcOrgY[ x + (y+1)*uiStride ] - pcOrgY [ x + y*uiStride ]; 6535 if(*psDiffYPtr >= LGE_EDGE_INTRA_THRESHOLD || *psDiffYPtr <= (-1)*LGE_EDGE_INTRA_THRESHOLD) 6536 { 6537 *pbEdgeYPtr = true; 6538 } 6539 else 6540 { 6541 *pbEdgeYPtr = false; 6542 } 6543 6544 psDiffYPtr++; 6545 pbEdgeYPtr++; 6546 } 6547 } 6548 6549 // Eliminate local maximum 6550 for( Int y=0; y<iHeight; y++ ) 6551 { 6552 Short* psDiffXPtr = &psDiffX[ y * iHeight ]; 6553 Bool* pbEdgeXPtr = &pbEdgeX[ y * iHeight ]; 6554 for( Int x=0; x<iWidth-1; x++ ) 6555 { 6556 UShort usAbs0=0, usAbs1=0, usAbs2=0; // 0 : left, 1 : current, 2 : right 6557 6558 if( x > 0 && *(pbEdgeXPtr-1) == true ) 6559 { 6560 if( *(psDiffXPtr-1) >= 0) 6561 { 6562 usAbs0 = *(psDiffXPtr-1); 6563 6564 } 6565 else 6566 { 6567 usAbs0 = (-1) * *(psDiffXPtr-1); 6568 } 6569 } 6570 if( *pbEdgeXPtr == true ) 6571 { 6572 if( *(psDiffXPtr) >= 0) 6573 { 6574 usAbs1 = *(psDiffXPtr); 6575 } 6576 else 6577 { 6578 usAbs1 = (-1) * *(psDiffXPtr); 6579 } 6580 } 6581 if( x < iWidth-2 && *(pbEdgeXPtr+1) == true ) 6582 { 6583 if( *(psDiffXPtr+1) >= 0) 6584 { 6585 usAbs2 = *(psDiffXPtr+1); 6586 //bSign2 = true; 6587 } 6588 else 6589 { 6590 usAbs2 = (-1) * *(psDiffXPtr+1); 6591 } 6592 } 6593 6594 if( x == 0 ) 6595 { 6596 if( usAbs1 < usAbs2 ) 6597 { 6598 *pbEdgeXPtr = false; 6599 } 6600 } 6601 else if( x == iWidth-2 ) 6602 { 6603 if( usAbs1 <= usAbs0 ) 6604 *pbEdgeXPtr = false; 6605 } 6606 else 6607 { 6608 if( usAbs2 > usAbs0 ) 6609 { 6610 if( usAbs1 < usAbs2 ) 6611 *pbEdgeXPtr = false; 6612 } 6613 else 6614 { 6615 if( usAbs1 <= usAbs0 ) 6616 *pbEdgeXPtr = false; 6617 } 6618 } 6619 6620 psDiffXPtr++; 6621 pbEdgeXPtr++; 6622 } 6623 } 6624 6625 for( Int y=0; y<iHeight-1; y++ ) 6626 { 6627 Short* psDiffYPtr = &psDiffY[ y * iWidth ]; 6628 Bool* pbEdgeYPtr = &pbEdgeY[ y * iWidth ]; 6629 for( Int x=0; x<iWidth; x++ ) 6630 { 6631 UShort usAbs0=0, usAbs1=0, usAbs2=0; // 0 : upper, 1 : current, 2 : bottom 6632 if( y > 0 && *(pbEdgeYPtr-iWidth) == true ) 6633 { 6634 if( *(psDiffYPtr-iWidth) >= 0) 6635 { 6636 usAbs0 = *(psDiffYPtr-iWidth); 6637 } 6638 else 6639 { 6640 usAbs0 = (-1) * *(psDiffYPtr-iWidth); 6641 } 6642 } 6643 if( *pbEdgeYPtr == true ) 6644 { 6645 if( *(psDiffYPtr) >= 0) 6646 { 6647 usAbs1 = *(psDiffYPtr); 6648 } 6649 else 6650 { 6651 usAbs1 = (-1) * *(psDiffYPtr); 6652 } 6653 } 6654 if( y < iHeight-2 && *(pbEdgeYPtr+iWidth) == true ) 6655 { 6656 if( *(psDiffYPtr+iWidth) >= 0) 6657 { 6658 usAbs2 = *(psDiffYPtr+iWidth); 6659 } 6660 else 6661 { 6662 usAbs2 = (-1) * *(psDiffYPtr+iWidth); 6663 } 6664 } 6665 6666 if( y == 0 ) 6667 { 6668 if( usAbs1 < usAbs2 ) 6669 *pbEdgeYPtr = false; 6670 } 6671 else if( y == iHeight-2 ) 6672 { 6673 if( usAbs1 <= usAbs0 ) 6674 *pbEdgeYPtr = false; 6675 } 6676 else 6677 { 6678 if( usAbs2 > usAbs0 ) 6679 { 6680 if( usAbs1 < usAbs2 ) 6681 *pbEdgeYPtr = false; 6682 } 6683 else 6684 { 6685 if( usAbs1 <= usAbs0 ) 6686 *pbEdgeYPtr = false; 6687 } 6688 } 6689 6690 psDiffYPtr++; 6691 pbEdgeYPtr++; 6692 } 6693 } 6694 6695 // Edge Merging 6696 for( Int i=0; i< 4 * iWidth * iHeight; i++ ) 6697 pbEdge[ i ] = false; 6698 /// Even Line (0,2,4,6,...) => Vertical Edge 6699 for( Int i=0; i<iHeight; i++) 6700 { 6701 for( Int j=0; j<iWidth-1; j++) 6702 { 6703 pbEdge[ (2 * j + 1) + (2 * i) * 2 * iWidth ] = pbEdgeX[ j + i * iHeight ]; 6704 } 6705 } 6706 /// Odd Line (1,3,5,7,...) => Horizontal Edge 6707 for( Int i=0; i<iHeight-1; i++) 6708 { 6709 for( Int j=0; j<iWidth; j++) 6710 { 6711 pbEdge[ (2 * j) + (2 * i + 1) * 2 * iWidth ] = pbEdgeY[ j + i * iHeight ]; 6712 } 6713 } 6714 6715 // Intersection Filling 6716 /// Vertical Edge between Horizontal Edges 6717 for( Int i = 1; i < 2 * iHeight - 3; i += 2) 6718 { 6719 for( Int j = 0; j < 2 * iWidth - 1; j += 2) 6720 { 6721 if( pbEdge[ j + i * 2 * iWidth ] ) 6722 { 6723 if( j != 0 && pbEdge[ (j - 2) + ((i + 2) * 2 * iWidth) ] ) 6724 { 6725 if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j - 1) + ((i + 3) * 2 * iWidth) ] ) 6726 pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] = true; 6727 } 6728 if( j != 2 * iWidth - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] ) 6729 { 6730 if( !pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 1) + ((i + 3) * 2 * iWidth) ] ) 6731 pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true; 6732 } 6733 } 6734 } 6735 } 6736 /// Horizontal Edge between Vertical Edges 6737 for( Int j = 1; j < 2 * iWidth - 3; j += 2) 6738 { 6739 for( Int i = 0; i < 2 * iHeight - 1; i += 2) 6740 { 6741 if( pbEdge[ j + i * 2 * iWidth ] ) 6742 { 6743 if( i != 0 && pbEdge[ (j + 2) + ((i - 2) * 2 * iWidth) ] ) 6744 { 6745 if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i - 1) * 2 * iWidth) ] ) 6746 pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] = true; 6747 } 6748 if( i != 2 * iHeight - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] ) 6749 { 6750 if( !pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i + 1) * 2 * iWidth) ] ) 6751 pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true; 6752 } 6753 } 6754 } 6755 } 6756 6757 // Static Pruning Unnecessary Edges 6758 /// Step1. Stack push the unconnected edges 6759 UShort* pusUnconnectedEdgeStack = new UShort[ 4 * iWidth * iHeight ]; // approximate size calculation 6760 Int iUnconnectedEdgeStackPtr = 0; 6761 //// Vertical Edges 6762 for( Int i = 0; i < 2 * iHeight - 1; i += 2 ) 6763 { 6764 for( Int j = 1; j < 2 * iWidth - 2; j += 2 ) 6765 { 6766 if( pbEdge[ j + i * 2 * iWidth ] ) 6767 { 6768 if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) ) 6769 { 6770 pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j); 6771 iUnconnectedEdgeStackPtr++; 6772 } 6773 } 6774 } 6775 } 6776 6777 //// Horizontal Edges 6778 for( Int i = 1; i < 2 * iHeight - 2; i += 2 ) 6779 { 6780 for( Int j = 0; j < 2 * iWidth - 1; j += 2 ) 6781 { 6782 if( pbEdge[ j + i * 2 * iWidth ] ) 6783 { 6784 if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) ) 6785 { 6786 pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j); 6787 iUnconnectedEdgeStackPtr++; 6788 } 6789 } 6790 } 6791 } 6792 6793 /// Step2. Remove the edges from the stack and push the new unconnected edges 6794 //// (This step may contain duplicated edges already in the stack) 6795 //// (But it doesn't cause any functional problems) 6796 while( iUnconnectedEdgeStackPtr != 0 ) 6797 { 6798 iUnconnectedEdgeStackPtr--; 6799 Int iX = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] & 0xff; 6800 Int iY = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] >> 8; 6801 6802 pbEdge[ iX + iY * 2 * iWidth ] = false; 6803 6804 if( iY % 2 == 1 && iX > 0 && pbEdge[ iX - 2 + iY * 2 * iWidth ] && 6805 !xCheckTerminatedEdge( pbEdge, iX - 2, iY, iWidth, iHeight ) ) // left 6806 { 6807 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX - 2); 6808 iUnconnectedEdgeStackPtr++; 6809 } 6810 if( iY % 2 == 1 && iX < 2 * iWidth - 2 && pbEdge[ iX + 2 + iY * 2 * iWidth ] && 6811 !xCheckTerminatedEdge( pbEdge, iX + 2, iY, iWidth, iHeight ) ) // right 6812 { 6813 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX + 2); 6814 iUnconnectedEdgeStackPtr++; 6815 } 6816 if( iY % 2 == 0 && iY > 0 && pbEdge[ iX + (iY - 2) * 2 * iWidth ] && 6817 !xCheckTerminatedEdge( pbEdge, iX, iY - 2, iWidth, iHeight ) ) // top 6818 { 6819 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 2) << 8) | (iX + 0); 6820 iUnconnectedEdgeStackPtr++; 6821 } 6822 if( iY % 2 == 0 && iY < 2 * iHeight - 2 && pbEdge[ iX + (iY + 2) * 2 * iWidth ] && 6823 !xCheckTerminatedEdge( pbEdge, iX, iY + 2, iWidth, iHeight ) ) // bottom 6824 { 6825 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 2) << 8) | (iX + 0); 6826 iUnconnectedEdgeStackPtr++; 6827 } 6828 if( iX > 0 && iY > 0 && pbEdge[ iX - 1 + (iY - 1) * 2 * iWidth ] && 6829 !xCheckTerminatedEdge( pbEdge, iX - 1, iY - 1, iWidth, iHeight ) ) // left-top 6830 { 6831 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX - 1); 6832 iUnconnectedEdgeStackPtr++; 6833 } 6834 if( iX < 2 * iWidth - 1 && iY > 0 && pbEdge[ iX + 1 + (iY - 1) * 2 * iWidth ] && 6835 !xCheckTerminatedEdge( pbEdge, iX + 1, iY - 1, iWidth, iHeight ) ) // right-top 6836 { 6837 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX + 1); 6838 iUnconnectedEdgeStackPtr++; 6839 } 6840 if( iX > 0 && iY < 2 * iHeight - 1 && pbEdge[ iX - 1 + (iY + 1) * 2 * iWidth ] && 6841 !xCheckTerminatedEdge( pbEdge, iX - 1, iY + 1, iWidth, iHeight ) ) // left-bottom 6842 { 6843 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX - 1); 6844 iUnconnectedEdgeStackPtr++; 6845 } 6846 if( iX < 2 * iWidth - 1 && iY < 2 * iHeight - 1 && pbEdge[ iX + 1 + (iY + 1) * 2 * iWidth ] && 6847 !xCheckTerminatedEdge( pbEdge, iX + 1, iY + 1, iWidth, iHeight ) ) // right-bottom 6848 { 6849 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX + 1); 6850 iUnconnectedEdgeStackPtr++; 6851 } 6852 } 6853 6854 6855 // Region Generation ( edge -> region ) 6856 Bool* pbRegion = pcCU->getEdgePartition( uiPartIdx ); 6857 Bool* pbVisit = new Bool[ iWidth * iHeight ]; 6858 6859 for( UInt ui = 0; ui < iWidth * iHeight; ui++ ) 6860 { 6861 pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next) 6862 pbVisit [ ui ] = false; 6863 } 6864 6865 Int* piStack = new Int[ iWidth * iHeight ]; 6866 6867 Int iPtr = 0; 6868 6869 piStack[iPtr++] = (0 << 8) | (0); 6870 pbRegion[ 0 ] = false; 6871 6872 while(iPtr > 0) 6873 { 6874 Int iTmp = piStack[--iPtr]; 6875 Int iX1, iY1; 6876 iX1 = iTmp & 0xff; 6877 iY1 = (iTmp >> 8) & 0xff; 6878 6879 pbVisit[ iX1 + iY1 * iWidth ] = true; 6880 6881 assert( iX1 >= 0 && iX1 < iWidth ); 6882 assert( iY1 >= 0 && iY1 < iHeight ); 6883 6884 if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] ) 6885 { 6886 piStack[iPtr++] = (iY1 << 8) | (iX1 - 1); 6887 pbRegion[ iX1 - 1 + iY1 * iWidth ] = false; 6888 } 6889 if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] ) 6890 { 6891 piStack[iPtr++] = (iY1 << 8) | (iX1 + 1); 6892 pbRegion[ iX1 + 1 + iY1 * iWidth ] = false; 6893 } 6894 if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] ) 6895 { 6896 piStack[iPtr++] = ((iY1 - 1) << 8) | iX1; 6897 pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false; 6898 } 6899 if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] ) 6900 { 6901 piStack[iPtr++] = ((iY1 + 1) << 8) | iX1; 6902 pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false; 6903 } 6904 } 6905 6906 /////////// 6907 iPtr = 0; 6908 for( Int i = 0; i < iWidth * iHeight; i++ ) 6909 pbVisit[ i ] = false; 6910 piStack[ iPtr++ ] = (0 << 8) | (0); // initial seed 6911 while( iPtr > 0 && iPtr < iWidth * iHeight ) 6912 { 6913 Int iX; 6914 Int iY; 6915 iPtr--; 6916 iX = piStack[ iPtr ] & 0xff; 6917 iY = piStack[ iPtr ] >> 8; 6918 pbVisit[ iY * iWidth + iX ] = true; 6919 6920 if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] ) 6921 { 6922 piStack[ iPtr++ ] = ((iY - 1) << 8) | iX; 6923 } 6924 if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] ) 6925 { 6926 piStack[ iPtr++ ] = ((iY + 1) << 8) | iX; 6927 } 6928 if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] ) 6929 { 6930 piStack[ iPtr++ ] = (iY << 8) | (iX - 1); 6931 } 6932 if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] ) 6933 { 6934 piStack[ iPtr++ ] = (iY << 8) | (iX + 1); 6935 } 6936 } 6937 assert( iPtr == 0 || iPtr == iWidth * iHeight ); 6938 6939 Bool bBipartition; 6940 if( iPtr == iWidth * iHeight ) 6941 { 6942 bBipartition = false; // single partition 6943 } 6944 else 6945 { 6946 for( Int i = 0; i < iWidth * iHeight; i++ ) 6947 { 6948 if( !pbVisit[ i ] ) 6949 { 6950 piStack[ iPtr++ ] = (( i / iWidth ) << 8) | ( i % iWidth ); 6951 pbVisit[ i ] = true; 6952 break; 6953 } 6954 } 6955 while( iPtr > 0 ) 6956 { 6957 Int iX; 6958 Int iY; 6959 iPtr--; 6960 iX = piStack[ iPtr ] & 0xff; 6961 iY = piStack[ iPtr ] >> 8; 6962 pbVisit[ iY * iWidth + iX ] = true; 6963 6964 if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] ) 6965 { 6966 piStack[ iPtr++ ] = ((iY - 1) << 8) | iX; 6967 } 6968 if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] ) 6969 { 6970 piStack[ iPtr++ ] = ((iY + 1) << 8) | iX; 6971 } 6972 if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] ) 6973 { 6974 piStack[ iPtr++ ] = (iY << 8) | (iX - 1); 6975 } 6976 if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] ) 6977 { 6978 piStack[ iPtr++ ] = (iY << 8) | (iX + 1); 6979 } 6980 } 6981 bBipartition = true; 6982 for( Int i = 0; i < iWidth * iHeight; i++ ) 6983 { 6984 if( !pbVisit[ i ] ) 6985 { 6986 bBipartition = false; 6987 break; 6988 } 6989 } 6990 } 6991 6992 xFree( pbEdge ); 6993 delete[] pbEdgeX; pbEdgeX = NULL; 6994 delete[] pbEdgeY; pbEdgeY = NULL; 6995 delete[] psDiffX; psDiffX = NULL; 6996 delete[] psDiffY; psDiffY = NULL; 6997 delete[] pusUnconnectedEdgeStack; pusUnconnectedEdgeStack = NULL; 6998 delete[] pbVisit; pbVisit = NULL; 6999 delete[] piStack; piStack = NULL; 7000 7001 Bool bCheckPossibleChain; 7002 7003 if( bBipartition ) 7004 bCheckPossibleChain = xConstructChainCode( pcCU, uiPartIdx, bPU4x4 ); 7005 else 7006 bCheckPossibleChain = false; 7007 7008 return bCheckPossibleChain; 7009 } 7010 7011 #endif 7012 7013 Bool TEncSearch::xConstructChainCode( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 ) 7014 { 7015 UInt uiWidth = pcCU->getWidth( uiPartIdx ) >> (bPU4x4 ? 1 : 0); 7016 UInt uiHeight = pcCU->getHeight( uiPartIdx ) >> (bPU4x4 ? 1 : 0); 7017 Bool* pbEdge = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 ); 7018 Bool* pbVisit = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 ); 7019 UInt uiMaxEdge = uiWidth * (LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 / 4); 7020 Bool* pbRegion = pcCU->getEdgePartition( uiPartIdx ); 7021 UChar* piEdgeCode = pcCU->getEdgeCode( uiPartIdx ); 7022 Bool bStartLeft = false; 7023 Bool bPossible = false; 7024 Bool bFinish = false; 7025 Int iStartPosition = -1; 7026 Int iPtr = 0; 7027 Int iDir = -1, iNextDir = -1; 7028 Int iArrow = -1, iNextArrow = -1; 7029 Int iX = -1, iY = -1; 7030 Int iDiffX = 0, iDiffY = 0; 7031 UChar iCode = 255; 7032 UInt uiWidth2 = uiWidth * 2; 7033 7034 for( Int i = 0; i < uiWidth * uiHeight * 4; i++ ) 7035 pbEdge[ i ] = false; 7036 7037 for( Int i = 0; i < uiHeight; i++ ) 7038 { 7039 for( Int j = 0; j < uiWidth - 1; j++ ) 7040 { 7041 if( pbRegion[ i * uiWidth + j ] != pbRegion[ i * uiWidth + j + 1 ] ) 7042 pbEdge[ i * uiWidth * 4 + j * 2 + 1 ] = true; 7043 } 7044 } 7045 7046 for( Int i = 0; i < uiHeight - 1; i++ ) 7047 { 7048 for( Int j = 0; j < uiWidth; j++ ) 7049 { 7050 if( pbRegion[ (i + 0) * uiWidth + j ] != pbRegion[ (i + 1) * uiWidth + j ] ) 7051 pbEdge[ (2 * i + 1) * 2 * uiWidth + j * 2 ] = true; 7052 } 7053 } 7054 7055 for( Int i = 1; i < uiWidth2 - 2; i+=2 ) 7056 { 7057 if(pbEdge[ i ]) 7058 { 7059 bPossible = true; 7060 bStartLeft = false; 7061 iStartPosition = iX = i; 7062 iY = 0; 7063 iDir = 3; 7064 iArrow = 3; 7065 break; 7066 } 7067 } 7068 7069 if( !bPossible ) 7070 { 7071 for( Int i = 1; i < uiWidth2 - 2; i+=2 ) 7072 { 7073 if(pbEdge[ i * uiWidth2 ]) 7074 { 7075 bPossible = true; 7076 bStartLeft = true; 7077 iX = 0; 7078 iStartPosition = iY = i; 7079 iDir = 1; 7080 iArrow = 1; 7081 break; 7082 } 7083 } 7084 } 7085 7086 if( bPossible ) 7087 { 7088 for( Int i = 0; i < 4 * uiWidth * uiHeight; i++ ) 7089 pbVisit[ i ] = false; 7090 7091 while( !bFinish ) 7092 { 7093 Bool bArrowSkip = false; 7094 pbVisit[ iX + iY * uiWidth2 ] = true; 7095 7096 switch( iDir ) 7097 { 7098 case 0: // left 7099 if( iX > 0 && !pbVisit[ (iX - 2) + iY * uiWidth2 ] && pbEdge[ (iX - 2) + iY * uiWidth2 ] ) // left 7100 { 7101 iDiffX = -2; 7102 iDiffY = 0; 7103 iNextDir = 0; 7104 iNextArrow = 0; 7105 } 7106 else if( iX > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // top 7107 { 7108 iDiffX = -1; 7109 iDiffY = -1; 7110 iNextDir = 2; 7111 iNextArrow = 4; 7112 } 7113 else if( iX > 0 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // bottom 7114 { 7115 iDiffX = -1; 7116 iDiffY = +1; 7117 iNextDir = 3; 7118 iNextArrow = iArrow; 7119 if( !(iPtr == 0 && iX == uiWidth2 - 2 && iY == uiHeight * 2 - 3) ) 7120 bArrowSkip = true; 7121 else 7122 iNextArrow = 3; 7123 } 7124 else if( iX == 0 ) 7125 { 7126 iDiffX = 0; 7127 iDiffY = 0; 7128 iNextDir = iDir; 7129 iNextArrow = iArrow; 7130 bFinish = true; 7131 continue; 7132 } 7133 else 7134 { 7135 iPtr = 0; // edge loop or unwanted case 7136 bFinish = true; 7137 //continue; 7138 assert(false); 7139 } 7140 break; 7141 case 1: // right 7142 if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 2) + iY * uiWidth2 ] && pbEdge[ (iX + 2) + iY * uiWidth2 ] ) // right 7143 { 7144 iDiffX = +2; 7145 iDiffY = 0; 7146 iNextDir = 1; 7147 iNextArrow = 1; 7148 } 7149 else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // top 7150 { 7151 iDiffX = +1; 7152 iDiffY = -1; 7153 iNextDir = 2; 7154 iNextArrow = iArrow; 7155 if( !(iPtr == 0 && iX == 0 && iY == 1) ) 7156 bArrowSkip = true; 7157 else 7158 iNextArrow = 2; 7159 } 7160 else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // bottom 7161 { 7162 iDiffX = +1; 7163 iDiffY = +1; 7164 iNextDir = 3; 7165 iNextArrow = 7; 7166 } 7167 else if( iX == uiWidth2 - 2 ) 7168 { 7169 iDiffX = 0; 7170 iDiffY = 0; 7171 iNextDir = iDir; 7172 iNextArrow = iArrow; 7173 bFinish = true; 7174 continue; 7175 } 7176 else 7177 { 7178 iPtr = 0; // edge loop or unwanted case 7179 bFinish = true; 7180 //continue; 7181 assert(false); 7182 } 7183 break; 7184 case 2: // top 7185 if( iY > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // left 7186 { 7187 iDiffX = -1; 7188 iDiffY = -1; 7189 iNextDir = 0; 7190 iNextArrow = iArrow; 7191 if( !(iPtr == 0 && iX == 1 && iY == uiHeight * 2 - 2) ) 7192 bArrowSkip = true; 7193 else 7194 iNextArrow = 0; 7195 } 7196 else if( iY > 0 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // right 7197 { 7198 iDiffX = +1; 7199 iDiffY = -1; 7200 iNextDir = 1; 7201 iNextArrow = 5; 7202 } 7203 else if( iY > 0 && !pbVisit[ iX + (iY - 2) * uiWidth2 ] && pbEdge[ iX + (iY - 2) * uiWidth2 ] ) // top 7204 { 7205 iDiffX = 0; 7206 iDiffY = -2; 7207 iNextDir = 2; 7208 iNextArrow = 2; 7209 } 7210 else if( iY == 0 ) 7211 { 7212 iDiffX = 0; 7213 iDiffY = 0; 7214 iNextDir = iDir; 7215 iNextArrow = iArrow; 7216 bFinish = true; 7217 continue; 7218 } 7219 else 7220 { 7221 iPtr = 0; // edge loop or unwanted case 7222 bFinish = true; 7223 //continue; 7224 assert(false); 7225 } 7226 break; 7227 case 3: // bottom 7228 if( iY < uiWidth2 - 2 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // left 7229 { 7230 iDiffX = -1; 7231 iDiffY = +1; 7232 iNextDir = 0; 7233 iNextArrow = 6; 7234 } 7235 else if( iY < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // right 7236 { 7237 iDiffX = +1; 7238 iDiffY = +1; 7239 iNextDir = 1; 7240 iNextArrow = iArrow; 7241 if( !(iPtr == 0 && iX == uiWidth * 2 - 3 && iY == 0) ) 7242 bArrowSkip = true; 7243 else 7244 iNextArrow = 1; 7245 } 7246 else if( iY < uiWidth2 - 2 && !pbVisit[ iX + (iY + 2) * uiWidth2 ] && pbEdge[ iX + (iY + 2) * uiWidth2 ] ) // bottom 7247 { 7248 iDiffX = 0; 7249 iDiffY = +2; 7250 iNextDir = 3; 7251 iNextArrow = 3; 7252 } 7253 else if( iY == uiWidth2 - 2 ) 7254 { 7255 iDiffX = 0; 7256 iDiffY = 0; 7257 iNextDir = iDir; 7258 iNextArrow = iArrow; 7259 bFinish = true; 7260 continue; 7261 } 7262 else 7263 { 7264 iPtr = 0; // edge loop or unwanted case 7265 bFinish = true; 7266 //continue; 7267 assert(false); 7268 } 7269 break; 7270 } 7271 7272 const UChar tableCode[8][8] = { { 0, -1, 4, 3, 2, 6, 1, 5 }, // iArrow(current direction), iNextArrow(next direction) 7273 { -1, 0, 3, 4, 5, 1, 6, 2 }, 7274 { 3, 4, 0, -1, 1, 2, 5, 6 }, 7275 { 4, 3, -1, 0, 6, 5, 2, 1 }, 7276 { 1, 6, 2, 5, 0, 4, 3, -1 }, 7277 { 5, 2, 1, 6, 3, 0, -1, 4 }, 7278 { 2, 5, 6, 1, 4, -1, 0, 3 }, 7279 { 6, 1, 5, 2, -1, 3, 4, 0 } }; 7280 7281 iCode = tableCode[iArrow][iNextArrow]; 7282 7283 if(iPtr >= uiMaxEdge) 7284 { 7285 iPtr = 0; // over the maximum number of edge 7286 bPossible = false; 7287 break; 7288 } 7289 7290 if( !bArrowSkip ) 7291 { 7292 piEdgeCode[iPtr++] = iCode; // first edge coding 7293 //printf("xEdgeCoding: (%d,%d)->(%d,%d) code %d\n",iX,iY, iX+iDiffX, iY+iDiffY, iCode); 7294 } 7295 7296 iX += iDiffX; 7297 iY += iDiffY; 7298 iDir = iNextDir; 7299 iArrow = iNextArrow; 7300 } 7301 } 7302 7303 pcCU->setEdgeLeftFirst( uiPartIdx, bStartLeft ); 7304 pcCU->setEdgeStartPos ( uiPartIdx, bStartLeft ? (iStartPosition - 1) >> 1 : (iStartPosition + 1) >> 1); 7305 pcCU->setEdgeNumber ( uiPartIdx, iPtr ); 7306 7307 xFree( pbEdge ); 7308 xFree( pbVisit ); 7309 7310 return (iPtr != 0); 7311 } 7312 7313 #if LGE_EDGE_INTRA_DELTA_DC 7314 Void TEncSearch::xAssignEdgeIntraDeltaDCs( TComDataCU* pcCU, 7315 UInt uiAbsPartIdx, 7316 Pel* piOrig, 7317 UInt uiStride, 7318 Pel* piPredic, 7319 UInt uiWidth, 7320 UInt uiHeight ) 7321 { 7322 Int iDC0 = 0; 7323 Int iDC1 = 0; 7324 Int iPredDC0 = 0; 7325 Int iPredDC1 = 0; 7326 Int iDeltaDC0 = 0; 7327 Int iDeltaDC1 = 0; 7328 7329 Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); 7330 7331 Int* piMask = pcCU->getPattern()->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); 7332 Int iMaskStride = ( uiWidth<<1 ) + 1; 7333 7334 // DC Calculation 7335 { 7336 UInt uiSum0 = 0; 7337 UInt uiSum1 = 0; 7338 UInt uiCount0 = 0; 7339 UInt uiCount1 = 0; 7340 7341 Pel* piTemp = piOrig; 7342 for( UInt ui = 0; ui < uiHeight; ui++ ) 7343 { 7344 for( UInt uii = 0; uii < uiWidth; uii++ ) 7345 { 7346 if( pbRegion[ ui * uiWidth + uii ] == false ) 7347 { 7348 uiSum0 += (piTemp[ uii ]); 7349 uiCount0++; 7350 } 7351 else 7352 { 7353 uiSum1 += (piTemp[ uii ]); 7354 uiCount1++; 7355 } 7356 } 7357 piTemp += uiStride; 7358 } 7359 if( uiCount0 == 0 ) 7360 assert(false); 7361 if( uiCount1 == 0 ) 7362 assert(false); 7363 iDC0 = uiSum0 / uiCount0; // TODO : integer op. 7364 iDC1 = uiSum1 / uiCount1; 7365 } 7366 7367 // PredDC Calculation 7368 { 7369 UInt uiSum0 = 0; 7370 UInt uiSum1 = 0; 7371 UInt uiCount0 = 0; 7372 UInt uiCount1 = 0; 7373 7374 for( UInt ui = 0; ui < uiWidth; ui++ ) 7375 { 7376 if( pbRegion[ ui ] == false ) 7377 { 7378 uiSum0 += (piMask[ ui + 1 ]); 7379 uiCount0++; 7380 } 7381 else 7382 { 7383 uiSum1 += (piMask[ ui + 1 ]); 7384 uiCount1++; 7385 } 7386 } 7387 for( UInt ui = 0; ui < uiHeight; ui++ ) // (0,0) recount (to avoid division) 7388 { 7389 if( pbRegion[ ui * uiWidth ] == false ) 7390 { 7391 uiSum0 += (piMask[ (ui + 1) * iMaskStride ]); 7392 uiCount0++; 7393 } 7394 else 7395 { 7396 uiSum1 += (piMask[ (ui + 1) * iMaskStride ]); 7397 uiCount1++; 7398 } 7399 } 7400 if( uiCount0 == 0 ) 7401 assert(false); 7402 if( uiCount1 == 0 ) 7403 assert(false); 7404 iPredDC0 = uiSum0 / uiCount0; // TODO : integer op. 7405 iPredDC1 = uiSum1 / uiCount1; 7406 } 7407 7408 iDeltaDC0 = iDC0 - iPredDC0; 7409 iDeltaDC1 = iDC1 - iPredDC1; 7410 7411 #if HHI_VSO 7412 if( m_pcRdCost->getUseVSO() ) 7413 { 7414 Int iFullDeltaDC0 = iDeltaDC0; 7415 Int iFullDeltaDC1 = iDeltaDC1; 7416 7417 xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC0 ); 7418 xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC1 ); 7419 7420 Dist uiBestDist = RDO_DIST_MAX; 7421 UInt uiBestQStepDC0 = 0; 7422 UInt uiBestQStepDC1 = 0; 7423 7424 UInt uiDeltaDC0Max = abs(iFullDeltaDC0); 7425 UInt uiDeltaDC1Max = abs(iFullDeltaDC1); 7426 7427 //VSO Level delta DC check range extension 7428 uiDeltaDC0Max += (uiDeltaDC0Max>>1); 7429 uiDeltaDC1Max += (uiDeltaDC1Max>>1); 7430 7431 for( UInt uiQStepDC0 = 1; uiQStepDC0 <= uiDeltaDC0Max; uiQStepDC0++ ) 7432 { 7433 Int iLevelDeltaDC0 = (Int)(uiQStepDC0) * (Int)(( iFullDeltaDC0 < 0 ) ? -1 : 1); 7434 xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC0 ); 7435 7436 Int iTestDC0 = Clip( iPredDC0 + iLevelDeltaDC0 ); 7437 for( UInt uiQStepDC1 = 1; uiQStepDC1 <= uiDeltaDC1Max; uiQStepDC1++ ) 7438 { 7439 Int iLevelDeltaDC1 = (Int)(uiQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1); 7440 xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC1 ); 7441 7442 Int iTestDC1 = Clip( iPredDC1 + iLevelDeltaDC1 ); 7443 7444 Pel* piTemp = piPredic; 7445 for( UInt ui = 0; ui < uiHeight; ui++ ) 7446 { 7447 for( UInt uii = 0; uii < uiWidth; uii++ ) 7448 { 7449 if( pbRegion[ ui * uiWidth + uii ] == false ) 7450 { 7451 piTemp[ uii ] = iTestDC0; 7452 } 7453 else 7454 { 7455 piTemp[ uii ] = iTestDC1; 7456 } 7457 } 7458 piTemp += uiStride; 7459 } 7460 7461 Dist uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, 0 ); 7462 if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 7463 { 7464 uiBestDist = uiActDist; 7465 uiBestQStepDC0 = uiQStepDC0; 7466 uiBestQStepDC1 = uiQStepDC1; 7467 } 7468 } 7469 } 7470 7471 iFullDeltaDC0 = (Int)(uiBestQStepDC0) * (Int)(( iFullDeltaDC0 < 0 ) ? -1 : 1); 7472 iFullDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1); 7473 xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC0 ); 7474 xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC1 ); 7475 iDeltaDC0 = iFullDeltaDC0; 7476 iDeltaDC1 = iFullDeltaDC1; 7477 } 7478 #endif 7479 7480 xDeltaDCQuantScaleDown( pcCU, iDeltaDC0 ); 7481 xDeltaDCQuantScaleDown( pcCU, iDeltaDC1 ); 7482 7483 pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 ); 7484 pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 ); 7485 } 7486 #endif 7487 #endif 7488 6209 7489 //! \} -
trunk/source/Lib/TLibEncoder/TEncSearch.h
r77 r100 189 189 TComYuv* pcOrgYuv, 190 190 #if LG_RESTRICTEDRESPRED_M24766 191 TComYuv*rpcResiPredYuv,191 TComYuv* rpcResiPredYuv, 192 192 #endif 193 193 TComYuv*& rpcPredYuv, … … 259 259 TComYuv* pcPredYuv, 260 260 TComYuv* pcResiYuv, 261 Dist& ruiDist ); 261 Dist& ruiDist 262 #if LG_ZEROINTRADEPTHRESI_M26039 263 ,Bool bZeroResi = false 264 #endif 265 ); 262 266 Void xIntraCodingChromaBlk ( TComDataCU* pcCU, 263 267 UInt uiTrDepth, … … 278 282 Dist& ruiDistC, 279 283 #if HHI_RQT_INTRA_SPEEDUP 280 Bool bCheckFirst, 281 #endif 282 Double& dRDCost ); 284 Bool bCheckFirst, 285 #endif 286 Double& dRDCost 287 #if LG_ZEROINTRADEPTHRESI_M26039 288 ,Bool bZeroResi = false 289 #endif 290 ); 283 291 284 292 Void xSetIntraResultQT ( TComDataCU* pcCU, … … 321 329 Bool bLeftAvail ); 322 330 #endif 331 332 #if LGE_EDGE_INTRA 333 Bool xEdgePartition ( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 ); 334 Bool xCheckTerminatedEdge ( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight ); 335 Bool xConstructChainCode ( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 ); 336 #if LGE_EDGE_INTRA_DELTA_DC 337 Void xAssignEdgeIntraDeltaDCs( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piOrig, UInt uiStride, Pel* piPredic, UInt uiWidth, UInt uiHeight ); 338 #endif 339 #endif 340 323 341 #if HHI_DMM_WEDGE_INTRA 324 342 Void findWedgeFullMinDist ( TComDataCU* pcCU, … … 444 462 TComYuv* pcYuvOrg, 445 463 #if LG_RESTRICTEDRESPRED_M24766 446 464 TComYuv* rpcResiPredYuv, 447 465 #endif 448 466 Int iPartIdx, -
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r77 r100 38 38 #include "TEncTop.h" 39 39 #include "TEncSlice.h" 40 #if HHI_VSO_SPEEDUP_A033 41 #include "../../App/TAppEncoder/TAppEncTop.h" 42 #endif 40 43 #include <math.h> 44 #if SAIT_VSO_EST_A0033 45 extern Double g_dDispCoeff; 46 #endif 41 47 42 48 //! \ingroup TLibEncoder … … 627 633 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); 628 634 xDetermineStartAndBoundingCUAddr ( uiStartCUAddr, uiBoundingCUAddr, rpcPic, false ); 635 #if LG_ZEROINTRADEPTHRESI_M26039 636 rpcPic->setIntraPeriod(this->m_pcCfg->getIntraPeriod()); 637 #endif 629 638 630 639 // initialize cost values … … 702 711 m_pcEntropyCoder->setMaxAlfCtrlDepth(0); //unnecessary 703 712 713 #if SAIT_VSO_EST_A0033 714 if( m_pcCfg->getUseVSO() ) 715 { 716 m_pcRdCost->setDisparityCoeff( g_dDispCoeff ); // Temp. code!!! 717 //printf( "Disp Coeff : %3.4f \n", m_pcRdCost->getDisparityCoeff() ); 718 719 Int frameWidth = m_pcCfg->getSourceWidth(); 720 Pel* pVideoRec = m_pcRdCost->getVideoRecPicYuv()->getLumaAddr(); 721 Int iVideoRecStride = m_pcRdCost->getVideoRecPicYuv()->getStride(); 722 723 Pel* pDepthOrg = m_pcRdCost->getDepthPicYuv()->getLumaAddr(); 724 Int iDepthOrgStride = m_pcRdCost->getDepthPicYuv()->getStride(); 725 726 for( Int y = 0 ; y < m_pcCfg->getSourceHeight() ; y++ ) 727 { 728 pVideoRec[-4] = pVideoRec[-3] = pVideoRec[-2] = pVideoRec[-1] = pVideoRec[0]; 729 pVideoRec[frameWidth+3] = pVideoRec[frameWidth+2] = pVideoRec[frameWidth+1] = pVideoRec[frameWidth] = pVideoRec[frameWidth-1]; 730 pDepthOrg[-4] = pDepthOrg[-3] = pDepthOrg[-2] = pDepthOrg[-1] = pDepthOrg[0]; 731 pDepthOrg[frameWidth+3] = pDepthOrg[frameWidth+2] = pDepthOrg[frameWidth+1] = pDepthOrg[frameWidth] = pDepthOrg[frameWidth-1]; 732 733 pVideoRec += iVideoRecStride; 734 pDepthOrg += iDepthOrgStride; 735 } 736 } 737 #endif 704 738 TEncTop* pcEncTop = (TEncTop*) m_pcCfg; 705 739 TEncSbac**** ppppcRDSbacCoders = pcEncTop->getRDSbacCoders(); … … 753 787 UInt uiTileLCUX = 0; 754 788 789 #if HHI_VSO_SPEEDUP_A033 790 Int iLastPosY = -1; 791 #endif 792 755 793 // for every CU in slice 756 794 UInt uiEncCUOrder; … … 763 801 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 764 802 pcCU->initCU( rpcPic, uiCUAddr ); 803 804 #if HHI_VSO_SPEEDUP_A033 805 if ( m_pcRdCost->getUseRenModel() ) 806 { 807 // updated renderer model if necessary 808 Int iCurPosX; 809 Int iCurPosY; 810 pcCU->getPosInPic(0, iCurPosX, iCurPosY ); 811 if ( iCurPosY != iLastPosY ) 812 { 813 iLastPosY = iCurPosY; 814 815 m_pcGOPEncoder->getEncTop()->getEncTop()->setupRenModel( rpcPic->getCurrSlice()->getPOC() , rpcPic->getCurrSlice()->getSPS()->getViewId(), rpcPic->getCurrSlice()->getSPS()->isDepth() ? 1 : 0, iCurPosY ); 816 } 817 } 818 #endif 819 765 820 766 821 // inherit from TR if necessary, select substream to use. -
trunk/source/Lib/TLibEncoder/TEncTop.cpp
r77 r100 597 597 // mark it should be extended 598 598 rpcPic->getPicYuvRec()->setBorderExtension(false); 599 #if FIXES 600 rpcPic->getPicYuvOrg()->setBorderExtension(false); 601 #endif 599 602 } 600 603 … … 981 984 Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic ) 982 985 { 983 #if HHI_FIX984 986 if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && POCCurr == 0 ) 985 #else986 if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV )987 #endif988 987 { 989 988 TComReferencePictureSet* rps = slice->getLocalRPS();
Note: See TracChangeset for help on using the changeset viewer.