Changeset 764 in 3DVCSoftware for branches/HTM-9.2-dev0/source/Lib/TLibEncoder
- Timestamp:
- 12 Jan 2014, 00:23:20 (11 years ago)
- Location:
- branches/HTM-9.2-dev0/source/Lib/TLibEncoder
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-9.2-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp
r763 r764 2124 2124 } 2125 2125 #if H_3D_IC 2126 #if SEC_ONLY_TEXTURE_IC_F01512127 2126 else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) && !pcSlice->getIsDepth()) 2128 #else2129 else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) )2130 #endif2131 2127 { 2132 2128 WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "slice_ic_enable_flag" ); -
branches/HTM-9.2-dev0/source/Lib/TLibEncoder/TEncCfg.h
r758 r764 420 420 #if H_3D_DIM 421 421 Bool m_useDMM; 422 #if !SEC_DMM3_RBC_F0147423 Bool m_useRBC;424 #endif425 422 Bool m_useSDC; 426 423 Bool m_useDLT; … … 1003 1000 Bool getUseDMM () { return m_useDMM; } 1004 1001 Void setUseDMM ( Bool b) { m_useDMM = b; } 1005 #if !SEC_DMM3_RBC_F01471006 Bool getUseRBC () { return m_useRBC; }1007 Void setUseRBC ( Bool b) { m_useRBC = b; }1008 #endif1009 1002 Bool getUseSDC () { return m_useSDC; } 1010 1003 Void setUseSDC ( Bool b) { m_useSDC = b; } -
branches/HTM-9.2-dev0/source/Lib/TLibEncoder/TEncCu.cpp
r735 r764 497 497 #endif 498 498 #if H_3D_IC 499 #if SEC_ONLY_TEXTURE_IC_F0151500 499 Bool bICEnabled = rpcTempCU->getSlice()->getViewIndex() && ( rpcTempCU->getSlice()->getSliceType() == P_SLICE || rpcTempCU->getSlice()->getSliceType() == B_SLICE ) && !rpcTempCU->getSlice()->getIsDepth(); 501 #else502 Bool bICEnabled = rpcTempCU->getSlice()->getViewIndex() && ( rpcTempCU->getSlice()->getSliceType() == P_SLICE || rpcTempCU->getSlice()->getSliceType() == B_SLICE );503 #endif504 500 bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC(); 505 501 #endif … … 1779 1775 #endif 1780 1776 1781 #if H_3D_ARP && LGE_SHARP_VSP_INHERIT_F01041777 #if H_3D_ARP 1782 1778 DisInfo cOrigDisInfo = rpcTempCU->getDvInfo(0); 1783 1779 #else … … 1787 1783 1788 1784 #if H_3D_VSP 1789 #if ! (H_3D_ARP && LGE_SHARP_VSP_INHERIT_F0104)1785 #if !H_3D_ARP 1790 1786 Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; 1791 1787 memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); 1792 1788 InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; 1793 #if ETRIKHU_MERGE_REUSE_F00931794 1789 rpcTempCU->m_bAvailableFlagA1 = 0; 1795 1790 rpcTempCU->m_bAvailableFlagB1 = 0; … … 1799 1794 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); 1800 1795 rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo, numValidMergeCand ); 1801 #else 1802 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand ); 1803 #endif 1804 #endif 1805 #else 1806 #if ETRIKHU_MERGE_REUSE_F0093 1796 #endif 1797 #else 1807 1798 rpcTempCU->m_bAvailableFlagA1 = 0; 1808 1799 rpcTempCU->m_bAvailableFlagB1 = 0; … … 1812 1803 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); 1813 1804 rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); 1814 #else1815 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );1816 #endif1817 1805 #endif 1818 1806 … … 1822 1810 Int mergeCandBuffer[MRG_MAX_NUM_CANDS]; 1823 1811 #endif 1824 #if H_3D_ARP && LGE_SHARP_VSP_INHERIT_F01041812 #if H_3D_ARP 1825 1813 for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui ) 1826 1814 #else … … 1856 1844 memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS*sizeof(Int) ); 1857 1845 #endif 1858 #if LGE_SHARP_VSP_INHERIT_F01041859 1846 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level 1860 1847 rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth ); … … 1876 1863 puhInterDirSP = new UChar[rpcTempCU->getPic()->getPicSym()->getNumPartition()]; 1877 1864 #endif 1878 #if ETRIKHU_MERGE_REUSE_F00931865 #if H_3D 1879 1866 rpcTempCU->initAvailableFlags(); 1880 1867 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); … … 1888 1875 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand ); 1889 1876 #endif 1890 #endif 1877 1891 1878 #endif 1892 1879 for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual ) … … 1950 1937 rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level 1951 1938 #if MTK_SPIVMP_F0110 1952 }1953 #endif1954 #if H_3D_ARP && !QC_MTK_INTERVIEW_ARP_F0123_F01081955 if( nARPW )1956 {1957 Bool bSignalflag[2] = { true, true };1958 for( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx ++ )1959 {1960 Int iRefIdx = cMvFieldNeighbours[uiRefListIdx + 2*uiMergeCand].getRefIdx();1961 RefPicList eRefList = uiRefListIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;1962 if( iRefIdx < 0 || rpcTempCU->getSlice()->getPOC() == rpcTempCU->getSlice()->getRefPOC(eRefList, iRefIdx) )1963 {1964 bSignalflag[uiRefListIdx] = false;1965 }1966 }1967 if( !bSignalflag[0] && !bSignalflag[1] )1968 {1969 #if LGE_SHARP_VSP_INHERIT_F01041970 continue;1971 #else1972 rpcTempCU->setARPWSubParts( 0 , 0 , uhDepth );1973 #endif1974 }1975 1939 } 1976 1940 #endif -
branches/HTM-9.2-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp
r724 r764 160 160 Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 161 161 { 162 #if SEC_ONLY_TEXTURE_IC_F0151163 162 if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() ) 164 #else165 if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) )166 #endif167 163 { 168 164 return; -
branches/HTM-9.2-dev0/source/Lib/TLibEncoder/TEncSbac.cpp
r758 r764 95 95 #if H_3D_DIM_DMM 96 96 , m_cDmm1DataSCModel ( 1, 1, NUM_DMM1_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 97 #if !SEC_DMM3_RBC_F014798 , m_cDmm3DataSCModel ( 1, 1, NUM_DMM3_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels)99 #endif100 #endif101 #if H_3D_DIM_RBC102 , m_cRbcDataSCModel ( 1, 1, NUM_RBC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels)103 97 #endif 104 98 #if H_3D_DIM_SDC … … 176 170 #if H_3D_DIM_DMM 177 171 m_cDmm1DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA ); 178 #if !SEC_DMM3_RBC_F0147179 m_cDmm3DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA );180 #endif181 #endif182 #if H_3D_DIM_RBC183 m_cRbcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_RBC_DATA );184 172 #endif 185 173 #if H_3D_DIM_SDC … … 266 254 #if H_3D_DIM_DMM 267 255 curCost += m_cDmm1DataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DMM1_DATA ); 268 #if !SEC_DMM3_RBC_F0147269 curCost += m_cDmm3DataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DMM3_DATA );270 #endif271 #endif272 #if H_3D_DIM_RBC273 curCost += m_cRbcDataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_RBC_DATA );274 256 #endif 275 257 } … … 337 319 #if H_3D_DIM_DMM 338 320 m_cDmm1DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA ); 339 #if !SEC_DMM3_RBC_F0147340 m_cDmm3DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA );341 #endif342 #endif343 #if H_3D_DIM_RBC344 m_cRbcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_RBC_DATA );345 321 #endif 346 322 #if H_3D_DIM_SDC … … 526 502 } 527 503 528 #if QC_DIM_DELTADC_UNIFY_F0132529 504 Void TEncSbac::xCodeDimDeltaDC( Pel valDeltaDC, UInt uiNumSeg ) 530 505 { … … 536 511 } 537 512 } 538 #else539 Void TEncSbac::xCodeDimDeltaDC( Pel valDeltaDC, UInt dimType )540 {541 xWriteExGolombLevel( UInt( abs( valDeltaDC ) ), m_cDdcDataSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) );542 if( valDeltaDC != 0 )543 {544 UInt uiSign = valDeltaDC > 0 ? 0 : 1;545 m_pcBinIf->encodeBinEP( uiSign );546 }547 }548 #endif549 513 550 514 #if H_3D_DIM_DMM … … 557 521 } 558 522 559 #if !SEC_DMM3_RBC_F0147 560 Void TEncSbac::xCodeDmm3WedgeIdx( UInt uiIntraIdx, Int iNumBit ) 561 { 562 for( Int i = 0; i < iNumBit; i++ ) 563 { 564 m_pcBinIf->encodeBin( ( uiIntraIdx >> i ) & 1, m_cDmm3DataSCModel.get(0, 0, 0) ); 565 } 566 } 567 #endif 568 #endif 569 #if H_3D_DIM_RBC 570 Void TEncSbac::xCodeRbcEdge( TComDataCU* pcCU, UInt uiAbsPartIdx ) 571 { 572 UInt uiDepth = pcCU->getDepth( uiAbsPartIdx ) + (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0); 573 UChar* pucSymbolList = pcCU->getEdgeCode ( uiAbsPartIdx ); 574 UChar ucEdgeNumber = pcCU->getEdgeNumber ( uiAbsPartIdx ); 575 Bool bLeft = pcCU->getEdgeLeftFirst( uiAbsPartIdx ); 576 UChar ucStart = pcCU->getEdgeStartPos ( uiAbsPartIdx ); 577 UInt uiSymbol; 578 579 // 1. Top(0) or Left(1) 580 uiSymbol = (bLeft == false) ? 0 : 1; 581 m_pcBinIf->encodeBinEP( uiSymbol ); 582 583 // 2. Start position (lowest bit first) 584 uiSymbol = ucStart; 585 for( UInt ui = 6; ui > uiDepth; ui-- ) // 64(0)->6, 32(1)->5, 16(2)->4, 8(3)->3, 4(4)->2 586 { 587 m_pcBinIf->encodeBinEP( uiSymbol & 0x1 ); 588 uiSymbol >>= 1; 589 } 590 591 // 3. Number of edges 592 uiSymbol = ucEdgeNumber > 0 ? ucEdgeNumber - 1 : 0; 593 for( UInt ui = 7; ui > uiDepth; ui-- ) // 64(0)->7, 32(1)->6, 16(2)->5, 8(3)->4, 4(4)->3 594 { 595 m_pcBinIf->encodeBinEP( uiSymbol & 0x1 ); 596 uiSymbol >>= 1; 597 } 598 599 if(uiSymbol != 0) 600 { 601 printf(" ucEdgeNumber %d at depth %d\n",ucEdgeNumber, uiDepth); 602 assert(false); 603 } 604 605 // 4. Edges 606 for( Int iPtr2 = 0; iPtr2 < ucEdgeNumber; iPtr2++ ) 607 { 608 UInt uiReorderSymbol = pucSymbolList[iPtr2]; 609 for( UInt ui = 0; ui < uiReorderSymbol; ui++ ) 610 { 611 m_pcBinIf->encodeBin( 1, m_cRbcDataSCModel.get( 0, 0, 0 ) ); 612 } 613 614 if( uiReorderSymbol != 6 ) 615 m_pcBinIf->encodeBin( 0, m_cRbcDataSCModel.get( 0, 0, 0 ) ); 616 } 617 } 618 #endif 523 #endif 524 619 525 #if H_3D_DIM_SDC 620 526 Void TEncSbac::xCodeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) … … 1239 1145 xCodeDmm1WedgeIdx( pcCU->getDmmWedgeTabIdx( dimType, absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); 1240 1146 } break; 1241 #if !SEC_DMM3_RBC_F01471242 case( DMM3_IDX ):1243 {1244 xCodeDmm3WedgeIdx( pcCU->getDmm3IntraTabIdx( absPartIdx ), g_dmm3IntraTabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );1245 } break;1246 #endif1247 1147 case( DMM4_IDX ): break; 1248 1148 #endif 1249 #if H_3D_DIM_RBC1250 case( RBC_IDX ):1251 {1252 assert( pcCU->getWidth( absPartIdx ) < 64 );1253 xCodeRbcEdge( pcCU, absPartIdx );1254 } break;1255 #endif1256 1149 default: break; 1257 1150 } 1258 1151 1259 #if H_3D_DIM_SDC && !QC_DIM_DELTADC_UNIFY_F0132 1260 if( pcCU->getSDCFlag( absPartIdx ) ) 1261 { 1262 assert(pcCU->getPartitionSize(absPartIdx)==SIZE_2Nx2N); 1263 UInt uiNumSegments = ( dir == DC_IDX || dir == PLANAR_IDX )? 1 : 2; 1264 for(UInt uiSeg=0; uiSeg<uiNumSegments; uiSeg++) 1265 { 1266 xCodeSDCResidualData(pcCU, absPartIdx, uiSeg); 1267 } 1268 } 1269 else 1270 { 1271 #endif 1272 #if QC_DIM_DELTADC_UNIFY_F0132 1273 if( dimType < DIM_NUM_TYPE || pcCU->getSDCFlag( absPartIdx ) ) 1274 #else 1275 if( dimType < DIM_NUM_TYPE ) 1276 #endif 1277 { 1278 #if QC_DIM_DELTADC_UNIFY_F0132 1279 UInt dimDeltaDC; 1280 Pel deltaDC; 1281 UInt uiNumSegments = ( dir == PLANAR_IDX ) ? 1 : 2; 1282 if( pcCU->getSDCFlag( absPartIdx ) ) 1283 { 1284 if( uiNumSegments==1 ) 1285 { 1286 dimDeltaDC = pcCU->getSDCSegmentDCOffset(0, absPartIdx) ? 1 : 0; 1287 } 1288 else 1289 { 1290 dimDeltaDC = ( pcCU->getSDCSegmentDCOffset(0, absPartIdx) || pcCU->getSDCSegmentDCOffset(1, absPartIdx) ) ? 1 : 0; 1291 } 1152 if( dimType < DIM_NUM_TYPE || pcCU->getSDCFlag( absPartIdx ) ) 1153 { 1154 UInt dimDeltaDC; 1155 Pel deltaDC; 1156 UInt uiNumSegments = ( dir == PLANAR_IDX ) ? 1 : 2; 1157 if( pcCU->getSDCFlag( absPartIdx ) ) 1158 { 1159 if( uiNumSegments==1 ) 1160 { 1161 dimDeltaDC = pcCU->getSDCSegmentDCOffset(0, absPartIdx) ? 1 : 0; 1292 1162 } 1293 1163 else 1294 1164 { 1295 dimDeltaDC = isDimDeltaDC( dir ); 1296 } 1297 1298 m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get(0, 0, uiNumSegments-1) ); 1299 1300 if( dimDeltaDC ) 1301 { 1302 for( UInt segment = 0; segment < uiNumSegments; segment++ ) 1303 { 1304 deltaDC = pcCU->getSDCFlag( absPartIdx ) ? pcCU->getSDCSegmentDCOffset(segment, absPartIdx) : pcCU->getDimDeltaDC( dimType, segment, absPartIdx ); 1305 xCodeDimDeltaDC( deltaDC, uiNumSegments ); 1306 } 1307 } 1308 #else 1309 UInt dimDeltaDC = isDimDeltaDC( dir ); 1310 m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) ); 1311 if( dimDeltaDC ) 1312 { 1313 for( UInt segment = 0; segment < 2; segment++ ) 1314 { 1315 xCodeDimDeltaDC( pcCU->getDimDeltaDC( dimType, segment, absPartIdx ), dimType ); 1316 } 1317 } 1318 #endif 1319 } 1320 #if H_3D_DIM_SDC && !QC_DIM_DELTADC_UNIFY_F0132 1321 } 1322 #endif 1165 dimDeltaDC = ( pcCU->getSDCSegmentDCOffset(0, absPartIdx) || pcCU->getSDCSegmentDCOffset(1, absPartIdx) ) ? 1 : 0; 1166 } 1167 } 1168 else 1169 { 1170 dimDeltaDC = isDimDeltaDC( dir ); 1171 } 1172 1173 m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get(0, 0, uiNumSegments-1) ); 1174 1175 if( dimDeltaDC ) 1176 { 1177 for( UInt segment = 0; segment < uiNumSegments; segment++ ) 1178 { 1179 deltaDC = pcCU->getSDCFlag( absPartIdx ) ? pcCU->getSDCSegmentDCOffset(segment, absPartIdx) : pcCU->getDimDeltaDC( dimType, segment, absPartIdx ); 1180 xCodeDimDeltaDC( deltaDC, uiNumSegments ); 1181 } 1182 } 1183 } 1323 1184 } 1324 1185 1325 1186 Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx ) 1326 1187 { 1327 #if SEC_DMM3_RBC_F01471328 1188 UInt codeWordTable[3][7] = {{0, 0, 0, 1, 0, 0, 0},{0, 2, 6, 14, 15, 0, 0},{0, 1, 0, 0, 0, 0, 0}}; 1329 1189 UInt codeWordLenTable[3][7] = {{0, 1, 0, 1, 0, 0, 0},{1, 2, 3, 4, 4, 0, 0},{1, 1, 0, 0, 0, 0, 0}}; 1330 #else1331 UInt codeWordTable[3][7] = {{0, 0, 0, 2, 0,6, 7},{0, 0, 2, 7, 3, 6, 2},{0, 1, 0, 0, 0, 0, 0}};1332 UInt codeWordLenTable[3][7] = {{0, 1, 0, 2, 0,3, 3},{1, 1, 2, 3, 2, 3, 2},{1, 1, 0, 0, 0, 0, 0}};1333 #endif1334 1190 UInt dir = pcCU->getLumaIntraDir( absPartIdx ); 1335 1191 UInt puIdx = (pcCU->getWidth(absPartIdx) == 64) ? 2 : ( (pcCU->getPartitionSize(absPartIdx) == SIZE_NxN && pcCU->getWidth(absPartIdx) == 8) ? 0 : 1 ); … … 1346 1202 case DMM1_IDX: codeIdx = 3; break; 1347 1203 case DMM4_IDX: codeIdx = 4; break; 1348 #if !SEC_DMM3_RBC_F01471349 case DMM3_IDX: codeIdx = 5; break;1350 case RBC_IDX: codeIdx = 6; break;1351 #endif1352 1204 default: break; 1353 1205 } … … 1362 1214 default: codeIdx = 2; break; 1363 1215 } 1364 }1365 #endif1366 #if !SEC_DMM3_RBC_F01471367 if( puIdx==1 )1368 {1369 if( codeIdx==1 || codeIdx==2 || codeIdx==4 )1370 {1371 m_pcBinIf->encodeBinEP( 0 );1372 }1373 else1374 {1375 m_pcBinIf->encodeBinEP( 1 );1376 }1377 1216 } 1378 1217 #endif -
branches/HTM-9.2-dev0/source/Lib/TLibEncoder/TEncSbac.h
r724 r764 116 116 Void xWriteEpExGolomb ( UInt uiSymbol, UInt uiCount ); 117 117 Void xWriteCoefRemainExGolomb ( UInt symbol, UInt &rParam ); 118 118 #if H_3D_DIM 119 119 Void xWriteExGolombLevel ( UInt uiSymbol, ContextModel& rcSCModel ); 120 #if QC_DIM_DELTADC_UNIFY_F0132121 120 Void xCodeDimDeltaDC ( Pel valDeltaDC, UInt uiNumSeg ); 122 #else123 Void xCodeDimDeltaDC ( Pel valDeltaDC, UInt dimType );124 #endif125 121 #if H_3D_DIM_DMM 126 122 Void xCodeDmm1WedgeIdx ( UInt uiTabIdx, Int iNumBit ); 127 #if !SEC_DMM3_RBC_F0147128 Void xCodeDmm3WedgeIdx ( UInt uiIntraIdx, Int iNumBit );129 #endif130 #endif131 #if H_3D_DIM_RBC132 Void xCodeRbcEdge ( TComDataCU* pcCU, UInt uiAbsPartIdx );133 123 #endif 134 124 #if H_3D_DIM_SDC … … 259 249 #if H_3D_DIM_DMM 260 250 ContextModel3DBuffer m_cDmm1DataSCModel; 261 #if !SEC_DMM3_RBC_F0147262 ContextModel3DBuffer m_cDmm3DataSCModel;263 #endif264 #endif265 #if H_3D_DIM_RBC266 ContextModel3DBuffer m_cRbcDataSCModel;267 251 #endif 268 252 #if H_3D_DIM_SDC -
branches/HTM-9.2-dev0/source/Lib/TLibEncoder/TEncSearch.cpp
r758 r764 1124 1124 { 1125 1125 #endif 1126 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 1127 { 1128 #if LGE_PRED_RES_CODING_DLT_DOMAIN_F0159 1129 #if DLT_DIFF_CODING_IN_PPS 1130 if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) ) 1131 #else 1132 if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) ) 1133 #endif 1126 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 1127 { 1128 #if H_3D_DIM 1129 if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) ) 1134 1130 { 1135 #if DLT_DIFF_CODING_IN_PPS1136 1131 pResi[ uiX ] = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pOrg[ uiX ] ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ); 1137 #else1138 pResi[ uiX ] = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pOrg[ uiX ] ) - pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] );1139 #endif1140 1132 } 1141 1133 else 1142 1134 { 1143 1135 pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ]; 1144 1136 } 1145 1137 #else 1146 pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];1147 #endif 1148 }1149 pOrg += uiStride;1150 pResi += uiStride;1151 pPred += uiStride;1138 pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ]; 1139 #endif 1140 } 1141 pOrg += uiStride; 1142 pResi += uiStride; 1143 pPred += uiStride; 1152 1144 #if H_3D_DIM_ENC 1153 1145 } … … 1209 1201 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 1210 1202 { 1211 #if LGE_PRED_RES_CODING_DLT_DOMAIN_F0159 1212 #if DLT_DIFF_CODING_IN_PPS 1203 #if H_3D_DIM 1213 1204 if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) ) 1214 #else 1215 if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) ) 1216 #endif 1217 { 1218 #if DLT_DIFF_CODING_IN_PPS 1219 pReco [ uiX ] = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) ); 1220 #else 1221 pReco [ uiX ] = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getVPS()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) ); 1222 #endif 1223 } 1224 else 1225 { 1226 pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); 1227 } 1205 { 1206 pReco [ uiX ] = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) ); 1207 } 1208 else 1209 { 1210 pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); 1211 } 1228 1212 #else 1229 1213 pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); … … 2924 2908 biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]); 2925 2909 } break; 2926 #if !SEC_DMM3_RBC_F0147 2927 case( DMM3_IDX ): 2928 { 2929 2930 TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); 2931 TComDataCU* pcColTexCU = pcPicTex->getCU( pcCU->getAddr() ); 2932 UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiPartOffset; 2933 Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; 2934 2935 if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) 2936 { 2937 UInt uiIntraTabIdx = 0; 2938 xSearchDmm3Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx, uiIntraTabIdx, uiColTexIntraDir ); 2939 pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dmmType, uiPartOffset, uiDepth + uiInitTrDepth ); 2940 pcCU->setDmm3IntraTabIdxSubParts( uiIntraTabIdx, uiPartOffset, uiDepth + uiInitTrDepth ); 2941 biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]); 2942 } 2943 } break; 2944 #endif 2910 2945 2911 case( DMM4_IDX ): 2946 2912 { … … 2968 2934 } 2969 2935 #endif 2970 #if H_3D_DIM_RBC2971 if( m_pcEncCfg->getUseRBC()2972 #if H_3D_FAST_DEPTH_INTRA2973 && (uiRdModeList[0] != PLANAR_IDX || varCU >= varThreshold)2974 #endif2975 )2976 {2977 if( xSearchRbcEdge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight ) )2978 {2979 Pel deltaDC1 = 0; Pel deltaDC2 = 0;2980 #if QC_DIM_DELTADC_UNIFY_F01322981 xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, pcCU->getEdgePartition( uiPartOffset ), uiWidth, uiWidth, uiHeight, deltaDC1, deltaDC2 );2982 #else2983 xSearchRbcDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, pcCU->getEdgePartition( uiPartOffset ), uiWidth, uiWidth, uiHeight, deltaDC1, deltaDC2 );2984 #endif2985 pcCU->setDimDeltaDC( RBC_IDX, 0, uiPartOffset, deltaDC1 );2986 pcCU->setDimDeltaDC( RBC_IDX, 1, uiPartOffset, deltaDC2 );2987 2988 uiRdModeList[ numModesForFullRD++ ] = (2*RBC_IDX +DIM_OFFSET);2989 uiRdModeList[ numModesForFullRD++ ] = (2*RBC_IDX+1+DIM_OFFSET);2990 }2991 }2992 #endif2993 2936 } 2994 2937 #endif … … 3029 2972 Bool bTestZeroResi = false; 3030 2973 #if H_3D_DIM_ENC 3031 #if LGE_BUGFIX_F01583032 2974 bTestZeroResi |= pcCU->getSlice()->getIsDepth() && !pcCU->getSlice()->isIRAP(); 3033 #else3034 bTestZeroResi |= pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->isIRAP();3035 #endif3036 2975 #endif 3037 2976 #if H_3D_DIM_SDC … … 3660 3599 if ( iPUIdx == 0 ) 3661 3600 { 3662 #if ETRIKHU_MERGE_REUSE_F00933601 #if H_3D 3663 3602 pcCU->initAvailableFlags(); 3664 3603 pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand); … … 3674 3613 ); 3675 3614 #else 3676 pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours 3677 #if H_3D_VSP 3678 , vspFlag 3679 , inheritedVSPDisInfo 3680 #endif 3681 , numValidMergeCand 3682 ); 3615 pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); 3683 3616 #endif 3684 3617 } … … 3687 3620 else 3688 3621 { 3689 #if ETRIKHU_MERGE_REUSE_F00933622 #if H_3D 3690 3623 pcCU->initAvailableFlags(); 3691 3624 pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand); … … 3701 3634 ); 3702 3635 #else 3703 pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours 3704 #if H_3D_VSP 3705 , vspFlag 3706 , inheritedVSPDisInfo 3707 #endif 3708 , numValidMergeCand 3636 pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand 3709 3637 ); 3710 3638 #endif … … 7477 7405 } 7478 7406 7479 #if !SEC_DMM3_RBC_F0147 7480 Void TEncSearch::xSearchDmm3Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx, UInt colTexIntraDir ) 7481 { 7482 ruiTabIdx = 0; 7483 ruiIntraTabIdx = 0; 7484 7485 // local pred buffer 7486 TComYuv cPredYuv; 7487 cPredYuv.create( uiWidth, uiHeight ); 7488 cPredYuv.clear(); 7489 Pel* piPred = cPredYuv.getLumaAddr(); 7490 UInt uiPredStride = cPredYuv.getStride(); 7491 7492 // wedge search 7493 UInt uiBestDist = MAX_UINT; 7494 WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])]; 7495 Pel refDC1 = 0; Pel refDC2 = 0; 7496 7497 std::vector< std::vector<UInt> > pauiWdgLstSz = g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]]; 7498 std::vector<UInt>* pauiWdgLst = &pauiWdgLstSz[colTexIntraDir-2]; 7499 for( UInt uiIdxW = 0; uiIdxW < pauiWdgLst->size(); uiIdxW++ ) 7500 { 7501 UInt uiIdx = pauiWdgLst->at(uiIdxW); 7502 TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiIdx)); 7503 xCalcBiSegDCs ( piRef, uiRefStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 7504 xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 7505 7506 UInt uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD ); 7507 if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) 7508 { 7509 uiBestDist = uiActDist; 7510 ruiTabIdx = uiIdx; 7511 ruiIntraTabIdx = uiIdxW; 7512 } 7513 } 7514 cPredYuv.destroy(); 7515 } 7516 #endif 7517 #endif 7518 #if H_3D_DIM_RBC 7519 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 ) 7520 { 7521 assert( biSegPattern ); 7522 Pel origDC1 = 0; Pel origDC2 = 0; 7523 xCalcBiSegDCs ( piOrig, uiStride, biSegPattern, patternStride, origDC1, origDC2 ); 7524 xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, origDC1, origDC2 ); 7525 7526 Int* piMask = pcCU->getPattern()->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); // no filtering for DMM 7527 Int maskStride = 2*uiWidth + 1; 7528 Int* ptrSrc = piMask+maskStride+1; 7529 Pel predDC1 = 0; Pel predDC2 = 0; 7530 xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 ); 7531 7532 rDeltaDC1 = origDC1 - predDC1; 7533 rDeltaDC2 = origDC2 - predDC2; 7534 7535 #if H_3D_VSO 7536 if( m_pcRdCost->getUseVSO() ) 7537 { 7538 Pel fullDeltaDC1 = rDeltaDC1; 7539 Pel fullDeltaDC2 = rDeltaDC2; 7540 7541 xDeltaDCQuantScaleDown( pcCU, fullDeltaDC1 ); 7542 xDeltaDCQuantScaleDown( pcCU, fullDeltaDC2 ); 7543 7544 Dist uiBestDist = RDO_DIST_MAX; 7545 UInt uiBestQStepDC1 = 0; 7546 UInt uiBestQStepDC2 = 0; 7547 7548 UInt uiDeltaDC1Max = abs(fullDeltaDC1); 7549 UInt uiDeltaDC2Max = abs(fullDeltaDC2); 7550 7551 //VSO Level delta DC check range extension 7552 uiDeltaDC1Max += (uiDeltaDC1Max>>1); 7553 uiDeltaDC2Max += (uiDeltaDC2Max>>1); 7554 7555 for( UInt uiQStepDC1 = 1; uiQStepDC1 <= uiDeltaDC1Max; uiQStepDC1++ ) 7556 { 7557 Pel iLevelDeltaDC1 = (Pel)(uiQStepDC1) * (Pel)(( fullDeltaDC1 < 0 ) ? -1 : 1); 7558 xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC1 ); 7559 Pel testDC1 = ClipY( predDC1 + iLevelDeltaDC1 ); 7560 7561 for( UInt uiQStepDC2 = 1; uiQStepDC2 <= uiDeltaDC2Max; uiQStepDC2++ ) 7562 { 7563 Pel iLevelDeltaDC2 = (Pel)(uiQStepDC2) * (Pel)(( fullDeltaDC2 < 0 ) ? -1 : 1); 7564 xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC2 ); 7565 Pel testDC2 = ClipY( predDC2 + iLevelDeltaDC2 ); 7566 7567 xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, testDC1, testDC2 ); 7568 7569 Dist uiActDist = RDO_DIST_MAX; 7570 if( m_pcRdCost->getUseEstimatedVSD() ) 7571 { 7572 uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false ); 7573 } 7574 else 7575 { 7576 uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false ); 7577 } 7578 7579 if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 7580 { 7581 uiBestDist = uiActDist; 7582 uiBestQStepDC1 = uiQStepDC1; 7583 uiBestQStepDC2 = uiQStepDC2; 7584 } 7585 } 7586 } 7587 7588 fullDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( fullDeltaDC1 < 0 ) ? -1 : 1); 7589 fullDeltaDC2 = (Int)(uiBestQStepDC2) * (Int)(( fullDeltaDC2 < 0 ) ? -1 : 1); 7590 xDeltaDCQuantScaleUp( pcCU, fullDeltaDC1 ); 7591 xDeltaDCQuantScaleUp( pcCU, fullDeltaDC2 ); 7592 rDeltaDC1 = fullDeltaDC1; 7593 rDeltaDC2 = fullDeltaDC2; 7594 } 7595 #endif 7596 7597 xDeltaDCQuantScaleDown( pcCU, rDeltaDC1 ); 7598 xDeltaDCQuantScaleDown( pcCU, rDeltaDC2 ); 7599 } 7600 7601 Bool TEncSearch::xSearchRbcEdge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, Int iWidth, Int iHeight ) 7602 { 7603 Bool* pbEdge = (Bool*) xMalloc( Bool, iWidth * iHeight * 4 ); 7604 7605 Short* psDiffX = new Short[ iWidth * iHeight ]; 7606 Short* psDiffY = new Short[ iWidth * iHeight ]; 7607 Bool* pbEdgeX = new Bool [ iWidth * iHeight ]; 7608 Bool* pbEdgeY = new Bool [ iWidth * iHeight ]; 7609 7610 // Find Horizontal Gradient & Edge Detection ((x+1, y) - (x,y)) 7611 for( Int y=0; y<iHeight; y++ ) 7612 { 7613 Short* psDiffXPtr = &psDiffX[ y * iHeight ]; 7614 Bool* pbEdgeXPtr = &pbEdgeX[ y * iHeight ]; 7615 for(Int x=0; x<iWidth-1; x++ ) 7616 { 7617 *psDiffXPtr = piRef[ x+1 + y*uiRefStride ] - piRef[ x + y*uiRefStride ]; 7618 if(*psDiffXPtr >= RBC_THRESHOLD || *psDiffXPtr <= (-1)*RBC_THRESHOLD) 7619 { 7620 *pbEdgeXPtr = true; 7621 } 7622 else 7623 { 7624 *pbEdgeXPtr = false; 7625 } 7626 7627 psDiffXPtr++; 7628 pbEdgeXPtr++; 7629 } 7630 } 7631 7632 // Find Vertical Gradient & Edge Detection((x,y+1) - (x,y)) 7633 for( Int y=0; y<iHeight-1; y++ ) 7634 { 7635 Short* psDiffYPtr = &psDiffY[ y * iHeight ]; 7636 Bool* pbEdgeYPtr = &pbEdgeY[ y * iHeight ]; 7637 for(Int x=0; x<iWidth; x++ ) 7638 { 7639 *psDiffYPtr = piRef[ x + (y+1)*uiRefStride ] - piRef[ x + y*uiRefStride ]; 7640 if(*psDiffYPtr >= RBC_THRESHOLD || *psDiffYPtr <= (-1)*RBC_THRESHOLD) 7641 { 7642 *pbEdgeYPtr = true; 7643 } 7644 else 7645 { 7646 *pbEdgeYPtr = false; 7647 } 7648 7649 psDiffYPtr++; 7650 pbEdgeYPtr++; 7651 } 7652 } 7653 7654 // Eliminate local maximum 7655 for( Int y=0; y<iHeight; y++ ) 7656 { 7657 Short* psDiffXPtr = &psDiffX[ y * iHeight ]; 7658 Bool* pbEdgeXPtr = &pbEdgeX[ y * iHeight ]; 7659 for( Int x=0; x<iWidth-1; x++ ) 7660 { 7661 UShort usAbs0=0, usAbs1=0, usAbs2=0; // 0 : left, 1 : current, 2 : right 7662 7663 if( x > 0 && *(pbEdgeXPtr-1) == true ) 7664 { 7665 if( *(psDiffXPtr-1) >= 0) 7666 { 7667 usAbs0 = *(psDiffXPtr-1); 7668 7669 } 7670 else 7671 { 7672 usAbs0 = (-1) * *(psDiffXPtr-1); 7673 } 7674 } 7675 if( *pbEdgeXPtr == true ) 7676 { 7677 if( *(psDiffXPtr) >= 0) 7678 { 7679 usAbs1 = *(psDiffXPtr); 7680 } 7681 else 7682 { 7683 usAbs1 = (-1) * *(psDiffXPtr); 7684 } 7685 } 7686 if( x < iWidth-2 && *(pbEdgeXPtr+1) == true ) 7687 { 7688 if( *(psDiffXPtr+1) >= 0) 7689 { 7690 usAbs2 = *(psDiffXPtr+1); 7691 //bSign2 = true; 7692 } 7693 else 7694 { 7695 usAbs2 = (-1) * *(psDiffXPtr+1); 7696 } 7697 } 7698 7699 if( x == 0 ) 7700 { 7701 if( usAbs1 < usAbs2 ) 7702 { 7703 *pbEdgeXPtr = false; 7704 } 7705 } 7706 else if( x == iWidth-2 ) 7707 { 7708 if( usAbs1 <= usAbs0 ) 7709 *pbEdgeXPtr = false; 7710 } 7711 else 7712 { 7713 if( usAbs2 > usAbs0 ) 7714 { 7715 if( usAbs1 < usAbs2 ) 7716 *pbEdgeXPtr = false; 7717 } 7718 else 7719 { 7720 if( usAbs1 <= usAbs0 ) 7721 *pbEdgeXPtr = false; 7722 } 7723 } 7724 7725 psDiffXPtr++; 7726 pbEdgeXPtr++; 7727 } 7728 } 7729 7730 for( Int y=0; y<iHeight-1; y++ ) 7731 { 7732 Short* psDiffYPtr = &psDiffY[ y * iWidth ]; 7733 Bool* pbEdgeYPtr = &pbEdgeY[ y * iWidth ]; 7734 for( Int x=0; x<iWidth; x++ ) 7735 { 7736 UShort usAbs0=0, usAbs1=0, usAbs2=0; // 0 : upper, 1 : current, 2 : bottom 7737 if( y > 0 && *(pbEdgeYPtr-iWidth) == true ) 7738 { 7739 if( *(psDiffYPtr-iWidth) >= 0) 7740 { 7741 usAbs0 = *(psDiffYPtr-iWidth); 7742 } 7743 else 7744 { 7745 usAbs0 = (-1) * *(psDiffYPtr-iWidth); 7746 } 7747 } 7748 if( *pbEdgeYPtr == true ) 7749 { 7750 if( *(psDiffYPtr) >= 0) 7751 { 7752 usAbs1 = *(psDiffYPtr); 7753 } 7754 else 7755 { 7756 usAbs1 = (-1) * *(psDiffYPtr); 7757 } 7758 } 7759 if( y < iHeight-2 && *(pbEdgeYPtr+iWidth) == true ) 7760 { 7761 if( *(psDiffYPtr+iWidth) >= 0) 7762 { 7763 usAbs2 = *(psDiffYPtr+iWidth); 7764 } 7765 else 7766 { 7767 usAbs2 = (-1) * *(psDiffYPtr+iWidth); 7768 } 7769 } 7770 7771 if( y == 0 ) 7772 { 7773 if( usAbs1 < usAbs2 ) 7774 *pbEdgeYPtr = false; 7775 } 7776 else if( y == iHeight-2 ) 7777 { 7778 if( usAbs1 <= usAbs0 ) 7779 *pbEdgeYPtr = false; 7780 } 7781 else 7782 { 7783 if( usAbs2 > usAbs0 ) 7784 { 7785 if( usAbs1 < usAbs2 ) 7786 *pbEdgeYPtr = false; 7787 } 7788 else 7789 { 7790 if( usAbs1 <= usAbs0 ) 7791 *pbEdgeYPtr = false; 7792 } 7793 } 7794 7795 psDiffYPtr++; 7796 pbEdgeYPtr++; 7797 } 7798 } 7799 7800 // Edge Merging 7801 for( Int i=0; i< 4 * iWidth * iHeight; i++ ) 7802 pbEdge[ i ] = false; 7803 /// Even Line (0,2,4,6,...) => Vertical Edge 7804 for( Int i=0; i<iHeight; i++) 7805 { 7806 for( Int j=0; j<iWidth-1; j++) 7807 { 7808 pbEdge[ (2 * j + 1) + (2 * i) * 2 * iWidth ] = pbEdgeX[ j + i * iHeight ]; 7809 } 7810 } 7811 /// Odd Line (1,3,5,7,...) => Horizontal Edge 7812 for( Int i=0; i<iHeight-1; i++) 7813 { 7814 for( Int j=0; j<iWidth; j++) 7815 { 7816 pbEdge[ (2 * j) + (2 * i + 1) * 2 * iWidth ] = pbEdgeY[ j + i * iHeight ]; 7817 } 7818 } 7819 7820 // Intersection Filling 7821 /// Vertical Edge between Horizontal Edges 7822 for( Int i = 1; i < 2 * iHeight - 3; i += 2) 7823 { 7824 for( Int j = 0; j < 2 * iWidth - 1; j += 2) 7825 { 7826 if( pbEdge[ j + i * 2 * iWidth ] ) 7827 { 7828 if( j != 0 && pbEdge[ (j - 2) + ((i + 2) * 2 * iWidth) ] ) 7829 { 7830 if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j - 1) + ((i + 3) * 2 * iWidth) ] ) 7831 pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] = true; 7832 } 7833 if( j != 2 * iWidth - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] ) 7834 { 7835 if( !pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 1) + ((i + 3) * 2 * iWidth) ] ) 7836 pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true; 7837 } 7838 } 7839 } 7840 } 7841 /// Horizontal Edge between Vertical Edges 7842 for( Int j = 1; j < 2 * iWidth - 3; j += 2) 7843 { 7844 for( Int i = 0; i < 2 * iHeight - 1; i += 2) 7845 { 7846 if( pbEdge[ j + i * 2 * iWidth ] ) 7847 { 7848 if( i != 0 && pbEdge[ (j + 2) + ((i - 2) * 2 * iWidth) ] ) 7849 { 7850 if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i - 1) * 2 * iWidth) ] ) 7851 pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] = true; 7852 } 7853 if( i != 2 * iHeight - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] ) 7854 { 7855 if( !pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i + 1) * 2 * iWidth) ] ) 7856 pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true; 7857 } 7858 } 7859 } 7860 } 7861 7862 // Static Pruning Unnecessary Edges 7863 /// Step1. Stack push the unconnected edges 7864 UShort* pusUnconnectedEdgeStack = new UShort[ 4 * iWidth * iHeight ]; // approximate size calculation 7865 Int iUnconnectedEdgeStackPtr = 0; 7866 //// Vertical Edges 7867 for( Int i = 0; i < 2 * iHeight - 1; i += 2 ) 7868 { 7869 for( Int j = 1; j < 2 * iWidth - 2; j += 2 ) 7870 { 7871 if( pbEdge[ j + i * 2 * iWidth ] ) 7872 { 7873 if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) ) 7874 { 7875 pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j); 7876 iUnconnectedEdgeStackPtr++; 7877 } 7878 } 7879 } 7880 } 7881 7882 //// Horizontal Edges 7883 for( Int i = 1; i < 2 * iHeight - 2; i += 2 ) 7884 { 7885 for( Int j = 0; j < 2 * iWidth - 1; j += 2 ) 7886 { 7887 if( pbEdge[ j + i * 2 * iWidth ] ) 7888 { 7889 if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) ) 7890 { 7891 pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j); 7892 iUnconnectedEdgeStackPtr++; 7893 } 7894 } 7895 } 7896 } 7897 7898 /// Step2. Remove the edges from the stack and push the new unconnected edges 7899 //// (This step may contain duplicated edges already in the stack) 7900 //// (But it doesn't cause any functional problems) 7901 while( iUnconnectedEdgeStackPtr != 0 ) 7902 { 7903 iUnconnectedEdgeStackPtr--; 7904 Int iX = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] & 0xff; 7905 Int iY = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] >> 8; 7906 7907 pbEdge[ iX + iY * 2 * iWidth ] = false; 7908 7909 if( iY % 2 == 1 && iX > 0 && pbEdge[ iX - 2 + iY * 2 * iWidth ] && 7910 !xCheckTerminatedEdge( pbEdge, iX - 2, iY, iWidth, iHeight ) ) // left 7911 { 7912 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX - 2); 7913 iUnconnectedEdgeStackPtr++; 7914 } 7915 if( iY % 2 == 1 && iX < 2 * iWidth - 2 && pbEdge[ iX + 2 + iY * 2 * iWidth ] && 7916 !xCheckTerminatedEdge( pbEdge, iX + 2, iY, iWidth, iHeight ) ) // right 7917 { 7918 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX + 2); 7919 iUnconnectedEdgeStackPtr++; 7920 } 7921 if( iY % 2 == 0 && iY > 0 && pbEdge[ iX + (iY - 2) * 2 * iWidth ] && 7922 !xCheckTerminatedEdge( pbEdge, iX, iY - 2, iWidth, iHeight ) ) // top 7923 { 7924 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 2) << 8) | (iX + 0); 7925 iUnconnectedEdgeStackPtr++; 7926 } 7927 if( iY % 2 == 0 && iY < 2 * iHeight - 2 && pbEdge[ iX + (iY + 2) * 2 * iWidth ] && 7928 !xCheckTerminatedEdge( pbEdge, iX, iY + 2, iWidth, iHeight ) ) // bottom 7929 { 7930 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 2) << 8) | (iX + 0); 7931 iUnconnectedEdgeStackPtr++; 7932 } 7933 if( iX > 0 && iY > 0 && pbEdge[ iX - 1 + (iY - 1) * 2 * iWidth ] && 7934 !xCheckTerminatedEdge( pbEdge, iX - 1, iY - 1, iWidth, iHeight ) ) // left-top 7935 { 7936 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX - 1); 7937 iUnconnectedEdgeStackPtr++; 7938 } 7939 if( iX < 2 * iWidth - 1 && iY > 0 && pbEdge[ iX + 1 + (iY - 1) * 2 * iWidth ] && 7940 !xCheckTerminatedEdge( pbEdge, iX + 1, iY - 1, iWidth, iHeight ) ) // right-top 7941 { 7942 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX + 1); 7943 iUnconnectedEdgeStackPtr++; 7944 } 7945 if( iX > 0 && iY < 2 * iHeight - 1 && pbEdge[ iX - 1 + (iY + 1) * 2 * iWidth ] && 7946 !xCheckTerminatedEdge( pbEdge, iX - 1, iY + 1, iWidth, iHeight ) ) // left-bottom 7947 { 7948 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX - 1); 7949 iUnconnectedEdgeStackPtr++; 7950 } 7951 if( iX < 2 * iWidth - 1 && iY < 2 * iHeight - 1 && pbEdge[ iX + 1 + (iY + 1) * 2 * iWidth ] && 7952 !xCheckTerminatedEdge( pbEdge, iX + 1, iY + 1, iWidth, iHeight ) ) // right-bottom 7953 { 7954 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX + 1); 7955 iUnconnectedEdgeStackPtr++; 7956 } 7957 } 7958 7959 7960 // Region Generation ( edge -> region ) 7961 Bool* pbRegion = pcCU->getEdgePartition( uiAbsPtIdx ); 7962 Bool* pbVisit = new Bool[ iWidth * iHeight ]; 7963 7964 for( UInt ui = 0; ui < iWidth * iHeight; ui++ ) 7965 { 7966 pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next) 7967 pbVisit [ ui ] = false; 7968 } 7969 7970 Int* piStack = new Int[ iWidth * iHeight ]; 7971 7972 Int iPtr = 0; 7973 7974 piStack[iPtr++] = (0 << 8) | (0); 7975 pbRegion[ 0 ] = false; 7976 7977 while(iPtr > 0) 7978 { 7979 Int iTmp = piStack[--iPtr]; 7980 Int iX1, iY1; 7981 iX1 = iTmp & 0xff; 7982 iY1 = (iTmp >> 8) & 0xff; 7983 7984 pbVisit[ iX1 + iY1 * iWidth ] = true; 7985 7986 assert( iX1 >= 0 && iX1 < iWidth ); 7987 assert( iY1 >= 0 && iY1 < iHeight ); 7988 7989 if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] ) 7990 { 7991 piStack[iPtr++] = (iY1 << 8) | (iX1 - 1); 7992 pbRegion[ iX1 - 1 + iY1 * iWidth ] = false; 7993 } 7994 if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] ) 7995 { 7996 piStack[iPtr++] = (iY1 << 8) | (iX1 + 1); 7997 pbRegion[ iX1 + 1 + iY1 * iWidth ] = false; 7998 } 7999 if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] ) 8000 { 8001 piStack[iPtr++] = ((iY1 - 1) << 8) | iX1; 8002 pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false; 8003 } 8004 if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] ) 8005 { 8006 piStack[iPtr++] = ((iY1 + 1) << 8) | iX1; 8007 pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false; 8008 } 8009 } 8010 8011 /////////// 8012 iPtr = 0; 8013 for( Int i = 0; i < iWidth * iHeight; i++ ) 8014 pbVisit[ i ] = false; 8015 piStack[ iPtr++ ] = (0 << 8) | (0); // initial seed 8016 while( iPtr > 0 && iPtr < iWidth * iHeight ) 8017 { 8018 Int iX; 8019 Int iY; 8020 iPtr--; 8021 iX = piStack[ iPtr ] & 0xff; 8022 iY = piStack[ iPtr ] >> 8; 8023 pbVisit[ iY * iWidth + iX ] = true; 8024 8025 if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] ) 8026 { 8027 piStack[ iPtr++ ] = ((iY - 1) << 8) | iX; 8028 } 8029 if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] ) 8030 { 8031 piStack[ iPtr++ ] = ((iY + 1) << 8) | iX; 8032 } 8033 if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] ) 8034 { 8035 piStack[ iPtr++ ] = (iY << 8) | (iX - 1); 8036 } 8037 if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] ) 8038 { 8039 piStack[ iPtr++ ] = (iY << 8) | (iX + 1); 8040 } 8041 } 8042 assert( iPtr == 0 || iPtr == iWidth * iHeight ); 8043 8044 Bool bBipartition; 8045 if( iPtr == iWidth * iHeight ) 8046 { 8047 bBipartition = false; // single partition 8048 } 8049 else 8050 { 8051 for( Int i = 0; i < iWidth * iHeight; i++ ) 8052 { 8053 if( !pbVisit[ i ] ) 8054 { 8055 piStack[ iPtr++ ] = (( i / iWidth ) << 8) | ( i % iWidth ); 8056 pbVisit[ i ] = true; 8057 break; 8058 } 8059 } 8060 while( iPtr > 0 ) 8061 { 8062 Int iX; 8063 Int iY; 8064 iPtr--; 8065 iX = piStack[ iPtr ] & 0xff; 8066 iY = piStack[ iPtr ] >> 8; 8067 pbVisit[ iY * iWidth + iX ] = true; 8068 8069 if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] ) 8070 { 8071 piStack[ iPtr++ ] = ((iY - 1) << 8) | iX; 8072 } 8073 if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] ) 8074 { 8075 piStack[ iPtr++ ] = ((iY + 1) << 8) | iX; 8076 } 8077 if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] ) 8078 { 8079 piStack[ iPtr++ ] = (iY << 8) | (iX - 1); 8080 } 8081 if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] ) 8082 { 8083 piStack[ iPtr++ ] = (iY << 8) | (iX + 1); 8084 } 8085 } 8086 bBipartition = true; 8087 for( Int i = 0; i < iWidth * iHeight; i++ ) 8088 { 8089 if( !pbVisit[ i ] ) 8090 { 8091 bBipartition = false; 8092 break; 8093 } 8094 } 8095 } 8096 8097 xFree( pbEdge ); 8098 delete[] pbEdgeX; pbEdgeX = NULL; 8099 delete[] pbEdgeY; pbEdgeY = NULL; 8100 delete[] psDiffX; psDiffX = NULL; 8101 delete[] psDiffY; psDiffY = NULL; 8102 delete[] pusUnconnectedEdgeStack; pusUnconnectedEdgeStack = NULL; 8103 delete[] pbVisit; pbVisit = NULL; 8104 delete[] piStack; piStack = NULL; 8105 8106 if( bBipartition ) 8107 { 8108 return xConstructChainCode( pcCU, uiAbsPtIdx, (UInt)iWidth, (UInt)iHeight ); 8109 } 8110 else 8111 { 8112 return false; 8113 } 8114 } 8115 8116 Bool TEncSearch::xCheckTerminatedEdge( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight ) 8117 { 8118 if( (iY % 2) == 0 ) // vertical edge 8119 { 8120 Bool bTopConnected = false; 8121 Bool bBottomConnected = false; 8122 8123 if( iY != 0 ) 8124 { 8125 if( pbEdge[ iX + (iY - 2) * 2 * iWidth ] ) 8126 bTopConnected = true; 8127 if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] ) 8128 bTopConnected = true; 8129 if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] ) 8130 bTopConnected = true; 8131 } 8132 else 8133 { 8134 bTopConnected = true; 8135 } 8136 8137 8138 if( iY != 2 * iHeight - 2 ) 8139 { 8140 if( pbEdge[ iX + (iY + 2) * 2 * iWidth ] ) 8141 bBottomConnected = true; 8142 if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] ) 8143 bBottomConnected = true; 8144 if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] ) 8145 bBottomConnected = true; 8146 } 8147 else 8148 { 8149 bBottomConnected = true; 8150 } 8151 8152 8153 if( bTopConnected && bBottomConnected ) 8154 { 8155 return true; 8156 } 8157 else 8158 { 8159 return false; 8160 } 8161 } 8162 else 8163 { 8164 Bool bLeftConnected = false; 8165 Bool bRightConnected = false; 8166 8167 if( iX != 0 ) 8168 { 8169 if( pbEdge[ (iX - 2) + iY * 2 * iWidth ] ) 8170 bLeftConnected = true; 8171 if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] ) 8172 bLeftConnected = true; 8173 if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] ) 8174 bLeftConnected = true; 8175 } 8176 else 8177 { 8178 bLeftConnected = true; 8179 } 8180 8181 if( iX != 2 * iWidth - 2 ) 8182 { 8183 if( pbEdge[ (iX + 2) + iY * 2 * iWidth ] ) 8184 bRightConnected = true; 8185 if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] ) 8186 bRightConnected = true; 8187 if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] ) 8188 bRightConnected = true; 8189 } 8190 else 8191 { 8192 bRightConnected = true; 8193 } 8194 8195 8196 if( bLeftConnected && bRightConnected ) 8197 { 8198 return true; 8199 } 8200 else 8201 { 8202 return false; 8203 } 8204 } 8205 } 8206 Bool TEncSearch::xConstructChainCode( TComDataCU* pcCU, UInt uiAbsPtIdx, UInt uiWidth, UInt uiHeight ) 8207 { 8208 //UInt uiWidth = pcCU->getWidth( uiPartIdx ) >> (bPU4x4 ? 1 : 0); 8209 //UInt uiHeight = pcCU->getHeight( uiPartIdx ) >> (bPU4x4 ? 1 : 0); 8210 Bool* pbEdge = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 ); 8211 Bool* pbVisit = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 ); 8212 UInt uiMaxEdge = uiWidth * (RBC_MAX_EDGE_NUM_PER_4x4 / 4); 8213 Bool* pbRegion = pcCU->getEdgePartition( uiAbsPtIdx ); 8214 UChar* piEdgeCode = pcCU->getEdgeCode( uiAbsPtIdx ); 8215 Bool bStartLeft = false; 8216 Bool bPossible = false; 8217 Bool bFinish = false; 8218 Int iStartPosition = -1; 8219 Int iPtr = 0; 8220 Int iDir = -1, iNextDir = -1; 8221 Int iArrow = -1, iNextArrow = -1; 8222 Int iX = -1, iY = -1; 8223 Int iDiffX = 0, iDiffY = 0; 8224 UChar iCode = 255; 8225 UInt uiWidth2 = uiWidth * 2; 8226 8227 for( Int i = 0; i < uiWidth * uiHeight * 4; i++ ) 8228 pbEdge[ i ] = false; 8229 8230 for( Int i = 0; i < uiHeight; i++ ) 8231 { 8232 for( Int j = 0; j < uiWidth - 1; j++ ) 8233 { 8234 if( pbRegion[ i * uiWidth + j ] != pbRegion[ i * uiWidth + j + 1 ] ) 8235 pbEdge[ i * uiWidth * 4 + j * 2 + 1 ] = true; 8236 } 8237 } 8238 8239 for( Int i = 0; i < uiHeight - 1; i++ ) 8240 { 8241 for( Int j = 0; j < uiWidth; j++ ) 8242 { 8243 if( pbRegion[ (i + 0) * uiWidth + j ] != pbRegion[ (i + 1) * uiWidth + j ] ) 8244 pbEdge[ (2 * i + 1) * 2 * uiWidth + j * 2 ] = true; 8245 } 8246 } 8247 8248 for( Int i = 1; i < uiWidth2 - 2; i+=2 ) 8249 { 8250 if(pbEdge[ i ]) 8251 { 8252 bPossible = true; 8253 bStartLeft = false; 8254 iStartPosition = iX = i; 8255 iY = 0; 8256 iDir = 3; 8257 iArrow = 3; 8258 break; 8259 } 8260 } 8261 8262 if( !bPossible ) 8263 { 8264 for( Int i = 1; i < uiWidth2 - 2; i+=2 ) 8265 { 8266 if(pbEdge[ i * uiWidth2 ]) 8267 { 8268 bPossible = true; 8269 bStartLeft = true; 8270 iX = 0; 8271 iStartPosition = iY = i; 8272 iDir = 1; 8273 iArrow = 1; 8274 break; 8275 } 8276 } 8277 } 8278 8279 if( bPossible ) 8280 { 8281 for( Int i = 0; i < 4 * uiWidth * uiHeight; i++ ) 8282 pbVisit[ i ] = false; 8283 8284 while( !bFinish ) 8285 { 8286 Bool bArrowSkip = false; 8287 pbVisit[ iX + iY * uiWidth2 ] = true; 8288 8289 switch( iDir ) 8290 { 8291 case 0: // left 8292 if( iX > 0 && !pbVisit[ (iX - 2) + iY * uiWidth2 ] && pbEdge[ (iX - 2) + iY * uiWidth2 ] ) // left 8293 { 8294 iDiffX = -2; 8295 iDiffY = 0; 8296 iNextDir = 0; 8297 iNextArrow = 0; 8298 } 8299 else if( iX > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // top 8300 { 8301 iDiffX = -1; 8302 iDiffY = -1; 8303 iNextDir = 2; 8304 iNextArrow = 4; 8305 } 8306 else if( iX > 0 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // bottom 8307 { 8308 iDiffX = -1; 8309 iDiffY = +1; 8310 iNextDir = 3; 8311 iNextArrow = iArrow; 8312 if( !(iPtr == 0 && iX == uiWidth2 - 2 && iY == uiHeight * 2 - 3) ) 8313 bArrowSkip = true; 8314 else 8315 iNextArrow = 3; 8316 } 8317 else if( iX == 0 ) 8318 { 8319 iDiffX = 0; 8320 iDiffY = 0; 8321 iNextDir = iDir; 8322 iNextArrow = iArrow; 8323 bFinish = true; 8324 continue; 8325 } 8326 else 8327 { 8328 iPtr = 0; // edge loop or unwanted case 8329 bFinish = true; 8330 //continue; 8331 assert(false); 8332 } 8333 break; 8334 case 1: // right 8335 if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 2) + iY * uiWidth2 ] && pbEdge[ (iX + 2) + iY * uiWidth2 ] ) // right 8336 { 8337 iDiffX = +2; 8338 iDiffY = 0; 8339 iNextDir = 1; 8340 iNextArrow = 1; 8341 } 8342 else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // top 8343 { 8344 iDiffX = +1; 8345 iDiffY = -1; 8346 iNextDir = 2; 8347 iNextArrow = iArrow; 8348 if( !(iPtr == 0 && iX == 0 && iY == 1) ) 8349 bArrowSkip = true; 8350 else 8351 iNextArrow = 2; 8352 } 8353 else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // bottom 8354 { 8355 iDiffX = +1; 8356 iDiffY = +1; 8357 iNextDir = 3; 8358 iNextArrow = 7; 8359 } 8360 else if( iX == uiWidth2 - 2 ) 8361 { 8362 iDiffX = 0; 8363 iDiffY = 0; 8364 iNextDir = iDir; 8365 iNextArrow = iArrow; 8366 bFinish = true; 8367 continue; 8368 } 8369 else 8370 { 8371 iPtr = 0; // edge loop or unwanted case 8372 bFinish = true; 8373 //continue; 8374 assert(false); 8375 } 8376 break; 8377 case 2: // top 8378 if( iY > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // left 8379 { 8380 iDiffX = -1; 8381 iDiffY = -1; 8382 iNextDir = 0; 8383 iNextArrow = iArrow; 8384 if( !(iPtr == 0 && iX == 1 && iY == uiHeight * 2 - 2) ) 8385 bArrowSkip = true; 8386 else 8387 iNextArrow = 0; 8388 } 8389 else if( iY > 0 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // right 8390 { 8391 iDiffX = +1; 8392 iDiffY = -1; 8393 iNextDir = 1; 8394 iNextArrow = 5; 8395 } 8396 else if( iY > 0 && !pbVisit[ iX + (iY - 2) * uiWidth2 ] && pbEdge[ iX + (iY - 2) * uiWidth2 ] ) // top 8397 { 8398 iDiffX = 0; 8399 iDiffY = -2; 8400 iNextDir = 2; 8401 iNextArrow = 2; 8402 } 8403 else if( iY == 0 ) 8404 { 8405 iDiffX = 0; 8406 iDiffY = 0; 8407 iNextDir = iDir; 8408 iNextArrow = iArrow; 8409 bFinish = true; 8410 continue; 8411 } 8412 else 8413 { 8414 iPtr = 0; // edge loop or unwanted case 8415 bFinish = true; 8416 //continue; 8417 assert(false); 8418 } 8419 break; 8420 case 3: // bottom 8421 if( iY < uiWidth2 - 2 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // left 8422 { 8423 iDiffX = -1; 8424 iDiffY = +1; 8425 iNextDir = 0; 8426 iNextArrow = 6; 8427 } 8428 else if( iY < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // right 8429 { 8430 iDiffX = +1; 8431 iDiffY = +1; 8432 iNextDir = 1; 8433 iNextArrow = iArrow; 8434 if( !(iPtr == 0 && iX == uiWidth * 2 - 3 && iY == 0) ) 8435 bArrowSkip = true; 8436 else 8437 iNextArrow = 1; 8438 } 8439 else if( iY < uiWidth2 - 2 && !pbVisit[ iX + (iY + 2) * uiWidth2 ] && pbEdge[ iX + (iY + 2) * uiWidth2 ] ) // bottom 8440 { 8441 iDiffX = 0; 8442 iDiffY = +2; 8443 iNextDir = 3; 8444 iNextArrow = 3; 8445 } 8446 else if( iY == uiWidth2 - 2 ) 8447 { 8448 iDiffX = 0; 8449 iDiffY = 0; 8450 iNextDir = iDir; 8451 iNextArrow = iArrow; 8452 bFinish = true; 8453 continue; 8454 } 8455 else 8456 { 8457 iPtr = 0; // edge loop or unwanted case 8458 bFinish = true; 8459 //continue; 8460 assert(false); 8461 } 8462 break; 8463 } 8464 8465 const UChar tableCode[8][8] = { { 0, -1, 4, 3, 2, 6, 1, 5 }, // iArrow(current direction), iNextArrow(next direction) 8466 { -1, 0, 3, 4, 5, 1, 6, 2 }, 8467 { 3, 4, 0, -1, 1, 2, 5, 6 }, 8468 { 4, 3, -1, 0, 6, 5, 2, 1 }, 8469 { 1, 6, 2, 5, 0, 4, 3, -1 }, 8470 { 5, 2, 1, 6, 3, 0, -1, 4 }, 8471 { 2, 5, 6, 1, 4, -1, 0, 3 }, 8472 { 6, 1, 5, 2, -1, 3, 4, 0 } }; 8473 8474 iCode = tableCode[iArrow][iNextArrow]; 8475 8476 if(iPtr >= uiMaxEdge) 8477 { 8478 iPtr = 0; // over the maximum number of edge 8479 bPossible = false; 8480 break; 8481 } 8482 8483 if( !bArrowSkip ) 8484 { 8485 piEdgeCode[iPtr++] = iCode; // first edge coding 8486 //printf("xEdgeCoding: (%d,%d)->(%d,%d) code %d\n",iX,iY, iX+iDiffX, iY+iDiffY, iCode); 8487 } 8488 8489 iX += iDiffX; 8490 iY += iDiffY; 8491 iDir = iNextDir; 8492 iArrow = iNextArrow; 8493 } 8494 } 8495 8496 pcCU->setEdgeLeftFirst( uiAbsPtIdx, bStartLeft ); 8497 pcCU->setEdgeStartPos ( uiAbsPtIdx, bStartLeft ? (iStartPosition - 1) >> 1 : (iStartPosition + 1) >> 1); 8498 pcCU->setEdgeNumber ( uiAbsPtIdx, iPtr ); 8499 8500 xFree( pbEdge ); 8501 xFree( pbVisit ); 8502 8503 return (iPtr != 0); 8504 } 8505 #endif 7407 7408 #endif 7409 8506 7410 #endif 8507 7411 //! \} -
branches/HTM-9.2-dev0/source/Lib/TLibEncoder/TEncSearch.h
r724 r764 351 351 Void xSearchDmmDeltaDCs ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 ); 352 352 Void xSearchDmm1Wedge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx ); 353 #if !SEC_DMM3_RBC_F0147354 Void xSearchDmm3Wedge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx, UInt colTexIntraDir );355 #endif356 #endif357 #if H_3D_DIM_RBC358 Void xSearchRbcDeltaDCs ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 );359 Bool xSearchRbcEdge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, Int iWidth, Int iHeight );360 361 Bool xCheckTerminatedEdge ( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight );362 Bool xConstructChainCode ( TComDataCU* pcCU, UInt uiAbsPtIdx, UInt uiWidth, UInt uiHeight );363 353 #endif 364 354 #if H_3D_DIM_SDC
Note: See TracChangeset for help on using the changeset viewer.