Changeset 97 in 3DVCSoftware for branches/HTM-3.1-LG/source/Lib/TLibCommon/TComDataCU.cpp
- Timestamp:
- 6 Aug 2012, 05:35:11 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-3.1-LG/source/Lib/TLibCommon/TComDataCU.cpp
r92 r97 141 141 m_pbResPredFlag = NULL; 142 142 #endif 143 #if LGE_EDGE_INTRA 144 m_pucEdgeCode = NULL; 145 m_pucEdgeNumber = NULL; 146 m_pucEdgeStartPos = NULL; 147 m_pbEdgeLeftFirst = NULL; 148 m_pbEdgePartition = NULL; 149 #if LGE_EDGE_INTRA_DELTA_DC 150 m_piEdgeDeltaDC0 = NULL; 151 m_piEdgeDeltaDC1 = NULL; 152 #endif 153 #endif 143 154 } 144 155 … … 259 270 m_piContourPredTexDeltaDC2 = (Int* )xMalloc(Int, uiNumPartition); 260 271 #endif 272 #if LGE_EDGE_INTRA 273 m_pucEdgeCode = (UChar*)xMalloc(UChar, uiNumPartition * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4); 274 m_pucEdgeNumber = (UChar*)xMalloc(UChar, uiNumPartition); 275 m_pucEdgeStartPos = (UChar*)xMalloc(UChar, uiNumPartition); 276 m_pbEdgeLeftFirst = (Bool*) xMalloc(Bool, uiNumPartition); 277 m_pbEdgePartition = (Bool*) xMalloc(Bool, uiNumPartition * 16); 278 #if LGE_EDGE_INTRA_DELTA_DC 279 m_piEdgeDeltaDC0 = (Int* ) xMalloc(Int, uiNumPartition); 280 m_piEdgeDeltaDC1 = (Int* ) xMalloc(Int, uiNumPartition); 281 #endif 282 #endif 261 283 } 262 284 else … … 359 381 if ( m_piContourPredTexDeltaDC2 ) { xFree(m_piContourPredTexDeltaDC2); m_piContourPredTexDeltaDC2 = NULL; } 360 382 #endif 383 #if LGE_EDGE_INTRA 384 if ( m_pbEdgeLeftFirst ) { xFree(m_pbEdgeLeftFirst); m_pbEdgeLeftFirst = NULL; } 385 if ( m_pucEdgeStartPos ) { xFree(m_pucEdgeStartPos); m_pucEdgeStartPos = NULL; } 386 if ( m_pucEdgeNumber ) { xFree(m_pucEdgeNumber); m_pucEdgeNumber = NULL; } 387 if ( m_pucEdgeCode ) { xFree(m_pucEdgeCode); m_pucEdgeCode = NULL; } 388 if ( m_pbEdgePartition ) { xFree(m_pbEdgePartition); m_pbEdgePartition = NULL; } 389 #if LGE_EDGE_INTRA_DELTA_DC 390 if ( m_piEdgeDeltaDC0 ) { xFree(m_piEdgeDeltaDC0); m_piEdgeDeltaDC0 = NULL; } 391 if ( m_piEdgeDeltaDC1 ) { xFree(m_piEdgeDeltaDC1); m_piEdgeDeltaDC1 = NULL; } 392 #endif 393 #endif 361 394 m_acCUMvField[0].destroy(); 362 395 m_acCUMvField[1].destroy(); … … 1093 1126 m_piContourPredTexDeltaDC2 = pcCU->getContourPredTexDeltaDC2() + uiPart; 1094 1127 #endif 1128 #if LGE_EDGE_INTRA 1129 if( pcCU->getSlice()->getSPS()->isDepth() ) 1130 { 1131 m_pucEdgeCode = pcCU->getEdgeCode( uiPart ); 1132 m_pucEdgeNumber = pcCU->getEdgeNumber() + uiPart; 1133 m_pucEdgeStartPos = pcCU->getEdgeStartPos() + uiPart; 1134 m_pbEdgeLeftFirst = pcCU->getEdgeLeftFirst() + uiPart; 1135 m_pbEdgePartition = pcCU->getEdgePartition( uiPart ); 1136 #if LGE_EDGE_INTRA_DELTA_DC 1137 m_piEdgeDeltaDC0 = pcCU->getEdgeDeltaDC0() + uiPart; 1138 m_piEdgeDeltaDC1 = pcCU->getEdgeDeltaDC1() + uiPart; 1139 #endif 1140 } 1141 #endif 1095 1142 } 1096 1143 … … 1250 1297 memcpy( m_piContourPredTexDeltaDC2 + uiOffset, pcCU->getContourPredTexDeltaDC2(), sizeof( Int ) * uiNumPartition ); 1251 1298 #endif 1299 1300 #if LGE_EDGE_INTRA 1301 if( getSlice()->getSPS()->isDepth() ) 1302 { 1303 memcpy( getEdgeCode( uiOffset ), pcCU->getEdgeCode(0), iSizeInUchar * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 ); 1304 memcpy( getEdgeNumber() + uiOffset, pcCU->getEdgeNumber(), iSizeInUchar ); 1305 memcpy( getEdgeStartPos() + uiOffset, pcCU->getEdgeStartPos(), iSizeInUchar ); 1306 memcpy( getEdgeLeftFirst() + uiOffset, pcCU->getEdgeLeftFirst(), iSizeInBool ); 1307 memcpy( getEdgePartition( uiOffset ), pcCU->getEdgePartition(0), iSizeInBool * 16 ); 1308 #if LGE_EDGE_INTRA_DELTA_DC 1309 memcpy( getEdgeDeltaDC0() + uiOffset, pcCU->getEdgeDeltaDC0(), sizeof( Int ) * uiNumPartition ); 1310 memcpy( getEdgeDeltaDC1() + uiOffset, pcCU->getEdgeDeltaDC1(), sizeof( Int ) * uiNumPartition ); 1311 #endif 1312 } 1313 #endif 1314 1252 1315 #if HHI_MPI 1253 1316 memcpy( m_piTextureModeDepth + uiOffset, pcCU->getTextureModeDepth(), sizeof( Int ) * uiNumPartition ); … … 1352 1415 memcpy( rpcCU->getContourPredTexDeltaDC2() + m_uiAbsIdxInLCU, m_piContourPredTexDeltaDC2, sizeof( Int ) * m_uiNumPartition ); 1353 1416 #endif 1417 1418 #if LGE_EDGE_INTRA 1419 if( rpcCU->getSlice()->getSPS()->isDepth() ) 1420 { 1421 memcpy( rpcCU->getEdgeCode( m_uiAbsIdxInLCU ), m_pucEdgeCode, iSizeInUchar * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 ); 1422 memcpy( rpcCU->getEdgeNumber() + m_uiAbsIdxInLCU, m_pucEdgeNumber, iSizeInUchar ); 1423 memcpy( rpcCU->getEdgeStartPos() + m_uiAbsIdxInLCU, m_pucEdgeStartPos,iSizeInUchar ); 1424 memcpy( rpcCU->getEdgeLeftFirst() + m_uiAbsIdxInLCU, m_pbEdgeLeftFirst,iSizeInBool ); 1425 memcpy( rpcCU->getEdgePartition( m_uiAbsIdxInLCU ), m_pbEdgePartition,iSizeInBool * 16 ); 1426 #if LGE_EDGE_INTRA_DELTA_DC 1427 memcpy( rpcCU->getEdgeDeltaDC0() + m_uiAbsIdxInLCU, m_piEdgeDeltaDC0, sizeof( Int ) * m_uiNumPartition ); 1428 memcpy( rpcCU->getEdgeDeltaDC1() + m_uiAbsIdxInLCU, m_piEdgeDeltaDC1, sizeof( Int ) * m_uiNumPartition ); 1429 #endif 1430 } 1431 #endif 1432 1354 1433 #if HHI_MPI 1355 1434 memcpy( rpcCU->getTextureModeDepth() + m_uiAbsIdxInLCU, m_piTextureModeDepth, sizeof( Int ) * m_uiNumPartition ); … … 1455 1534 memcpy( rpcCU->getContourPredTexDeltaDC2() + uiPartOffset, m_piContourPredTexDeltaDC2, sizeof( Int ) * uiQNumPart ); 1456 1535 #endif 1536 1537 #if LGE_EDGE_INTRA 1538 if( rpcCU->getSlice()->getSPS()->isDepth() ) 1539 { 1540 memcpy( rpcCU->getEdgeCode( uiPartOffset ), m_pucEdgeCode, iSizeInUchar * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 ); 1541 memcpy( rpcCU->getEdgeNumber() + uiPartOffset, m_pucEdgeNumber, iSizeInUchar ); 1542 memcpy( rpcCU->getEdgeStartPos() + uiPartOffset, m_pucEdgeStartPos,iSizeInUchar ); 1543 memcpy( rpcCU->getEdgeLeftFirst() + uiPartOffset, m_pbEdgeLeftFirst,iSizeInBool ); 1544 memcpy( rpcCU->getEdgePartition( uiPartOffset ), m_pbEdgePartition,iSizeInBool * 16 ); 1545 #if LGE_EDGE_INTRA_DELTA_DC 1546 memcpy( rpcCU->getEdgeDeltaDC0() + uiPartOffset, m_piEdgeDeltaDC0, sizeof( Int ) * uiQNumPart ); 1547 memcpy( rpcCU->getEdgeDeltaDC1() + uiPartOffset, m_piEdgeDeltaDC1, sizeof( Int ) * uiQNumPart ); 1548 #endif 1549 } 1550 #endif 1551 1457 1552 #if HHI_MPI 1458 1553 memcpy( rpcCU->getTextureModeDepth() + uiPartOffset, m_piTextureModeDepth, sizeof( Int ) * uiQNumPart ); … … 2332 2427 mapDMMtoIntraMode( iLeftIntraDir ); 2333 2428 #endif 2429 #if LGE_EDGE_INTRA 2430 mapEdgeIntratoDC( iLeftIntraDir ); 2431 #endif 2334 2432 2335 2433 // Get intra direction of above PU … … 2343 2441 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 2344 2442 mapDMMtoIntraMode( iAboveIntraDir ); 2443 #endif 2444 #if LGE_EDGE_INTRA 2445 mapEdgeIntratoDC( iAboveIntraDir ); 2345 2446 #endif 2346 2447 … … 2426 2527 return uiPredNum; 2427 2528 } 2529 2530 #if LGE_EDGE_INTRA 2531 UInt TComDataCU::getCtxEdgeIntra( UInt uiAbsPartIdx ) 2532 { 2533 UInt uiCtx = 0; 2534 return uiCtx; 2535 } 2536 #endif 2428 2537 2429 2538 UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) … … 3362 3471 cDisInfo.iN = 0; 3363 3472 if(!bNoPdmMerge) 3473 { 3474 #if USE_DVMCP 3475 getDisMvpCand2(uiPUIdx, uiAbsPartIdx, &cDisInfo, true ); 3476 #else 3364 3477 getDisMvpCand (uiPUIdx, uiAbsPartIdx, &cDisInfo ); 3478 #endif 3479 } 3365 3480 if(cDisInfo.iN==0) 3366 3481 { … … 3428 3543 pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 3429 3544 } 3545 #if USE_DVMCP 3546 pcMvFieldNeighbours[iCount<<1 ].getMv().m_bDvMcp = false; 3547 pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false; 3548 #endif 3430 3549 #if SIMP_MRG_PRUN 3431 3550 if ( mrgCandIdx == iCount ) … … 3500 3619 pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 3501 3620 } 3621 #if USE_DVMCP 3622 pcMvFieldNeighbours[iCount<<1 ].getMv().m_bDvMcp = false; 3623 pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false; 3624 #endif 3502 3625 #if SIMP_MRG_PRUN 3503 3626 if ( mrgCandIdx == iCount ) … … 3567 3690 pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 3568 3691 } 3692 #if USE_DVMCP 3693 pcMvFieldNeighbours[iCount<<1 ].getMv().m_bDvMcp = false; 3694 pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false; 3695 #endif 3569 3696 #if SIMP_MRG_PRUN 3570 3697 if ( mrgCandIdx == iCount ) … … 3631 3758 pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 3632 3759 } 3760 #if USE_DVMCP 3761 pcMvFieldNeighbours[iCount<<1 ].getMv().m_bDvMcp = false; 3762 pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false; 3763 #endif 3633 3764 #if SIMP_MRG_PRUN 3634 3765 if ( mrgCandIdx == iCount ) … … 3704 3835 pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 3705 3836 } 3837 #if USE_DVMCP 3838 pcMvFieldNeighbours[iCount<<1 ].getMv().m_bDvMcp = false; 3839 pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false; 3840 #endif 3706 3841 #if SIMP_MRG_PRUN 3707 3842 if ( mrgCandIdx == iCount ) … … 3820 3955 puhInterDirNeighbours[uiArrayAddr] = 1; 3821 3956 } 3957 #if USE_DVMCP 3958 pcMvFieldNeighbours[uiArrayAddr<<1 ].getMv().m_bDvMcp = false; 3959 pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv().m_bDvMcp = false; 3960 #endif 3822 3961 #if SIMP_MRG_PRUN 3823 3962 if ( mrgCandIdx == iCount ) … … 4614 4753 }//remaining pictures 4615 4754 } 4755 4756 #if USE_DVMCP 4757 Void TComDataCU::getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr,DisInfo* pDInfo, Bool bMerge, RefPicList eRefPicList0, Int iRefIdx0 ) 4758 { 4759 PartSize eCUMode = getPartitionSize( uiPartAddr ); 4760 TComDataCU* pcTmpCU = NULL; 4761 TComDataCU* pcCULeft = NULL; 4762 pDInfo->iN = 0; 4763 4764 RefPicList eRefPicList = REF_PIC_LIST_0 ; 4765 //-- Get Spatial MV 4766 UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 4767 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 4768 4769 Int aiDvMcpDvCand[2][7] = {{0,}, {0,}}; // dummy, 5 spatial + 1 temporal, DV-MCP ÁÖº¯ ºí·°¿¡¼ »ç¿ëµÈ DV¸¦ ÀúÀå 4770 Bool abDvMcpFlag [2][7] = {{false,},{false,}}; 4771 //Int aiRefPOC [2][7] = {{-1,},{-1}}; // debug 4772 TComMv cTmpMvPred, cMv; 4773 Bool bTmpIsSkipped = false; 4774 Bool bDvMcpIsFound = false; 4775 4776 deriveLeftRightTopIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); 4777 deriveLeftBottomIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLB ); 4778 4779 UInt uiIdx = 0; 4780 #if MVP_AT_ENTROPYSLICE_BOUNDARY 4781 pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false); 4782 #else 4783 pcTmpCU = getPULeft(uiIdx, uiPartIdxLB); 4784 #endif 4785 4786 pcCULeft = pcTmpCU; 4787 UInt uiLeftPartIdx = uiIdx; 4788 if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) ) 4789 { 4790 bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); 4791 for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) 4792 { 4793 eRefPicList = RefPicList(iList); 4794 Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; 4795 if( refId >= 0) 4796 { 4797 Int refViewIdx = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId); 4798 if (refViewIdx!= m_pcSlice->getViewId()) // DCP 4799 { 4800 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 4801 clipMv(cMvPred); 4802 pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 4803 pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx; 4804 return; 4805 } 4806 else // MCP 4807 { 4808 cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 4809 if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped ) 4810 { 4811 aiDvMcpDvCand[iList][DVFROM_LEFT] = cTmpMvPred.m_iDvMcpDispX; 4812 abDvMcpFlag [iList][DVFROM_LEFT] = true; 4813 bDvMcpIsFound = true; 4814 } 4815 #if USE_DVMCP_MSG 4816 //printf("skipped %d =%d, curCUAddr=%d, leftCUAddr=%d\n",DVFROM_LEFT, iList, getAddr(), pcTmpCU->getAddr() ); 4817 aiRefPOC [iList][DVFROM_LEFT] = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx); 4818 if( aiRefPOC[iList][DVFROM_LEFT]<0 ) 4819 { 4820 printf("error\n"); 4821 } 4822 //aiRefPOC [iList][DVFROM_LEFT] = pcTmpCU->getSlice()->getRefPOC( eRefPicList, ); 4823 #endif 4824 } 4825 } 4826 } 4827 } 4828 4829 #if MVP_AT_ENTROPYSLICE_BOUNDARY 4830 pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true); 4831 #else 4832 pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT); 4833 #endif 4834 4835 if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx )) 4836 { 4837 bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); 4838 for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) 4839 { 4840 eRefPicList = RefPicList(iList); 4841 Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; 4842 if( refId >= 0) 4843 { 4844 Int refViewIdx = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId); 4845 if (refViewIdx!= m_pcSlice->getViewId()) 4846 { 4847 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 4848 clipMv(cMvPred); 4849 pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 4850 pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx; 4851 return; 4852 } 4853 else // MCP 4854 { 4855 cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 4856 if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped ) 4857 { 4858 aiDvMcpDvCand[iList][DVFROM_ABOVE] = cTmpMvPred.m_iDvMcpDispX; 4859 abDvMcpFlag [iList][DVFROM_ABOVE] = true; 4860 bDvMcpIsFound = true; 4861 } 4862 #if USE_DVMCP_MSG 4863 //printf("skipped %d =%d, curCUAddr=%d, leftCUAddr=%d\n",DVFROM_ABOVE, iList, getAddr(), pcTmpCU->getAddr() ); 4864 aiRefPOC [iList][DVFROM_ABOVE] = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx); 4865 if( aiRefPOC[iList][DVFROM_ABOVE]<0 ) 4866 { 4867 printf("error\n"); 4868 } 4869 #endif 4870 } 4871 } 4872 } 4873 } 4874 4875 #if MVP_AT_ENTROPYSLICE_BOUNDARY 4876 pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, false, true); 4877 #else 4878 pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, true, true); 4879 #endif 4880 if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) ) 4881 { 4882 bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); 4883 for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) 4884 { 4885 eRefPicList = RefPicList(iList); 4886 Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; 4887 if( refId >= 0) 4888 { 4889 Int refViewIdx = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId); 4890 if (refViewIdx!= m_pcSlice->getViewId()) 4891 { 4892 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 4893 clipMv(cMvPred); 4894 pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 4895 pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx; 4896 return; 4897 } 4898 else // MCP 4899 { 4900 cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 4901 if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped ) 4902 { 4903 aiDvMcpDvCand[iList][DVFROM_ABOVERIGHT] = cTmpMvPred.m_iDvMcpDispX; 4904 abDvMcpFlag [iList][DVFROM_ABOVERIGHT] = true; 4905 bDvMcpIsFound = true; 4906 } 4907 #if USE_DVMCP_MSG 4908 //printf("skipped %d =%d, curCUAddr=%d, leftCUAddr=%d\n",DVFROM_ABOVERIGHT, iList, getAddr(), pcTmpCU->getAddr() ); 4909 aiRefPOC [iList][DVFROM_ABOVERIGHT] = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx); 4910 #endif 4911 } 4912 } 4913 } 4914 } 4915 4916 #if MVP_AT_ENTROPYSLICE_BOUNDARY 4917 pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true, false); 4918 #else 4919 pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB); 4920 #endif 4921 if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx )) 4922 { 4923 bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); 4924 for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) 4925 { 4926 eRefPicList = RefPicList(iList); 4927 Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; 4928 if( refId >= 0) 4929 { 4930 Int refViewIdx = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId); 4931 if (refViewIdx!= m_pcSlice->getViewId()) 4932 { 4933 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 4934 clipMv(cMvPred); 4935 pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 4936 pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx; 4937 return; 4938 } 4939 else // MCP 4940 { 4941 cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 4942 if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped ) 4943 { 4944 aiDvMcpDvCand[iList][DVFROM_LEFTBELOW] = cTmpMvPred.m_iDvMcpDispX; 4945 abDvMcpFlag [iList][DVFROM_LEFTBELOW] = true; 4946 bDvMcpIsFound = true; 4947 } 4948 #if USE_DVMCP_MSG 4949 //printf("skipped %d =%d, curCUAddr=%d, leftCUAddr=%d\n",DVFROM_LEFTBELOW, iList, getAddr(), pcTmpCU->getAddr() ); 4950 aiRefPOC [iList][DVFROM_LEFTBELOW] = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx); 4951 #endif 4952 } 4953 } 4954 } 4955 } 4956 4957 // Above predictor search 4958 #if MVP_AT_ENTROPYSLICE_BOUNDARY 4959 pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true, false, true); 4960 assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr)); 4961 #else 4962 pcTmpCU = getPUAboveLeft(uiIdx, uiPartIdxLT, true, true, true); 4963 #endif 4964 if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx )) 4965 { 4966 bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); 4967 for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) 4968 { 4969 eRefPicList = RefPicList(iList); 4970 Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; 4971 if( refId >= 0) 4972 { 4973 Int refViewIdx = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId); 4974 if (refViewIdx!= m_pcSlice->getViewId()) 4975 { 4976 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 4977 clipMv(cMvPred); 4978 pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 4979 pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx; 4980 return; 4981 } 4982 else // MCP 4983 { 4984 cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 4985 if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped ) 4986 { 4987 aiDvMcpDvCand[iList][DVFROM_ABOVELEFT] = cTmpMvPred.m_iDvMcpDispX; 4988 abDvMcpFlag [iList][DVFROM_ABOVELEFT] = true; 4989 bDvMcpIsFound = true; 4990 } 4991 #if USE_DVMCP_MSG 4992 aiRefPOC [iList][DVFROM_ABOVELEFT] = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx); 4993 //printf("skipped %d =%d, curCUAddr=%d, leftCUAddr=%d\n",DVFROM_ABOVELEFT, iList, getAddr(), pcTmpCU->getAddr() ); 4994 #endif 4995 } 4996 } 4997 } 4998 } 4999 5000 // copied from getInterMergeCand() 5001 if ( getSlice()->getPPS()->getEnableTMVPFlag() ) 5002 { 5003 UInt uiPUIdx = uiPartIdx; 5004 UInt uiAbsPartAddr = uiPartAddr; 5005 5006 // col [2] 5007 Int iRefIdxSkip[2] = {-1, -1}; 5008 if( !bMerge ) 5009 { 5010 iRefIdxSkip[ eRefPicList0 ] = iRefIdx0; 5011 } 5012 else 5013 { 5014 for (Int i=0; i<2; i++) 5015 { 5016 RefPicList eRefPicList1 = ( i==1 ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 5017 #if SET_MERGE_TMVP_REFIDX 5018 Int iRefIdxTmp; 5019 if ( uiPUIdx != 0 ) 5020 { 5021 iRefIdxTmp = 0; 5022 } 5023 else 5024 { 5025 iRefIdxTmp = (pcCULeft != NULL) ? pcCULeft->getCUMvField(eRefPicList1)->getRefIdx(uiLeftPartIdx) : -1; 5026 } 5027 #else 5028 Int iRefIdxTmp = (pcCULeft != NULL) ? pcCULeft->getCUMvField(eRefPicList1)->getRefIdx(uiLeftPartIdx) : -1; 5029 #endif 5030 iRefIdxSkip[i] = (iRefIdxTmp != -1) ? iRefIdxTmp : 0; 5031 } 5032 } 5033 5034 //>> MTK colocated-RightBottom 5035 UInt uiPartIdxRB; 5036 Int uiLCUIdx = getAddr(); 5037 eCUMode = getPartitionSize( 0 ); 5038 5039 deriveRightBottomIdx( eCUMode, uiPUIdx, uiPartIdxRB ); 5040 5041 UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; 5042 //UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 5043 5044 TComMv cColMv; 5045 Int iRefIdx; 5046 5047 if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check 5048 { 5049 uiLCUIdx = -1; 5050 } 5051 else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 5052 { 5053 uiLCUIdx = -1; 5054 } 5055 else 5056 { 5057 if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU 5058 ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU 5059 { 5060 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; 5061 uiLCUIdx = getAddr(); 5062 } 5063 else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU 5064 { 5065 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; 5066 uiLCUIdx = -1 ; 5067 } 5068 else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU 5069 { 5070 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; 5071 uiLCUIdx = getAddr() + 1; 5072 } 5073 else //is the right bottom corner of LCU 5074 { 5075 uiAbsPartAddr = 0; 5076 uiLCUIdx = -1 ; 5077 } 5078 } 5079 5080 Bool bExistMV = false; 5081 UInt uiPartIdxCenter; 5082 UInt uiCurLCUIdx = getAddr(); 5083 xDeriveCenterIdx( eCUMode, uiPUIdx, uiPartIdxCenter ); 5084 5085 Int iTargetView, iStartView; 5086 if( !bMerge ) // AMVP 5087 { 5088 bExistMV = uiLCUIdx >= 0 && xGetColDisMV( eRefPicList0, iRefIdx0, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetView, iStartView ); 5089 if( bExistMV == false ) 5090 { 5091 bExistMV = xGetColDisMV( eRefPicList0, iRefIdx0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iTargetView, iStartView ); 5092 } 5093 if( bExistMV ) // DV is found 5094 { 5095 if( cColMv.m_bDvMcp == false ) //=> DCP, if true => DV-MCP 5096 { 5097 clipMv(cColMv); 5098 pDInfo->m_acMvCand[ pDInfo->iN] = cColMv; 5099 pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetView; 5100 return; 5101 } 5102 else // DV-MCP 5103 { 5104 aiDvMcpDvCand[eRefPicList0][DVFROM_COL] = cColMv.getHor(); 5105 abDvMcpFlag [eRefPicList0][DVFROM_COL] = true; 5106 bDvMcpIsFound = true; 5107 } 5108 } 5109 } 5110 else // MERGE 5111 { 5112 iRefIdx = iRefIdxSkip[0]; 5113 bExistMV = uiLCUIdx >= 0 && xGetColDisMV( REF_PIC_LIST_0, iRefIdx, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetView, iStartView ); 5114 if( bExistMV == false ) 5115 { 5116 bExistMV = xGetColDisMV( REF_PIC_LIST_0, iRefIdx, uiCurLCUIdx, uiPartIdxCenter, cColMv, iTargetView, iStartView ); 5117 } 5118 if( bExistMV ) 5119 { 5120 if( cColMv.m_bDvMcp == false ) // DCP 5121 { 5122 clipMv(cColMv); 5123 pDInfo->m_acMvCand[ pDInfo->iN] = cColMv; 5124 pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetView; 5125 return; 5126 } 5127 else { // // DV-MCP 5128 aiDvMcpDvCand[0][DVFROM_COL] = cColMv.getHor(); 5129 abDvMcpFlag [0][DVFROM_COL] = true; 5130 bDvMcpIsFound = true; 5131 }; 5132 5133 if ( getSlice()->isInterB() ) 5134 { 5135 iRefIdx = iRefIdxSkip[1]; 5136 bExistMV = uiLCUIdx >= 0 && xGetColDisMV( REF_PIC_LIST_1, iRefIdx, uiLCUIdx, uiAbsPartAddr, cColMv, iTargetView, iStartView ); 5137 if( bExistMV == false ) 5138 { 5139 bExistMV = xGetColDisMV( REF_PIC_LIST_1, iRefIdx, uiCurLCUIdx, uiPartIdxCenter, cColMv, iTargetView, iStartView ); 5140 } 5141 if( bExistMV ) 5142 { 5143 if( cColMv.m_bDvMcp == false ) // DCP 5144 { 5145 clipMv(cColMv); 5146 pDInfo->m_acMvCand[ pDInfo->iN] = cColMv; 5147 pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetView; 5148 return; 5149 } 5150 else // DV-MCP 5151 { 5152 aiDvMcpDvCand[1][DVFROM_COL] = cColMv.getHor(); 5153 abDvMcpFlag [1][DVFROM_COL] = true; 5154 bDvMcpIsFound = true; 5155 }; 5156 } 5157 } 5158 } 5159 } 5160 } // if TMVP Flag 5161 5162 if( bDvMcpIsFound ) // skip dvmcp 5163 { 5164 for( Int i=1 ; i<7 ; i++ ) // 5 spatial + 1 temporal 5165 { 5166 for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) 5167 { 5168 if( abDvMcpFlag[iList][i]==true ) 5169 { 5170 TComMv dv( aiDvMcpDvCand[iList][ i ], 0 ); 5171 clipMv( dv ); 5172 pDInfo->m_acMvCand[ pDInfo->iN ] = dv; 5173 pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; 5174 return; 5175 } 5176 5177 } 5178 } 5179 } 5180 5181 return; 5182 5183 } 5184 #endif 5185 4616 5186 #endif 4617 5187 … … 4640 5210 cDisInfo.iN = 0; 4641 5211 if(m_pcSlice->getSPS()->getViewId() && m_pcSlice->getSPS()->getMultiviewMvPredMode()) 4642 getDisMvpCand (uiPartIdx, uiPartAddr, &cDisInfo ); 5212 { 5213 #if USE_DVMCP 5214 getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo, false, eRefPicList, iRefIdx ); 5215 #else 5216 getDisMvpCand (uiPartIdx, uiPartAddr, &cDisInfo ); 5217 #endif 5218 } 4643 5219 if(cDisInfo.iN==0) 4644 5220 { … … 5064 5640 { 5065 5641 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 5066 5642 #if USE_DVMCP 5643 cMvPred.m_bDvMcp = false; 5644 #endif 5067 5645 pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; 5068 5646 return true; … … 5099 5677 { 5100 5678 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); 5679 #if USE_DVMCP 5680 cMvPred.m_bDvMcp = false; 5681 #endif 5101 5682 pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; 5102 5683 return true; … … 5239 5820 { 5240 5821 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); 5241 5822 #if USE_DVMCP 5823 cMvPred.m_bDvMcp = false; 5824 #endif 5242 5825 clipMv(cMvPred); 5243 5826 pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; … … 5267 5850 rcMv = cMvPred.scaleMv( iScale ); 5268 5851 } 5852 #if USE_DVMCP 5853 rcMv.m_bDvMcp = false; 5854 #endif 5269 5855 pInfo->m_acMvCand[ pInfo->iN++] = rcMv; 5270 5856 return true; … … 5291 5877 rcMv = cMvPred.scaleMv( iScale ); 5292 5878 } 5879 #if USE_DVMCP 5880 rcMv.m_bDvMcp = false; 5881 #endif 5293 5882 pInfo->m_acMvCand[ pInfo->iN++] = rcMv; 5294 5883 return true; … … 5301 5890 Bool TComDataCU::xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx ) 5302 5891 { 5892 #if USE_DVMCP 5893 Int iDvMcpDispX[2] = {-1,}; 5894 Bool bDvMcpFlag [2] = { false, }; 5895 Int iCurrViewIdx = m_pcSlice->getViewId(); 5896 #endif 5303 5897 5304 5898 UInt uiAbsPartAddr = uiPartUnitIdx; … … 5310 5904 iColViewIdx = pColCU->getSlice()->getViewId(); 5311 5905 5906 5312 5907 if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiAbsPartAddr)) 5313 5908 { 5314 5909 return false; 5315 5910 } 5911 #if USE_DVMCP 5912 Bool bColIsSkipped = pColCU->isSkipped( uiAbsPartAddr ); 5913 #endif 5316 5914 for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++) 5317 5915 { … … 5330 5928 iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewId(); 5331 5929 if ( iColViewIdx == iColRefViewIdx ) // temporal vector 5930 { 5931 #if USE_DVMCP 5932 if( iColViewIdx >0 ) 5933 { 5934 TComMv tmpMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); 5935 if( tmpMv.m_bDvMcp && bColIsSkipped ) // DV-MCP SKIP 5936 { 5937 iDvMcpDispX[ilist] = tmpMv.m_iDvMcpDispX; 5938 bDvMcpFlag [ilist] = true; 5939 iTargetViewIdx = 0; //iColRefViewIdx ; 5940 iStartViewIdx = 0; //iCurrViewIdx; //iColViewIdx ; 5941 } 5942 } 5943 #endif 5332 5944 continue; 5945 } 5333 5946 else 5334 5947 { 5335 5948 rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); 5949 #if USE_DVMCP 5950 rcMv.m_bDvMcp = false; 5951 #endif 5336 5952 iTargetViewIdx = iColRefViewIdx ; 5337 5953 iStartViewIdx = iColViewIdx ; … … 5339 5955 } 5340 5956 } 5957 5958 #if USE_DVMCP 5959 for( Int ilist=0 ; ilist<2 ; ilist++ ) 5960 { 5961 if( bDvMcpFlag[ilist] ) 5962 { 5963 rcMv.setHor( iDvMcpDispX[ilist] ); 5964 rcMv.setVer( 0 ); 5965 rcMv.m_bDvMcp = true; 5966 iTargetViewIdx = 0; //iColRefViewIdx ; 5967 iStartViewIdx = iCurrViewIdx; //iColViewIdx ; 5968 return true; 5969 } 5970 } 5971 #endif 5972 5341 5973 return false; 5342 5974 } … … 6446 7078 PartSize m_peSaved = getPartitionSize( 0 ); 6447 7079 m_pePartSize[0] = SIZE_2Nx2N; 7080 #if USE_DVMCP 7081 getDisMvpCand2( 0, 0, &cDisInfo, true ); 7082 #else 6448 7083 getDisMvpCand ( 0, 0, &cDisInfo ); 7084 #endif 6449 7085 if( cDisInfo.iN == 0) 6450 7086 { … … 6472 7108 #endif 6473 7109 7110 #if LGE_EDGE_INTRA 7111 Void TComDataCU::reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion ) 7112 { 7113 Int iWidth; 7114 Int iHeight; 7115 if( uiDepth == 0 ) 7116 { 7117 iWidth = 64; 7118 iHeight = 64; 7119 } 7120 else if( uiDepth == 1 ) 7121 { 7122 iWidth = 32; 7123 iHeight = 32; 7124 } 7125 else if( uiDepth == 2 ) 7126 { 7127 iWidth = 16; 7128 iHeight = 16; 7129 } 7130 else if( uiDepth == 3 ) 7131 { 7132 iWidth = 8; 7133 iHeight = 8; 7134 } 7135 else // uiDepth == 4 7136 { 7137 iWidth = 4; 7138 iHeight = 4; 7139 } 7140 7141 Int iPtr = 0; 7142 Int iX, iY; 7143 Int iDir = -1; 7144 Int iDiffX = 0, iDiffY = 0; 7145 7146 // 1. Edge Code -> Vert & Horz Edges 7147 Bool* pbEdge = (Bool*) xMalloc( Bool, 4 * iWidth * iHeight ); 7148 7149 for( UInt ui = 0; ui < 4 * iWidth * iHeight; ui++ ) 7150 pbEdge [ ui ] = false; 7151 7152 // Direction : left(0), right(1), top(2), bottom(3), left-top(4), right-top(5), left-bottom(6), right-bottom(7) 7153 // Code : 0deg(0), 45deg(1), -45deg(2), 90deg(3), -90deg(4), 135deg(5), -135deg(6) 7154 const UChar tableDir[8][7] = { { 0, 6, 4, 3, 2, 7, 5 }, 7155 { 1, 5, 7, 2, 3, 4, 6 }, 7156 { 2, 4, 5, 0, 1, 6, 7 }, 7157 { 3, 7, 6, 1, 0, 5, 4 }, 7158 { 4, 0, 2, 6, 5, 3, 1 }, 7159 { 5, 2, 1, 4, 7, 0, 3 }, 7160 { 6, 3, 0, 7, 4, 1, 2 }, 7161 { 7, 1, 3, 5, 6, 2, 0 }}; 7162 7163 UChar ucCode = pucEdgeCode[iPtr++]; 7164 7165 if( !bLeft ) 7166 { 7167 iX = ucStartPos; 7168 iY = 0; 7169 7170 switch(ucCode) 7171 { 7172 case 0: // bottom 7173 iDir = 3; 7174 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7175 break; 7176 case 2: // left-bottom 7177 iDir = 6; 7178 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7179 break; 7180 case 1: // right-bottom 7181 iDir = 7; 7182 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7183 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7184 break; 7185 case 4: // left 7186 iDir = 0; 7187 assert(false); 7188 break; 7189 case 3: // right 7190 iDir = 1; 7191 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7192 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7193 break; 7194 } 7195 } 7196 else 7197 { 7198 iX = 0; 7199 iY = ucStartPos; 7200 7201 switch(ucCode) 7202 { 7203 case 0: // right 7204 iDir = 1; 7205 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7206 break; 7207 case 1: // right-top 7208 iDir = 5; 7209 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7210 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7211 break; 7212 case 2: // right-bottom 7213 iDir = 7; 7214 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7215 break; 7216 case 3: // top 7217 iDir = 2; 7218 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7219 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7220 break; 7221 case 4: // bottom 7222 iDir = 3; 7223 assert(false); 7224 break; 7225 } 7226 } 7227 7228 switch( iDir ) 7229 { 7230 case 0: // left 7231 iDiffX = -1; 7232 iDiffY = 0; 7233 break; 7234 case 1: // right 7235 iDiffX = +1; 7236 iDiffY = 0; 7237 break; 7238 case 2: // top 7239 iDiffX = 0; 7240 iDiffY = -1; 7241 break; 7242 case 3: // bottom 7243 iDiffX = 0; 7244 iDiffY = +1; 7245 break; 7246 case 4: // left-top 7247 iDiffX = -1; 7248 iDiffY = -1; 7249 break; 7250 case 5: // right-top 7251 iDiffX = +1; 7252 iDiffY = -1; 7253 break; 7254 case 6: // left-bottom 7255 iDiffX = -1; 7256 iDiffY = +1; 7257 break; 7258 case 7: // right-bottom 7259 iDiffX = +1; 7260 iDiffY = +1; 7261 break; 7262 } 7263 7264 iX += iDiffX; 7265 iY += iDiffY; 7266 7267 while( iPtr < ucNumEdge ) 7268 { 7269 ucCode = pucEdgeCode[iPtr++]; 7270 7271 Int iNewDir = tableDir[iDir][ucCode]; 7272 7273 switch( iNewDir ) 7274 { 7275 case 0: // left 7276 iDiffX = -1; 7277 iDiffY = 0; 7278 break; 7279 case 1: // right 7280 iDiffX = +1; 7281 iDiffY = 0; 7282 break; 7283 case 2: // top 7284 iDiffX = 0; 7285 iDiffY = -1; 7286 break; 7287 case 3: // bottom 7288 iDiffX = 0; 7289 iDiffY = +1; 7290 break; 7291 case 4: // left-top 7292 iDiffX = -1; 7293 iDiffY = -1; 7294 break; 7295 case 5: // right-top 7296 iDiffX = +1; 7297 iDiffY = -1; 7298 break; 7299 case 6: // left-bottom 7300 iDiffX = -1; 7301 iDiffY = +1; 7302 break; 7303 case 7: // right-bottom 7304 iDiffX = +1; 7305 iDiffY = +1; 7306 break; 7307 } 7308 7309 switch( iDir ) 7310 { 7311 case 0: // left 7312 switch( ucCode ) 7313 { 7314 case 0: 7315 case 2: 7316 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7317 break; 7318 case 1: 7319 case 3: 7320 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7321 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7322 break; 7323 case 4: 7324 case 6: 7325 // no 7326 break; 7327 case 5: 7328 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7329 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7330 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7331 break; 7332 } 7333 break; 7334 case 1: // right 7335 switch( ucCode ) 7336 { 7337 case 0: 7338 case 2: 7339 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7340 break; 7341 case 1: 7342 case 3: 7343 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7344 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7345 break; 7346 case 4: 7347 case 6: 7348 // no 7349 break; 7350 case 5: 7351 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7352 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7353 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7354 break; 7355 } 7356 break; 7357 case 2: // top 7358 switch( ucCode ) 7359 { 7360 case 0: 7361 case 2: 7362 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7363 break; 7364 case 1: 7365 case 3: 7366 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7367 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7368 break; 7369 case 4: 7370 case 6: 7371 // no 7372 break; 7373 case 5: 7374 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7375 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7376 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7377 break; 7378 } 7379 break; 7380 case 3: // bottom 7381 switch( ucCode ) 7382 { 7383 case 0: 7384 case 2: 7385 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7386 break; 7387 case 1: 7388 case 3: 7389 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7390 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7391 break; 7392 case 4: 7393 case 6: 7394 // no 7395 break; 7396 case 5: 7397 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7398 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7399 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7400 break; 7401 } 7402 break; 7403 case 4: // left-top 7404 switch( ucCode ) 7405 { 7406 case 0: 7407 case 1: 7408 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7409 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7410 break; 7411 case 2: 7412 case 4: 7413 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7414 break; 7415 case 3: 7416 case 5: 7417 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7418 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7419 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7420 break; 7421 case 6: 7422 // no 7423 break; 7424 } 7425 break; 7426 case 5: // right-top 7427 switch( ucCode ) 7428 { 7429 case 0: 7430 case 1: 7431 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7432 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7433 break; 7434 case 2: 7435 case 4: 7436 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7437 break; 7438 case 3: 7439 case 5: 7440 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7441 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7442 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7443 break; 7444 case 6: 7445 // no 7446 break; 7447 } 7448 break; 7449 case 6: // left-bottom 7450 switch( ucCode ) 7451 { 7452 case 0: 7453 case 1: 7454 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7455 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7456 break; 7457 case 2: 7458 case 4: 7459 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7460 break; 7461 case 3: 7462 case 5: 7463 if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; 7464 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7465 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7466 break; 7467 case 6: 7468 // no 7469 break; 7470 } 7471 break; 7472 case 7: // right-bottom 7473 switch( ucCode ) 7474 { 7475 case 0: 7476 case 1: 7477 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7478 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7479 break; 7480 case 2: 7481 case 4: 7482 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7483 break; 7484 case 3: 7485 case 5: 7486 if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; 7487 if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; 7488 if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; 7489 break; 7490 case 6: 7491 // no 7492 break; 7493 } 7494 break; 7495 } 7496 7497 assert( iX >= 0 && iX <= iWidth ); 7498 assert( iY >= 0 && iY <= iHeight ); 7499 7500 iX += iDiffX; 7501 iY += iDiffY; 7502 iDir = iNewDir; 7503 } 7504 7505 // finalize edge chain 7506 if( iX == iWidth-1 ) 7507 { 7508 if( iY == 0 ) 7509 { 7510 if( iDir == 1 ) 7511 { 7512 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 7513 } 7514 else if( iDir == 5 ) 7515 { 7516 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 7517 } 7518 else 7519 { 7520 assert(false); 7521 } 7522 } 7523 else if( iY == iHeight-1 ) 7524 { 7525 if( iDir == 3 ) 7526 { 7527 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 7528 } 7529 else if( iDir == 7 ) 7530 { 7531 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 7532 } 7533 else 7534 { 7535 assert(false); 7536 } 7537 } 7538 else 7539 { 7540 if( iDir == 1 ) 7541 { 7542 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 7543 } 7544 else if( iDir == 3 ) 7545 { 7546 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 7547 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 7548 } 7549 else if( iDir == 5 ) 7550 { 7551 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 7552 } 7553 else if( iDir == 7 ) 7554 { 7555 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 7556 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 7557 } 7558 else 7559 { 7560 assert(false); 7561 } 7562 } 7563 } 7564 else if( iX == 0 ) 7565 { 7566 if( iY == 0 ) 7567 { 7568 if( iDir == 2 ) 7569 { 7570 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 7571 } 7572 else if( iDir == 4 ) 7573 { 7574 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 7575 } 7576 else 7577 { 7578 assert(false); 7579 } 7580 } 7581 else if( iY == iHeight-1 ) 7582 { 7583 if( iDir == 0 ) 7584 { 7585 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 7586 } 7587 else if( iDir == 6 ) 7588 { 7589 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 7590 } 7591 else 7592 { 7593 assert(false); 7594 } 7595 } 7596 else 7597 { 7598 if( iDir == 0 ) 7599 { 7600 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 7601 } 7602 else if( iDir == 2 ) 7603 { 7604 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 7605 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 7606 } 7607 else if( iDir == 4 ) 7608 { 7609 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 7610 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 7611 } 7612 else if( iDir == 6 ) 7613 { 7614 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 7615 } 7616 else 7617 { 7618 assert(false); 7619 } 7620 } 7621 } 7622 else if( iY == 0 ) 7623 { 7624 if( iDir == 1 ) 7625 { 7626 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 7627 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 7628 } 7629 else if( iDir == 2 ) 7630 { 7631 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 7632 } 7633 else if( iDir == 4 ) 7634 { 7635 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 7636 } 7637 else if( iDir == 5 ) 7638 { 7639 pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; 7640 pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; 7641 } 7642 else 7643 { 7644 assert(false); 7645 } 7646 } 7647 else if( iY == iHeight-1 ) 7648 { 7649 if( iDir == 0 ) 7650 { 7651 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 7652 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 7653 } 7654 else if( iDir == 3 ) 7655 { 7656 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 7657 } 7658 else if( iDir == 6 ) 7659 { 7660 pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; 7661 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 7662 } 7663 else if( iDir == 7 ) 7664 { 7665 pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; 7666 } 7667 else 7668 { 7669 assert(false); 7670 } 7671 } 7672 else 7673 { 7674 printf("xPredIntraEdge: wrong termination\n"); 7675 assert(false); 7676 } 7677 7678 // Reconstruct Region from Chain Code 7679 Bool* pbVisit = (Bool*) xMalloc( Bool, iWidth * iHeight ); 7680 Int* piStack = (Int* ) xMalloc( Int, iWidth * iHeight ); 7681 7682 for( UInt ui = 0; ui < iWidth * iHeight; ui++ ) 7683 { 7684 pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next) 7685 pbVisit [ ui ] = false; 7686 } 7687 7688 iPtr = 0; 7689 piStack[iPtr++] = (0 << 8) | (0); 7690 pbRegion[ 0 ] = false; 7691 7692 while(iPtr > 0) 7693 { 7694 Int iTmp = piStack[--iPtr]; 7695 Int iX1, iY1; 7696 iX1 = iTmp & 0xff; 7697 iY1 = (iTmp >> 8) & 0xff; 7698 7699 pbVisit[ iX1 + iY1 * iWidth ] = true; 7700 7701 assert( iX1 >= 0 && iX1 < iWidth ); 7702 assert( iY1 >= 0 && iY1 < iHeight ); 7703 7704 if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] ) 7705 { 7706 piStack[iPtr++] = (iY1 << 8) | (iX1 - 1); 7707 pbRegion[ iX1 - 1 + iY1 * iWidth ] = false; 7708 } 7709 if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] ) 7710 { 7711 piStack[iPtr++] = (iY1 << 8) | (iX1 + 1); 7712 pbRegion[ iX1 + 1 + iY1 * iWidth ] = false; 7713 } 7714 if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] ) 7715 { 7716 piStack[iPtr++] = ((iY1 - 1) << 8) | iX1; 7717 pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false; 7718 } 7719 if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] ) 7720 { 7721 piStack[iPtr++] = ((iY1 + 1) << 8) | iX1; 7722 pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false; 7723 } 7724 } 7725 7726 xFree( pbEdge ); 7727 xFree( pbVisit ); 7728 xFree( piStack ); 7729 } 7730 7731 #endif 7732 6474 7733 //! \}
Note: See TracChangeset for help on using the changeset viewer.