Changeset 459 in 3DVCSoftware for branches/HTM-DEV-0.3-dev1
- Timestamp:
- 6 Jun 2013, 11:46:05 (11 years ago)
- Location:
- branches/HTM-DEV-0.3-dev1
- Files:
-
- 2 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-DEV-0.3-dev1/build/linux/lib/TLibCommon/makefile
r324 r459 55 55 $(OBJ_DIR)/TComInterpolationFilter.o \ 56 56 $(OBJ_DIR)/libmd5.o \ 57 $(OBJ_DIR)/TComWedgelet.o \ 57 58 $(OBJ_DIR)/TComWeightPrediction.o \ 58 59 $(OBJ_DIR)/TComRdCostWeightPrediction.o \ -
branches/HTM-DEV-0.3-dev1/build/vc10/TLibCommon_vc10.vcxproj
r324 r459 166 166 <ClCompile Include="..\..\source\Lib\TLibCommon\TComSlice.cpp" /> 167 167 <ClCompile Include="..\..\source\Lib\TLibCommon\TComTrQuant.cpp" /> 168 <ClCompile Include="..\..\source\Lib\TLibCommon\TComWedgelet.cpp" /> 168 169 <ClCompile Include="..\..\source\Lib\TLibCommon\TComWeightPrediction.cpp" /> 169 170 <ClCompile Include="..\..\source\Lib\TLibCommon\TComYuv.cpp" /> … … 199 200 <ClInclude Include="..\..\source\Lib\TLibCommon\TComSlice.h" /> 200 201 <ClInclude Include="..\..\source\Lib\TLibCommon\TComTrQuant.h" /> 202 <ClInclude Include="..\..\source\Lib\TLibCommon\TComWedgelet.h" /> 201 203 <ClInclude Include="..\..\source\Lib\TLibCommon\TComWeightPrediction.h" /> 202 204 <ClInclude Include="..\..\source\Lib\TLibCommon\TComYuv.h" /> -
branches/HTM-DEV-0.3-dev1/build/vc8/TLibCommon_vc8.vcproj
r324 r459 369 369 </File> 370 370 <File 371 RelativePath="..\..\source\Lib\TLibCommon\TComWedgelet.cpp" 372 > 373 </File> 374 <File 371 375 RelativePath="..\..\source\Lib\TLibCommon\TComWeightPrediction.cpp" 372 376 > … … 499 503 </File> 500 504 <File 505 RelativePath="..\..\source\Lib\TLibCommon\TComWedgelet.h" 506 > 507 </File> 508 <File 501 509 RelativePath="..\..\source\Lib\TLibCommon\TComWeightPrediction.h" 502 510 > -
branches/HTM-DEV-0.3-dev1/build/vc9/TLibCommon_vc9.vcproj
r324 r459 372 372 </File> 373 373 <File 374 RelativePath="..\..\source\Lib\TLibCommon\TComWedgelet.cpp" 375 > 376 </File> 377 <File 374 378 RelativePath="..\..\source\Lib\TLibCommon\TComWeightPrediction.cpp" 375 379 > … … 502 506 </File> 503 507 <File 508 RelativePath="..\..\source\Lib\TLibCommon\TComWedgelet.h" 509 > 510 </File> 511 <File 504 512 RelativePath="..\..\source\Lib\TLibCommon\TComWeightPrediction.h" 505 513 > -
branches/HTM-DEV-0.3-dev1/cfg/3D-HEVC/baseCfg_2view+depth.cfg
r446 r459 199 199 #========== depth coding tools ========== 200 200 VSO : 1 # use of view synthesis optimization for depth coding 201 DMM : 1 202 RBC : 1 203 SDC : 1 204 DLT : 1 201 205 202 206 #========== view synthesis optimization (VSO) ========== -
branches/HTM-DEV-0.3-dev1/cfg/3D-HEVC/baseCfg_3view+depth.cfg
r446 r459 198 198 #========== depth coding tools ========== 199 199 VSO : 1 # use of view synthesis optimization for depth coding 200 DMM : 1 201 RBC : 1 202 SDC : 1 203 DLT : 1 200 204 201 205 #========== view synthesis optimization (VSO) ========== -
branches/HTM-DEV-0.3-dev1/cfg/3D-HEVC/fullCfg.cfg
r446 r459 204 204 #========== depth coding tools ========== 205 205 VSO : 1 # use of view synthesis optimization for depth coding 206 DMM : 1 207 RBC : 1 208 SDC : 1 209 DLT : 1 206 210 207 211 #========== view synthesis optimization (VSO) ========== -
branches/HTM-DEV-0.3-dev1/source/App/TAppDecoder/TAppDecTop.cpp
r446 r459 371 371 // initialize global variables 372 372 initROM(); 373 #if H_3D_DIM_DMM 374 initWedgeLists(); 375 #endif 373 376 #else 374 377 // create decoder class -
branches/HTM-DEV-0.3-dev1/source/App/TAppEncoder/TAppEncCfg.cpp
r446 r459 389 389 #if H_3D 390 390 ("DepthFlag", m_depthFlag , std::vector<Int>(1,0), "Depth Flag") 391 #if H_3D_DIM 392 ("DMM", m_useDMM, true, "Depth intra model modes") 393 ("RBC", m_useRBC, true, "Region boundary chain mode") 394 ("SDC", m_useSDC, true, "Simplified depth coding") 395 ("DLT", m_useDLT, true, "Depth lookup table") 396 #endif 391 397 #endif 392 398 ("LayerIdInNuh", m_layerIdInNuh , std::vector<Int>(1,0), "LayerId in Nuh") … … 2278 2284 printf("WVSO:%d ", m_bUseWVSO ); 2279 2285 #endif 2286 #if H_3D_DIM 2287 printf("DMM:%d ", m_useDMM ); 2288 printf("RBC:%d ", m_useRBC ); 2289 printf("SDC:%d ", m_useSDC ); 2290 printf("DLT:%d ", m_useDLT ); 2291 #endif 2280 2292 printf("\n\n"); 2281 2293 -
branches/HTM-DEV-0.3-dev1/source/App/TAppEncoder/TAppEncCfg.h
r446 r459 405 405 TRenModSetupStrParser m_cRenModStrParser; 406 406 #endif 407 #if H_3D_DIM 408 Bool m_useDMM; ///< flag for using DMM 409 Bool m_useRBC; ///< flag for using RBC 410 Bool m_useSDC; ///< flag for using SDC 411 Bool m_useDLT; ///< flag for using DLT 412 #endif 407 413 #endif 408 414 // internal member functions -
branches/HTM-DEV-0.3-dev1/source/App/TAppEncoder/TAppEncTop.cpp
r446 r459 120 120 xSetDirectDependencyFlags( vps ); 121 121 #if H_3D 122 for( Int layer = 0; layer < m_numberOfLayers; layer++ ) 123 { 124 vps.setVpsDepthModesFlag( layer, ((vps.getDepthId( layer ) != 0) && (m_useDMM || m_useRBC || m_useSDC || m_useDLT)) ? true : false ); 125 } 126 122 127 vps.initViewIndex(); 123 128 m_ivPicLists.setVPS ( &vps ); … … 166 171 m_cTEncTop.setDWeight ( isDepth ? m_iDWeight : 0 ); 167 172 #endif // H_3D_VSO 173 174 //========== Depth intra modes ========== 175 #if H_3D_DIM 176 m_cTEncTop.setUseDMM ( isDepth ? m_useDMM : false ); 177 m_cTEncTop.setUseRBC ( isDepth ? m_useRBC : false ); 178 m_cTEncTop.setUseSDC ( isDepth ? m_useSDC : false ); 179 m_cTEncTop.setUseDLT ( isDepth ? m_useDLT : false ); 180 #endif 168 181 #endif // H_3D 169 182 … … 543 556 // initialize global variables 544 557 initROM(); 558 #if H_3D_DIM_DMM 559 initWedgeLists( true ); 560 #endif 545 561 546 562 for( Int layer=0; layer < m_numberOfLayers; layer++) -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/ContextTables.h
r324 r459 97 97 #define CNU 154 ///< dummy initialization value for unused context models 'Context model Not Used' 98 98 99 #if H_3D_DIM 100 #define NUM_DEPTH_INTRA_MODE_CTX 8 ///< number of context models for depth intra modes 101 #define NUM_DDC_FLAG_CTX 2 ///< number of context models for deltaDC flag (DMM or RBC) 102 #define NUM_DDC_DATA_CTX 2 ///< number of context models for deltaDC data (DMM or RBC) 103 #if H_3D_DIM_DMM 104 #define NUM_DMM1_DATA_CTX 1 ///< number of context models for DMM1 data 105 #define NUM_DMM2_DATA_CTX 1 ///< number of context models for DMM2 data 106 #define NUM_DMM3_DATA_CTX 1 ///< number of context models for DMM3 data 107 #endif 108 #if H_3D_DIM_RBC 109 #define NUM_RBC_DATA_CTX 1 ///< number of context models for RBC data 110 #endif 111 #endif 112 99 113 // ==================================================================================================================== 100 114 // Tables … … 334 348 { 139, 139}, 335 349 }; 350 351 #if H_3D_DIM 352 static const UChar 353 INIT_DEPTH_INTRA_MODE[3][NUM_DEPTH_INTRA_MODE_CTX] = 354 { 355 {0, 0, 64, 0, CNU, 0, CNU, 0}, 356 {0, 64, 0, CNU, 0, CNU, 0, 0}, 357 {64, 0, CNU, 0, CNU, 0, 0, 0} 358 }; 359 static const UChar 360 INIT_DDC_FLAG[3][NUM_DDC_FLAG_CTX] = 361 { 362 {0 , CNU}, 363 {0 , CNU}, 364 {64, CNU} 365 }; 366 static const UChar 367 INIT_DDC_DATA[3][NUM_DDC_DATA_CTX] = 368 { 369 { CNU, CNU }, 370 { CNU, CNU }, 371 { CNU, CNU }, 372 }; 373 #if H_3D_DIM_DMM 374 static const UChar 375 INIT_DMM1_DATA[3][NUM_DMM1_DATA_CTX] = 376 { 377 { CNU }, 378 { CNU }, 379 { CNU }, 380 }; 381 static const UChar 382 INIT_DMM2_DATA[3][NUM_DMM2_DATA_CTX] = 383 { 384 { CNU }, 385 { CNU }, 386 { CNU }, 387 }; 388 static const UChar 389 INIT_DMM3_DATA[3][NUM_DMM3_DATA_CTX] = 390 { 391 { CNU }, 392 { CNU }, 393 { CNU }, 394 }; 395 #endif 396 #if H_3D_DIM_RBC 397 static const UChar 398 INIT_RBC_DATA[3][NUM_RBC_DATA_CTX] = 399 { 400 { CNU }, 401 { CNU }, 402 { CNU }, 403 }; 404 #endif 405 #endif 336 406 //! \} 337 407 -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TComDataCU.cpp
r446 r459 109 109 m_apiMVPNum[1] = NULL; 110 110 111 #if H_3D_DIM 112 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 113 { 114 m_dimDeltaDC[i][0] = NULL; 115 m_dimDeltaDC[i][1] = NULL; 116 } 117 #if H_3D_DIM_DMM 118 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 119 { 120 m_dmmWedgeTabIdx[i] = NULL; 121 } 122 m_dmm2DeltaEnd = NULL; 123 m_dmm3IntraTabIdx = NULL; 124 #endif 125 #if H_3D_DIM_RBC 126 m_pucEdgeCode = NULL; 127 m_pucEdgeNumber = NULL; 128 m_pucEdgeStartPos = NULL; 129 m_pbEdgeLeftFirst = NULL; 130 m_pbEdgePartition = NULL; 131 #endif 132 #endif 133 111 134 m_bDecSubCu = false; 112 135 m_sliceStartCU = 0; … … 202 225 m_acCUMvField[1].create( uiNumPartition ); 203 226 227 #if H_3D_DIM 228 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 229 { 230 m_dimDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition); 231 m_dimDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition); 232 } 233 #if H_3D_DIM_DMM 234 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 235 { 236 m_dmmWedgeTabIdx[i] = (UInt*)xMalloc(UInt, uiNumPartition); 237 } 238 m_dmm2DeltaEnd = (Int* )xMalloc(Int, uiNumPartition); 239 m_dmm3IntraTabIdx = (UInt*)xMalloc(UInt, uiNumPartition); 240 #endif 241 #if H_3D_DIM_RBC 242 m_pucEdgeCode = (UChar*)xMalloc(UChar, uiNumPartition * RBC_MAX_EDGE_NUM_PER_4x4); 243 m_pucEdgeNumber = (UChar*)xMalloc(UChar, uiNumPartition); 244 m_pucEdgeStartPos = (UChar*)xMalloc(UChar, uiNumPartition); 245 m_pbEdgeLeftFirst = (Bool*)xMalloc(Bool, uiNumPartition); 246 m_pbEdgePartition = (Bool*)xMalloc(Bool, uiNumPartition * 16); 247 #endif 248 #endif 204 249 } 205 250 else … … 288 333 m_acCUMvField[1].destroy(); 289 334 335 #if H_3D_DIM 336 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 337 { 338 if ( m_dimDeltaDC[i][0] ) { xFree( m_dimDeltaDC[i][0] ); m_dimDeltaDC[i][0] = NULL; } 339 if ( m_dimDeltaDC[i][1] ) { xFree( m_dimDeltaDC[i][1] ); m_dimDeltaDC[i][1] = NULL; } 340 } 341 #if H_3D_DIM_DMM 342 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 343 { 344 if ( m_dmmWedgeTabIdx[i] ) { xFree( m_dmmWedgeTabIdx[i] ); m_dmmWedgeTabIdx[i] = NULL; } 345 } 346 if ( m_dmm2DeltaEnd ) { xFree( m_dmm2DeltaEnd ); m_dmm2DeltaEnd = NULL; } 347 if ( m_dmm3IntraTabIdx ) { xFree( m_dmm3IntraTabIdx ); m_dmm3IntraTabIdx = NULL; } 348 #endif 349 #if H_3D_DIM_RBC 350 if ( m_pbEdgeLeftFirst ) { xFree( m_pbEdgeLeftFirst ); m_pbEdgeLeftFirst = NULL; } 351 if ( m_pucEdgeStartPos ) { xFree( m_pucEdgeStartPos ); m_pucEdgeStartPos = NULL; } 352 if ( m_pucEdgeNumber ) { xFree( m_pucEdgeNumber ); m_pucEdgeNumber = NULL; } 353 if ( m_pucEdgeCode ) { xFree( m_pucEdgeCode ); m_pucEdgeCode = NULL; } 354 if ( m_pbEdgePartition ) { xFree( m_pbEdgePartition ); m_pbEdgePartition = NULL; } 355 #endif 356 #endif 290 357 } 291 358 … … 447 514 memset( m_puhCbf[2] + firstElement, 0, numElements * sizeof( *m_puhCbf[2] ) ); 448 515 memset( m_pbIPCMFlag + firstElement, false, numElements * sizeof( *m_pbIPCMFlag ) ); 516 517 #if H_3D_DIM 518 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 519 { 520 memset( m_dimDeltaDC[i][0] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][0] ) ); 521 memset( m_dimDeltaDC[i][1] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][1] ) ); 522 } 523 #if H_3D_DIM_DMM 524 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 525 { 526 memset( m_dmmWedgeTabIdx[i] + firstElement, 0, numElements * sizeof( *m_dmmWedgeTabIdx[i] ) ); 527 } 528 memset( m_dmm2DeltaEnd + firstElement, 0, numElements * sizeof( *m_dmm2DeltaEnd ) ); 529 memset( m_dmm3IntraTabIdx + firstElement, 0, numElements * sizeof( *m_dmm3IntraTabIdx ) ); 530 #endif 531 #if H_3D_DIM_RBC 532 memset( m_pucEdgeCode + firstElement, 0, numElements * sizeof( *m_pucEdgeCode ) * RBC_MAX_EDGE_NUM_PER_4x4 ); 533 memset( m_pucEdgeNumber + firstElement, 0, numElements * sizeof( *m_pucEdgeNumber ) ); 534 memset( m_pucEdgeStartPos + firstElement, 0, numElements * sizeof( *m_pucEdgeStartPos ) ); 535 memset( m_pbEdgeLeftFirst + firstElement, false, numElements * sizeof( *m_pbEdgeLeftFirst ) ); 536 memset( m_pbEdgePartition + firstElement, false, numElements * sizeof( *m_pbEdgePartition ) * 16 ); 537 #endif 538 #endif 449 539 } 450 540 … … 582 672 m_puhCbf[1][ui] = 0; 583 673 m_puhCbf[2][ui] = 0; 674 675 #if H_3D_DIM 676 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 677 { 678 m_dimDeltaDC[i][0] [ui] = 0; 679 m_dimDeltaDC[i][1] [ui] = 0; 680 } 681 #if H_3D_DIM_DMM 682 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 683 { 684 m_dmmWedgeTabIdx[i] [ui] = 0; 685 } 686 m_dmm2DeltaEnd [ui] = 0; 687 m_dmm3IntraTabIdx [ui] = 0; 688 #endif 689 #endif 584 690 } 585 691 } … … 658 764 memset( m_puhHeight, uhHeight, iSizeInUchar ); 659 765 memset( m_pbIPCMFlag, 0, iSizeInBool ); 766 767 #if H_3D_DIM 768 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 769 { 770 memset( m_dimDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition ); 771 memset( m_dimDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition ); 772 } 773 #if H_3D_DIM_DMM 774 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 775 { 776 memset( m_dmmWedgeTabIdx[i], 0, sizeof(UInt) * m_uiNumPartition ); 777 } 778 memset( m_dmm2DeltaEnd , 0, sizeof(Int ) * m_uiNumPartition ); 779 memset( m_dmm3IntraTabIdx, 0, sizeof(UInt) * m_uiNumPartition ); 780 #endif 781 #if H_3D_DIM_RBC 782 memset( m_pucEdgeCode , 0, iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); 783 memset( m_pucEdgeNumber , 0, iSizeInUchar ); 784 memset( m_pucEdgeStartPos, 0, iSizeInUchar ); 785 memset( m_pbEdgeLeftFirst, 0, iSizeInBool ); 786 memset( m_pbEdgePartition, 0, iSizeInBool * 16 ); 787 #endif 788 #endif 789 660 790 for (UInt ui = 0; ui < m_uiNumPartition; ui++) 661 791 { … … 696 826 m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui]; 697 827 828 #if H_3D_DIM 829 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 830 { 831 m_dimDeltaDC[i][0] [ui] = pcCU->m_dimDeltaDC[i][0] [uiPartOffset+ui]; 832 m_dimDeltaDC[i][1] [ui] = pcCU->m_dimDeltaDC[i][1] [uiPartOffset+ui]; 833 } 834 #if H_3D_DIM_DMM 835 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 836 { 837 m_dmmWedgeTabIdx[i] [ui] = pcCU->m_dmmWedgeTabIdx[i] [uiPartOffset+ui]; 838 } 839 m_dmm2DeltaEnd [ui] = pcCU->m_dmm2DeltaEnd [uiPartOffset+ui]; 840 m_dmm3IntraTabIdx [ui] = pcCU->m_dmm3IntraTabIdx[uiPartOffset+ui]; 841 #endif 842 #endif 698 843 } 699 844 } … … 815 960 m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; 816 961 962 #if H_3D_DIM 963 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 964 { 965 m_dimDeltaDC[i][0] = pcCU->getDimDeltaDC( i, 0 ) + uiPart; 966 m_dimDeltaDC[i][1] = pcCU->getDimDeltaDC( i, 1 ) + uiPart; 967 } 968 #if H_3D_DIM_DMM 969 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 970 { 971 m_dmmWedgeTabIdx[i] = pcCU->getDmmWedgeTabIdx( i ) + uiPart; 972 } 973 m_dmm2DeltaEnd = pcCU->getDmm2DeltaEnd() + uiPart; 974 m_dmm3IntraTabIdx = pcCU->getDmm3IntraTabIdx() + uiPart; 975 #endif 976 #if H_3D_DIM_RBC 977 m_pucEdgeCode = pcCU->getEdgeCode( uiPart ); 978 m_pucEdgeNumber = pcCU->getEdgeNumber() + uiPart; 979 m_pucEdgeStartPos = pcCU->getEdgeStartPos() + uiPart; 980 m_pbEdgeLeftFirst = pcCU->getEdgeLeftFirst() + uiPart; 981 m_pbEdgePartition = pcCU->getEdgePartition( uiPart ); 982 #endif 983 #endif 984 817 985 m_puhDepth=pcCU->getDepth() + uiPart; 818 986 m_puhWidth=pcCU->getWidth() + uiPart; … … 942 1110 memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); 943 1111 1112 #if H_3D_DIM 1113 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 1114 { 1115 memcpy( m_dimDeltaDC[i][0] + uiOffset, pcCU->getDimDeltaDC( i, 0 ), sizeof(Pel ) * uiNumPartition ); 1116 memcpy( m_dimDeltaDC[i][1] + uiOffset, pcCU->getDimDeltaDC( i, 1 ), sizeof(Pel ) * uiNumPartition ); 1117 } 1118 #if H_3D_DIM_DMM 1119 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 1120 { 1121 memcpy( m_dmmWedgeTabIdx[i] + uiOffset, pcCU->getDmmWedgeTabIdx( i ), sizeof(UInt) * uiNumPartition ); 1122 } 1123 memcpy( m_dmm2DeltaEnd + uiOffset, pcCU->getDmm2DeltaEnd() , sizeof(Int ) * uiNumPartition ); 1124 memcpy( m_dmm3IntraTabIdx + uiOffset, pcCU->getDmm3IntraTabIdx(), sizeof(UInt) * uiNumPartition ); 1125 #endif 1126 #if H_3D_DIM_RBC 1127 memcpy( getEdgeCode( uiOffset ), pcCU->getEdgeCode(0), iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); 1128 memcpy( getEdgeNumber() + uiOffset, pcCU->getEdgeNumber(), iSizeInUchar ); 1129 memcpy( getEdgeStartPos() + uiOffset, pcCU->getEdgeStartPos(), iSizeInUchar ); 1130 memcpy( getEdgeLeftFirst() + uiOffset, pcCU->getEdgeLeftFirst(), iSizeInBool ); 1131 memcpy( getEdgePartition( uiOffset ), pcCU->getEdgePartition(0), iSizeInBool * 16 ); 1132 #endif 1133 #endif 1134 944 1135 memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); 945 1136 memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); … … 1022 1213 memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); 1023 1214 1215 #if H_3D_DIM 1216 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 1217 { 1218 memcpy( rpcCU->getDimDeltaDC( i, 0 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition ); 1219 memcpy( rpcCU->getDimDeltaDC( i, 1 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition ); 1220 } 1221 #if H_3D_DIM_DMM 1222 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 1223 { 1224 memcpy( rpcCU->getDmmWedgeTabIdx( i ) + m_uiAbsIdxInLCU, m_dmmWedgeTabIdx[i], sizeof(UInt) * m_uiNumPartition ); 1225 } 1226 memcpy( rpcCU->getDmm2DeltaEnd() + m_uiAbsIdxInLCU, m_dmm2DeltaEnd , sizeof(Int ) * m_uiNumPartition ); 1227 memcpy( rpcCU->getDmm3IntraTabIdx() + m_uiAbsIdxInLCU, m_dmm3IntraTabIdx, sizeof(UInt) * m_uiNumPartition ); 1228 #endif 1229 #if H_3D_DIM_RBC 1230 memcpy( rpcCU->getEdgeCode( m_uiAbsIdxInLCU ), m_pucEdgeCode, iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); 1231 memcpy( rpcCU->getEdgeNumber() + m_uiAbsIdxInLCU, m_pucEdgeNumber, iSizeInUchar ); 1232 memcpy( rpcCU->getEdgeStartPos() + m_uiAbsIdxInLCU, m_pucEdgeStartPos, iSizeInUchar ); 1233 memcpy( rpcCU->getEdgeLeftFirst() + m_uiAbsIdxInLCU, m_pbEdgeLeftFirst, iSizeInBool ); 1234 memcpy( rpcCU->getEdgePartition( m_uiAbsIdxInLCU ), m_pbEdgePartition, iSizeInBool * 16 ); 1235 #endif 1236 #endif 1237 1024 1238 memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); 1025 1239 memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); … … 1093 1307 memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); 1094 1308 1309 #if H_3D_DIM 1310 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 1311 { 1312 memcpy( rpcCU->getDimDeltaDC( i, 0 ) + uiPartOffset, m_dimDeltaDC[i][0], sizeof(Pel ) * uiQNumPart ); 1313 memcpy( rpcCU->getDimDeltaDC( i, 1 ) + uiPartOffset, m_dimDeltaDC[i][1], sizeof(Pel ) * uiQNumPart ); 1314 } 1315 #if H_3D_DIM_DMM 1316 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 1317 { 1318 memcpy( rpcCU->getDmmWedgeTabIdx( i ) + uiPartOffset, m_dmmWedgeTabIdx[i], sizeof(UInt) * uiQNumPart ); 1319 } 1320 memcpy( rpcCU->getDmm2DeltaEnd() + uiPartOffset, m_dmm2DeltaEnd , sizeof(Int ) * uiQNumPart ); 1321 memcpy( rpcCU->getDmm3IntraTabIdx() + uiPartOffset, m_dmm3IntraTabIdx, sizeof(UInt) * uiQNumPart ); 1322 #endif 1323 #if H_3D_DIM_RBC 1324 memcpy( rpcCU->getEdgeCode( uiPartOffset ), m_pucEdgeCode, iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); 1325 memcpy( rpcCU->getEdgeNumber() + uiPartOffset, m_pucEdgeNumber, iSizeInUchar ); 1326 memcpy( rpcCU->getEdgeStartPos() + uiPartOffset, m_pucEdgeStartPos, iSizeInUchar ); 1327 memcpy( rpcCU->getEdgeLeftFirst() + uiPartOffset, m_pbEdgeLeftFirst, iSizeInBool ); 1328 memcpy( rpcCU->getEdgePartition( uiPartOffset ), m_pbEdgePartition, iSizeInBool * 16 ); 1329 #endif 1330 #endif 1331 1095 1332 memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); 1096 1333 memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); … … 1648 1885 1649 1886 iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; 1887 #if H_3D_DIM 1888 mapDepthModeToIntraDir( iLeftIntraDir ); 1889 #endif 1650 1890 1651 1891 // Get intra direction of above PU … … 1653 1893 1654 1894 iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; 1895 #if H_3D_DIM 1896 mapDepthModeToIntraDir( iAboveIntraDir ); 1897 #endif 1655 1898 1656 1899 uiPredNum = 3; … … 3437 3680 { 3438 3681 uiDirMode = getLumaIntraDir(uiAbsPartIdx); 3682 #if H_3D_DIM 3683 mapDepthModeToIntraDir( uiDirMode ); 3684 #endif 3439 3685 uiScanIdx = SCAN_DIAG; 3440 3686 if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size … … 3454 3700 // get luma mode from upper-left corner of current CU 3455 3701 uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); 3702 #if H_3D_DIM 3703 mapDepthModeToIntraDir( uiDirMode ); 3704 #endif 3456 3705 } 3457 3706 uiScanIdx = SCAN_DIAG; … … 3845 4094 riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); 3846 4095 } 4096 #if H_3D_DIM_DMM 4097 Void TComDataCU::setDmmWedgeTabIdxSubParts( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth ) 4098 { 4099 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 4100 for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; } 4101 } 4102 Void TComDataCU::setDmm2DeltaEndSubParts( Int iDelta, UInt uiAbsPartIdx, UInt uiDepth ) 4103 { 4104 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 4105 for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm2DeltaEnd[uiAbsPartIdx+ui] = iDelta; } 4106 } 4107 Void TComDataCU::setDmm3IntraTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth ) 4108 { 4109 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 4110 for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm3IntraTabIdx[uiAbsPartIdx+ui] = uiTIdx; } 4111 } 4112 #endif 4113 #if H_3D_DIM_RBC 4114 Void TComDataCU::reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion ) 4115 { 4116 Int iWidth; 4117 Int iHeight; 4118 if( uiDepth == 0 ) 4119 { 4120 iWidth = 64; 4121 iHeight = 64; 4122 } 4123 else if( uiDepth == 1 ) 4124 { 4125 iWidth = 32; 4126 iHeight = 32; 4127 } 4128 else if( uiDepth == 2 ) 4129 { 4130 iWidth = 16; 4131 iHeight = 16; 4132 } 4133 else if( uiDepth == 3 ) 4134 { 4135 iWidth = 8; 4136 iHeight = 8; 4137 } 4138 else // uiDepth == 4 4139 { 4140 iWidth = 4; 4141 iHeight = 4; 4142 } 4143 4144 Int iPtr = 0; 4145 Int iX, iY; 4146 Int iDir = -1; 4147 Int iDiffX = 0, iDiffY = 0; 4148 4149 // 1. Edge Code -> Vert & Horz Edges 4150 Bool* pbEdge = (Bool*) xMalloc( Bool, 4 * iWidth * iHeight ); 4151 4152 for( UInt ui = 0; ui < 4 * iWidth * iHeight; ui++ ) 4153 pbEdge [ ui ] = false; 4154 4155 // Direction : left(0), right(1), top(2), bottom(3), left-top(4), right-top(5), left-bottom(6), right-bottom(7) 4156 // Code : 0deg(0), 45deg(1), -45deg(2), 90deg(3), -90deg(4), 135deg(5), -135deg(6) 4157 const UChar tableDir[8][7] = { { 0, 6, 4, 3, 2, 7, 5 }, 4158 { 1, 5, 7, 2, 3, 4, 6 }, 4159 { 2, 4, 5, 0, 1, 6, 7 }, 4160 { 3, 7, 6, 1, 0, 5, 4 }, 4161 { 4, 0, 2, 6, 5, 3, 1 }, 4162 { 5, 2, 1, 4, 7, 0, 3 }, 4163 { 6, 3, 0, 7, 4, 1, 2 }, 4164 { 7, 1, 3, 5, 6, 2, 0 }}; 4165 4166 UChar ucCode = pucEdgeCode[iPtr++]; 4167 4168 if( !bLeft ) 4169 { 4170 iX = ucStartPos; 4171 iY = 0; 4172 4173 switch(ucCode) 4174 { 4175 case 0: // bottom 4176 iDir = 3; 4177 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4178 break; 4179 case 2: // left-bottom 4180 iDir = 6; 4181 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4182 break; 4183 case 1: // right-bottom 4184 iDir = 7; 4185 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4186 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4187 break; 4188 case 4: // left 4189 iDir = 0; 4190 assert(false); 4191 break; 4192 case 3: // right 4193 iDir = 1; 4194 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4195 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4196 break; 4197 } 4198 } 4199 else 4200 { 4201 iX = 0; 4202 iY = ucStartPos; 4203 4204 switch(ucCode) 4205 { 4206 case 0: // right 4207 iDir = 1; 4208 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4209 break; 4210 case 1: // right-top 4211 iDir = 5; 4212 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4213 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4214 break; 4215 case 2: // right-bottom 4216 iDir = 7; 4217 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4218 break; 4219 case 3: // top 4220 iDir = 2; 4221 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4222 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4223 break; 4224 case 4: // bottom 4225 iDir = 3; 4226 assert(false); 4227 break; 4228 } 4229 } 4230 4231 switch( iDir ) 4232 { 4233 case 0: // left 4234 iDiffX = -1; 4235 iDiffY = 0; 4236 break; 4237 case 1: // right 4238 iDiffX = +1; 4239 iDiffY = 0; 4240 break; 4241 case 2: // top 4242 iDiffX = 0; 4243 iDiffY = -1; 4244 break; 4245 case 3: // bottom 4246 iDiffX = 0; 4247 iDiffY = +1; 4248 break; 4249 case 4: // left-top 4250 iDiffX = -1; 4251 iDiffY = -1; 4252 break; 4253 case 5: // right-top 4254 iDiffX = +1; 4255 iDiffY = -1; 4256 break; 4257 case 6: // left-bottom 4258 iDiffX = -1; 4259 iDiffY = +1; 4260 break; 4261 case 7: // right-bottom 4262 iDiffX = +1; 4263 iDiffY = +1; 4264 break; 4265 } 4266 4267 iX += iDiffX; 4268 iY += iDiffY; 4269 4270 while( iPtr < ucNumEdge ) 4271 { 4272 ucCode = pucEdgeCode[iPtr++]; 4273 4274 Int iNewDir = tableDir[iDir][ucCode]; 4275 4276 switch( iNewDir ) 4277 { 4278 case 0: // left 4279 iDiffX = -1; 4280 iDiffY = 0; 4281 break; 4282 case 1: // right 4283 iDiffX = +1; 4284 iDiffY = 0; 4285 break; 4286 case 2: // top 4287 iDiffX = 0; 4288 iDiffY = -1; 4289 break; 4290 case 3: // bottom 4291 iDiffX = 0; 4292 iDiffY = +1; 4293 break; 4294 case 4: // left-top 4295 iDiffX = -1; 4296 iDiffY = -1; 4297 break; 4298 case 5: // right-top 4299 iDiffX = +1; 4300 iDiffY = -1; 4301 break; 4302 case 6: // left-bottom 4303 iDiffX = -1; 4304 iDiffY = +1; 4305 break; 4306 case 7: // right-bottom 4307 iDiffX = +1; 4308 iDiffY = +1; 4309 break; 4310 } 4311 4312 switch( iDir ) 4313 { 4314 case 0: // left 4315 switch( ucCode ) 4316 { 4317 case 0: 4318 case 2: 4319 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4320 break; 4321 case 1: 4322 case 3: 4323 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4324 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4325 break; 4326 case 4: 4327 case 6: 4328 // no 4329 break; 4330 case 5: 4331 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4332 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4333 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4334 break; 4335 } 4336 break; 4337 case 1: // right 4338 switch( ucCode ) 4339 { 4340 case 0: 4341 case 2: 4342 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4343 break; 4344 case 1: 4345 case 3: 4346 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4347 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4348 break; 4349 case 4: 4350 case 6: 4351 // no 4352 break; 4353 case 5: 4354 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4355 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4356 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4357 break; 4358 } 4359 break; 4360 case 2: // top 4361 switch( ucCode ) 4362 { 4363 case 0: 4364 case 2: 4365 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4366 break; 4367 case 1: 4368 case 3: 4369 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4370 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4371 break; 4372 case 4: 4373 case 6: 4374 // no 4375 break; 4376 case 5: 4377 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4378 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4379 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4380 break; 4381 } 4382 break; 4383 case 3: // bottom 4384 switch( ucCode ) 4385 { 4386 case 0: 4387 case 2: 4388 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4389 break; 4390 case 1: 4391 case 3: 4392 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4393 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4394 break; 4395 case 4: 4396 case 6: 4397 // no 4398 break; 4399 case 5: 4400 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4401 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4402 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4403 break; 4404 } 4405 break; 4406 case 4: // left-top 4407 switch( ucCode ) 4408 { 4409 case 0: 4410 case 1: 4411 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4412 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4413 break; 4414 case 2: 4415 case 4: 4416 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4417 break; 4418 case 3: 4419 case 5: 4420 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4421 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4422 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4423 break; 4424 case 6: 4425 // no 4426 break; 4427 } 4428 break; 4429 case 5: // right-top 4430 switch( ucCode ) 4431 { 4432 case 0: 4433 case 1: 4434 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4435 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4436 break; 4437 case 2: 4438 case 4: 4439 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4440 break; 4441 case 3: 4442 case 5: 4443 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4444 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4445 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4446 break; 4447 case 6: 4448 // no 4449 break; 4450 } 4451 break; 4452 case 6: // left-bottom 4453 switch( ucCode ) 4454 { 4455 case 0: 4456 case 1: 4457 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4458 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4459 break; 4460 case 2: 4461 case 4: 4462 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4463 break; 4464 case 3: 4465 case 5: 4466 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 4467 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4468 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4469 break; 4470 case 6: 4471 // no 4472 break; 4473 } 4474 break; 4475 case 7: // right-bottom 4476 switch( ucCode ) 4477 { 4478 case 0: 4479 case 1: 4480 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4481 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4482 break; 4483 case 2: 4484 case 4: 4485 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4486 break; 4487 case 3: 4488 case 5: 4489 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 4490 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 4491 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 4492 break; 4493 case 6: 4494 // no 4495 break; 4496 } 4497 break; 4498 } 4499 4500 assert( iX >= 0 && iX <= iWidth ); 4501 assert( iY >= 0 && iY <= iHeight ); 4502 4503 iX += iDiffX; 4504 iY += iDiffY; 4505 iDir = iNewDir; 4506 } 4507 4508 // finalize edge chain 4509 if( iX == iWidth-1 ) 4510 { 4511 if( iY == 0 ) 4512 { 4513 if( iDir == 1 ) 4514 { 4515 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 4516 } 4517 else if( iDir == 5 ) 4518 { 4519 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 4520 } 4521 else 4522 { 4523 assert(false); 4524 } 4525 } 4526 else if( iY == iHeight-1 ) 4527 { 4528 if( iDir == 3 ) 4529 { 4530 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 4531 } 4532 else if( iDir == 7 ) 4533 { 4534 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 4535 } 4536 else 4537 { 4538 assert(false); 4539 } 4540 } 4541 else 4542 { 4543 if( iDir == 1 ) 4544 { 4545 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 4546 } 4547 else if( iDir == 3 ) 4548 { 4549 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 4550 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 4551 } 4552 else if( iDir == 5 ) 4553 { 4554 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 4555 } 4556 else if( iDir == 7 ) 4557 { 4558 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 4559 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 4560 } 4561 else 4562 { 4563 assert(false); 4564 } 4565 } 4566 } 4567 else if( iX == 0 ) 4568 { 4569 if( iY == 0 ) 4570 { 4571 if( iDir == 2 ) 4572 { 4573 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 4574 } 4575 else if( iDir == 4 ) 4576 { 4577 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 4578 } 4579 else 4580 { 4581 assert(false); 4582 } 4583 } 4584 else if( iY == iHeight-1 ) 4585 { 4586 if( iDir == 0 ) 4587 { 4588 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 4589 } 4590 else if( iDir == 6 ) 4591 { 4592 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 4593 } 4594 else 4595 { 4596 assert(false); 4597 } 4598 } 4599 else 4600 { 4601 if( iDir == 0 ) 4602 { 4603 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 4604 } 4605 else if( iDir == 2 ) 4606 { 4607 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 4608 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 4609 } 4610 else if( iDir == 4 ) 4611 { 4612 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 4613 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 4614 } 4615 else if( iDir == 6 ) 4616 { 4617 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 4618 } 4619 else 4620 { 4621 assert(false); 4622 } 4623 } 4624 } 4625 else if( iY == 0 ) 4626 { 4627 if( iDir == 1 ) 4628 { 4629 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 4630 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 4631 } 4632 else if( iDir == 2 ) 4633 { 4634 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 4635 } 4636 else if( iDir == 4 ) 4637 { 4638 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 4639 } 4640 else if( iDir == 5 ) 4641 { 4642 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 4643 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 4644 } 4645 else 4646 { 4647 assert(false); 4648 } 4649 } 4650 else if( iY == iHeight-1 ) 4651 { 4652 if( iDir == 0 ) 4653 { 4654 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 4655 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 4656 } 4657 else if( iDir == 3 ) 4658 { 4659 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 4660 } 4661 else if( iDir == 6 ) 4662 { 4663 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 4664 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 4665 } 4666 else if( iDir == 7 ) 4667 { 4668 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 4669 } 4670 else 4671 { 4672 assert(false); 4673 } 4674 } 4675 else 4676 { 4677 printf("reconPartiton: wrong termination\n"); 4678 assert(false); 4679 } 4680 4681 // Reconstruct Region from Chain Code 4682 Bool* pbVisit = (Bool*) xMalloc( Bool, iWidth * iHeight ); 4683 Int* piStack = (Int* ) xMalloc( Int, iWidth * iHeight ); 4684 4685 for( UInt ui = 0; ui < iWidth * iHeight; ui++ ) 4686 { 4687 pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next) 4688 pbVisit [ ui ] = false; 4689 } 4690 4691 iPtr = 0; 4692 piStack[iPtr++] = (0 << 8) | (0); 4693 pbRegion[ 0 ] = false; 4694 4695 while(iPtr > 0) 4696 { 4697 Int iTmp = piStack[--iPtr]; 4698 Int iX1, iY1; 4699 iX1 = iTmp & 0xff; 4700 iY1 = (iTmp >> 8) & 0xff; 4701 4702 pbVisit[ iX1 + iY1 * iWidth ] = true; 4703 4704 assert( iX1 >= 0 && iX1 < iWidth ); 4705 assert( iY1 >= 0 && iY1 < iHeight ); 4706 4707 if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] ) 4708 { 4709 piStack[iPtr++] = (iY1 << 8) | (iX1 - 1); 4710 pbRegion[ iX1 - 1 + iY1 * iWidth ] = false; 4711 } 4712 if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] ) 4713 { 4714 piStack[iPtr++] = (iY1 << 8) | (iX1 + 1); 4715 pbRegion[ iX1 + 1 + iY1 * iWidth ] = false; 4716 } 4717 if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] ) 4718 { 4719 piStack[iPtr++] = ((iY1 - 1) << 8) | iX1; 4720 pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false; 4721 } 4722 if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] ) 4723 { 4724 piStack[iPtr++] = ((iY1 + 1) << 8) | iX1; 4725 pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false; 4726 } 4727 } 4728 4729 xFree( pbEdge ); 4730 xFree( pbVisit ); 4731 xFree( piStack ); 4732 } 4733 #endif 3847 4734 #endif 3848 4735 -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TComDataCU.h
r446 r459 188 188 Bool* m_pbIPCMFlag; ///< array of intra_pcm flags 189 189 190 #if H_3D_DIM 191 Pel* m_dimDeltaDC[DIM_NUM_TYPE][2]; 192 #if H_3D_DIM_DMM 193 UInt* m_dmmWedgeTabIdx[DMM_NUM_TYPE]; 194 Int* m_dmm2DeltaEnd; 195 UInt* m_dmm3IntraTabIdx; 196 #endif 197 #if H_3D_DIM_RBC 198 UChar* m_pucEdgeCode; ///< array of edge code 199 UChar* m_pucEdgeNumber; ///< total number of edge 200 UChar* m_pucEdgeStartPos; ///< starting point position 201 Bool* m_pbEdgeLeftFirst; ///< true if edge should be checked in left boundary first 202 Bool* m_pbEdgePartition; ///< true if it belongs to region 1, otherwise, region 0 203 #endif 204 #endif 205 190 206 // ------------------------------------------------------------------------------------------------------------------- 191 207 // misc. variables … … 406 422 ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary 407 423 ,Bool bIndependentTileBoundaryEnabled ); 424 425 #if H_3D_DIM 426 Pel* getDimDeltaDC ( UInt dimType, UInt segId ) { return m_dimDeltaDC[dimType][segId]; } 427 Pel getDimDeltaDC ( UInt dimType, UInt segId, UInt uiIdx ) { return m_dimDeltaDC[dimType][segId][uiIdx]; } 428 Void setDimDeltaDC ( UInt dimType, UInt segId, UInt uiIdx, Pel val ) { m_dimDeltaDC[dimType][segId][uiIdx] = val; } 429 #if H_3D_DIM_DMM 430 UInt* getDmmWedgeTabIdx ( UInt dmmType ) { return m_dmmWedgeTabIdx[dmmType]; } 431 UInt getDmmWedgeTabIdx ( UInt dmmType, UInt uiIdx ) { return m_dmmWedgeTabIdx[dmmType][uiIdx]; } 432 Void setDmmWedgeTabIdx ( UInt dmmType, UInt uiIdx, UInt tabIdx ) { m_dmmWedgeTabIdx[dmmType][uiIdx] = tabIdx; } 433 Void setDmmWedgeTabIdxSubParts ( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth ); 434 435 Int* getDmm2DeltaEnd () { return m_dmm2DeltaEnd; } 436 Int getDmm2DeltaEnd ( UInt uiIdx ) { return m_dmm2DeltaEnd[uiIdx]; } 437 Void setDmm2DeltaEnd ( UInt uiIdx, Int iD ) { m_dmm2DeltaEnd[uiIdx] = iD; } 438 Void setDmm2DeltaEndSubParts ( Int iDelta, UInt uiAbsPartIdx, UInt uiDepth ); 439 440 UInt* getDmm3IntraTabIdx () { return m_dmm3IntraTabIdx; } 441 UInt getDmm3IntraTabIdx ( UInt uiIdx ) { return m_dmm3IntraTabIdx[uiIdx]; } 442 Void setDmm3IntraTabIdx ( UInt uiIdx, UInt uh ) { m_dmm3IntraTabIdx[uiIdx] = uh; } 443 Void setDmm3IntraTabIdxSubParts ( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth ); 444 #endif 445 #if H_3D_DIM_RBC 446 UChar* getEdgeCode( UInt uiIdx ) { return &m_pucEdgeCode[uiIdx * RBC_MAX_EDGE_NUM_PER_4x4]; } 447 448 UChar* getEdgeNumber( ) { return m_pucEdgeNumber; } 449 UChar getEdgeNumber( UInt uiIdx ) { return m_pucEdgeNumber[uiIdx]; } 450 Void setEdgeNumber( UInt uiIdx, UChar val ) { m_pucEdgeNumber[uiIdx] = val; } 451 452 UChar* getEdgeStartPos( ) { return m_pucEdgeStartPos; } 453 UChar getEdgeStartPos( UInt uiIdx ) { return m_pucEdgeStartPos[uiIdx]; } 454 Void setEdgeStartPos( UInt uiIdx, UChar val ) { m_pucEdgeStartPos[uiIdx] = val; } 455 456 Bool* getEdgeLeftFirst( ) { return m_pbEdgeLeftFirst; } 457 Bool getEdgeLeftFirst( UInt uiIdx ) { return m_pbEdgeLeftFirst[uiIdx]; } 458 Void setEdgeLeftFirst( UInt uiIdx, Bool val ) { m_pbEdgeLeftFirst[uiIdx] = val; } 459 460 Bool* getEdgePartition( UInt uiIdx ) { return &m_pbEdgePartition[uiIdx * 16]; } 461 462 Void reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion ); 463 #endif 464 #endif 465 408 466 // ------------------------------------------------------------------------------------------------------------------- 409 467 // member functions for accessing partition information -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TComPrediction.cpp
r446 r459 386 386 } 387 387 388 #if H_3D_DIM 389 Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc ) 390 { 391 assert( iWidth == iHeight ); 392 assert( iWidth >= DIM_MIN_SIZE && iWidth <= DIM_MAX_SIZE ); 393 assert( isDimMode( uiIntraMode ) ); 394 395 UInt dimType = getDimType ( uiIntraMode ); 396 Bool dimDeltaDC = isDimDeltaDC( uiIntraMode ); 397 Bool isDmmMode = (dimType < DMM_NUM_TYPE); 398 Bool isRbcMode = (dimType == RBC_IDX); 399 400 Bool* biSegPattern = NULL; 401 UInt patternStride = 0; 402 403 // get partiton 404 #if H_3D_DIM_DMM 405 TComWedgelet* dmmSegmentation = NULL; 406 if( isDmmMode ) 407 { 408 switch( dimType ) 409 { 410 case( DMM1_IDX ): 411 { 412 dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]); 413 } break; 414 case( DMM2_IDX ): 415 { 416 UInt uiTabIdx = 0; 417 if( bFastEnc ) { uiTabIdx = pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ); } 418 else 419 { 420 uiTabIdx = xPredWedgeFromIntra( pcCU, uiAbsPartIdx, iWidth, iHeight, pcCU->getDmm2DeltaEnd( uiAbsPartIdx ) ); 421 pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, uiAbsPartIdx, (pcCU->getDepth(0) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1)) ); 422 } 423 dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ uiTabIdx ]); 424 } break; 425 case( DMM3_IDX ): 426 { 427 UInt uiTabIdx = 0; 428 if( bFastEnc ) { uiTabIdx = pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ); } 429 else 430 { 431 uiTabIdx = xPredWedgeFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, pcCU->getDmm3IntraTabIdx( uiAbsPartIdx ) ); 432 pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, uiAbsPartIdx, (pcCU->getDepth(0) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1)) ); 433 } 434 dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ uiTabIdx ]); 435 } break; 436 case( DMM4_IDX ): 437 { 438 dmmSegmentation = new TComWedgelet( iWidth, iHeight ); 439 xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation ); 440 } break; 441 default: assert(0); 442 } 443 assert( dmmSegmentation ); 444 biSegPattern = dmmSegmentation->getPattern(); 445 patternStride = dmmSegmentation->getStride (); 446 } 447 #endif 448 #if H_3D_DIM_RBC 449 if( isRbcMode ) 450 { 451 biSegPattern = pcCU->getEdgePartition( uiAbsPartIdx ); 452 patternStride = iWidth; 453 } 454 #endif 455 456 // get predicted partition values 457 assert( biSegPattern ); 458 Int* piMask = NULL; 459 if( isDmmMode ) piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering for DMM 460 else piMask = pcCU->getPattern()->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); 461 assert( piMask ); 462 Int maskStride = 2*iWidth + 1; 463 Int* ptrSrc = piMask+maskStride+1; 464 Pel predDC1 = 0; Pel predDC2 = 0; 465 xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 ); 466 467 // set segment values with deltaDC offsets 468 Pel segDC1 = 0; 469 Pel segDC2 = 0; 470 if( dimDeltaDC ) 471 { 472 Pel deltaDC1 = pcCU->getDimDeltaDC( dimType, 0, uiAbsPartIdx ); 473 Pel deltaDC2 = pcCU->getDimDeltaDC( dimType, 1, uiAbsPartIdx ); 474 #if H_3D_DIM_DMM 475 if( isDmmMode ) 476 { 477 #if H_3D_DIM_DLT 478 segDC1 = GetIdx2DepthValue( GetDepthValue2Idx( predDC1 ) + deltaDC1 ); 479 segDC2 = GetIdx2DepthValue( GetDepthValue2Idx( predDC2 ) + deltaDC2 ); 480 #else 481 segDC1 = ClipY( predDC1 + deltaDC1 ); 482 segDC2 = ClipY( predDC2 + deltaDC2 ); 483 #endif 484 } 485 #endif 486 #if H_3D_DIM_RBC 487 if( isRbcMode ) 488 { 489 xDeltaDCQuantScaleUp( pcCU, deltaDC1 ); 490 xDeltaDCQuantScaleUp( pcCU, deltaDC2 ); 491 segDC1 = ClipY( predDC1 + deltaDC1 ); 492 segDC2 = ClipY( predDC2 + deltaDC2 ); 493 } 494 #endif 495 } 496 else 497 { 498 segDC1 = predDC1; 499 segDC2 = predDC2; 500 } 501 502 // set prediction signal 503 Pel* pDst = piPred; 504 xAssignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 ); 505 506 #if H_3D_DIM_DMM 507 if( dimType == DMM4_IDX ) { dmmSegmentation->destroy(); delete dmmSegmentation; } 508 #endif 509 } 510 #endif 511 388 512 /** Function for checking identical motion. 389 513 * \param TComDataCU* pcCU … … 758 882 return; 759 883 } 884 885 #if H_3D_DIM 886 Void TComPrediction::xPredBiSegDCs( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ) 887 { 888 Int refDC1, refDC2; 889 const Int iTR = ( patternStride - 1 ) - srcStride; 890 const Int iTM = ( ( patternStride - 1 ) >> 1 ) - srcStride; 891 const Int iLB = ( patternStride - 1 ) * srcStride - 1; 892 const Int iLM = ( ( patternStride - 1 ) >> 1 ) * srcStride - 1; 893 894 Bool bL = ( biSegPattern[0] != biSegPattern[(patternStride-1)*patternStride] ); 895 Bool bT = ( biSegPattern[0] != biSegPattern[(patternStride-1)] ); 896 897 if( bL == bT ) 898 { 899 refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : 1<<( g_bitDepthY - 1 ); 900 refDC2 = ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1; 901 } 902 else 903 { 904 refDC1 = bL ? ptrSrc[iLB] : ptrSrc[iTR]; 905 refDC2 = bL ? ptrSrc[iTM] : ptrSrc[iLM]; 906 } 907 908 predDC1 = biSegPattern[0] ? refDC1 : refDC2; 909 predDC2 = biSegPattern[0] ? refDC2 : refDC1; 910 } 911 912 Void TComPrediction::xAssignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 ) 913 { 914 if( dstStride == patternStride ) 915 { 916 for( UInt k = 0; k < (patternStride * patternStride); k++ ) 917 { 918 if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; } 919 else { ptrDst[k] = valDC1; } 920 } 921 } 922 else 923 { 924 Pel* piTemp = ptrDst; 925 for( UInt uiY = 0; uiY < patternStride; uiY++ ) 926 { 927 for( UInt uiX = 0; uiX < patternStride; uiX++ ) 928 { 929 if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; } 930 else { piTemp[uiX] = valDC1; } 931 } 932 piTemp += dstStride; 933 biSegPattern += patternStride; 934 } 935 } 936 } 937 938 #if H_3D_DIM_DMM 939 UInt TComPrediction::xPredWedgeFromIntra( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd ) 940 { 941 UInt uiThisBlockSize = uiWidth; 942 943 TComDataCU* pcTempCU; 944 UInt uiTempPartIdx; 945 // 1st: try continue above wedgelet 946 pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); 947 if( pcTempCU && isDimMode( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ) ) 948 { 949 UInt dimType = getDimType( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ); 950 if( DMM1_IDX == dimType || DMM2_IDX == dimType || DMM3_IDX == dimType ) 951 { 952 // get offset between current and reference block 953 UInt uiOffsetX = 0, uiOffsetY = 0; 954 xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); 955 956 // get reference wedgelet 957 WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[(pcTempCU->getWidth( uiTempPartIdx )>>((pcTempCU->getPartitionSize( uiTempPartIdx ) == SIZE_NxN) ? 1 : 0))])]; 958 TComWedgelet* pcRefWedgelet = &(pacWedgeList->at( pcTempCU->getDmmWedgeTabIdx( dimType, uiTempPartIdx ) ) ); 959 960 // find wedgelet, if direction is suitable for continue wedge 961 if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) ) 962 { 963 UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; 964 pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd ); 965 return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); 966 } 967 } 968 } 969 970 // 2nd: try continue left wedglelet 971 pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); 972 if( pcTempCU && isDimMode( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ) ) 973 { 974 UInt dimType = getDimType( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ); 975 if( DMM1_IDX == dimType || DMM2_IDX == dimType || DMM3_IDX == dimType ) 976 { 977 // get offset between current and reference block 978 UInt uiOffsetX = 0, uiOffsetY = 0; 979 xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); 980 981 // get reference wedgelet 982 WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[(pcTempCU->getWidth( uiTempPartIdx )>>((pcTempCU->getPartitionSize( uiTempPartIdx ) == SIZE_NxN) ? 1 : 0))])]; 983 TComWedgelet* pcRefWedgelet = &(pacWedgeList->at( pcTempCU->getDmmWedgeTabIdx( dimType, uiTempPartIdx ) ) ); 984 985 // find wedgelet, if direction is suitable for continue wedge 986 if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) ) 987 { 988 UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; 989 pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd ); 990 return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); 991 } 992 } 993 } 994 995 // 3rd: (default) make wedglet from intra dir and max slope point 996 Int iSlopeX = 0, iSlopeY = 0; 997 UInt uiStartPosX = 0, uiStartPosY = 0; 998 if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) ) 999 { 1000 UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; 1001 xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd ); 1002 return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); 1003 } 1004 1005 return 0; 1006 } 1007 1008 UInt TComPrediction::xPredWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx ) 1009 { 1010 TComPic* pcPicTex = pcCU->getSlice()->getPicLists()->getPic( pcCU->getSlice()->getViewIndex(), false, pcCU->getSlice()->getPOC() ); 1011 assert( pcPicTex != NULL ); 1012 TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); 1013 UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; 1014 Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; 1015 1016 if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) { return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx); } 1017 else { return g_dmmWedgeNodeLists[(g_aucConvertToBit[uiWidth])].at(intraTabIdx).getPatternIdx(); } 1018 } 1019 1020 Void TComPrediction::xPredContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) 1021 { 1022 pcContourWedge->clear(); 1023 1024 // get copy of co-located texture luma block 1025 TComYuv cTempYuv; 1026 cTempYuv.create( uiWidth, uiHeight ); 1027 cTempYuv.clear(); 1028 Pel* piRefBlkY = cTempYuv.getLumaAddr(); 1029 xCopyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); 1030 piRefBlkY = cTempYuv.getLumaAddr(); 1031 1032 // find contour for texture luma block 1033 UInt iDC = 0; 1034 for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) 1035 { 1036 iDC += piRefBlkY[k]; 1037 } 1038 iDC /= (uiWidth*uiHeight); 1039 piRefBlkY = cTempYuv.getLumaAddr(); 1040 1041 Bool* pabContourPattern = pcContourWedge->getPattern(); 1042 for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) 1043 { 1044 pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; 1045 } 1046 1047 cTempYuv.destroy(); 1048 } 1049 1050 1051 Void TComPrediction::xCopyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) 1052 { 1053 TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getPicLists()->getPic( pcCU->getSlice()->getViewIndex(), false, pcCU->getSlice()->getPOC() )->getPicYuvRec(); 1054 assert( pcPicYuvRef != NULL ); 1055 Int iRefStride = pcPicYuvRef->getStride(); 1056 Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx ); 1057 1058 for ( Int y = 0; y < uiHeight; y++ ) 1059 { 1060 ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); 1061 piDestBlockY += uiWidth; 1062 piRefY += iRefStride; 1063 } 1064 } 1065 1066 Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ) 1067 { 1068 ruiOffsetX = 0; 1069 ruiOffsetY = 0; 1070 1071 // get offset between current and above/left block 1072 UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1073 UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1074 1075 UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart(); 1076 UInt uiMaxDepthRefCU = 0; 1077 while( uiNumPartInRefCU > 1 ) 1078 { 1079 uiNumPartInRefCU >>= 2; 1080 uiMaxDepthRefCU++; 1081 } 1082 1083 UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1); 1084 UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2; 1085 UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts; 1086 1087 UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; 1088 UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; 1089 1090 if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); } 1091 if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); } 1092 } 1093 1094 Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ) 1095 { 1096 riSlopeX = 0, riSlopeY = 0, ruiStartPosX = 0, ruiStartPosY = 0; 1097 1098 // 1st step: get wedge start point (max. slope) 1099 Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt ); 1100 Int iSourceStride = ( uiBlockSize<<1 ) + 1; 1101 1102 UInt uiSlopeMaxAbove = 0, uiPosSlopeMaxAbove = 0; 1103 for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ ) 1104 { 1105 if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove ) 1106 { 1107 uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] ); 1108 uiPosSlopeMaxAbove = uiPosHor; 1109 } 1110 } 1111 1112 UInt uiSlopeMaxLeft = 0, uiPosSlopeMaxLeft = 0; 1113 for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ ) 1114 { 1115 if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft ) 1116 { 1117 uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ); 1118 uiPosSlopeMaxLeft = uiPosVer; 1119 } 1120 } 1121 1122 if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 ) 1123 { 1124 return false; 1125 } 1126 1127 ruiStartPosX = ( uiSlopeMaxAbove > uiSlopeMaxLeft ) ? uiPosSlopeMaxAbove : 0; 1128 ruiStartPosY = ( uiSlopeMaxLeft >= uiSlopeMaxAbove ) ? uiPosSlopeMaxLeft : 0; 1129 1130 // 2nd step: derive wedge direction 1131 Int uiPreds[3] = {-1, -1, -1}; 1132 Int iMode = -1; 1133 Int iPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds, &iMode ); 1134 1135 UInt uiDirMode = 0; 1136 if( iMode >= 0 ) { iPredNum = iMode; } 1137 if( iPredNum == 1 ) { uiDirMode = uiPreds[0]; } 1138 if( iPredNum == 2 ) { uiDirMode = uiPreds[1]; } 1139 1140 if( uiDirMode < 2 ) { return false; } // no planar & DC 1141 1142 Bool modeHor = (uiDirMode < 18); 1143 Bool modeVer = !modeHor; 1144 Int intraPredAngle = modeVer ? (Int)uiDirMode - VER_IDX : modeHor ? -((Int)uiDirMode - HOR_IDX) : 0; 1145 Int absAng = abs(intraPredAngle); 1146 Int signAng = intraPredAngle < 0 ? -1 : 1; 1147 Int angTable[9] = {0,2,5,9,13,17,21,26,32}; 1148 absAng = angTable[absAng]; 1149 intraPredAngle = signAng * absAng; 1150 1151 // 3rd step: set slope for direction 1152 if( modeHor ) 1153 { 1154 riSlopeX = ( intraPredAngle > 0 ) ? -32 : 32; 1155 riSlopeY = ( intraPredAngle > 0 ) ? intraPredAngle : -intraPredAngle; 1156 } 1157 else if( modeVer ) 1158 { 1159 riSlopeX = ( intraPredAngle > 0 ) ? intraPredAngle : -intraPredAngle; 1160 riSlopeY = ( intraPredAngle > 0 ) ? -32 : 32; 1161 } 1162 1163 return true; 1164 } 1165 1166 Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd ) 1167 { 1168 ruhXs = 0; 1169 ruhYs = 0; 1170 ruhXe = 0; 1171 ruhYe = 0; 1172 1173 // scaling of start pos and block size to wedge resolution 1174 UInt uiScaledStartPosX = 0; 1175 UInt uiScaledStartPosY = 0; 1176 UInt uiScaledBlockSize = 0; 1177 WedgeResolution eWedgeRes = g_dmmWedgeResolution[(UInt)g_aucConvertToBit[uiBlockSize]]; 1178 switch( eWedgeRes ) 1179 { 1180 case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; } 1181 case( FULL_PEL ): { uiScaledStartPosX = uiPMSPosX; uiScaledStartPosY = uiPMSPosY; uiScaledBlockSize = uiBlockSize; break; } 1182 case( HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; } 1183 } 1184 Int iMaxPos = (Int)uiScaledBlockSize - 1; 1185 1186 // case above 1187 if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 ) 1188 { 1189 ruhXs = (UChar)uiScaledStartPosX; 1190 ruhYs = 0; 1191 1192 if( iDeltaY == 0 ) 1193 { 1194 if( iDeltaX < 0 ) 1195 { 1196 ruhXe = 0; 1197 ruhYe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); 1198 return; 1199 } 1200 else 1201 { 1202 ruhXe = (UChar)iMaxPos; 1203 ruhYe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); 1204 std::swap( ruhXs, ruhXe ); 1205 std::swap( ruhYs, ruhYe ); 1206 return; 1207 } 1208 } 1209 1210 // regular case 1211 Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); 1212 1213 if( iVirtualEndX < 0 ) 1214 { 1215 Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd; 1216 if( iYe < (Int)uiScaledBlockSize ) 1217 { 1218 ruhXe = 0; 1219 ruhYe = (UChar)std::max( iYe, 0 ); 1220 return; 1221 } 1222 else 1223 { 1224 ruhXe = (UChar)std::min( (iYe - iMaxPos), iMaxPos ); 1225 ruhYe = (UChar)iMaxPos; 1226 return; 1227 } 1228 } 1229 else if( iVirtualEndX > iMaxPos ) 1230 { 1231 Int iYe = roftoi( (Double)(iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; 1232 if( iYe < (Int)uiScaledBlockSize ) 1233 { 1234 ruhXe = (UChar)iMaxPos; 1235 ruhYe = (UChar)std::max( iYe, 0 ); 1236 std::swap( ruhXs, ruhXe ); 1237 std::swap( ruhYs, ruhYe ); 1238 return; 1239 } 1240 else 1241 { 1242 ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); 1243 ruhYe = (UChar)iMaxPos; 1244 return; 1245 } 1246 } 1247 else 1248 { 1249 Int iXe = iVirtualEndX + iDeltaEnd; 1250 if( iXe < 0 ) 1251 { 1252 ruhXe = 0; 1253 ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); 1254 return; 1255 } 1256 else if( iXe > iMaxPos ) 1257 { 1258 ruhXe = (UChar)iMaxPos; 1259 ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); 1260 std::swap( ruhXs, ruhXe ); 1261 std::swap( ruhYs, ruhYe ); 1262 return; 1263 } 1264 else 1265 { 1266 ruhXe = (UChar)iXe; 1267 ruhYe = (UChar)iMaxPos; 1268 return; 1269 } 1270 } 1271 } 1272 1273 // case left 1274 if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 ) 1275 { 1276 ruhXs = 0; 1277 ruhYs = (UChar)uiScaledStartPosY; 1278 1279 if( iDeltaX == 0 ) 1280 { 1281 if( iDeltaY < 0 ) 1282 { 1283 ruhXe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); 1284 ruhYe = 0; 1285 std::swap( ruhXs, ruhXe ); 1286 std::swap( ruhYs, ruhYe ); 1287 return; 1288 } 1289 else 1290 { 1291 ruhXe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); 1292 ruhYe = (UChar)iMaxPos; 1293 return; 1294 } 1295 } 1296 1297 // regular case 1298 Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iMaxPos * ((Double)iDeltaY / (Double)iDeltaX) ); 1299 1300 if( iVirtualEndY < 0 ) 1301 { 1302 Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd; 1303 if( iXe < (Int)uiScaledBlockSize ) 1304 { 1305 ruhXe = (UChar)std::max( iXe, 0 ); 1306 ruhYe = 0; 1307 std::swap( ruhXs, ruhXe ); 1308 std::swap( ruhYs, ruhYe ); 1309 return; 1310 } 1311 else 1312 { 1313 ruhXe = (UChar)iMaxPos; 1314 ruhYe = (UChar)std::min( (iXe - iMaxPos), iMaxPos ); 1315 std::swap( ruhXs, ruhXe ); 1316 std::swap( ruhYs, ruhYe ); 1317 return; 1318 } 1319 } 1320 else if( iVirtualEndY > (uiScaledBlockSize-1) ) 1321 { 1322 Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd; 1323 if( iXe < (Int)uiScaledBlockSize ) 1324 { 1325 ruhXe = (UChar)std::max( iXe, 0 ); 1326 ruhYe = (UChar)(uiScaledBlockSize-1); 1327 return; 1328 } 1329 else 1330 { 1331 ruhXe = (UChar)iMaxPos; 1332 ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); 1333 std::swap( ruhXs, ruhXe ); 1334 std::swap( ruhYs, ruhYe ); 1335 return; 1336 } 1337 } 1338 else 1339 { 1340 Int iYe = iVirtualEndY - iDeltaEnd; 1341 if( iYe < 0 ) 1342 { 1343 ruhXe = (UChar)std::max( (iMaxPos + iYe), 0 ); 1344 ruhYe = 0; 1345 std::swap( ruhXs, ruhXe ); 1346 std::swap( ruhYs, ruhYe ); 1347 return; 1348 } 1349 else if( iYe > iMaxPos ) 1350 { 1351 ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); 1352 ruhYe = (UChar)iMaxPos; 1353 return; 1354 } 1355 else 1356 { 1357 ruhXe = (UChar)iMaxPos; 1358 ruhYe = (UChar)iYe; 1359 std::swap( ruhXs, ruhXe ); 1360 std::swap( ruhYs, ruhYe ); 1361 return; 1362 } 1363 } 1364 } 1365 1366 // case origin 1367 if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 ) 1368 { 1369 if( iDeltaX*iDeltaY < 0 ) 1370 { 1371 return; 1372 } 1373 1374 ruhXs = 0; 1375 ruhYs = 0; 1376 1377 if( iDeltaY == 0 ) 1378 { 1379 ruhXe = (UChar)iMaxPos; 1380 ruhYe = 0; 1381 std::swap( ruhXs, ruhXe ); 1382 std::swap( ruhYs, ruhYe ); 1383 return; 1384 } 1385 1386 if( iDeltaX == 0 ) 1387 { 1388 ruhXe = 0; 1389 ruhYe = (UChar)iMaxPos; 1390 return; 1391 } 1392 1393 Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); 1394 1395 if( iVirtualEndX > iMaxPos ) 1396 { 1397 Int iYe = roftoi( (Double)((Int)iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; 1398 if( iYe < (Int)uiScaledBlockSize ) 1399 { 1400 ruhXe = (UChar)(uiScaledBlockSize-1); 1401 ruhYe = (UChar)std::max( iYe, 0 ); 1402 std::swap( ruhXs, ruhXe ); 1403 std::swap( ruhYs, ruhYe ); 1404 return; 1405 } 1406 else 1407 { 1408 ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); 1409 ruhYe = (UChar)(uiScaledBlockSize-1); 1410 return; 1411 } 1412 } 1413 else 1414 { 1415 Int iXe = iVirtualEndX + iDeltaEnd; 1416 if( iXe < 0 ) 1417 { 1418 ruhXe = 0; 1419 ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); 1420 return; 1421 } 1422 else if( iXe > iMaxPos ) 1423 { 1424 ruhXe = (UChar)(uiScaledBlockSize-1); 1425 ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); 1426 std::swap( ruhXs, ruhXe ); 1427 std::swap( ruhYs, ruhYe ); 1428 return; 1429 } 1430 else 1431 { 1432 ruhXe = (UChar)iXe; 1433 ruhYe = (UChar)(uiScaledBlockSize-1); 1434 return; 1435 } 1436 } 1437 } 1438 } 1439 1440 UInt TComPrediction::xGetWedgePatternIdx( UInt uiBlockSize, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ) 1441 { 1442 WedgeRefList* pcWedgeRefList = &g_dmmWedgeRefLists[(g_aucConvertToBit[uiBlockSize])]; 1443 for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ ) 1444 { 1445 TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx)); 1446 if( pcTestWedgeRef->getStartX() == uhXs && pcTestWedgeRef->getStartY() == uhYs && pcTestWedgeRef->getEndX() == uhXe && pcTestWedgeRef->getEndY() == uhYe ) 1447 { 1448 return pcTestWedgeRef->getRefIdx(); 1449 } 1450 } 1451 return 0; 1452 } 1453 #endif 1454 #if H_3D_DIM_RBC 1455 Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Pel& rDeltaDC ) 1456 { 1457 Int iSign = rDeltaDC < 0 ? -1 : 1; 1458 UInt uiAbs = abs( rDeltaDC ); 1459 1460 Int iQp = pcCU->getQP(0); 1461 Double dMax = (Double)( 1<<( g_bitDepthY - 1 ) ); 1462 Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 - 2.0 ) ); 1463 1464 rDeltaDC = iSign * roftoi( uiAbs * dStepSize ); 1465 return; 1466 } 1467 1468 Void TComPrediction::xDeltaDCQuantScaleDown( TComDataCU* pcCU, Pel& rDeltaDC ) 1469 { 1470 Int iSign = rDeltaDC < 0 ? -1 : 1; 1471 UInt uiAbs = abs( rDeltaDC ); 1472 1473 Int iQp = pcCU->getQP(0); 1474 Double dMax = (Double)( 1<<( g_bitDepthY - 1 ) ); 1475 Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 - 2.0 ) ); 1476 1477 rDeltaDC = iSign * roftoi( uiAbs / dStepSize ); 1478 return; 1479 } 1480 #endif 1481 #endif 760 1482 //! \} -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TComPrediction.h
r324 r459 88 88 Bool xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr); 89 89 90 #if H_3D_DIM 91 // depth intra functions 92 Void xPredBiSegDCs ( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ); 93 Void xAssignBiSegDCs ( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 ); 94 #if H_3D_DIM_DMM 95 UInt xPredWedgeFromIntra ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd = 0 ); 96 UInt xPredWedgeFromTex ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx ); 97 Void xPredContourFromTex ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ); 98 99 Void xCopyTextureLumaBlock ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ); 100 101 Void xGetBlockOffset ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ); 102 Bool xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ); 103 Void xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd = 0 ); 104 UInt xGetWedgePatternIdx ( UInt uiBlockSize, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ); 105 #endif 106 #if H_3D_DIM_RBC 107 Void xDeltaDCQuantScaleUp ( TComDataCU* pcCU, Pel& rDeltaDC ); 108 Void xDeltaDCQuantScaleDown ( TComDataCU* pcCU, Pel& rDeltaDC ); 109 #endif 110 #endif 111 90 112 public: 91 113 TComPrediction(); … … 104 126 Void predIntraChromaAng ( Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ); 105 127 128 #if H_3D_DIM 129 // Depth intra 130 Void predIntraLumaDepth ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc = false ); 131 #endif 132 106 133 Pel predIntraGetPredValDC ( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ); 107 134 -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TComRom.cpp
r446 r459 82 82 delete[] g_auiSigLastScan[2][i]; 83 83 } 84 85 #if H_3D_DIM_DMM 86 if( !g_dmmWedgeLists.empty() ) 87 { 88 for( UInt ui = 0; ui < g_dmmWedgeLists.size(); ui++ ) { g_dmmWedgeLists[ui].clear(); } 89 g_dmmWedgeLists.clear(); 90 } 91 if( !g_dmmWedgeRefLists.empty() ) 92 { 93 for( UInt ui = 0; ui < g_dmmWedgeRefLists.size(); ui++ ) { g_dmmWedgeRefLists[ui].clear(); } 94 g_dmmWedgeRefLists.clear(); 95 } 96 97 if( !g_dmmWedgeNodeLists.empty() ) 98 { 99 for( UInt ui = 0; ui < g_dmmWedgeNodeLists.size(); ui++ ) { g_dmmWedgeNodeLists[ui].clear(); } 100 g_dmmWedgeNodeLists.clear(); 101 } 102 #endif 84 103 } 85 104 … … 312 331 313 332 // ==================================================================================================================== 333 // Depth coding modes 334 // ==================================================================================================================== 335 #if H_3D_DIM_DMM 336 const WedgeResolution g_dmmWedgeResolution[6] = 337 { 338 HALF_PEL, // 4x4 339 HALF_PEL, // 8x8 340 FULL_PEL, // 16x16 341 DOUBLE_PEL, // 32x32 342 DOUBLE_PEL, // 64x64 343 DOUBLE_PEL // 128x128 344 }; 345 346 const UChar g_dmm1TabIdxBits[6] = 347 { //2x2 4x4 8x8 16x16 32x32 64x64 348 0, 7, 10, 11, 11, 13 }; 349 const UChar g_dmm3IntraTabIdxBits[6] = 350 { //2x2 4x4 8x8 16x16 32x32 64x64 351 0, 6, 9, 9, 9, 0 }; 352 353 extern std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; 354 extern std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; 355 extern std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; 356 #endif 357 358 // ==================================================================================================================== 314 359 // Misc. 315 360 // ==================================================================================================================== … … 518 563 Int g_eTTable[4] = {0,3,1,2}; 519 564 565 #if H_3D_DIM_DMM 566 std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; 567 std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; 568 std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; 569 std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3; 570 571 Void initWedgeLists( Bool initRefinements ) 572 { 573 if( !g_dmmWedgeLists.empty() ) return; 574 575 for( UInt ui = g_aucConvertToBit[DIM_MIN_SIZE]; ui < (g_aucConvertToBit[DIM_MAX_SIZE]+1); ui++ ) 576 { 577 UInt uiWedgeBlockSize = ((UInt)DIM_MIN_SIZE)<<ui; 578 std::vector<TComWedgelet> acWedgeList; 579 std::vector<TComWedgeRef> acWedgeRefList; 580 createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_dmmWedgeResolution[ui] ); 581 g_dmmWedgeLists.push_back( acWedgeList ); 582 g_dmmWedgeRefLists.push_back( acWedgeRefList ); 583 584 // create WedgeNodeList 585 std::vector<TComWedgeNode> acWedgeNodeList; 586 for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ ) 587 { 588 if( acWedgeList[uiPos].getIsCoarse() ) 589 { 590 TComWedgeNode cWedgeNode; 591 cWedgeNode.setPatternIdx( uiPos ); 592 593 if( initRefinements ) 594 { 595 UInt uiRefPos = 0; 596 for( Int iOffS = -1; iOffS <= 1; iOffS++ ) 597 { 598 for( Int iOffE = -1; iOffE <= 1; iOffE++ ) 599 { 600 if( iOffS == 0 && iOffE == 0 ) { continue; } 601 602 Int iSx = (Int)acWedgeList[uiPos].getStartX(); 603 Int iSy = (Int)acWedgeList[uiPos].getStartY(); 604 Int iEx = (Int)acWedgeList[uiPos].getEndX(); 605 Int iEy = (Int)acWedgeList[uiPos].getEndY(); 606 607 switch( acWedgeList[uiPos].getOri() ) 608 { 609 case( 0 ): { iSx += iOffS; iEy += iOffE; } break; 610 case( 1 ): { iSy += iOffS; iEx -= iOffE; } break; 611 case( 2 ): { iSx -= iOffS; iEy -= iOffE; } break; 612 case( 3 ): { iSy -= iOffS; iEx += iOffE; } break; 613 case( 4 ): { iSx += iOffS; iEx += iOffE; } break; 614 case( 5 ): { iSy += iOffS; iEy += iOffE; } break; 615 default: assert( 0 ); 616 } 617 618 for( UInt k = 0; k < acWedgeRefList.size(); k++ ) 619 { 620 if( iSx == (Int)acWedgeRefList[k].getStartX() && 621 iSy == (Int)acWedgeRefList[k].getStartY() && 622 iEx == (Int)acWedgeRefList[k].getEndX() && 623 iEy == (Int)acWedgeRefList[k].getEndY() ) 624 { 625 if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() ) 626 { 627 Bool bNew = true; 628 for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } } 629 630 if( bNew ) 631 { 632 cWedgeNode.setRefineIdx( acWedgeRefList[k].getRefIdx(), uiRefPos ); 633 uiRefPos++; 634 break; 635 } 636 } 637 } 638 } 639 } 640 } 641 } 642 acWedgeNodeList.push_back( cWedgeNode ); 643 } 644 } 645 g_dmmWedgeNodeLists.push_back( acWedgeNodeList ); 646 } 647 return; 648 } 649 650 Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes ) 651 { 652 assert( uiWidth == uiHeight ); 653 654 UChar uhStartX = 0, uhStartY = 0, uhEndX = 0, uhEndY = 0; 655 Int iStepStartX = 0, iStepStartY = 0, iStepEndX = 0, iStepEndY = 0; 656 657 UInt uiBlockSize = 0; 658 switch( eWedgeRes ) 659 { 660 case( DOUBLE_PEL ): { uiBlockSize = (uiWidth>>1); break; } 661 case( FULL_PEL ): { uiBlockSize = uiWidth; break; } 662 case( HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; } 663 } 664 665 TComWedgelet cTempWedgelet( uiWidth, uiHeight ); 666 for( UInt uiOri = 0; uiOri < 6; uiOri++ ) 667 { 668 // init the edge line parameters for each of the 6 wedgelet types 669 switch( uiOri ) 670 { 671 case( 0 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = +1; iStepStartY = 0; iStepEndX = 0; iStepEndY = +1; break; } 672 case( 1 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = (uiBlockSize-1); uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = -1; iStepEndY = 0; break; } 673 case( 2 ): { uhStartX = (uiBlockSize-1); uhStartY = (uiBlockSize-1); uhEndX = (uiBlockSize-1); uhEndY = (uiBlockSize-1); iStepStartX = -1; iStepStartY = 0; iStepEndX = 0; iStepEndY = -1; break; } 674 case( 3 ): { uhStartX = 0; uhStartY = (uiBlockSize-1); uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = 0; iStepStartY = -1; iStepEndX = +1; iStepEndY = 0; break; } 675 case( 4 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = +1; iStepStartY = 0; iStepEndX = +1; iStepEndY = 0; break; } 676 case( 5 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = 0; iStepEndY = +1; break; } 677 } 678 679 for( Int iK = 0; iK < uiBlockSize; iK++ ) 680 { 681 for( Int iL = 0; iL < uiBlockSize; iL++ ) 682 { 683 cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes, ((iL%2)==0 && (iK%2)==0) ); 684 addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList ); 685 } 686 } 687 } 688 689 UInt uiThrSz = DMM3_SIMPLIFY_TR; 690 std::vector< std::vector<UInt> > auiWdgListSz; 691 for( Int idxM=2; idxM<=34 ; idxM++) 692 { 693 std::vector<UInt> auiWdgList; 694 for( Int idxW=0; idxW<racWedgeList.size(); idxW++) 695 { 696 UInt uiAbsDiff = abs(idxM-(Int)racWedgeList[idxW].getAng()); 697 if( uiAbsDiff <= uiThrSz ) 698 { 699 auiWdgList.push_back(idxW); 700 } 701 } 702 auiWdgListSz.push_back(auiWdgList); 703 } 704 g_aauiWdgLstM3.push_back(auiWdgListSz); 705 } 706 707 Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList ) 708 { 709 Bool bValid = cWedgelet.checkNotPlain(); 710 if( bValid ) 711 { 712 for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) 713 { 714 if( cWedgelet.checkIdentical( racWedgeList[uiPos].getPattern() ) ) 715 { 716 TComWedgeRef cWedgeRef; 717 cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); 718 racWedgeRefList.push_back( cWedgeRef ); 719 bValid = false; 720 return; 721 } 722 } 723 } 724 if( bValid ) 725 { 726 for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) 727 { 728 if( cWedgelet.checkInvIdentical( racWedgeList[uiPos].getPattern() ) ) 729 { 730 TComWedgeRef cWedgeRef; 731 cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); 732 racWedgeRefList.push_back( cWedgeRef ); 733 bValid = false; 734 return; 735 } 736 } 737 } 738 if( bValid ) 739 { 740 cWedgelet.findClosestAngle(); 741 racWedgeList.push_back( cWedgelet ); 742 TComWedgeRef cWedgeRef; 743 cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), (UInt)(racWedgeList.size()-1) ); 744 racWedgeRefList.push_back( cWedgeRef ); 745 } 746 } 747 #endif //H_3D_DIM_DMM 520 748 //! \} -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TComRom.h
r324 r459 44 44 #include<iostream> 45 45 46 #if H_3D_DIM 47 #include "TComWedgelet.h" 48 #endif 49 46 50 //! \ingroup TLibCommon 47 51 //! \{ … … 147 151 148 152 extern const UChar g_aucConvertTxtTypeToIdx[4]; 153 154 #if H_3D_DIM 155 // ==================================================================================================================== 156 // Depth coding modes 157 // ==================================================================================================================== 158 __inline Void mapDepthModeToIntraDir( UInt& intraMode ) { if( isDimMode( intraMode ) ) intraMode = DC_IDX; } 159 __inline Void mapDepthModeToIntraDir( Int& intraMode ) { if( isDimMode( intraMode ) ) intraMode = DC_IDX; } 160 161 #if H_3D_DIM_DMM 162 extern const WedgeResolution g_dmmWedgeResolution [6]; 163 extern const UChar g_dmm1TabIdxBits [6]; 164 extern const UChar g_dmm3IntraTabIdxBits[6]; 165 166 extern std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; 167 extern std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; 168 extern std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; 169 extern std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3; 170 171 Void initWedgeLists( Bool initRefinements = false ); 172 Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes ); 173 Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList ); 174 #endif 175 #endif 149 176 150 177 // ========================================== -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TComSlice.cpp
r446 r459 73 73 , m_pcPPS ( NULL ) 74 74 , m_pcPic ( NULL ) 75 #if H_3D 76 , m_picLists ( NULL ) 77 #endif 75 78 , m_colFromL0Flag ( 1 ) 76 79 , m_colRefIdx ( 0 ) … … 913 916 914 917 m_pcPic = pSrc->m_pcPic; 915 918 #if H_3D 919 m_picLists = pSrc->m_picLists; 920 #endif 916 921 m_colFromL0Flag = pSrc->m_colFromL0Flag; 917 922 m_colRefIdx = pSrc->m_colRefIdx; … … 1474 1479 #if H_3D 1475 1480 m_viewIndex [i] = -1; 1481 m_vpsDepthModesFlag [i] = false; 1476 1482 #endif 1477 1483 -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TComSlice.h
r446 r459 524 524 #if H_3D 525 525 Int m_viewIndex [MAX_NUM_LAYERS ]; 526 Bool m_vpsDepthModesFlag [MAX_NUM_LAYERS ]; 526 527 #endif 527 528 … … 642 643 Int getDepthId ( Int layerIdInVps ) { return getScalabilityId( layerIdInVps, DEPTH_ID ); } 643 644 Int getLayerIdInNuh( Int viewIndex, Bool depthFlag ); 645 646 Void setVpsDepthModesFlag( Int layerIdInVps, Bool val ) { m_vpsDepthModesFlag[ layerIdInVps ] = val; } 647 Bool getVpsDepthModesFlag( Int layerIdInVps ) { return m_vpsDepthModesFlag[ layerIdInVps ]; } 644 648 #endif 645 649 … … 1424 1428 TComPPS* m_pcPPS; 1425 1429 TComPic* m_pcPic; 1430 #if H_3D 1431 TComPicLists* m_picLists; 1432 #endif 1426 1433 #if ADAPTIVE_QP_SELECTION 1427 1434 TComTrQuant* m_pcTrQuant; … … 1542 1549 Int getNumRefIdx ( RefPicList e ) { return m_aiNumRefIdx[e]; } 1543 1550 TComPic* getPic () { return m_pcPic; } 1551 #if H_3D 1552 TComPicLists* getPicLists () { return m_picLists; } 1553 #endif 1544 1554 TComPic* getRefPic ( RefPicList e, Int iRefIdx) { return m_apcRefPicList[e][iRefIdx]; } 1545 1555 Int getRefPOC ( RefPicList e, Int iRefIdx) { return m_aiRefPOCList[e][iRefIdx]; } … … 1596 1606 Void setNumRefIdx ( RefPicList e, Int i ) { m_aiNumRefIdx[e] = i; } 1597 1607 Void setPic ( TComPic* p ) { m_pcPic = p; } 1608 #if H_3D 1609 Void setPicLists ( TComPicLists* p ) { m_picLists = p; } 1610 #endif 1598 1611 Void setDepth ( Int iDepth ) { m_iDepth = iDepth; } 1599 1612 … … 1756 1769 Int* getInvCodedScale () { return m_aaiCodedScale [1]; } 1757 1770 Int* getInvCodedOffset () { return m_aaiCodedOffset[1]; } 1771 1772 Bool getVpsDepthModesFlag () { return getVPS()->getVpsDepthModesFlag( getVPS()->getLayerIdInVps( m_layerId ) ); } 1758 1773 #endif 1759 1774 #endif -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibCommon/TypeDef.h
r446 r459 78 78 // SAIT_VSO_EST_A0033, JCT3V-A0033 modification 3 79 79 // LGE_WVSO_A0119 80 #define H_3D_DIM 1 // DIM, Depth intra modes, includes: 81 // HHI_DMM_WEDGE_INTRA 82 // HHI_DMM_PRED_TEX 83 // FIX_WEDGE_NOFLOAT_D0036 84 // LGE_EDGE_INTRA_A0070 85 // LGE_DMM3_SIMP_C0044 86 // QC_DC_PREDICTOR_D0183 87 // HHI_DELTADC_DLT_D0035 88 // PKU_QC_DEPTH_INTRA_UNI_D0195 89 // ... [PM: add SDC and DLT related] 80 90 #endif 81 91 … … 91 101 #define H_3D_VSO_RM_ASSERTIONS 0 // Output VSO assertions 92 102 #define H_3D_VSO_SYNTH_DIST_OUT 0 // Output of synthesized view distortion instead of depth distortion in encoder output 103 #endif 104 105 ///// ***** DEPTH INTRA MODES ********* 106 #if H_3D_DIM 107 #define H_3D_DIM_DMM 1 // Depth Modeling Modes 108 #define H_3D_DIM_RBC 1 // Region Boundary Chain mode 109 #define H_3D_DIM_SDC 0 // Simplified Depth Coding method 110 #define H_3D_DIM_DLT 0 // Depth Lookup Table 93 111 #endif 94 112 -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibDecoder/TDecCAVLC.cpp
r446 r459 953 953 if (uiCode) 954 954 { 955 #if H_3D 956 m_pcBitstream->readOutTrailingBits(); 957 958 for( Int i = 0; i <= pcVPS->getMaxLayers() - 1; i++ ) 959 { 960 if( pcVPS->getDepthId( i ) ) 961 { 962 READ_FLAG( uiCode, "vps_depth_modes_flag[i]" ); pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false ); 963 } 964 } 965 #else 955 966 while ( xMoreRbspData() ) 956 967 { 957 968 READ_FLAG( uiCode, "vps_extension2_data_flag"); 958 969 } 970 #endif 959 971 } 960 972 -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibDecoder/TDecCu.cpp
r324 r459 468 468 469 469 //===== get prediction signal ===== 470 #if H_3D_DIM 471 if( isDimMode( uiLumaPredMode ) ) 472 { 473 m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight ); 474 } 475 else 476 { 477 #endif 470 478 m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 479 #if H_3D_DIM 480 } 481 #endif 471 482 472 483 //===== inverse transform ===== … … 556 567 { 557 568 uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); 569 #if H_3D_DIM 570 mapDepthModeToIntraDir( uiChromaPredMode ); 571 #endif 558 572 } 559 573 m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibDecoder/TDecSbac.cpp
r324 r459 77 77 , m_cTransformSkipSCModel ( 1, 2, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 78 78 , m_CUTransquantBypassFlagSCModel( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels) 79 #if H_3D_DIM 80 , m_cDepthIntraModeSCModel ( 1, 1, NUM_DEPTH_INTRA_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 81 , m_cDdcFlagSCModel ( 1, 1, NUM_DDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 82 , m_cDdcDataSCModel ( 1, 1, NUM_DDC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 83 #if H_3D_DIM_DMM 84 , m_cDmm1DataSCModel ( 1, 1, NUM_DMM1_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 85 , m_cDmm2DataSCModel ( 1, 1, NUM_DMM2_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 86 , m_cDmm3DataSCModel ( 1, 1, NUM_DMM3_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 87 #endif 88 #if H_3D_DIM_RBC 89 , m_cRbcDataSCModel ( 1, 1, NUM_RBC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 90 #endif 91 #endif 79 92 { 80 93 assert( m_numContextModels <= MAX_NUM_CTX_MOD ); … … 137 150 m_cTransformSkipSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); 138 151 m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); 152 153 #if H_3D_DIM 154 m_cDepthIntraModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE ); 155 m_cDdcFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_FLAG ); 156 m_cDdcDataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DDC_DATA ); 157 #if H_3D_DIM_DMM 158 m_cDmm1DataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM1_DATA ); 159 m_cDmm2DataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM2_DATA ); 160 m_cDmm3DataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DMM3_DATA ); 161 #endif 162 #if H_3D_DIM_RBC 163 m_cRbcDataSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_RBC_DATA ); 164 #endif 165 #endif 166 139 167 m_uiLastDQpNonZero = 0; 140 168 … … 181 209 m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); 182 210 m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); 211 212 #if H_3D_DIM 213 m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE ); 214 m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); 215 m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA ); 216 #if H_3D_DIM_DMM 217 m_cDmm1DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA ); 218 m_cDmm2DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM2_DATA ); 219 m_cDmm3DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA ); 220 #endif 221 #if H_3D_DIM_RBC 222 m_cRbcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_RBC_DATA ); 223 #endif 224 #endif 183 225 m_pcTDecBinIf->start(); 184 226 } … … 297 339 } 298 340 } 341 342 #if H_3D_DIM 343 Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) 344 { 345 UInt uiSymbol; 346 UInt uiCount = 0; 347 do 348 { 349 m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); 350 uiCount++; 351 } 352 while( uiSymbol && ( uiCount != 13 ) ); 353 354 ruiSymbol = uiCount - 1; 355 356 if( uiSymbol ) 357 { 358 xReadEpExGolomb( uiSymbol, 0 ); 359 ruiSymbol += uiSymbol + 1; 360 } 361 362 return; 363 } 364 365 Void TDecSbac::xParseDimDeltaDC( Pel& rValDeltaDC, UInt dimType ) 366 { 367 UInt absValDeltaDC = 0; 368 xReadExGolombLevel( absValDeltaDC, m_cDdcDataSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) ); 369 rValDeltaDC = (Pel)absValDeltaDC; 370 371 if( rValDeltaDC != 0 ) 372 { 373 UInt uiSign; 374 m_pcTDecBinIf->decodeBinEP( uiSign ); 375 if ( uiSign ) 376 { 377 rValDeltaDC = -rValDeltaDC; 378 } 379 } 380 } 381 #if H_3D_DIM_DMM 382 Void TDecSbac::xParseDmm1WedgeIdx( UInt& ruiTabIdx, Int iNumBit ) 383 { 384 UInt uiSymbol, uiIdx = 0; 385 for( Int i = 0; i < iNumBit; i++ ) 386 { 387 m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm1DataSCModel.get(0, 0, 0) ); 388 uiIdx += uiSymbol << i; 389 } 390 ruiTabIdx = uiIdx; 391 } 392 Void TDecSbac::xParseDmm2Offset( Int& riOffset ) 393 { 394 Int iDeltaEnd = 0; 395 if( DMM2_DELTAEND_MAX > 0 ) 396 { 397 UInt uiFlag = 0; 398 m_pcTDecBinIf->decodeBin( uiFlag, m_cDmm2DataSCModel.get(0, 0, 0) ); 399 400 if( uiFlag ) 401 { 402 UInt uiAbsValMinus1; 403 UInt uiSymbol; 404 m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm2DataSCModel.get(0, 0, 0) ); uiAbsValMinus1 = uiSymbol; 405 m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm2DataSCModel.get(0, 0, 0) ); uiAbsValMinus1 |= uiSymbol << 1; 406 iDeltaEnd = uiAbsValMinus1 + 1; 407 UInt uiSign; 408 m_pcTDecBinIf->decodeBinEP( uiSign ); 409 if( uiSign ) 410 { 411 iDeltaEnd = -iDeltaEnd; 412 } 413 } 414 } 415 riOffset = iDeltaEnd; 416 } 417 Void TDecSbac::xParseDmm3WedgeIdx( UInt& ruiIntraIdx, Int iNumBit ) 418 { 419 UInt uiSymbol, uiIdx = 0; 420 for( Int i = 0; i < iNumBit; i++ ) 421 { 422 m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm3DataSCModel.get(0, 0, 0) ); 423 uiIdx += uiSymbol << i; 424 } 425 ruiIntraIdx = uiIdx; 426 } 427 #endif 428 #if H_3D_DIM_RBC 429 Void TDecSbac::xParseRbcEdge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 430 { 431 UInt uiSymbol = 0; 432 433 // 1. Top(0) or Left(1) 434 UChar ucLeft; 435 m_pcTDecBinIf->decodeBinEP( uiSymbol ); 436 ucLeft = uiSymbol; 437 438 // 2. Start position (lowest bit first) 439 UChar ucStart = 0; 440 for( UInt ui = 0; ui < 6 - uiDepth; ui++ ) 441 { 442 m_pcTDecBinIf->decodeBinEP( uiSymbol ); 443 ucStart |= (uiSymbol << ui); 444 } 445 446 // 3. Number of edges 447 UChar ucMax = 0; 448 for( UInt ui = 0; ui < 7 - uiDepth; ui++ ) 449 { 450 m_pcTDecBinIf->decodeBinEP( uiSymbol ); 451 ucMax |= (uiSymbol << ui); 452 } 453 ucMax++; // +1 454 455 // 4. Edges 456 UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * RBC_MAX_EDGE_NUM_PER_4x4 ); 457 for( Int iPtr = 0; iPtr < ucMax; iPtr++ ) 458 { 459 UChar ucEdge = 0; 460 UInt uiReorderEdge = 0; 461 for( UInt ui = 0; ui < 6; ui++ ) 462 { 463 m_pcTDecBinIf->decodeBin( uiSymbol, m_cRbcDataSCModel.get( 0, 0, 0 ) ); 464 ucEdge <<= 1; 465 ucEdge |= uiSymbol; 466 if( uiSymbol == 0 ) 467 break; 468 } 469 470 switch( ucEdge ) 471 { 472 case 0 : // "0" 473 uiReorderEdge = 0; 474 break; 475 case 2 : // "10" 476 uiReorderEdge = 1; 477 break; 478 case 6 : // "110" 479 uiReorderEdge = 2; 480 break; 481 case 14 : // "1110" 482 uiReorderEdge = 3; 483 break; 484 case 30 : // "11110" 485 uiReorderEdge = 4; 486 break; 487 case 62 : // "111110" 488 uiReorderEdge = 5; 489 break; 490 case 63 : // "111111" 491 uiReorderEdge = 6; 492 break; 493 default : 494 printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge); 495 assert(false); 496 break; 497 } 498 pucSymbolList[iPtr] = uiReorderEdge; 499 } 500 ///////////////////// 501 // Edge Reconstruction 502 Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); 503 pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion ); 504 xFree( pucSymbolList ); 505 } 506 #endif 507 #endif 299 508 300 509 /** Parse I_PCM information. … … 619 828 for (j=0;j<partNum;j++) 620 829 { 830 #if H_3D_DIM 831 if( pcCU->getSlice()->getVpsDepthModesFlag() ) 832 { 833 parseIntraDepth( pcCU, absPartIdx+partOffset*j, depth ); 834 } 835 if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) 836 #if H_3D_DIM_SDC 837 if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) ) 838 #endif 839 { 840 #endif 621 841 m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); 622 842 mpmPred[j] = symbol; 843 #if H_3D_DIM 844 } 845 #endif 623 846 } 624 847 for (j=0;j<partNum;j++) 625 848 { 849 #if H_3D_DIM 850 if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) 851 #if H_3D_DIM_SDC 852 if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) ) 853 #endif 854 { 855 #endif 626 856 Int preds[3] = {-1, -1, -1}; 627 857 Int predNum = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds); … … 661 891 } 662 892 pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth ); 893 #if H_3D_DIM 894 } 895 #endif 663 896 } 664 897 } … … 687 920 return; 688 921 } 922 923 #if H_3D_DIM 924 Void TDecSbac::parseIntraDepth( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) 925 { 926 parseIntraDepthMode( pcCU, absPartIdx, depth ); 927 928 UInt dir = pcCU->getLumaIntraDir( absPartIdx ); 929 UInt dimType = getDimType( dir ); 930 931 switch( dimType ) 932 { 933 #if H_3D_DIM_DMM 934 case( DMM1_IDX ): 935 { 936 UInt uiTabIdx = 0; 937 xParseDmm1WedgeIdx( uiTabIdx, g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); 938 pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, absPartIdx, depth ); 939 } break; 940 case( DMM2_IDX ): 941 { 942 Int iOffset = 0; 943 xParseDmm2Offset( iOffset ); 944 pcCU->setDmm2DeltaEndSubParts( iOffset, absPartIdx, depth ); 945 } break; 946 case( DMM3_IDX ): 947 { 948 UInt uiIntraIdx = 0; 949 xParseDmm3WedgeIdx( uiIntraIdx, g_dmm3IntraTabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); 950 pcCU->setDmm3IntraTabIdxSubParts( uiIntraIdx, absPartIdx, depth ); 951 } break; 952 case( DMM4_IDX ): break; 953 #endif 954 #if H_3D_DIM_RBC 955 case( RBC_IDX ): 956 { 957 xParseRbcEdge( pcCU, absPartIdx, depth ); 958 } break; 959 #endif 960 default: break; 961 } 962 963 #if H_3D_DIM_SDC 964 if( pcCU->getSDCAvailable(absPartIdx) && pcCU->getSDCFlag(absPartIdx) ) // sdcFlag 965 { 966 //assert(pcCU->getPartitionSize(uiAbsPartIdx)!=SIZE_NxN); 967 //pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth); 968 //pcCU->setCbfSubParts(1, 1, 1, uiAbsPartIdx, uiDepth); 969 970 //UInt uiNumSegments = ( uiDir == DC_IDX || uiDir == PLANAR_IDX )? 1 : 2; 971 //for (int uiSeg=0; uiSeg<uiNumSegments; uiSeg++) 972 //{ 973 // parseSDCResidualData(pcCU, uiAbsPartIdx, uiDepth, uiSeg); 974 //} 975 } 976 else 977 { 978 #endif 979 if( dimType < DIM_NUM_TYPE ) 980 { 981 UInt symbol; 982 m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) ); 983 if( symbol ) 984 { 985 dir += symbol; 986 for( UInt segment = 0; segment < 2; segment++ ) 987 { 988 Pel valDeltaDC = 0; 989 xParseDimDeltaDC( valDeltaDC, dimType ); 990 pcCU->setDimDeltaDC( dimType, segment, absPartIdx, valDeltaDC ); 991 } 992 } 993 } 994 #if H_3D_DIM_SDC 995 } 996 #endif 997 998 pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth ); 999 } 1000 1001 Void TDecSbac::parseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) 1002 { 1003 UInt puIdx = (pcCU->getWidth(absPartIdx) == 64) ? 2 : ( (pcCU->getPartitionSize(absPartIdx) == SIZE_NxN && pcCU->getWidth(absPartIdx) == 8) ? 0 : 1 ); 1004 UInt dir = 0; 1005 Bool sdcFlag = 0; 1006 UInt symbol = 1; 1007 UInt modeCode = 0 ; 1008 UInt binNum = 0; 1009 UInt ctxDepthMode = 0; 1010 1011 if( puIdx == 2 ) 1012 { 1013 while( binNum < 2 && symbol ) 1014 { 1015 ctxDepthMode = puIdx*3 + binNum; 1016 m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); 1017 modeCode = (modeCode<<1) + symbol; 1018 binNum++; 1019 } 1020 if( modeCode == 0 ) { dir = PLANAR_IDX; sdcFlag = 1;} 1021 else if( modeCode == 2 ) { dir = 0; sdcFlag = 0;} 1022 else if( modeCode == 3 ) { dir = DC_IDX; sdcFlag = 1;} 1023 } 1024 else if( puIdx == 0 ) 1025 { 1026 while( binNum < 3 && symbol ) 1027 { 1028 ctxDepthMode = puIdx*3 + ((binNum >= 2) ? 2 : binNum); 1029 m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); 1030 modeCode = (modeCode<<1) + symbol; 1031 binNum++; 1032 } 1033 if( modeCode == 0 ) { dir = 0; sdcFlag = 0;} 1034 else if( modeCode == 2 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;} 1035 else if( modeCode == 6 ) { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;} 1036 else if( modeCode == 7 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;} 1037 } 1038 else 1039 { 1040 ctxDepthMode = puIdx*3 ; 1041 m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); 1042 modeCode = (modeCode<<1) + symbol; 1043 if( !symbol ) 1044 { 1045 ctxDepthMode = puIdx*3 + 1; 1046 m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); 1047 modeCode = (modeCode<<1) + symbol; 1048 if( symbol ) 1049 { 1050 ctxDepthMode = puIdx*3 + 2; 1051 m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); 1052 modeCode = (modeCode<<1) + symbol; 1053 } 1054 } 1055 else 1056 { 1057 ctxDepthMode = puIdx*3 + 1; 1058 m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); 1059 modeCode = (modeCode<<1) + symbol; 1060 if( !symbol ) 1061 { 1062 ctxDepthMode = puIdx*3 + 2; 1063 m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); 1064 modeCode = (modeCode<<1) + symbol; 1065 } 1066 else 1067 { 1068 binNum = 0; 1069 while( symbol && binNum < 3 ) 1070 { 1071 ctxDepthMode = puIdx*3 + 2; 1072 m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) ); 1073 modeCode = (modeCode<<1) + symbol; 1074 binNum++; 1075 } 1076 } 1077 } 1078 if( modeCode == 0 ) { dir = PLANAR_IDX; sdcFlag = 1;} 1079 else if( modeCode == 2 ) { dir = 5; sdcFlag = 0;} 1080 else if( modeCode == 3 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 1;} 1081 else if( modeCode == 4 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;} 1082 else if( modeCode == 5 ) { dir = (2*DMM4_IDX+DIM_OFFSET); sdcFlag = 0;} 1083 else if( modeCode == 6 ) { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;} 1084 else if( modeCode == 14 ) { dir = DC_IDX; sdcFlag = 1;} 1085 else if( modeCode == 30 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;} 1086 else if( modeCode == 31 ) { dir = (2*DMM2_IDX+DIM_OFFSET); sdcFlag = 0;} 1087 } 1088 pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth ); 1089 #if H_3D_DIM_SDC 1090 pcCU->setSDCFlagSubParts( sdcFlag, absPartIdx, 0, depth ); 1091 #endif 1092 } 1093 #endif 689 1094 690 1095 Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ) -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibDecoder/TDecSbac.h
r446 r459 97 97 Void xReadEpExGolomb ( UInt& ruiSymbol, UInt uiCount ); 98 98 Void xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam ); 99 #if H_3D_DIM 100 Void xReadExGolombLevel ( UInt& ruiSymbol, ContextModel& rcSCModel ); 101 Void xParseDimDeltaDC ( Pel& rValDeltaDC, UInt dimType ); 102 #if H_3D_DIM_DMM 103 Void xParseDmm1WedgeIdx ( UInt& ruiTabIdx, Int iNumBit ); 104 Void xParseDmm2Offset ( Int& riOffset ); 105 Void xParseDmm3WedgeIdx ( UInt& ruiIntraIdx, Int iNumBit ); 106 #endif 107 #if H_3D_DIM_RBC 108 Void xParseRbcEdge ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 109 #endif 110 #endif 99 111 private: 100 112 TComInputBitstream* m_pcBitstream; … … 115 127 Void parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 116 128 129 #if H_3D_DIM 130 Void parseIntraDepth ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ); 131 Void parseIntraDepthMode ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ); 132 #endif 133 117 134 Void parseInterDir ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ); 118 135 Void parseRefFrmIdx ( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ); … … 171 188 ContextModel3DBuffer m_cTransformSkipSCModel; 172 189 ContextModel3DBuffer m_CUTransquantBypassFlagSCModel; 190 191 #if H_3D_DIM 192 ContextModel3DBuffer m_cDepthIntraModeSCModel; 193 ContextModel3DBuffer m_cDdcFlagSCModel; 194 ContextModel3DBuffer m_cDdcDataSCModel; 195 #if H_3D_DIM_DMM 196 ContextModel3DBuffer m_cDmm1DataSCModel; 197 ContextModel3DBuffer m_cDmm2DataSCModel; 198 ContextModel3DBuffer m_cDmm3DataSCModel; 199 #endif 200 #if H_3D_DIM_RBC 201 ContextModel3DBuffer m_cRbcDataSCModel; 202 #endif 203 #endif 173 204 }; 174 205 -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibDecoder/TDecTop.cpp
r446 r459 894 894 895 895 #endif 896 #if H_3D 897 pcSlice->setPicLists( m_ivPicLists ); 898 #endif 896 899 // For generalized B 897 900 // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncCavlc.cpp
r446 r459 741 741 } 742 742 } 743 744 #if H_3D 745 WRITE_FLAG( 1, "vps_extension2_flag" ); 746 747 m_pcBitIf->writeAlignOne(); 748 749 for( Int i = 0; i <= pcVPS->getMaxLayers() - 1; i++ ) 750 { 751 if( pcVPS->getDepthId( i ) ) 752 { 753 WRITE_FLAG( pcVPS->getVpsDepthModesFlag( i ), "vps_depth_modes_flag[i]" ); 754 } 755 } 756 #else 743 757 WRITE_FLAG( 0, "vps_extension2_flag" ); 758 #endif 744 759 #else 745 760 WRITE_FLAG( 0, "vps_extension_flag" ); -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncCfg.h
r446 r459 394 394 Bool m_bUseEstimatedVSD; 395 395 Double m_dDispCoeff; 396 397 //====== Depth Intra Modes ====== 398 #if H_3D_DIM 399 Bool m_useDMM; 400 Bool m_useRBC; 401 Bool m_useSDC; 402 Bool m_useDLT; 403 #endif 396 404 #endif 397 405 … … 926 934 Void setDispCoeff ( Double d ) { m_dDispCoeff = d; } 927 935 #endif // H_3D_VSO 936 937 //==== DIM ========== 938 #if H_3D_DIM 939 Bool getUseDMM () { return m_useDMM; } 940 Void setUseDMM ( Bool b) { m_useDMM = b; } 941 Bool getUseRBC () { return m_useRBC; } 942 Void setUseRBC ( Bool b) { m_useRBC = b; } 943 Bool getUseSDC () { return m_useSDC; } 944 Void setUseSDC ( Bool b) { m_useSDC = b; } 945 Bool getUseDLT () { return m_useDLT; } 946 Void setUseDLT ( Bool b) { m_useDLT = b; } 947 #endif 928 948 #endif // H_3D 929 949 }; -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncGOP.cpp
r446 r459 673 673 pcSlice->setRefPicList ( rcListPic ); 674 674 #endif 675 #if H_3D 676 pcSlice->setPicLists( m_ivPicLists ); 677 #endif 675 678 676 679 // Slice info. refinement -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncSbac.cpp
r446 r459 83 83 , m_cTransformSkipSCModel ( 1, 2, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 84 84 , m_CUTransquantBypassFlagSCModel( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels) 85 #if H_3D_DIM 86 , m_cDepthIntraModeSCModel ( 1, 1, NUM_DEPTH_INTRA_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 87 , m_cDdcFlagSCModel ( 1, 1, NUM_DDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 88 , m_cDdcDataSCModel ( 1, 1, NUM_DDC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 89 #if H_3D_DIM_DMM 90 , m_cDmm1DataSCModel ( 1, 1, NUM_DMM1_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 91 , m_cDmm2DataSCModel ( 1, 1, NUM_DMM2_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 92 , m_cDmm3DataSCModel ( 1, 1, NUM_DMM3_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 93 #endif 94 #if H_3D_DIM_RBC 95 , m_cRbcDataSCModel ( 1, 1, NUM_RBC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 96 #endif 97 #endif 85 98 { 86 99 assert( m_numContextModels <= MAX_NUM_CTX_MOD ); … … 134 147 m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); 135 148 m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); 149 150 #if H_3D_DIM 151 m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE ); 152 m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); 153 m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA ); 154 #if H_3D_DIM_DMM 155 m_cDmm1DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA ); 156 m_cDmm2DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM2_DATA ); 157 m_cDmm3DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA ); 158 #endif 159 #if H_3D_DIM_RBC 160 m_cRbcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_RBC_DATA ); 161 #endif 162 #endif 136 163 // new structure 137 164 m_uiLastQp = iQp; … … 188 215 curCost += m_cTransformSkipSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); 189 216 curCost += m_CUTransquantBypassFlagSCModel.calcCost( curSliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); 217 #if H_3D_DIM 218 if( m_pcSlice->getVpsDepthModesFlag() ) 219 { 220 curCost += m_cDepthIntraModeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE ); 221 curCost += m_cDdcFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DDC_FLAG ); 222 curCost += m_cDdcDataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DDC_DATA ); 223 #if H_3D_DIM_DMM 224 curCost += m_cDmm1DataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DMM1_DATA ); 225 curCost += m_cDmm2DataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DMM2_DATA ); 226 curCost += m_cDmm3DataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DMM3_DATA ); 227 #endif 228 #if H_3D_DIM_RBC 229 curCost += m_cRbcDataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_RBC_DATA ); 230 #endif 231 } 232 #endif 190 233 if (curCost < bestCost) 191 234 { … … 237 280 m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); 238 281 m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); 282 283 #if H_3D_DIM 284 m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE ); 285 m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); 286 m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA ); 287 #if H_3D_DIM_DMM 288 m_cDmm1DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA ); 289 m_cDmm2DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM2_DATA ); 290 m_cDmm3DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA ); 291 #endif 292 #if H_3D_DIM_RBC 293 m_cRbcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_RBC_DATA ); 294 #endif 295 #endif 239 296 m_pcBinIf->start(); 240 297 } … … 379 436 } 380 437 438 #if H_3D_DIM 439 Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel ) 440 { 441 if( uiSymbol ) 442 { 443 m_pcBinIf->encodeBin( 1, rcSCModel ); 444 UInt uiCount = 0; 445 Bool bNoExGo = (uiSymbol < 13); 446 447 while( --uiSymbol && ++uiCount < 13 ) 448 { 449 m_pcBinIf->encodeBin( 1, rcSCModel ); 450 } 451 if( bNoExGo ) 452 { 453 m_pcBinIf->encodeBin( 0, rcSCModel ); 454 } 455 else 456 { 457 xWriteEpExGolomb( uiSymbol, 0 ); 458 } 459 } 460 else 461 { 462 m_pcBinIf->encodeBin( 0, rcSCModel ); 463 } 464 465 return; 466 } 467 468 Void TEncSbac::xCodeDimDeltaDC( Pel valDeltaDC, UInt dimType ) 469 { 470 xWriteExGolombLevel( UInt( abs( valDeltaDC ) ), m_cDdcDataSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) ); 471 if( valDeltaDC != 0 ) 472 { 473 UInt uiSign = valDeltaDC > 0 ? 0 : 1; 474 m_pcBinIf->encodeBinEP( uiSign ); 475 } 476 } 477 478 #if H_3D_DIM_DMM 479 Void TEncSbac::xCodeDmm1WedgeIdx( UInt uiTabIdx, Int iNumBit ) 480 { 481 for ( Int i = 0; i < iNumBit; i++ ) 482 { 483 m_pcBinIf->encodeBin( ( uiTabIdx >> i ) & 1, m_cDmm1DataSCModel.get(0, 0, 0) ); 484 } 485 } 486 487 Void TEncSbac::xCodeDmm2Offset( Int iOffset ) 488 { 489 if( DMM2_DELTAEND_MAX > 0 ) 490 { 491 m_pcBinIf->encodeBin( (iOffset != 0) , m_cDmm2DataSCModel.get(0, 0, 0) ); 492 if( iOffset != 0 ) 493 { 494 UInt uiAbsValMinus1 = abs(iOffset)-1; 495 m_pcBinIf->encodeBin( (uiAbsValMinus1 & 0x01), m_cDmm2DataSCModel.get(0, 0, 0) ); 496 m_pcBinIf->encodeBin( (uiAbsValMinus1 & 0x02) >> 1, m_cDmm2DataSCModel.get(0, 0, 0) ); 497 498 UInt uiSign = (iOffset > 0) ? 0 : 1; 499 m_pcBinIf->encodeBinEP( uiSign ); 500 } 501 } 502 } 503 504 Void TEncSbac::xCodeDmm3WedgeIdx( UInt uiIntraIdx, Int iNumBit ) 505 { 506 for( Int i = 0; i < iNumBit; i++ ) 507 { 508 m_pcBinIf->encodeBin( ( uiIntraIdx >> i ) & 1, m_cDmm3DataSCModel.get(0, 0, 0) ); 509 } 510 } 511 #endif 512 #if H_3D_DIM_RBC 513 Void TEncSbac::xCodeRbcEdge( TComDataCU* pcCU, UInt uiAbsPartIdx ) 514 { 515 UInt uiDepth = pcCU->getDepth( uiAbsPartIdx ) + (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0); 516 UChar* pucSymbolList = pcCU->getEdgeCode ( uiAbsPartIdx ); 517 UChar ucEdgeNumber = pcCU->getEdgeNumber ( uiAbsPartIdx ); 518 Bool bLeft = pcCU->getEdgeLeftFirst( uiAbsPartIdx ); 519 UChar ucStart = pcCU->getEdgeStartPos ( uiAbsPartIdx ); 520 UInt uiSymbol; 521 522 // 1. Top(0) or Left(1) 523 uiSymbol = (bLeft == false) ? 0 : 1; 524 m_pcBinIf->encodeBinEP( uiSymbol ); 525 526 // 2. Start position (lowest bit first) 527 uiSymbol = ucStart; 528 for( UInt ui = 6; ui > uiDepth; ui-- ) // 64(0)->6, 32(1)->5, 16(2)->4, 8(3)->3, 4(4)->2 529 { 530 m_pcBinIf->encodeBinEP( uiSymbol & 0x1 ); 531 uiSymbol >>= 1; 532 } 533 534 // 3. Number of edges 535 uiSymbol = ucEdgeNumber > 0 ? ucEdgeNumber - 1 : 0; 536 for( UInt ui = 7; ui > uiDepth; ui-- ) // 64(0)->7, 32(1)->6, 16(2)->5, 8(3)->4, 4(4)->3 537 { 538 m_pcBinIf->encodeBinEP( uiSymbol & 0x1 ); 539 uiSymbol >>= 1; 540 } 541 542 if(uiSymbol != 0) 543 { 544 printf(" ucEdgeNumber %d at depth %d\n",ucEdgeNumber, uiDepth); 545 assert(false); 546 } 547 548 // 4. Edges 549 for( Int iPtr2 = 0; iPtr2 < ucEdgeNumber; iPtr2++ ) 550 { 551 UInt uiReorderSymbol = pucSymbolList[iPtr2]; 552 for( UInt ui = 0; ui < uiReorderSymbol; ui++ ) 553 { 554 m_pcBinIf->encodeBin( 1, m_cRbcDataSCModel.get( 0, 0, 0 ) ); 555 } 556 557 if( uiReorderSymbol != 6 ) 558 m_pcBinIf->encodeBin( 0, m_cRbcDataSCModel.get( 0, 0, 0 ) ); 559 } 560 } 561 #endif 562 #endif 563 381 564 // SBAC RD 382 565 Void TEncSbac::load ( TEncSbac* pSrc) … … 391 574 this->m_cCUIntraPredSCModel .copyFrom( &pSrc->m_cCUIntraPredSCModel ); 392 575 } 393 576 #if H_3D_DIM 577 Void TEncSbac::loadIntraDepthMode( TEncSbac* pSrc) 578 { 579 m_pcBinIf->copyState( pSrc->m_pcBinIf ); 580 581 this->m_cDepthIntraModeSCModel .copyFrom( &pSrc->m_cDepthIntraModeSCModel ); 582 this->m_cDdcFlagSCModel .copyFrom( &pSrc->m_cDdcFlagSCModel ); 583 } 584 #endif 394 585 395 586 Void TEncSbac::store( TEncSbac* pDest) … … 628 819 { 629 820 dir[j] = pcCU->getLumaIntraDir( absPartIdx+partOffset*j ); 821 #if H_3D_DIM 822 if( pcCU->getSlice()->getVpsDepthModesFlag() ) 823 { 824 codeIntraDepth( pcCU, absPartIdx+partOffset*j ); 825 } 826 if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) 827 #if H_3D_DIM_SDC 828 if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) ) 829 #endif 830 { 831 #endif 630 832 predNum[j] = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds[j]); 631 833 for(UInt i = 0; i < predNum[j]; i++) … … 637 839 } 638 840 m_pcBinIf->encodeBin((predIdx[j] != -1)? 1 : 0, m_cCUIntraPredSCModel.get( 0, 0, 0 ) ); 841 #if H_3D_DIM 842 } 843 #endif 639 844 } 640 845 for (j=0;j<partNum;j++) 641 846 { 847 #if H_3D_DIM 848 if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) 849 #if H_3D_DIM_SDC 850 if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) ) 851 #endif 852 { 853 #endif 642 854 if(predIdx[j] != -1) 643 855 { … … 668 880 m_pcBinIf->encodeBinsEP( dir[j], 5 ); 669 881 } 882 #if H_3D_DIM 883 } 884 #endif 670 885 } 671 886 return; … … 699 914 return; 700 915 } 916 917 #if H_3D_DIM 918 Void TEncSbac::codeIntraDepth( TComDataCU* pcCU, UInt absPartIdx, Bool sdcRD ) 919 { 920 codeIntraDepthMode( pcCU, absPartIdx ); 921 922 UInt dir = pcCU->getLumaIntraDir( absPartIdx ); 923 UInt dimType = getDimType( dir ); 924 925 switch( dimType ) 926 { 927 #if H_3D_DIM_DMM 928 case( DMM1_IDX ): 929 { 930 xCodeDmm1WedgeIdx( pcCU->getDmmWedgeTabIdx( dimType, absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); 931 } break; 932 case( DMM2_IDX ): 933 { 934 xCodeDmm2Offset( pcCU->getDmm2DeltaEnd( absPartIdx ) ); 935 } break; 936 case( DMM3_IDX ): 937 { 938 xCodeDmm3WedgeIdx( pcCU->getDmm3IntraTabIdx( absPartIdx ), g_dmm3IntraTabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); 939 } break; 940 case( DMM4_IDX ): break; 941 #endif 942 #if H_3D_DIM_RBC 943 case( RBC_IDX ): 944 { 945 assert( pcCU->getWidth( absPartIdx ) < 64 ); 946 xCodeRbcEdge( pcCU, absPartIdx ); 947 } break; 948 #endif 949 default: break; 950 } 951 952 #if H_3D_DIM_SDC 953 if( pcCU->getSDCFlag( absPartIdx ) ) 954 { 955 // assert(pcCU->getPartitionSize(uiAbsPartIdx)==SIZE_2Nx2N); 956 // UInt uiNumSegments = ( uiDir == DC_IDX || uiDir == PLANAR_IDX )? 1 : 2; 957 // if(!bSdcRD) 958 // { 959 // for (int uiSeg=0; uiSeg<uiNumSegments; uiSeg++) 960 // { 961 // codeSDCResidualData(pcCU, uiAbsPartIdx, uiSeg); 962 // } 963 // } 964 } 965 else 966 { 967 #endif 968 if( dimType < DIM_NUM_TYPE ) 969 { 970 UInt dimDeltaDC = isDimDeltaDC( dir ); 971 m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) ); 972 if( dimDeltaDC ) 973 { 974 for( UInt segment = 0; segment < 2; segment++ ) 975 { 976 xCodeDimDeltaDC( pcCU->getDimDeltaDC( dimType, segment, absPartIdx ), dimType ); 977 } 978 } 979 } 980 #if H_3D_DIM_SDC 981 } 982 #endif 983 } 984 985 Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx ) 986 { 987 UInt codeWordTable[3][9] = {{0, 0, 0, 2, 0,6, 0, 0, 7},{0, 2, 3, 4, 5, 6, 14, 31, 30},{0, 2, 0, 0, 0, 0, 3, 0, 0}}; 988 UInt codeWordLenTable[3][9] = {{0, 1, 0, 2, 0,3, 0, 0, 3},{2, 3, 3, 3, 3, 3, 4, 5, 5},{1, 2, 0, 0, 0, 0, 2, 0, 0}}; 989 UInt dir = pcCU->getLumaIntraDir( absPartIdx ); 990 UInt puIdx = (pcCU->getWidth(absPartIdx) == 64) ? 2 : ( (pcCU->getPartitionSize(absPartIdx) == SIZE_NxN && pcCU->getWidth(absPartIdx) == 8) ? 0 : 1 ); 991 UInt codeIdx = 0; 992 993 if( dir < NUM_INTRA_MODE ) 994 { 995 codeIdx = 1; 996 } 997 if( isDimMode( dir ) ) 998 { 999 switch( getDimType( dir ) ) 1000 { 1001 case DMM1_IDX: codeIdx = 3; break; 1002 case DMM4_IDX: codeIdx = 4; break; 1003 case DMM3_IDX: codeIdx = 5; break; 1004 case DMM2_IDX: codeIdx = 7; break; 1005 case RBC_IDX: codeIdx = 8; break; 1006 default: break; 1007 } 1008 } 1009 1010 #if H_3D_DIM_SDC 1011 if( pcCU->getSDCFlag( absPartIdx ) ) 1012 { 1013 // switch( dir ) 1014 // { 1015 // case PLANAR_IDX: codeIdx = 0; break; 1016 // case DC_IDX: codeIdx = 6; break; 1017 // case (2*DMM1_IDX+DIM_OFFSET): codeIdx = 2; break; 1018 // default: break; 1019 // } 1020 } 1021 #endif 1022 //mode coding 1023 for( UInt i = 0; i < codeWordLenTable[puIdx][codeIdx]; i++ ) 1024 { 1025 UInt bit = codeWordTable[puIdx][codeIdx] & ( 1<<(codeWordLenTable[puIdx][codeIdx] - i - 1) ); 1026 UInt ctxDepthMode = puIdx*3 + ( (i >= 2) ? 2 : i ); 1027 m_pcBinIf->encodeBin( bit!=0 , m_cDepthIntraModeSCModel.get(0, 0, ctxDepthMode) ); 1028 } 1029 } 1030 #endif 701 1031 702 1032 Void TEncSbac::codeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx ) -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncSbac.h
r446 r459 84 84 Void load ( TEncSbac* pScr ); 85 85 Void loadIntraDirModeLuma ( TEncSbac* pScr ); 86 #if H_3D_DIM 87 Void loadIntraDepthMode ( TEncSbac* pScr ); 88 #endif 86 89 Void store ( TEncSbac* pDest ); 87 90 Void loadContexts ( TEncSbac* pScr ); … … 113 116 Void xWriteEpExGolomb ( UInt uiSymbol, UInt uiCount ); 114 117 Void xWriteCoefRemainExGolomb ( UInt symbol, UInt &rParam ); 118 #if H_3D_DIM 119 Void xWriteExGolombLevel ( UInt uiSymbol, ContextModel& rcSCModel ); 120 Void xCodeDimDeltaDC ( Pel valDeltaDC, UInt dimType ); 121 #if H_3D_DIM_DMM 122 Void xCodeDmm1WedgeIdx ( UInt uiTabIdx, Int iNumBit ); 123 Void xCodeDmm2Offset ( Int iOffset ); 124 Void xCodeDmm3WedgeIdx ( UInt uiIntraIdx, Int iNumBit ); 125 #endif 126 #if H_3D_DIM_RBC 127 Void xCodeRbcEdge ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 128 #endif 129 #endif 115 130 116 131 Void xCopyFrom ( TEncSbac* pSrc ); … … 148 163 149 164 Void codeIntraDirChroma ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 165 166 #if H_3D_DIM 167 Void codeIntraDepth ( TComDataCU* pcCU, UInt absPartIdx, Bool sdcRD = false ); 168 Void codeIntraDepthMode ( TComDataCU* pcCU, UInt absPartIdx ); 169 #endif 170 150 171 Void codeInterDir ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 151 172 Void codeRefFrmIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ); … … 207 228 ContextModel3DBuffer m_cTransformSkipSCModel; 208 229 ContextModel3DBuffer m_CUTransquantBypassFlagSCModel; 230 231 #if H_3D_DIM 232 ContextModel3DBuffer m_cDepthIntraModeSCModel; 233 ContextModel3DBuffer m_cDdcFlagSCModel; 234 ContextModel3DBuffer m_cDdcDataSCModel; 235 #if H_3D_DIM_DMM 236 ContextModel3DBuffer m_cDmm1DataSCModel; 237 ContextModel3DBuffer m_cDmm2DataSCModel; 238 ContextModel3DBuffer m_cDmm3DataSCModel; 239 #endif 240 #if H_3D_DIM_RBC 241 ContextModel3DBuffer m_cRbcDataSCModel; 242 #endif 243 #endif 209 244 }; 210 245 -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncSearch.cpp
r446 r459 1047 1047 pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail ); 1048 1048 //===== get prediction signal ===== 1049 #if H_3D_DIM 1050 if( isDimMode( uiLumaPredMode ) ) 1051 { 1052 predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, true ); 1053 } 1054 else 1055 { 1056 #endif 1049 1057 predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 1058 #if H_3D_DIM 1059 } 1060 #endif 1061 1050 1062 // save prediction 1051 1063 if(default0Save1Load2 == 1) … … 1224 1236 { 1225 1237 uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); 1238 #if H_3D_DIM 1239 mapDepthModeToIntraDir( uiChromaPredMode ); 1240 #endif 1226 1241 } 1227 1242 … … 1431 1446 #endif 1432 1447 #endif 1448 #if H_3D_DIM 1449 if( isDimMode( pcCU->getLumaIntraDir( uiAbsPartIdx ) ) ) 1450 { 1451 bCheckSplit = false; 1452 } 1453 #endif 1454 1433 1455 Double dSingleCost = MAX_DOUBLE; 1434 1456 #if H_3D_VSO … … 2624 2646 } 2625 2647 2648 #if H_3D_DIM 2649 //===== determine set of depth intra modes to be tested ===== 2650 if( m_pcEncCfg->getIsDepth() && uiWidth >= DIM_MIN_SIZE && uiWidth <= DIM_MAX_SIZE && uiWidth == uiHeight ) 2651 { 2652 #if H_3D_DIM_DMM 2653 if( m_pcEncCfg->getUseDMM() ) 2654 { 2655 for( UInt dmmType = 0; dmmType < DMM_NUM_TYPE; dmmType++ ) 2656 { 2657 UInt uiTabIdx = 0; 2658 TComWedgelet* biSegmentation = NULL; 2659 Pel deltaDC1 = 0; Pel deltaDC2 = 0; 2660 switch( dmmType ) 2661 { 2662 case( DMM1_IDX ): 2663 { 2664 xSearchDmm1Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx ); 2665 pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dmmType, uiPartOffset, uiDepth + uiInitTrDepth ); 2666 biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]); 2667 } break; 2668 case( DMM2_IDX ): 2669 { 2670 if( uiWidth > 4 ) 2671 { 2672 Int dmm2DeltaEnd = 0; 2673 xSearchDmm2Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx, dmm2DeltaEnd ); 2674 pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dmmType, uiPartOffset, uiDepth + uiInitTrDepth ); 2675 pcCU->setDmm2DeltaEndSubParts( dmm2DeltaEnd, uiPartOffset, uiDepth + uiInitTrDepth ); 2676 biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]); 2677 } 2678 } break; 2679 case( DMM3_IDX ): 2680 { 2681 UInt uiIntraTabIdx = 0; 2682 xSearchDmm3Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx, uiIntraTabIdx ); 2683 pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dmmType, uiPartOffset, uiDepth + uiInitTrDepth ); 2684 pcCU->setDmm3IntraTabIdxSubParts( uiIntraTabIdx, uiPartOffset, uiDepth + uiInitTrDepth ); 2685 biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]); 2686 } break; 2687 case( DMM4_IDX ): 2688 { 2689 if( uiWidth > 4 ) 2690 { 2691 biSegmentation = new TComWedgelet( uiWidth, uiHeight ); 2692 xPredContourFromTex( pcCU, uiPartOffset, uiWidth, uiHeight, biSegmentation ); 2693 } 2694 } break; 2695 default: assert(0); 2696 } 2697 2698 if( biSegmentation ) 2699 { 2700 xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, biSegmentation->getPattern(), biSegmentation->getStride(), uiWidth, uiHeight, deltaDC1, deltaDC2 ); 2701 pcCU->setDimDeltaDC( dmmType, 0, uiPartOffset, deltaDC1 ); 2702 pcCU->setDimDeltaDC( dmmType, 1, uiPartOffset, deltaDC2 ); 2703 2704 uiRdModeList[ numModesForFullRD++ ] = (2*dmmType +DIM_OFFSET); 2705 uiRdModeList[ numModesForFullRD++ ] = (2*dmmType+1+DIM_OFFSET); 2706 2707 if( DMM4_IDX == dmmType ) { biSegmentation->destroy(); delete biSegmentation; } 2708 } 2709 } 2710 } 2711 #endif 2712 #if H_3D_DIM_RBC 2713 if( m_pcEncCfg->getUseRBC() ) 2714 { 2715 if( xSearchRbcEdge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight ) ) 2716 { 2717 Pel deltaDC1 = 0; Pel deltaDC2 = 0; 2718 xSearchRbcDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, pcCU->getEdgePartition( uiPartOffset ), uiWidth, uiWidth, uiHeight, deltaDC1, deltaDC2 ); 2719 pcCU->setDimDeltaDC( RBC_IDX, 0, uiPartOffset, deltaDC1 ); 2720 pcCU->setDimDeltaDC( RBC_IDX, 1, uiPartOffset, deltaDC2 ); 2721 2722 uiRdModeList[ numModesForFullRD++ ] = (2*RBC_IDX +DIM_OFFSET); 2723 uiRdModeList[ numModesForFullRD++ ] = (2*RBC_IDX+1+DIM_OFFSET); 2724 } 2725 } 2726 #endif 2727 } 2728 #endif 2729 2626 2730 //===== check modes (using r-d costs) ===== 2627 2731 #if HHI_RQT_INTRA_SPEEDUP_MOD … … 6091 6195 // Reload only contexts required for coding intra mode information 6092 6196 m_pcRDGoOnSbacCoder->loadIntraDirModeLuma( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 6197 #if H_3D_DIM 6198 m_pcRDGoOnSbacCoder->loadIntraDepthMode( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] ); 6199 #endif 6093 6200 } 6094 6201 … … 6407 6514 } 6408 6515 6516 // ------------------------------------------------------------------------------------------------------------------- 6517 // Depth intra search 6518 // ------------------------------------------------------------------------------------------------------------------- 6519 #if H_3D_DIM 6520 Void TEncSearch::xCalcBiSegDCs( Pel* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& valDC1, Pel& valDC2 ) 6521 { 6522 valDC1 = ( 1<<( g_bitDepthY - 1) ); 6523 valDC2 = ( 1<<( g_bitDepthY - 1) ); 6524 6525 UInt uiDC1 = 0; 6526 UInt uiDC2 = 0; 6527 UInt uiNumPixDC1 = 0, uiNumPixDC2 = 0; 6528 if( srcStride == patternStride ) 6529 { 6530 for( UInt k = 0; k < (patternStride * patternStride); k++ ) 6531 { 6532 if( true == biSegPattern[k] ) 6533 { 6534 uiDC2 += ptrSrc[k]; 6535 uiNumPixDC2++; 6536 } 6537 else 6538 { 6539 uiDC1 += ptrSrc[k]; 6540 uiNumPixDC1++; 6541 } 6542 } 6543 } 6544 else 6545 { 6546 Pel* piTemp = ptrSrc; 6547 for( UInt uiY = 0; uiY < patternStride; uiY++ ) 6548 { 6549 for( UInt uiX = 0; uiX < patternStride; uiX++ ) 6550 { 6551 if( true == biSegPattern[uiX] ) 6552 { 6553 uiDC2 += piTemp[uiX]; 6554 uiNumPixDC2++; 6555 } 6556 else 6557 { 6558 uiDC1 += piTemp[uiX]; 6559 uiNumPixDC1++; 6560 } 6561 } 6562 piTemp += srcStride; 6563 biSegPattern += patternStride; 6564 } 6565 } 6566 6567 if( uiNumPixDC1 > 0 ) { valDC1 = uiDC1 / uiNumPixDC1; } 6568 if( uiNumPixDC2 > 0 ) { valDC2 = uiDC2 / uiNumPixDC2; } 6569 } 6570 6571 #if H_3D_DIM_DMM 6572 Void TEncSearch::xSearchDmmDeltaDCs( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 ) 6573 { 6574 assert( biSegPattern ); 6575 Pel origDC1 = 0; Pel origDC2 = 0; 6576 xCalcBiSegDCs ( piOrig, uiStride, biSegPattern, patternStride, origDC1, origDC2 ); 6577 xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, origDC1, origDC2 ); 6578 6579 Int* piMask = pcCU->getPattern()->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); // no filtering for DMM 6580 Int maskStride = 2*uiWidth + 1; 6581 Int* ptrSrc = piMask+maskStride+1; 6582 Pel predDC1 = 0; Pel predDC2 = 0; 6583 xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 ); 6584 6585 rDeltaDC1 = origDC1 - predDC1; 6586 rDeltaDC2 = origDC2 - predDC2; 6587 6588 #if H_3D_VSO 6589 if( m_pcRdCost->getUseVSO() ) 6590 { 6591 Pel fullDeltaDC1 = rDeltaDC1; 6592 Pel fullDeltaDC2 = rDeltaDC2; 6593 6594 Dist uiBestDist = RDO_DIST_MAX; 6595 UInt uiBestQStepDC1 = 0; 6596 UInt uiBestQStepDC2 = 0; 6597 6598 UInt uiDeltaDC1Max = abs(fullDeltaDC1); 6599 UInt uiDeltaDC2Max = abs(fullDeltaDC2); 6600 6601 //VSO Level delta DC check range extension 6602 uiDeltaDC1Max += (uiDeltaDC1Max>>1); 6603 uiDeltaDC2Max += (uiDeltaDC2Max>>1); 6604 6605 // limit search range to [0, IBDI_MAX] 6606 if( fullDeltaDC1 < 0 && uiDeltaDC1Max > abs(predDC1) ) { uiDeltaDC1Max = abs(predDC1); } 6607 if( fullDeltaDC1 >= 0 && uiDeltaDC1Max > ((1 << g_bitDepthY)-1) - abs(predDC1) ) { uiDeltaDC1Max = ((1 << g_bitDepthY)-1) - abs(predDC1); } 6608 6609 if( fullDeltaDC2 < 0 && uiDeltaDC2Max > abs(predDC2) ) { uiDeltaDC2Max = abs(predDC2); } 6610 if( fullDeltaDC2 >= 0 && uiDeltaDC2Max > ((1 << g_bitDepthY)-1) - abs(predDC2) ) { uiDeltaDC2Max = ((1 << g_bitDepthY)-1) - abs(predDC2); } 6611 6612 // init dist with original segment DCs 6613 xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, origDC1, origDC2 ); 6614 6615 Dist uiOrgDist = RDO_DIST_MAX; 6616 if( m_pcRdCost->getUseEstimatedVSD() ) 6617 { 6618 uiOrgDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false ); 6619 } 6620 else 6621 { 6622 uiOrgDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false ); 6623 } 6624 6625 uiBestDist = uiOrgDist; 6626 uiBestQStepDC1 = abs(fullDeltaDC1); 6627 uiBestQStepDC2 = abs(fullDeltaDC2); 6628 6629 // coarse search with step size 4 6630 for( UInt uiQStepDC1 = 0; uiQStepDC1 < uiDeltaDC1Max; uiQStepDC1 += 4 ) 6631 { 6632 Pel testDC1 = ClipY( predDC1 + ((Int)(uiQStepDC1) * (( fullDeltaDC1 < 0 ) ? -1 : 1)) ); 6633 for( UInt uiQStepDC2 = 0; uiQStepDC2 < uiDeltaDC2Max; uiQStepDC2 += 4 ) 6634 { 6635 Pel testDC2 = ClipY( predDC2 + ((Int)(uiQStepDC2) * (( fullDeltaDC2 < 0 ) ? -1 : 1)) ); 6636 6637 xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, testDC1, testDC2 ); 6638 6639 Dist uiAct4Dist = RDO_DIST_MAX; 6640 if( m_pcRdCost->getUseEstimatedVSD() ) 6641 { 6642 uiAct4Dist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false ); 6643 } 6644 else 6645 { 6646 uiAct4Dist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false ); 6647 } 6648 6649 if( uiAct4Dist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 6650 { 6651 uiBestDist = uiAct4Dist; 6652 uiBestQStepDC1 = uiQStepDC1; 6653 uiBestQStepDC2 = uiQStepDC2; 6654 } 6655 } 6656 } 6657 6658 // refinement +-3 6659 for( UInt uiQStepDC1 = (UInt)max(0, ((Int)uiBestQStepDC1-3)); uiQStepDC1 <= (uiBestQStepDC1+3); uiQStepDC1++ ) 6660 { 6661 Pel testDC1 = ClipY( predDC1 + ((Int)(uiQStepDC1) * (( fullDeltaDC1 < 0 ) ? -1 : 1)) ); 6662 for( UInt uiQStepDC2 = (UInt)max(0, ((Int)uiBestQStepDC2-3)); uiQStepDC2 <= (uiBestQStepDC2+3); uiQStepDC2++ ) 6663 { 6664 Pel testDC2 = ClipY( predDC2 + ((Int)(uiQStepDC2) * (( fullDeltaDC2 < 0 ) ? -1 : 1)) ); 6665 6666 xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, testDC1, testDC2 ); 6667 6668 Dist uiActDist = RDO_DIST_MAX; 6669 if( m_pcRdCost->getUseEstimatedVSD() ) 6670 { 6671 uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false ); 6672 } 6673 else 6674 { 6675 uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false ); 6676 } 6677 6678 if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 6679 { 6680 uiBestDist = uiActDist; 6681 uiBestQStepDC1 = uiQStepDC1; 6682 uiBestQStepDC2 = uiQStepDC2; 6683 } 6684 } 6685 } 6686 rDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( fullDeltaDC1 < 0 ) ? -1 : 1); 6687 rDeltaDC2 = (Int)(uiBestQStepDC2) * (Int)(( fullDeltaDC2 < 0 ) ? -1 : 1); 6688 } 6689 #endif 6690 6691 #if H_3D_DIM_DLT 6692 rDeltaDC1 = (Int)GetDepthValue2Idx( ClipY(predDC1 + rDeltaDC1) ) - (Int)GetDepthValue2Idx( predDC1 ); 6693 rDeltaDC2 = (Int)GetDepthValue2Idx( ClipY(predDC2 + rDeltaDC2) ) - (Int)GetDepthValue2Idx( predDC2 ); 6694 #endif 6695 } 6696 6697 Void TEncSearch::xSearchDmm1Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx ) 6698 { 6699 ruiTabIdx = 0; 6700 6701 // local pred buffer 6702 TComYuv cPredYuv; 6703 cPredYuv.create( uiWidth, uiHeight ); 6704 cPredYuv.clear(); 6705 6706 UInt uiPredStride = cPredYuv.getStride(); 6707 Pel* piPred = cPredYuv.getLumaAddr(); 6708 6709 Pel refDC1 = 0; Pel refDC2 = 0; 6710 WedgeList* pacWedgeList = &g_dmmWedgeLists [(g_aucConvertToBit[uiWidth])]; 6711 WedgeNodeList* pacWedgeNodeList = &g_dmmWedgeNodeLists[(g_aucConvertToBit[uiWidth])]; 6712 6713 // coarse wedge search 6714 Dist uiBestDist = RDO_DIST_MAX; 6715 UInt uiBestNodeId = 0; 6716 for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ ) 6717 { 6718 TComWedgelet* pcWedgelet = &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())); 6719 xCalcBiSegDCs ( piRef, uiRefStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 6720 xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 6721 6722 Dist uiActDist = RDO_DIST_MAX; 6723 #if H_3D_VSO 6724 if( m_pcRdCost->getUseVSO() ) 6725 { 6726 if( m_pcRdCost->getUseEstimatedVSD() ) 6727 { 6728 uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false ); 6729 } 6730 else 6731 { 6732 uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false ); 6733 } 6734 } 6735 else 6736 #endif 6737 { 6738 uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD ); 6739 } 6740 6741 if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 6742 { 6743 uiBestDist = uiActDist; 6744 uiBestNodeId = uiNodeId; 6745 } 6746 } 6747 6748 // refinement 6749 Dist uiBestDistRef = uiBestDist; 6750 UInt uiBestTabIdxRef = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx(); 6751 for( UInt uiRefId = 0; uiRefId < DMM_NUM_WEDGE_REFINES; uiRefId++ ) 6752 { 6753 if( pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ) != DMM_NO_WEDGEINDEX ) 6754 { 6755 TComWedgelet* pcWedgelet = &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))); 6756 xCalcBiSegDCs ( piRef, uiRefStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 6757 xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 6758 6759 Dist uiActDist = RDO_DIST_MAX; 6760 #if H_3D_VSO 6761 if( m_pcRdCost->getUseVSO() ) 6762 { 6763 if( m_pcRdCost->getUseEstimatedVSD() ) 6764 { 6765 uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false ); 6766 } 6767 else 6768 { 6769 uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false ); 6770 } 6771 } 6772 else 6773 #endif 6774 { 6775 uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD ); 6776 } 6777 6778 if( uiActDist < uiBestDistRef || uiBestDistRef == RDO_DIST_MAX ) 6779 { 6780 uiBestDistRef = uiActDist; 6781 uiBestTabIdxRef = pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ); 6782 } 6783 } 6784 } 6785 6786 ruiTabIdx = uiBestTabIdxRef; 6787 6788 cPredYuv.destroy(); 6789 return; 6790 } 6791 6792 Void TEncSearch::xSearchDmm2Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Int& riWedgeDeltaEnd ) 6793 { 6794 ruiTabIdx = 0; 6795 riWedgeDeltaEnd = 0; 6796 6797 // local pred buffer 6798 TComYuv cPredYuv; 6799 cPredYuv.create( uiWidth, uiHeight ); 6800 cPredYuv.clear(); 6801 6802 UInt uiPredStride = cPredYuv.getStride(); 6803 Pel* piPred = cPredYuv.getLumaAddr(); 6804 6805 6806 // regular wedge search 6807 Dist uiBestDist = RDO_DIST_MAX; 6808 UInt uiBestTabIdx = 0; 6809 Int iBestDeltaEnd = 0; 6810 6811 UInt uiIdx = 0; 6812 Pel refDC1 = 0; Pel refDC2 = 0; 6813 for( Int iTestDeltaEnd = -DMM2_DELTAEND_MAX; iTestDeltaEnd <= DMM2_DELTAEND_MAX; iTestDeltaEnd++ ) 6814 { 6815 uiIdx = xPredWedgeFromIntra( pcCU, uiAbsPtIdx, uiWidth, uiHeight, iTestDeltaEnd ); 6816 TComWedgelet* pcWedgelet = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiIdx]); 6817 xCalcBiSegDCs ( piRef, uiRefStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 6818 xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 6819 6820 Dist uiActDist = RDO_DIST_MAX; 6821 #if H_3D_VSO 6822 if( m_pcRdCost->getUseVSO() ) 6823 { 6824 if( m_pcRdCost->getUseEstimatedVSD() ) 6825 { 6826 uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false ); 6827 } 6828 else 6829 { 6830 uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false ); 6831 } 6832 } 6833 else 6834 #endif 6835 { 6836 uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD ); 6837 } 6838 6839 if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 6840 { 6841 uiBestDist = uiActDist; 6842 uiBestTabIdx = uiIdx; 6843 iBestDeltaEnd = iTestDeltaEnd; 6844 } 6845 else if( uiIdx == uiBestTabIdx && abs(iTestDeltaEnd) < abs(iBestDeltaEnd) ) 6846 { 6847 iBestDeltaEnd = iTestDeltaEnd; 6848 } 6849 } 6850 6851 ruiTabIdx = uiBestTabIdx; 6852 riWedgeDeltaEnd = iBestDeltaEnd; 6853 6854 cPredYuv.destroy(); 6855 return; 6856 } 6857 6858 Void TEncSearch::xSearchDmm3Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx ) 6859 { 6860 ruiTabIdx = 0; 6861 ruiIntraTabIdx = 0; 6862 6863 // local pred buffer 6864 TComYuv cPredYuv; 6865 cPredYuv.create( uiWidth, uiHeight ); 6866 cPredYuv.clear(); 6867 Pel* piPred = cPredYuv.getLumaAddr(); 6868 UInt uiPredStride = cPredYuv.getStride(); 6869 6870 // wedge search 6871 UInt uiBestDist = MAX_UINT; 6872 WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])]; 6873 Pel refDC1 = 0; Pel refDC2 = 0; 6874 6875 TComPic* pcPicTex = pcCU->getSlice()->getPicLists()->getPic( pcCU->getSlice()->getViewIndex(), false, pcCU->getSlice()->getPOC() ); 6876 assert( pcPicTex != NULL ); 6877 TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); 6878 UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPtIdx; 6879 Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; 6880 6881 std::vector< std::vector<UInt> > pauiWdgLstSz = g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]]; 6882 if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) 6883 { 6884 std::vector<UInt>* pauiWdgLst = &pauiWdgLstSz[uiColTexIntraDir-2]; 6885 for( UInt uiIdxW = 0; uiIdxW < pauiWdgLst->size(); uiIdxW++ ) 6886 { 6887 UInt uiIdx = pauiWdgLst->at(uiIdxW); 6888 TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiIdx)); 6889 xCalcBiSegDCs ( piRef, uiRefStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 6890 xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 6891 6892 UInt uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD ); 6893 if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) 6894 { 6895 uiBestDist = uiActDist; 6896 ruiTabIdx = uiIdx; 6897 ruiIntraTabIdx = uiIdxW; 6898 } 6899 } 6900 } 6901 else 6902 { 6903 WedgeNodeList* pacWedgeNodeList = &g_dmmWedgeNodeLists[(g_aucConvertToBit[uiWidth])]; 6904 UInt uiBestNodeDist = MAX_UINT; 6905 UInt uiBestNodeId = 0; 6906 for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ ) 6907 { 6908 TComWedgelet* pcWedgelet = &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())); 6909 xCalcBiSegDCs ( piRef, uiRefStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 6910 xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 6911 6912 UInt uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD ); 6913 if( uiActDist < uiBestNodeDist || uiBestNodeDist == MAX_UINT ) 6914 { 6915 uiBestNodeDist = uiActDist; 6916 uiBestNodeId = uiNodeId; 6917 ruiIntraTabIdx = uiNodeId; 6918 } 6919 } 6920 ruiTabIdx = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx(); 6921 } 6922 6923 cPredYuv.destroy(); 6924 } 6925 #endif 6926 #if H_3D_DIM_RBC 6927 Void TEncSearch::xSearchRbcDeltaDCs( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 ) 6928 { 6929 assert( biSegPattern ); 6930 Pel origDC1 = 0; Pel origDC2 = 0; 6931 xCalcBiSegDCs ( piOrig, uiStride, biSegPattern, patternStride, origDC1, origDC2 ); 6932 xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, origDC1, origDC2 ); 6933 6934 Int* piMask = pcCU->getPattern()->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); // no filtering for DMM 6935 Int maskStride = 2*uiWidth + 1; 6936 Int* ptrSrc = piMask+maskStride+1; 6937 Pel predDC1 = 0; Pel predDC2 = 0; 6938 xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 ); 6939 6940 rDeltaDC1 = origDC1 - predDC1; 6941 rDeltaDC2 = origDC2 - predDC2; 6942 6943 #if H_3D_VSO 6944 if( m_pcRdCost->getUseVSO() ) 6945 { 6946 Pel fullDeltaDC1 = rDeltaDC1; 6947 Pel fullDeltaDC2 = rDeltaDC2; 6948 6949 xDeltaDCQuantScaleDown( pcCU, fullDeltaDC1 ); 6950 xDeltaDCQuantScaleDown( pcCU, fullDeltaDC2 ); 6951 6952 Dist uiBestDist = RDO_DIST_MAX; 6953 UInt uiBestQStepDC1 = 0; 6954 UInt uiBestQStepDC2 = 0; 6955 6956 UInt uiDeltaDC1Max = abs(fullDeltaDC1); 6957 UInt uiDeltaDC2Max = abs(fullDeltaDC2); 6958 6959 //VSO Level delta DC check range extension 6960 uiDeltaDC1Max += (uiDeltaDC1Max>>1); 6961 uiDeltaDC2Max += (uiDeltaDC2Max>>1); 6962 6963 for( UInt uiQStepDC1 = 1; uiQStepDC1 <= uiDeltaDC1Max; uiQStepDC1++ ) 6964 { 6965 Pel iLevelDeltaDC1 = (Pel)(uiQStepDC1) * (Pel)(( fullDeltaDC1 < 0 ) ? -1 : 1); 6966 xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC1 ); 6967 Pel testDC1 = ClipY( predDC1 + iLevelDeltaDC1 ); 6968 6969 for( UInt uiQStepDC2 = 1; uiQStepDC2 <= uiDeltaDC2Max; uiQStepDC2++ ) 6970 { 6971 Pel iLevelDeltaDC2 = (Pel)(uiQStepDC2) * (Pel)(( fullDeltaDC2 < 0 ) ? -1 : 1); 6972 xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC2 ); 6973 Pel testDC2 = ClipY( predDC2 + iLevelDeltaDC2 ); 6974 6975 xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, testDC1, testDC2 ); 6976 6977 Dist uiActDist = RDO_DIST_MAX; 6978 if( m_pcRdCost->getUseEstimatedVSD() ) 6979 { 6980 uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false ); 6981 } 6982 else 6983 { 6984 uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false ); 6985 } 6986 6987 if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 6988 { 6989 uiBestDist = uiActDist; 6990 uiBestQStepDC1 = uiQStepDC1; 6991 uiBestQStepDC2 = uiQStepDC2; 6992 } 6993 } 6994 } 6995 6996 fullDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( fullDeltaDC1 < 0 ) ? -1 : 1); 6997 fullDeltaDC2 = (Int)(uiBestQStepDC2) * (Int)(( fullDeltaDC2 < 0 ) ? -1 : 1); 6998 xDeltaDCQuantScaleUp( pcCU, fullDeltaDC1 ); 6999 xDeltaDCQuantScaleUp( pcCU, fullDeltaDC2 ); 7000 rDeltaDC1 = fullDeltaDC1; 7001 rDeltaDC2 = fullDeltaDC2; 7002 } 7003 #endif 7004 7005 xDeltaDCQuantScaleDown( pcCU, rDeltaDC1 ); 7006 xDeltaDCQuantScaleDown( pcCU, rDeltaDC2 ); 7007 } 7008 7009 Bool TEncSearch::xSearchRbcEdge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, Int iWidth, Int iHeight ) 7010 { 7011 Bool* pbEdge = (Bool*) xMalloc( Bool, iWidth * iHeight * 4 ); 7012 7013 Short* psDiffX = new Short[ iWidth * iHeight ]; 7014 Short* psDiffY = new Short[ iWidth * iHeight ]; 7015 Bool* pbEdgeX = new Bool [ iWidth * iHeight ]; 7016 Bool* pbEdgeY = new Bool [ iWidth * iHeight ]; 7017 7018 // Find Horizontal Gradient & Edge Detection ((x+1, y) - (x,y)) 7019 for( Int y=0; y<iHeight; y++ ) 7020 { 7021 Short* psDiffXPtr = &psDiffX[ y * iHeight ]; 7022 Bool* pbEdgeXPtr = &pbEdgeX[ y * iHeight ]; 7023 for(Int x=0; x<iWidth-1; x++ ) 7024 { 7025 *psDiffXPtr = piRef[ x+1 + y*uiRefStride ] - piRef[ x + y*uiRefStride ]; 7026 if(*psDiffXPtr >= RBC_THRESHOLD || *psDiffXPtr <= (-1)*RBC_THRESHOLD) 7027 { 7028 *pbEdgeXPtr = true; 7029 } 7030 else 7031 { 7032 *pbEdgeXPtr = false; 7033 } 7034 7035 psDiffXPtr++; 7036 pbEdgeXPtr++; 7037 } 7038 } 7039 7040 // Find Vertical Gradient & Edge Detection((x,y+1) - (x,y)) 7041 for( Int y=0; y<iHeight-1; y++ ) 7042 { 7043 Short* psDiffYPtr = &psDiffY[ y * iHeight ]; 7044 Bool* pbEdgeYPtr = &pbEdgeY[ y * iHeight ]; 7045 for(Int x=0; x<iWidth; x++ ) 7046 { 7047 *psDiffYPtr = piRef[ x + (y+1)*uiRefStride ] - piRef[ x + y*uiRefStride ]; 7048 if(*psDiffYPtr >= RBC_THRESHOLD || *psDiffYPtr <= (-1)*RBC_THRESHOLD) 7049 { 7050 *pbEdgeYPtr = true; 7051 } 7052 else 7053 { 7054 *pbEdgeYPtr = false; 7055 } 7056 7057 psDiffYPtr++; 7058 pbEdgeYPtr++; 7059 } 7060 } 7061 7062 // Eliminate local maximum 7063 for( Int y=0; y<iHeight; y++ ) 7064 { 7065 Short* psDiffXPtr = &psDiffX[ y * iHeight ]; 7066 Bool* pbEdgeXPtr = &pbEdgeX[ y * iHeight ]; 7067 for( Int x=0; x<iWidth-1; x++ ) 7068 { 7069 UShort usAbs0=0, usAbs1=0, usAbs2=0; // 0 : left, 1 : current, 2 : right 7070 7071 if( x > 0 && *(pbEdgeXPtr-1) == true ) 7072 { 7073 if( *(psDiffXPtr-1) >= 0) 7074 { 7075 usAbs0 = *(psDiffXPtr-1); 7076 7077 } 7078 else 7079 { 7080 usAbs0 = (-1) * *(psDiffXPtr-1); 7081 } 7082 } 7083 if( *pbEdgeXPtr == true ) 7084 { 7085 if( *(psDiffXPtr) >= 0) 7086 { 7087 usAbs1 = *(psDiffXPtr); 7088 } 7089 else 7090 { 7091 usAbs1 = (-1) * *(psDiffXPtr); 7092 } 7093 } 7094 if( x < iWidth-2 && *(pbEdgeXPtr+1) == true ) 7095 { 7096 if( *(psDiffXPtr+1) >= 0) 7097 { 7098 usAbs2 = *(psDiffXPtr+1); 7099 //bSign2 = true; 7100 } 7101 else 7102 { 7103 usAbs2 = (-1) * *(psDiffXPtr+1); 7104 } 7105 } 7106 7107 if( x == 0 ) 7108 { 7109 if( usAbs1 < usAbs2 ) 7110 { 7111 *pbEdgeXPtr = false; 7112 } 7113 } 7114 else if( x == iWidth-2 ) 7115 { 7116 if( usAbs1 <= usAbs0 ) 7117 *pbEdgeXPtr = false; 7118 } 7119 else 7120 { 7121 if( usAbs2 > usAbs0 ) 7122 { 7123 if( usAbs1 < usAbs2 ) 7124 *pbEdgeXPtr = false; 7125 } 7126 else 7127 { 7128 if( usAbs1 <= usAbs0 ) 7129 *pbEdgeXPtr = false; 7130 } 7131 } 7132 7133 psDiffXPtr++; 7134 pbEdgeXPtr++; 7135 } 7136 } 7137 7138 for( Int y=0; y<iHeight-1; y++ ) 7139 { 7140 Short* psDiffYPtr = &psDiffY[ y * iWidth ]; 7141 Bool* pbEdgeYPtr = &pbEdgeY[ y * iWidth ]; 7142 for( Int x=0; x<iWidth; x++ ) 7143 { 7144 UShort usAbs0=0, usAbs1=0, usAbs2=0; // 0 : upper, 1 : current, 2 : bottom 7145 if( y > 0 && *(pbEdgeYPtr-iWidth) == true ) 7146 { 7147 if( *(psDiffYPtr-iWidth) >= 0) 7148 { 7149 usAbs0 = *(psDiffYPtr-iWidth); 7150 } 7151 else 7152 { 7153 usAbs0 = (-1) * *(psDiffYPtr-iWidth); 7154 } 7155 } 7156 if( *pbEdgeYPtr == true ) 7157 { 7158 if( *(psDiffYPtr) >= 0) 7159 { 7160 usAbs1 = *(psDiffYPtr); 7161 } 7162 else 7163 { 7164 usAbs1 = (-1) * *(psDiffYPtr); 7165 } 7166 } 7167 if( y < iHeight-2 && *(pbEdgeYPtr+iWidth) == true ) 7168 { 7169 if( *(psDiffYPtr+iWidth) >= 0) 7170 { 7171 usAbs2 = *(psDiffYPtr+iWidth); 7172 } 7173 else 7174 { 7175 usAbs2 = (-1) * *(psDiffYPtr+iWidth); 7176 } 7177 } 7178 7179 if( y == 0 ) 7180 { 7181 if( usAbs1 < usAbs2 ) 7182 *pbEdgeYPtr = false; 7183 } 7184 else if( y == iHeight-2 ) 7185 { 7186 if( usAbs1 <= usAbs0 ) 7187 *pbEdgeYPtr = false; 7188 } 7189 else 7190 { 7191 if( usAbs2 > usAbs0 ) 7192 { 7193 if( usAbs1 < usAbs2 ) 7194 *pbEdgeYPtr = false; 7195 } 7196 else 7197 { 7198 if( usAbs1 <= usAbs0 ) 7199 *pbEdgeYPtr = false; 7200 } 7201 } 7202 7203 psDiffYPtr++; 7204 pbEdgeYPtr++; 7205 } 7206 } 7207 7208 // Edge Merging 7209 for( Int i=0; i< 4 * iWidth * iHeight; i++ ) 7210 pbEdge[ i ] = false; 7211 /// Even Line (0,2,4,6,...) => Vertical Edge 7212 for( Int i=0; i<iHeight; i++) 7213 { 7214 for( Int j=0; j<iWidth-1; j++) 7215 { 7216 pbEdge[ (2 * j + 1) + (2 * i) * 2 * iWidth ] = pbEdgeX[ j + i * iHeight ]; 7217 } 7218 } 7219 /// Odd Line (1,3,5,7,...) => Horizontal Edge 7220 for( Int i=0; i<iHeight-1; i++) 7221 { 7222 for( Int j=0; j<iWidth; j++) 7223 { 7224 pbEdge[ (2 * j) + (2 * i + 1) * 2 * iWidth ] = pbEdgeY[ j + i * iHeight ]; 7225 } 7226 } 7227 7228 // Intersection Filling 7229 /// Vertical Edge between Horizontal Edges 7230 for( Int i = 1; i < 2 * iHeight - 3; i += 2) 7231 { 7232 for( Int j = 0; j < 2 * iWidth - 1; j += 2) 7233 { 7234 if( pbEdge[ j + i * 2 * iWidth ] ) 7235 { 7236 if( j != 0 && pbEdge[ (j - 2) + ((i + 2) * 2 * iWidth) ] ) 7237 { 7238 if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j - 1) + ((i + 3) * 2 * iWidth) ] ) 7239 pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] = true; 7240 } 7241 if( j != 2 * iWidth - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] ) 7242 { 7243 if( !pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 1) + ((i + 3) * 2 * iWidth) ] ) 7244 pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true; 7245 } 7246 } 7247 } 7248 } 7249 /// Horizontal Edge between Vertical Edges 7250 for( Int j = 1; j < 2 * iWidth - 3; j += 2) 7251 { 7252 for( Int i = 0; i < 2 * iHeight - 1; i += 2) 7253 { 7254 if( pbEdge[ j + i * 2 * iWidth ] ) 7255 { 7256 if( i != 0 && pbEdge[ (j + 2) + ((i - 2) * 2 * iWidth) ] ) 7257 { 7258 if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i - 1) * 2 * iWidth) ] ) 7259 pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] = true; 7260 } 7261 if( i != 2 * iHeight - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] ) 7262 { 7263 if( !pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i + 1) * 2 * iWidth) ] ) 7264 pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true; 7265 } 7266 } 7267 } 7268 } 7269 7270 // Static Pruning Unnecessary Edges 7271 /// Step1. Stack push the unconnected edges 7272 UShort* pusUnconnectedEdgeStack = new UShort[ 4 * iWidth * iHeight ]; // approximate size calculation 7273 Int iUnconnectedEdgeStackPtr = 0; 7274 //// Vertical Edges 7275 for( Int i = 0; i < 2 * iHeight - 1; i += 2 ) 7276 { 7277 for( Int j = 1; j < 2 * iWidth - 2; j += 2 ) 7278 { 7279 if( pbEdge[ j + i * 2 * iWidth ] ) 7280 { 7281 if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) ) 7282 { 7283 pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j); 7284 iUnconnectedEdgeStackPtr++; 7285 } 7286 } 7287 } 7288 } 7289 7290 //// Horizontal Edges 7291 for( Int i = 1; i < 2 * iHeight - 2; i += 2 ) 7292 { 7293 for( Int j = 0; j < 2 * iWidth - 1; j += 2 ) 7294 { 7295 if( pbEdge[ j + i * 2 * iWidth ] ) 7296 { 7297 if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) ) 7298 { 7299 pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j); 7300 iUnconnectedEdgeStackPtr++; 7301 } 7302 } 7303 } 7304 } 7305 7306 /// Step2. Remove the edges from the stack and push the new unconnected edges 7307 //// (This step may contain duplicated edges already in the stack) 7308 //// (But it doesn't cause any functional problems) 7309 while( iUnconnectedEdgeStackPtr != 0 ) 7310 { 7311 iUnconnectedEdgeStackPtr--; 7312 Int iX = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] & 0xff; 7313 Int iY = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] >> 8; 7314 7315 pbEdge[ iX + iY * 2 * iWidth ] = false; 7316 7317 if( iY % 2 == 1 && iX > 0 && pbEdge[ iX - 2 + iY * 2 * iWidth ] && 7318 !xCheckTerminatedEdge( pbEdge, iX - 2, iY, iWidth, iHeight ) ) // left 7319 { 7320 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX - 2); 7321 iUnconnectedEdgeStackPtr++; 7322 } 7323 if( iY % 2 == 1 && iX < 2 * iWidth - 2 && pbEdge[ iX + 2 + iY * 2 * iWidth ] && 7324 !xCheckTerminatedEdge( pbEdge, iX + 2, iY, iWidth, iHeight ) ) // right 7325 { 7326 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX + 2); 7327 iUnconnectedEdgeStackPtr++; 7328 } 7329 if( iY % 2 == 0 && iY > 0 && pbEdge[ iX + (iY - 2) * 2 * iWidth ] && 7330 !xCheckTerminatedEdge( pbEdge, iX, iY - 2, iWidth, iHeight ) ) // top 7331 { 7332 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 2) << 8) | (iX + 0); 7333 iUnconnectedEdgeStackPtr++; 7334 } 7335 if( iY % 2 == 0 && iY < 2 * iHeight - 2 && pbEdge[ iX + (iY + 2) * 2 * iWidth ] && 7336 !xCheckTerminatedEdge( pbEdge, iX, iY + 2, iWidth, iHeight ) ) // bottom 7337 { 7338 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 2) << 8) | (iX + 0); 7339 iUnconnectedEdgeStackPtr++; 7340 } 7341 if( iX > 0 && iY > 0 && pbEdge[ iX - 1 + (iY - 1) * 2 * iWidth ] && 7342 !xCheckTerminatedEdge( pbEdge, iX - 1, iY - 1, iWidth, iHeight ) ) // left-top 7343 { 7344 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX - 1); 7345 iUnconnectedEdgeStackPtr++; 7346 } 7347 if( iX < 2 * iWidth - 1 && iY > 0 && pbEdge[ iX + 1 + (iY - 1) * 2 * iWidth ] && 7348 !xCheckTerminatedEdge( pbEdge, iX + 1, iY - 1, iWidth, iHeight ) ) // right-top 7349 { 7350 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX + 1); 7351 iUnconnectedEdgeStackPtr++; 7352 } 7353 if( iX > 0 && iY < 2 * iHeight - 1 && pbEdge[ iX - 1 + (iY + 1) * 2 * iWidth ] && 7354 !xCheckTerminatedEdge( pbEdge, iX - 1, iY + 1, iWidth, iHeight ) ) // left-bottom 7355 { 7356 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX - 1); 7357 iUnconnectedEdgeStackPtr++; 7358 } 7359 if( iX < 2 * iWidth - 1 && iY < 2 * iHeight - 1 && pbEdge[ iX + 1 + (iY + 1) * 2 * iWidth ] && 7360 !xCheckTerminatedEdge( pbEdge, iX + 1, iY + 1, iWidth, iHeight ) ) // right-bottom 7361 { 7362 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX + 1); 7363 iUnconnectedEdgeStackPtr++; 7364 } 7365 } 7366 7367 7368 // Region Generation ( edge -> region ) 7369 Bool* pbRegion = pcCU->getEdgePartition( uiAbsPtIdx ); 7370 Bool* pbVisit = new Bool[ iWidth * iHeight ]; 7371 7372 for( UInt ui = 0; ui < iWidth * iHeight; ui++ ) 7373 { 7374 pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next) 7375 pbVisit [ ui ] = false; 7376 } 7377 7378 Int* piStack = new Int[ iWidth * iHeight ]; 7379 7380 Int iPtr = 0; 7381 7382 piStack[iPtr++] = (0 << 8) | (0); 7383 pbRegion[ 0 ] = false; 7384 7385 while(iPtr > 0) 7386 { 7387 Int iTmp = piStack[--iPtr]; 7388 Int iX1, iY1; 7389 iX1 = iTmp & 0xff; 7390 iY1 = (iTmp >> 8) & 0xff; 7391 7392 pbVisit[ iX1 + iY1 * iWidth ] = true; 7393 7394 assert( iX1 >= 0 && iX1 < iWidth ); 7395 assert( iY1 >= 0 && iY1 < iHeight ); 7396 7397 if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] ) 7398 { 7399 piStack[iPtr++] = (iY1 << 8) | (iX1 - 1); 7400 pbRegion[ iX1 - 1 + iY1 * iWidth ] = false; 7401 } 7402 if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] ) 7403 { 7404 piStack[iPtr++] = (iY1 << 8) | (iX1 + 1); 7405 pbRegion[ iX1 + 1 + iY1 * iWidth ] = false; 7406 } 7407 if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] ) 7408 { 7409 piStack[iPtr++] = ((iY1 - 1) << 8) | iX1; 7410 pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false; 7411 } 7412 if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] ) 7413 { 7414 piStack[iPtr++] = ((iY1 + 1) << 8) | iX1; 7415 pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false; 7416 } 7417 } 7418 7419 /////////// 7420 iPtr = 0; 7421 for( Int i = 0; i < iWidth * iHeight; i++ ) 7422 pbVisit[ i ] = false; 7423 piStack[ iPtr++ ] = (0 << 8) | (0); // initial seed 7424 while( iPtr > 0 && iPtr < iWidth * iHeight ) 7425 { 7426 Int iX; 7427 Int iY; 7428 iPtr--; 7429 iX = piStack[ iPtr ] & 0xff; 7430 iY = piStack[ iPtr ] >> 8; 7431 pbVisit[ iY * iWidth + iX ] = true; 7432 7433 if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] ) 7434 { 7435 piStack[ iPtr++ ] = ((iY - 1) << 8) | iX; 7436 } 7437 if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] ) 7438 { 7439 piStack[ iPtr++ ] = ((iY + 1) << 8) | iX; 7440 } 7441 if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] ) 7442 { 7443 piStack[ iPtr++ ] = (iY << 8) | (iX - 1); 7444 } 7445 if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] ) 7446 { 7447 piStack[ iPtr++ ] = (iY << 8) | (iX + 1); 7448 } 7449 } 7450 assert( iPtr == 0 || iPtr == iWidth * iHeight ); 7451 7452 Bool bBipartition; 7453 if( iPtr == iWidth * iHeight ) 7454 { 7455 bBipartition = false; // single partition 7456 } 7457 else 7458 { 7459 for( Int i = 0; i < iWidth * iHeight; i++ ) 7460 { 7461 if( !pbVisit[ i ] ) 7462 { 7463 piStack[ iPtr++ ] = (( i / iWidth ) << 8) | ( i % iWidth ); 7464 pbVisit[ i ] = true; 7465 break; 7466 } 7467 } 7468 while( iPtr > 0 ) 7469 { 7470 Int iX; 7471 Int iY; 7472 iPtr--; 7473 iX = piStack[ iPtr ] & 0xff; 7474 iY = piStack[ iPtr ] >> 8; 7475 pbVisit[ iY * iWidth + iX ] = true; 7476 7477 if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] ) 7478 { 7479 piStack[ iPtr++ ] = ((iY - 1) << 8) | iX; 7480 } 7481 if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] ) 7482 { 7483 piStack[ iPtr++ ] = ((iY + 1) << 8) | iX; 7484 } 7485 if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] ) 7486 { 7487 piStack[ iPtr++ ] = (iY << 8) | (iX - 1); 7488 } 7489 if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] ) 7490 { 7491 piStack[ iPtr++ ] = (iY << 8) | (iX + 1); 7492 } 7493 } 7494 bBipartition = true; 7495 for( Int i = 0; i < iWidth * iHeight; i++ ) 7496 { 7497 if( !pbVisit[ i ] ) 7498 { 7499 bBipartition = false; 7500 break; 7501 } 7502 } 7503 } 7504 7505 xFree( pbEdge ); 7506 delete[] pbEdgeX; pbEdgeX = NULL; 7507 delete[] pbEdgeY; pbEdgeY = NULL; 7508 delete[] psDiffX; psDiffX = NULL; 7509 delete[] psDiffY; psDiffY = NULL; 7510 delete[] pusUnconnectedEdgeStack; pusUnconnectedEdgeStack = NULL; 7511 delete[] pbVisit; pbVisit = NULL; 7512 delete[] piStack; piStack = NULL; 7513 7514 if( bBipartition ) 7515 { 7516 return xConstructChainCode( pcCU, uiAbsPtIdx, (UInt)iWidth, (UInt)iHeight ); 7517 } 7518 else 7519 { 7520 return false; 7521 } 7522 } 7523 7524 Bool TEncSearch::xCheckTerminatedEdge( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight ) 7525 { 7526 if( (iY % 2) == 0 ) // vertical edge 7527 { 7528 Bool bTopConnected = false; 7529 Bool bBottomConnected = false; 7530 7531 if( iY != 0 ) 7532 { 7533 if( pbEdge[ iX + (iY - 2) * 2 * iWidth ] ) 7534 bTopConnected = true; 7535 if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] ) 7536 bTopConnected = true; 7537 if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] ) 7538 bTopConnected = true; 7539 } 7540 else 7541 { 7542 bTopConnected = true; 7543 } 7544 7545 7546 if( iY != 2 * iHeight - 2 ) 7547 { 7548 if( pbEdge[ iX + (iY + 2) * 2 * iWidth ] ) 7549 bBottomConnected = true; 7550 if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] ) 7551 bBottomConnected = true; 7552 if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] ) 7553 bBottomConnected = true; 7554 } 7555 else 7556 { 7557 bBottomConnected = true; 7558 } 7559 7560 7561 if( bTopConnected && bBottomConnected ) 7562 { 7563 return true; 7564 } 7565 else 7566 { 7567 return false; 7568 } 7569 } 7570 else 7571 { 7572 Bool bLeftConnected = false; 7573 Bool bRightConnected = false; 7574 7575 if( iX != 0 ) 7576 { 7577 if( pbEdge[ (iX - 2) + iY * 2 * iWidth ] ) 7578 bLeftConnected = true; 7579 if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] ) 7580 bLeftConnected = true; 7581 if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] ) 7582 bLeftConnected = true; 7583 } 7584 else 7585 { 7586 bLeftConnected = true; 7587 } 7588 7589 if( iX != 2 * iWidth - 2 ) 7590 { 7591 if( pbEdge[ (iX + 2) + iY * 2 * iWidth ] ) 7592 bRightConnected = true; 7593 if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] ) 7594 bRightConnected = true; 7595 if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] ) 7596 bRightConnected = true; 7597 } 7598 else 7599 { 7600 bRightConnected = true; 7601 } 7602 7603 7604 if( bLeftConnected && bRightConnected ) 7605 { 7606 return true; 7607 } 7608 else 7609 { 7610 return false; 7611 } 7612 } 7613 } 7614 Bool TEncSearch::xConstructChainCode( TComDataCU* pcCU, UInt uiAbsPtIdx, UInt uiWidth, UInt uiHeight ) 7615 { 7616 //UInt uiWidth = pcCU->getWidth( uiPartIdx ) >> (bPU4x4 ? 1 : 0); 7617 //UInt uiHeight = pcCU->getHeight( uiPartIdx ) >> (bPU4x4 ? 1 : 0); 7618 Bool* pbEdge = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 ); 7619 Bool* pbVisit = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 ); 7620 UInt uiMaxEdge = uiWidth * (RBC_MAX_EDGE_NUM_PER_4x4 / 4); 7621 Bool* pbRegion = pcCU->getEdgePartition( uiAbsPtIdx ); 7622 UChar* piEdgeCode = pcCU->getEdgeCode( uiAbsPtIdx ); 7623 Bool bStartLeft = false; 7624 Bool bPossible = false; 7625 Bool bFinish = false; 7626 Int iStartPosition = -1; 7627 Int iPtr = 0; 7628 Int iDir = -1, iNextDir = -1; 7629 Int iArrow = -1, iNextArrow = -1; 7630 Int iX = -1, iY = -1; 7631 Int iDiffX = 0, iDiffY = 0; 7632 UChar iCode = 255; 7633 UInt uiWidth2 = uiWidth * 2; 7634 7635 for( Int i = 0; i < uiWidth * uiHeight * 4; i++ ) 7636 pbEdge[ i ] = false; 7637 7638 for( Int i = 0; i < uiHeight; i++ ) 7639 { 7640 for( Int j = 0; j < uiWidth - 1; j++ ) 7641 { 7642 if( pbRegion[ i * uiWidth + j ] != pbRegion[ i * uiWidth + j + 1 ] ) 7643 pbEdge[ i * uiWidth * 4 + j * 2 + 1 ] = true; 7644 } 7645 } 7646 7647 for( Int i = 0; i < uiHeight - 1; i++ ) 7648 { 7649 for( Int j = 0; j < uiWidth; j++ ) 7650 { 7651 if( pbRegion[ (i + 0) * uiWidth + j ] != pbRegion[ (i + 1) * uiWidth + j ] ) 7652 pbEdge[ (2 * i + 1) * 2 * uiWidth + j * 2 ] = true; 7653 } 7654 } 7655 7656 for( Int i = 1; i < uiWidth2 - 2; i+=2 ) 7657 { 7658 if(pbEdge[ i ]) 7659 { 7660 bPossible = true; 7661 bStartLeft = false; 7662 iStartPosition = iX = i; 7663 iY = 0; 7664 iDir = 3; 7665 iArrow = 3; 7666 break; 7667 } 7668 } 7669 7670 if( !bPossible ) 7671 { 7672 for( Int i = 1; i < uiWidth2 - 2; i+=2 ) 7673 { 7674 if(pbEdge[ i * uiWidth2 ]) 7675 { 7676 bPossible = true; 7677 bStartLeft = true; 7678 iX = 0; 7679 iStartPosition = iY = i; 7680 iDir = 1; 7681 iArrow = 1; 7682 break; 7683 } 7684 } 7685 } 7686 7687 if( bPossible ) 7688 { 7689 for( Int i = 0; i < 4 * uiWidth * uiHeight; i++ ) 7690 pbVisit[ i ] = false; 7691 7692 while( !bFinish ) 7693 { 7694 Bool bArrowSkip = false; 7695 pbVisit[ iX + iY * uiWidth2 ] = true; 7696 7697 switch( iDir ) 7698 { 7699 case 0: // left 7700 if( iX > 0 && !pbVisit[ (iX - 2) + iY * uiWidth2 ] && pbEdge[ (iX - 2) + iY * uiWidth2 ] ) // left 7701 { 7702 iDiffX = -2; 7703 iDiffY = 0; 7704 iNextDir = 0; 7705 iNextArrow = 0; 7706 } 7707 else if( iX > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // top 7708 { 7709 iDiffX = -1; 7710 iDiffY = -1; 7711 iNextDir = 2; 7712 iNextArrow = 4; 7713 } 7714 else if( iX > 0 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // bottom 7715 { 7716 iDiffX = -1; 7717 iDiffY = +1; 7718 iNextDir = 3; 7719 iNextArrow = iArrow; 7720 if( !(iPtr == 0 && iX == uiWidth2 - 2 && iY == uiHeight * 2 - 3) ) 7721 bArrowSkip = true; 7722 else 7723 iNextArrow = 3; 7724 } 7725 else if( iX == 0 ) 7726 { 7727 iDiffX = 0; 7728 iDiffY = 0; 7729 iNextDir = iDir; 7730 iNextArrow = iArrow; 7731 bFinish = true; 7732 continue; 7733 } 7734 else 7735 { 7736 iPtr = 0; // edge loop or unwanted case 7737 bFinish = true; 7738 //continue; 7739 assert(false); 7740 } 7741 break; 7742 case 1: // right 7743 if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 2) + iY * uiWidth2 ] && pbEdge[ (iX + 2) + iY * uiWidth2 ] ) // right 7744 { 7745 iDiffX = +2; 7746 iDiffY = 0; 7747 iNextDir = 1; 7748 iNextArrow = 1; 7749 } 7750 else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // top 7751 { 7752 iDiffX = +1; 7753 iDiffY = -1; 7754 iNextDir = 2; 7755 iNextArrow = iArrow; 7756 if( !(iPtr == 0 && iX == 0 && iY == 1) ) 7757 bArrowSkip = true; 7758 else 7759 iNextArrow = 2; 7760 } 7761 else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // bottom 7762 { 7763 iDiffX = +1; 7764 iDiffY = +1; 7765 iNextDir = 3; 7766 iNextArrow = 7; 7767 } 7768 else if( iX == uiWidth2 - 2 ) 7769 { 7770 iDiffX = 0; 7771 iDiffY = 0; 7772 iNextDir = iDir; 7773 iNextArrow = iArrow; 7774 bFinish = true; 7775 continue; 7776 } 7777 else 7778 { 7779 iPtr = 0; // edge loop or unwanted case 7780 bFinish = true; 7781 //continue; 7782 assert(false); 7783 } 7784 break; 7785 case 2: // top 7786 if( iY > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // left 7787 { 7788 iDiffX = -1; 7789 iDiffY = -1; 7790 iNextDir = 0; 7791 iNextArrow = iArrow; 7792 if( !(iPtr == 0 && iX == 1 && iY == uiHeight * 2 - 2) ) 7793 bArrowSkip = true; 7794 else 7795 iNextArrow = 0; 7796 } 7797 else if( iY > 0 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // right 7798 { 7799 iDiffX = +1; 7800 iDiffY = -1; 7801 iNextDir = 1; 7802 iNextArrow = 5; 7803 } 7804 else if( iY > 0 && !pbVisit[ iX + (iY - 2) * uiWidth2 ] && pbEdge[ iX + (iY - 2) * uiWidth2 ] ) // top 7805 { 7806 iDiffX = 0; 7807 iDiffY = -2; 7808 iNextDir = 2; 7809 iNextArrow = 2; 7810 } 7811 else if( iY == 0 ) 7812 { 7813 iDiffX = 0; 7814 iDiffY = 0; 7815 iNextDir = iDir; 7816 iNextArrow = iArrow; 7817 bFinish = true; 7818 continue; 7819 } 7820 else 7821 { 7822 iPtr = 0; // edge loop or unwanted case 7823 bFinish = true; 7824 //continue; 7825 assert(false); 7826 } 7827 break; 7828 case 3: // bottom 7829 if( iY < uiWidth2 - 2 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // left 7830 { 7831 iDiffX = -1; 7832 iDiffY = +1; 7833 iNextDir = 0; 7834 iNextArrow = 6; 7835 } 7836 else if( iY < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // right 7837 { 7838 iDiffX = +1; 7839 iDiffY = +1; 7840 iNextDir = 1; 7841 iNextArrow = iArrow; 7842 if( !(iPtr == 0 && iX == uiWidth * 2 - 3 && iY == 0) ) 7843 bArrowSkip = true; 7844 else 7845 iNextArrow = 1; 7846 } 7847 else if( iY < uiWidth2 - 2 && !pbVisit[ iX + (iY + 2) * uiWidth2 ] && pbEdge[ iX + (iY + 2) * uiWidth2 ] ) // bottom 7848 { 7849 iDiffX = 0; 7850 iDiffY = +2; 7851 iNextDir = 3; 7852 iNextArrow = 3; 7853 } 7854 else if( iY == uiWidth2 - 2 ) 7855 { 7856 iDiffX = 0; 7857 iDiffY = 0; 7858 iNextDir = iDir; 7859 iNextArrow = iArrow; 7860 bFinish = true; 7861 continue; 7862 } 7863 else 7864 { 7865 iPtr = 0; // edge loop or unwanted case 7866 bFinish = true; 7867 //continue; 7868 assert(false); 7869 } 7870 break; 7871 } 7872 7873 const UChar tableCode[8][8] = { { 0, -1, 4, 3, 2, 6, 1, 5 }, // iArrow(current direction), iNextArrow(next direction) 7874 { -1, 0, 3, 4, 5, 1, 6, 2 }, 7875 { 3, 4, 0, -1, 1, 2, 5, 6 }, 7876 { 4, 3, -1, 0, 6, 5, 2, 1 }, 7877 { 1, 6, 2, 5, 0, 4, 3, -1 }, 7878 { 5, 2, 1, 6, 3, 0, -1, 4 }, 7879 { 2, 5, 6, 1, 4, -1, 0, 3 }, 7880 { 6, 1, 5, 2, -1, 3, 4, 0 } }; 7881 7882 iCode = tableCode[iArrow][iNextArrow]; 7883 7884 if(iPtr >= uiMaxEdge) 7885 { 7886 iPtr = 0; // over the maximum number of edge 7887 bPossible = false; 7888 break; 7889 } 7890 7891 if( !bArrowSkip ) 7892 { 7893 piEdgeCode[iPtr++] = iCode; // first edge coding 7894 //printf("xEdgeCoding: (%d,%d)->(%d,%d) code %d\n",iX,iY, iX+iDiffX, iY+iDiffY, iCode); 7895 } 7896 7897 iX += iDiffX; 7898 iY += iDiffY; 7899 iDir = iNextDir; 7900 iArrow = iNextArrow; 7901 } 7902 } 7903 7904 pcCU->setEdgeLeftFirst( uiAbsPtIdx, bStartLeft ); 7905 pcCU->setEdgeStartPos ( uiAbsPtIdx, bStartLeft ? (iStartPosition - 1) >> 1 : (iStartPosition + 1) >> 1); 7906 pcCU->setEdgeNumber ( uiAbsPtIdx, iPtr ); 7907 7908 xFree( pbEdge ); 7909 xFree( pbVisit ); 7910 7911 return (iPtr != 0); 7912 } 7913 #endif 7914 #endif 6409 7915 //! \} -
branches/HTM-DEV-0.3-dev1/source/Lib/TLibEncoder/TEncSearch.h
r446 r459 325 325 UInt stateU0V1Both2 ); 326 326 327 328 // ------------------------------------------------------------------------------------------------------------------- 329 // Depth intra search 330 // ------------------------------------------------------------------------------------------------------------------- 331 #if H_3D_DIM 332 Void xCalcBiSegDCs ( Pel* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& valDC1, Pel& valDC2 ); 333 #if H_3D_DIM_DMM 334 Void xSearchDmmDeltaDCs ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 ); 335 Void xSearchDmm1Wedge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx ); 336 Void xSearchDmm2Wedge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Int& riWedgeDeltaEnd ); 337 Void xSearchDmm3Wedge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx ); 338 #endif 339 #if H_3D_DIM_RBC 340 Void xSearchRbcDeltaDCs ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 ); 341 Bool xSearchRbcEdge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, Int iWidth, Int iHeight ); 342 343 Bool xCheckTerminatedEdge ( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight ); 344 Bool xConstructChainCode ( TComDataCU* pcCU, UInt uiAbsPtIdx, UInt uiWidth, UInt uiHeight ); 345 #endif 346 #endif 347 327 348 // ------------------------------------------------------------------------------------------------------------------- 328 349 // Inter search (AMP)
Note: See TracChangeset for help on using the changeset viewer.