Changeset 97 in 3DVCSoftware for branches/HTM-3.1-LG/source
- Timestamp:
- 6 Aug 2012, 05:35:11 (12 years ago)
- Location:
- branches/HTM-3.1-LG/source/Lib
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-3.1-LG/source/Lib/TLibCommon/ContextTables.h
r56 r97 152 152 #endif 153 153 154 #if LGE_EDGE_INTRA 155 #define NUM_EDGE_INTRA_CTX 1 156 #if LGE_EDGE_INTRA_DELTA_DC 157 #define NUM_EDGE_INTRA_DELTA_DC_CTX 2 // one for Delta_DC flag, another for Delta_DC value 158 #endif 159 #endif 160 154 161 // ==================================================================================================================== 155 162 // Tables … … 1272 1279 } 1273 1280 }; 1281 1282 #if LGE_EDGE_INTRA 1283 static const Short 1284 INIT_EDGE_INTRA[3][NUM_EDGE_INTRA_CTX] = 1285 { 1286 { 1287 CNU 1288 }, 1289 { 1290 CNU 1291 }, 1292 { 1293 CNU 1294 } 1295 }; 1296 1297 #if LGE_EDGE_INTRA_DELTA_DC 1298 static const Short 1299 INIT_EDGE_INTRA_DELTA_DC[3][NUM_EDGE_INTRA_DELTA_DC_CTX] = 1300 { 1301 { 1302 CNU, CNU 1303 }, 1304 { 1305 CNU, CNU 1306 }, 1307 { 1308 CNU, CNU 1309 } 1310 }; 1311 #endif 1312 #endif 1313 1274 1314 #endif 1275 1315 1276 1316 //! \} 1277 1317 1278 1279 #endif 1280 1318 #endif 1319 -
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 //! \} -
branches/HTM-3.1-LG/source/Lib/TLibCommon/TComDataCU.h
r91 r97 214 214 #endif 215 215 216 #if LGE_EDGE_INTRA 217 UChar* m_pucEdgeCode; ///< array of edge code 218 UChar* m_pucEdgeNumber; ///< total number of edge 219 UChar* m_pucEdgeStartPos; ///< starting point position 220 Bool* m_pbEdgeLeftFirst; ///< true if edge should be checked in left boundary first 221 Bool* m_pbEdgePartition; ///< true if it belongs to region 1, otherwise, region 0 222 #if LGE_EDGE_INTRA_DELTA_DC 223 Int* m_piEdgeDeltaDC0; 224 Int* m_piEdgeDeltaDC1; 225 #endif 226 #endif 227 216 228 // ------------------------------------------------------------------------------------------------------------------- 217 229 // misc. variables … … 513 525 Int getPdmMergeCandidateDisCan( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo ); 514 526 Void getDisMvpCand ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo ); 527 #if USE_DVMCP 528 Void getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo, Bool bMerge=false, RefPicList eRefPicList=REF_PIC_LIST_X, Int iRefIdx=-1 ); 529 #endif 530 515 531 #endif 516 532 Bool getIViewOrgDepthMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv ); … … 668 684 UInt getEntropySliceStartCU ( UInt pos ) { return m_uiEntropySliceStartCU[pos-m_uiAbsIdxInLCU]; } 669 685 UInt& getTotalBins () { return m_uiTotalBins; } 686 687 #if LGE_EDGE_INTRA 688 UInt getCtxEdgeIntra ( UInt uiAbsPartIdx ); 689 #endif 690 670 691 // ------------------------------------------------------------------------------------------------------------------- 671 692 // member functions for RD cost storage … … 743 764 Void setContourPredTexDeltaDC2SubParts ( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth ); 744 765 #endif 766 767 #if LGE_EDGE_INTRA 768 UChar* getEdgeCode( UInt uiIdx ) { return &m_pucEdgeCode[uiIdx * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4]; } 769 UChar* getEdgeNumber( ) { return m_pucEdgeNumber; } 770 UChar getEdgeNumber( UInt uiIdx ) { return m_pucEdgeNumber[uiIdx]; } 771 Void setEdgeNumber( UInt uiIdx, UChar val ) { m_pucEdgeNumber[uiIdx] = val; } 772 UChar* getEdgeStartPos( ) { return m_pucEdgeStartPos; } 773 UChar getEdgeStartPos( UInt uiIdx ) { return m_pucEdgeStartPos[uiIdx]; } 774 Void setEdgeStartPos( UInt uiIdx, UChar val ) { m_pucEdgeStartPos[uiIdx] = val; } 775 Bool* getEdgeLeftFirst( ) { return m_pbEdgeLeftFirst; } 776 Bool getEdgeLeftFirst( UInt uiIdx ) { return m_pbEdgeLeftFirst[uiIdx]; } 777 Void setEdgeLeftFirst( UInt uiIdx, Bool val ) { m_pbEdgeLeftFirst[uiIdx] = val; } 778 Bool* getEdgePartition( UInt uiIdx ) { return &m_pbEdgePartition[uiIdx * 16]; } 779 Void reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion ); 780 781 #if LGE_EDGE_INTRA_DELTA_DC 782 Int* getEdgeDeltaDC0( ) { return m_piEdgeDeltaDC0; } 783 Int* getEdgeDeltaDC1( ) { return m_piEdgeDeltaDC1; } 784 Int getEdgeDeltaDC0( UInt uiIdx ) { return m_piEdgeDeltaDC0[uiIdx]; } 785 Int getEdgeDeltaDC1( UInt uiIdx ) { return m_piEdgeDeltaDC1[uiIdx]; } 786 Void setEdgeDeltaDC0( UInt uiIdx, Int val ) { m_piEdgeDeltaDC0[uiIdx] = val; } 787 Void setEdgeDeltaDC1( UInt uiIdx, Int val ) { m_piEdgeDeltaDC1[uiIdx] = val; } 788 #endif 789 #endif 745 790 }; 746 791 -
branches/HTM-3.1-LG/source/Lib/TLibCommon/TComDepthMapGenerator.cpp
r95 r97 831 831 TComDepthMapGenerator::getDisCanPdmMvPred ( TComDataCU* pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge ) 832 832 { 833 #if USE_DVMCP 834 rcMv.m_bDvMcp = false; 835 #endif 833 836 AOF ( m_bCreated && m_bInit ); 834 837 AOF ( iRefIdx >= 0 ); … … 892 895 { 893 896 rcMv.set( cBaseMvField.getHor(), cBaseMvField.getVer() ); 897 #if USE_DVMCP 898 // save disparity vector when a merge candidate for IVMP is set as DV-MCP 899 if( bMerge ) 900 { 901 rcMv.m_bDvMcp = true; 902 rcMv.m_iDvMcpDispX = pDInfo->m_acMvCand[0].getHor(); 903 } 904 else { // AMVP ? 905 rcMv.m_bDvMcp = false; 906 } 907 #endif 894 908 return true; 895 909 } -
branches/HTM-3.1-LG/source/Lib/TLibCommon/TComMv.h
r56 r97 57 57 public: 58 58 59 #if USE_DVMCP 60 Bool m_bDvMcp; // is dv-mcp ? 61 Int m_iDvMcpDispX; // disparity for dv-mcp 62 #endif 63 59 64 // ------------------------------------------------------------------------------------------------------------------ 60 65 // constructors … … 64 69 m_iHor(0), 65 70 m_iVer(0) 71 #if USE_DVMCP 72 , m_bDvMcp(false) 73 , m_iDvMcpDispX(0) 74 #endif 66 75 { 67 76 } … … 70 79 m_iHor(iHor), 71 80 m_iVer(iVer) 81 #if USE_DVMCP 82 , m_bDvMcp(false) 83 , m_iDvMcpDispX(0) 84 #endif 72 85 { 73 86 } -
branches/HTM-3.1-LG/source/Lib/TLibCommon/TComPattern.cpp
r56 r97 675 675 { 676 676 Int* piSrc; 677 #if LGE_EDGE_INTRA 678 mapEdgeIntratoDC( uiDirMode ); 679 #endif 677 680 assert(log2BlkSize >= 2 && log2BlkSize < 7); 678 681 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX -
branches/HTM-3.1-LG/source/Lib/TLibCommon/TComPic.h
r93 r97 73 73 #endif 74 74 75 #if LG_ZEROINTRADEPTHRESI_M26039 76 Int m_uiIntraPeriod; 77 #endif 78 75 79 #if HHI_INTER_VIEW_MOTION_PRED 76 80 TComPicYuv* m_pcOrgDepthMap; // original depth map … … 129 133 #if VIDYO_VPS_INTEGRATION 130 134 TComVPS* getVPS() { return m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getVPS(); } 135 #endif 136 #if LG_ZEROINTRADEPTHRESI_M26039 137 Int getIntraPeriod() { return m_uiIntraPeriod; } 138 Void setIntraPeriod(Int uiIntraPeriod) { m_uiIntraPeriod = uiIntraPeriod; } 131 139 #endif 132 140 TComSPS* getSPS() { return m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getSPS(); } -
branches/HTM-3.1-LG/source/Lib/TLibCommon/TComPrediction.cpp
r93 r97 419 419 } 420 420 421 #if LGE_EDGE_INTRA 422 Void TComPrediction::predIntraLumaEdge ( TComDataCU* pcCU, TComPattern* pcTComPattern, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Pel* piPred, UInt uiStride, Bool bDelta ) 423 { 424 Pel *piDst = piPred; 425 Int *piSrc; 426 Int iSrcStride = ( iWidth<<1 ) + 1; 427 Int iDstStride = uiStride; 428 429 piSrc = pcTComPattern->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); 430 431 xPredIntraEdge ( pcCU, uiAbsPartIdx, iWidth, iHeight, piSrc, iSrcStride, piDst, iDstStride 432 #if LGE_EDGE_INTRA_DELTA_DC 433 , bDelta 434 #endif 435 ); 436 } 437 438 Pel TComPrediction::xGetNearestNeighbor( Int x, Int y, Int* pSrc, Int srcStride, Int iWidth, Int iHeight, Bool* bpRegion ) 439 { 440 Bool bLeft = (x < y) ? true : false; 441 Bool bFound = false; 442 Int iFoundX = -1, iFoundY = -1; 443 Int cResult = 0; 444 445 #define MAX_DISTANCE_EDGEINTRA 255 446 447 UChar* piTopDistance = new UChar[iWidth]; 448 UChar* piLeftDistance = new UChar[iHeight]; 449 450 for( Int i = 0; i < iWidth; i++ ) 451 { 452 int Abs = x > i ? x - i : i - x; 453 piTopDistance[ i ] = y + Abs; 454 455 Abs = y > i ? y - i : i - y; 456 piLeftDistance[ i ] = x + Abs; 457 } 458 459 for( Int dist = 0; dist < MAX_DISTANCE_EDGEINTRA && !bFound; dist++ ) 460 { 461 if( !bLeft ) 462 { 463 for( Int i = 0; i < iWidth; i++ ) 464 { 465 if( piTopDistance[ i ] == dist ) 466 { 467 if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] ) 468 { 469 iFoundX = i; 470 iFoundY = 0; 471 bFound = true; 472 } 473 } 474 } 475 for( Int i = 0; i < iHeight; i++ ) 476 { 477 if( piLeftDistance[ i ] == dist ) 478 { 479 if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] ) 480 { 481 iFoundX = 0; 482 iFoundY = i; 483 bFound = true; 484 } 485 } 486 } 487 } 488 else 489 { 490 for( Int i = 0; i < iHeight; i++ ) 491 { 492 if( piLeftDistance[ i ] == dist ) 493 { 494 if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] ) 495 { 496 iFoundX = 0; 497 iFoundY = i; 498 bFound = true; 499 } 500 } 501 } 502 for( Int i = 0; i < iWidth; i++ ) 503 { 504 if( piTopDistance[ i ] == dist ) 505 { 506 if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] ) 507 { 508 iFoundX = i; 509 iFoundY = 0; 510 bFound = true; 511 } 512 } 513 } 514 } 515 } 516 517 if( iFoundY == 0 ) 518 { 519 cResult = pSrc[ iFoundX + 1 ]; 520 } 521 else // iFoundX == 0 522 { 523 cResult = pSrc[ (iFoundY + 1) * srcStride ]; 524 } 525 526 delete[] piTopDistance; piTopDistance = NULL; 527 delete[] piLeftDistance; piLeftDistance = NULL; 528 529 assert( bFound ); 530 531 return cResult; 532 } 533 534 Void TComPrediction::xPredIntraEdge( TComDataCU* pcCU, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, Bool bDelta ) 535 { 536 Pel* pDst = rpDst; 537 Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); 538 539 // Do prediction 540 { 541 UInt uiSum0 = 0, uiSum1 = 0; 542 UInt uiMean0, uiMean1; 543 UInt uiCount0 = 0, uiCount1 = 0; 544 for( UInt ui = 0; ui < iWidth; ui++ ) 545 { 546 if( pbRegion[ ui ] == false ) 547 { 548 uiSum0 += (pSrc[ ui + 1 ]); 549 uiCount0++; 550 } 551 else 552 { 553 uiSum1 += (pSrc[ ui + 1 ]); 554 uiCount1++; 555 } 556 } 557 for( UInt ui = 0; ui < iHeight; ui++ ) // (0,0) recount (to avoid division) 558 { 559 if( pbRegion[ ui * iWidth ] == false ) 560 { 561 uiSum0 += (pSrc[ (ui + 1) * srcStride ]); 562 uiCount0++; 563 } 564 else 565 { 566 uiSum1 += (pSrc[ (ui + 1) * srcStride ]); 567 uiCount1++; 568 } 569 } 570 if( uiCount0 == 0 ) 571 assert(false); 572 if( uiCount1 == 0 ) 573 assert(false); 574 uiMean0 = uiSum0 / uiCount0; // TODO : integer op. 575 uiMean1 = uiSum1 / uiCount1; 576 #if LGE_EDGE_INTRA_DELTA_DC 577 if( bDelta ) 578 { 579 Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx ); 580 Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx ); 581 xDeltaDCQuantScaleUp( pcCU, iDeltaDC0 ); 582 xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); 583 uiMean0 = Clip( uiMean0 + iDeltaDC0 ); 584 uiMean1 = Clip( uiMean1 + iDeltaDC1 ); 585 } 586 #endif 587 for( UInt ui = 0; ui < iHeight; ui++ ) 588 { 589 for( UInt uii = 0; uii < iWidth; uii++ ) 590 { 591 if( pbRegion[ uii + ui * iWidth ] == false ) 592 pDst[ uii + ui * dstStride ] = uiMean0; 593 else 594 pDst[ uii + ui * dstStride ] = uiMean1; 595 } 596 } 597 } 598 } 599 #endif 600 421 601 #if DEPTH_MAP_GENERATION 422 602 Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY ) -
branches/HTM-3.1-LG/source/Lib/TLibCommon/TComPrediction.h
r56 r97 125 125 #endif 126 126 127 #if LGE_EDGE_INTRA 128 Pel xGetNearestNeighbor ( Int x, Int y, Int* pSrc, Int srcStride, Int iWidth, Int iHeight, Bool* bpRegion ); 129 Void xPredIntraEdge ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, Bool bDelta = false ); 130 #endif 131 127 132 public: 128 133 TComPrediction(); … … 170 175 Bool getWedgePatternIdx ( WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ); 171 176 #endif 177 #if LGE_EDGE_INTRA 178 Void predIntraLumaEdge ( TComDataCU* pcCU, TComPattern* pcTComPattern, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Pel* piPred, UInt uiStride, Bool bDelta = false ); 179 #endif 172 180 173 181 // simplified intra pred for "virtual" depth maps -
branches/HTM-3.1-LG/source/Lib/TLibCommon/TComRom.h
r56 r97 206 206 #endif 207 207 208 #if LGE_EDGE_INTRA 209 __inline Void mapEdgeIntratoDC( UChar& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; } 210 __inline Void mapEdgeIntratoDC( UInt& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; } 211 __inline Void mapEdgeIntratoDC( Int& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; } 212 #endif 213 208 214 // ========================================== 209 215 // Mode-Dependent DST Matrices -
branches/HTM-3.1-LG/source/Lib/TLibCommon/TypeDef.h
r95 r97 42 42 //! \{ 43 43 44 #define LGE_EDGE_INTRA 1 //JCT2-A0070 45 #if LGE_EDGE_INTRA 46 #define LGE_EDGE_INTRA_MIN_SIZE 4 47 #define LGE_EDGE_INTRA_MAX_SIZE 32 48 #define LGE_EDGE_INTRA_THRESHOLD 20 49 #define LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 8 50 #define LGE_EDGE_INTRA_DELTA_DC 1 51 #define LGE_EDGE_INTRA_PIXEL_DIFFERENCE 1 52 #endif 53 54 #define LG_ZEROINTRADEPTHRESI_M26039 1 //JCT2-A0087 55 44 56 #define SONY_COLPIC_AVAILABILITY 1 45 57 … … 54 66 #define MTK_INTERVIEW_MERGE_A0049 1 // JCT2-A0049 second part 55 67 68 #if QC_MULTI_DIS_CAN // JCT2-A0126 69 #define USE_DVMCP 0 70 71 #define DVFROM_LEFTBELOW 1 72 #define DVFROM_LEFT 2 73 #define DVFROM_ABOVERIGHT 3 74 #define DVFROM_ABOVE 4 75 #define DVFROM_ABOVELEFT 5 76 #define DVFROM_COL 6 77 #endif 78 56 79 57 80 #define HHI_VSO 1 … … 231 254 #define LOG2_SCAN_SET_SIZE 4 232 255 256 #if LGE_EDGE_INTRA 257 #if LGE_EDGE_INTRA_DELTA_DC 258 #define FAST_UDI_MAX_RDMODE_NUM 37 ///< maximum number of RD comparison in fast-UDI estimation loop 259 #else 260 #define FAST_UDI_MAX_RDMODE_NUM 36 ///< maximum number of RD comparison in fast-UDI estimation loop 261 #endif 262 #else 233 263 #define FAST_UDI_MAX_RDMODE_NUM 35 ///< maximum number of RD comparison in fast-UDI estimation loop 264 #endif 234 265 235 266 #define ZERO_MVD_EST 0 ///< Zero Mvd Estimation in normal mode … … 270 301 #define NUM_DMM_MODE 4 271 302 #endif 303 304 #if LGE_EDGE_INTRA 305 #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX 306 #define EDGE_INTRA_IDX (NUM_INTRA_MODE+NUM_DMM_MODE) 307 #endif // HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX 308 #if LGE_EDGE_INTRA_DELTA_DC 309 #define EDGE_INTRA_DELTA_IDX (EDGE_INTRA_IDX+1) 310 #endif 311 #endif // LGE_EDGE_INTRA 272 312 273 313 #define IBDI_DISTORTION 0 ///< enable/disable SSE modification when IBDI is used (JCTVC-D152) -
branches/HTM-3.1-LG/source/Lib/TLibDecoder/TDecCu.cpp
r77 r97 705 705 m_pcPrediction->getPredicBufHeight (), 706 706 bAboveAvail, bLeftAvail ); 707 #if LGE_EDGE_INTRA 708 if( uiLumaPredMode >= EDGE_INTRA_IDX ) 709 { 710 m_pcPrediction->predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride 711 #if LGE_EDGE_INTRA_DELTA_DC 712 , uiLumaPredMode == EDGE_INTRA_DELTA_IDX 713 #endif 714 ); 715 } 716 else 717 #endif 707 718 708 719 //===== get prediction signal ===== -
branches/HTM-3.1-LG/source/Lib/TLibDecoder/TDecSbac.cpp
r56 r97 98 98 , m_cDmmDataSCModel ( 1, 1, NUM_DMM_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 99 99 #endif 100 #if LGE_EDGE_INTRA 101 , m_cEdgeIntraSCModel ( 1, 1, NUM_EDGE_INTRA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 102 #if LGE_EDGE_INTRA_DELTA_DC 103 , m_cEdgeIntraDeltaDCSCModel ( 1, 1, NUM_EDGE_INTRA_DELTA_DC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 104 #endif 105 #endif 100 106 { 101 107 assert( m_numContextModels <= MAX_NUM_CTX_MOD ); … … 182 188 183 189 m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); 190 #if LGE_EDGE_INTRA 191 m_cEdgeIntraSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EDGE_INTRA ); 192 #if LGE_EDGE_INTRA_DELTA_DC 193 m_cEdgeIntraDeltaDCSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EDGE_INTRA_DELTA_DC ); 194 #endif 195 #endif 184 196 m_uiLastDQpNonZero = 0; 185 197 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX … … 850 862 #endif 851 863 864 #if LGE_EDGE_INTRA 865 Bool bCodeEdgeIntra = false; 866 if( pcCU->getSlice()->getSPS()->isDepth() ) 867 { 868 UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0); 869 if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE ) 870 bCodeEdgeIntra = true; 871 } 872 #endif 873 852 874 #if LOGI_INTRA_NAME_3MPM 853 875 Int uiPreds[3] = {-1, -1, -1}; … … 855 877 Int uiPreds[2] = {-1, -1}; 856 878 #endif 857 Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); 879 Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); 880 #if LGE_EDGE_INTRA 881 UInt uiCheckBit = 0; 882 #endif 858 883 859 884 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); … … 878 903 879 904 m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 ); 905 #if LGE_EDGE_INTRA 906 if (bCodeEdgeIntra) 907 { 908 if (uiSymbol==31) 909 { 910 m_pcTDecBinIf->decodeBinsEP(uiCheckBit,1); 911 if (uiCheckBit) 912 uiSymbol = EDGE_INTRA_IDX; 913 } 914 } 915 #endif 880 916 intraPredMode = uiSymbol; 881 917 … … 903 939 } 904 940 #endif 941 #if LGE_EDGE_INTRA 942 if ( intraPredMode != EDGE_INTRA_IDX) 943 { 944 #endif 905 945 for ( Int i = 0; i < uiPredNum; i++ ) 906 946 { 907 947 intraPredMode += ( intraPredMode >= uiPreds[i] ); 908 948 } 909 } 949 #if LGE_EDGE_INTRA 950 } 951 #endif 952 } 953 954 #if LGE_EDGE_INTRA 955 if( intraPredMode == EDGE_INTRA_IDX ) 956 { 957 xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth ); 958 #if LGE_EDGE_INTRA_DELTA_DC 959 m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) ); 960 if( uiSymbol ) 961 { 962 intraPredMode = EDGE_INTRA_DELTA_IDX; 963 Int iDeltaDC0; 964 Int iDeltaDC1; 965 966 xReadExGolombLevel( (UInt &) iDeltaDC0, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); 967 if( iDeltaDC0 != 0 ) 968 { 969 UInt uiSign; 970 m_pcTDecBinIf->decodeBinEP( uiSign ); 971 if ( uiSign ) 972 { 973 iDeltaDC0 = -iDeltaDC0; 974 } 975 } 976 xReadExGolombLevel( (UInt &) iDeltaDC1, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); 977 if( iDeltaDC1 != 0 ) 978 { 979 UInt uiSign; 980 m_pcTDecBinIf->decodeBinEP( uiSign ); 981 if ( uiSign ) 982 { 983 iDeltaDC1 = -iDeltaDC1; 984 } 985 } 986 987 pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 ); 988 pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 ); 989 } 990 #endif 991 } 992 #endif 993 910 994 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 911 995 } … … 2012 2096 #endif 2013 2097 2014 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 2098 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC) 2015 2099 Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) 2016 2100 { … … 2270 2354 } 2271 2355 #endif 2356 2357 #if LGE_EDGE_INTRA 2358 Void TDecSbac::xParseEdgeIntraInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 2359 { 2360 UInt uiSymbol = 0; 2361 2362 // 1. Top(0) or Left(1) 2363 UChar ucLeft; 2364 m_pcTDecBinIf->decodeBinEP( uiSymbol ); 2365 ucLeft = uiSymbol; 2366 2367 // 2. Start position (lowest bit first) 2368 UChar ucStart = 0; 2369 for( UInt ui = 0; ui < 6 - uiDepth; ui++ ) 2370 { 2371 m_pcTDecBinIf->decodeBinEP( uiSymbol ); 2372 ucStart |= (uiSymbol << ui); 2373 } 2374 2375 // 3. Number of edges 2376 UChar ucMax = 0; 2377 for( UInt ui = 0; ui < 7 - uiDepth; ui++ ) 2378 { 2379 m_pcTDecBinIf->decodeBinEP( uiSymbol ); 2380 ucMax |= (uiSymbol << ui); 2381 } 2382 ucMax++; // +1 2383 2384 // 4. Edges 2385 UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 ); 2386 UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiAbsPartIdx ); 2387 for( Int iPtr = 0; iPtr < ucMax; iPtr++ ) 2388 { 2389 UChar ucEdge = 0; 2390 UInt uiReorderEdge = 0; 2391 // Left-friendly direction 2392 // 0 ( 0deg) => 0 2393 // 1 ( 45deg) => 10 2394 // 2 ( -45deg) => 110 2395 // 3 ( 90deg) => 1110 2396 // 4 ( -90deg) => 11110 2397 // 5 ( 135deg) => 111110 2398 // 6 (-135deg) => 111111 2399 // Right-friendly direction 2400 // 0 ( 0deg) => 0 2401 // 1 ( -45deg) => 10 2402 // 2 ( 45deg) => 110 2403 // 3 ( -90deg) => 1110 2404 // 4 ( 90deg) => 11110 2405 // 5 (-135deg) => 111110 2406 // 6 ( 135deg) => 111111 2407 // refer to a paper "An efficient chain code with Huffman coding" 2408 for( UInt ui = 0; ui < 6; ui++ ) 2409 { 2410 m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) ); 2411 ucEdge <<= 1; 2412 ucEdge |= uiSymbol; 2413 if( uiSymbol == 0 ) 2414 break; 2415 } 2416 2417 switch( ucEdge ) 2418 { 2419 case 0 : // "0" 2420 uiReorderEdge = 0; 2421 break; 2422 case 2 : // "10" 2423 uiReorderEdge = 1; 2424 break; 2425 case 6 : // "110" 2426 uiReorderEdge = 2; 2427 break; 2428 case 14 : // "1110" 2429 uiReorderEdge = 3; 2430 break; 2431 case 30 : // "11110" 2432 uiReorderEdge = 4; 2433 break; 2434 case 62 : // "111110" 2435 uiReorderEdge = 5; 2436 break; 2437 case 63 : // "111111" 2438 uiReorderEdge = 6; 2439 break; 2440 default : 2441 printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge); 2442 assert(false); 2443 break; 2444 } 2445 pucSymbolList[iPtr] = uiReorderEdge; 2446 } 2447 ///////////////////// 2448 // Edge Reconstruction 2449 Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); 2450 pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion ); 2451 xFree( pucSymbolList ); 2452 } 2453 #endif 2454 2272 2455 //! \} -
branches/HTM-3.1-LG/source/Lib/TLibDecoder/TDecSbac.h
r77 r97 145 145 Void xParseContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 146 146 #endif 147 148 #if LGE_EDGE_INTRA 149 Void xParseEdgeIntraInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 150 #endif 147 151 148 152 private: … … 253 257 ContextModel3DBuffer m_cDmmDataSCModel; 254 258 #endif 259 #if LGE_EDGE_INTRA 260 ContextModel3DBuffer m_cEdgeIntraSCModel; 261 #if LGE_EDGE_INTRA_DELTA_DC 262 ContextModel3DBuffer m_cEdgeIntraDeltaDCSCModel; 263 #endif 264 #endif 255 265 }; 256 266 -
branches/HTM-3.1-LG/source/Lib/TLibEncoder/TEncSbac.cpp
r77 r97 106 106 , m_cDmmDataSCModel ( 1, 1, NUM_DMM_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 107 107 #endif 108 #if LGE_EDGE_INTRA 109 , m_cEdgeIntraSCModel ( 1, 1, NUM_EDGE_INTRA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 110 #if LGE_EDGE_INTRA_DELTA_DC 111 , m_cEdgeIntraDeltaDCSCModel ( 1, 1, NUM_EDGE_INTRA_DELTA_DC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 112 #endif 113 #endif 108 114 { 109 115 assert( m_numContextModels <= MAX_NUM_CTX_MOD ); … … 181 187 m_cDmmDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_DATA ); 182 188 #endif 189 #if LGE_EDGE_INTRA 190 m_cEdgeIntraSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA ); 191 #if LGE_EDGE_INTRA_DELTA_DC 192 m_cEdgeIntraDeltaDCSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA_DELTA_DC ); 193 #endif 194 #endif 183 195 184 196 // new structure … … 828 840 DTRACE_CABAC_T( "\n" ) 829 841 } 842 843 #if LGE_EDGE_INTRA 844 Void TEncSbac::xCodeEdgeIntraInfo( TComDataCU* pcCU, UInt uiPartIdx ) 845 { 846 UInt uiDepth = pcCU->getDepth( uiPartIdx ) + (pcCU->getPartitionSize( uiPartIdx ) == SIZE_NxN ? 1 : 0); 847 UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiPartIdx ); 848 UChar* pucSymbolList = pcCU->getEdgeCode( uiPartIdx ); 849 UChar ucEdgeNumber = pcCU->getEdgeNumber( uiPartIdx ); 850 Bool bLeft = pcCU->getEdgeLeftFirst( uiPartIdx ); 851 UChar ucStart = pcCU->getEdgeStartPos( uiPartIdx ); 852 UInt uiSymbol; 853 854 // 1. Top(0) or Left(1) 855 uiSymbol = (bLeft == false) ? 0 : 1; 856 m_pcBinIf->encodeBinEP( uiSymbol ); 857 858 // 2. Start position (lowest bit first) 859 uiSymbol = ucStart; 860 for( UInt ui = 6; ui > uiDepth; ui-- ) // 64(0)->6, 32(1)->5, 16(2)->4, 8(3)->3, 4(4)->2 861 { 862 m_pcBinIf->encodeBinEP( uiSymbol & 0x1 ); 863 uiSymbol >>= 1; 864 } 865 866 // 3. Number of edges 867 uiSymbol = ucEdgeNumber > 0 ? ucEdgeNumber - 1 : 0; 868 for( UInt ui = 7; ui > uiDepth; ui-- ) // 64(0)->7, 32(1)->6, 16(2)->5, 8(3)->4, 4(4)->3 869 { 870 m_pcBinIf->encodeBinEP( uiSymbol & 0x1 ); 871 uiSymbol >>= 1; 872 } 873 874 if(uiSymbol != 0) 875 { 876 printf(" ucEdgeNumber %d at depth %d\n",ucEdgeNumber, uiDepth); 877 assert(false); 878 } 879 880 // 4. Edges 881 for( Int iPtr2 = 0; iPtr2 < ucEdgeNumber; iPtr2++ ) 882 { 883 UInt uiReorderSymbol = pucSymbolList[iPtr2]; 884 885 //printf ("Ptr = %d, Symbol = %d\n", iPtr2, uiSymbol); 886 887 // Left-friendly direction (Top start) 888 // 0 ( 0deg) => 0 889 // 1 ( 45deg) => 10 890 // 2 ( -45deg) => 110 891 // 3 ( 90deg) => 1110 892 // 4 ( -90deg) => 11110 893 // 5 ( 135deg) => 111110 894 // 6 (-135deg) => 111111 895 // Right-friendly direction (Left start) 896 // 0 ( 0deg) => 0 897 // 2 ( -45deg) => 10 898 // 1 ( 45deg) => 110 899 // 4 ( -90deg) => 1110 900 // 3 ( 90deg) => 11110 901 // 6 (-135deg) => 111110 902 // 5 ( 135deg) => 111111 903 904 // refer to a paper "An efficient chain code with Huffman coding" 905 906 for( UInt ui = 0; ui < uiReorderSymbol; ui++ ) 907 { 908 m_pcBinIf->encodeBin( 1, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) ); 909 } 910 911 if( uiReorderSymbol != 6 ) 912 m_pcBinIf->encodeBin( 0, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) ); 913 } 914 } 915 #endif 916 830 917 Void TEncSbac::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) 831 918 { … … 835 922 if( pcCU->getSlice()->getSPS()->getUseDMM() && pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE ) 836 923 { 837 m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE, m_cDmmFlagSCModel.get(0, 0, 0) ); 838 } 924 #if LGE_EDGE_INTRA 925 m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX, m_cDmmFlagSCModel.get(0, 0, 0) ); 926 #else 927 m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE, m_cDmmFlagSCModel.get(0, 0, 0) ); 928 #endif 929 } 930 #if LGE_EDGE_INTRA 931 if( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX ) 932 #else 839 933 if( uiDir >= NUM_INTRA_MODE ) 934 #endif 840 935 { 841 936 assert( pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE ); … … 870 965 } 871 966 else 967 #if LGE_EDGE_INTRA 968 if ( uiDir >= EDGE_INTRA_IDX) 969 { 970 m_pcBinIf->encodeBin( 0, m_cCUIntraPredSCModel.get( 0, 0, 0 ) ); 971 m_pcBinIf->encodeBinsEP( 63, 6 ); 972 xCodeEdgeIntraInfo( pcCU, uiAbsPartIdx ); 973 #if LGE_EDGE_INTRA_DELTA_DC 974 m_pcBinIf->encodeBin( (uiDir == EDGE_INTRA_DELTA_IDX), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) ); 975 if( uiDir == EDGE_INTRA_DELTA_IDX ) 976 { 977 Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx ); 978 Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx ); 979 980 xWriteExGolombLevel( UInt( abs( iDeltaDC0 ) ), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); 981 if ( iDeltaDC0 != 0 ) 982 { 983 UInt uiSign = iDeltaDC0 > 0 ? 0 : 1; 984 m_pcBinIf->encodeBinEP( uiSign ); 985 } 986 xWriteExGolombLevel( UInt( abs( iDeltaDC1 ) ), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) ); 987 if ( iDeltaDC1 != 0 ) 988 { 989 UInt uiSign = iDeltaDC1 > 0 ? 0 : 1; 990 m_pcBinIf->encodeBinEP( uiSign ); 991 } 992 } 993 #endif 994 } 995 else 996 #endif // LGE_EDGE_INTRA 872 997 { 873 998 #endif 874 999 #if !LOGI_INTRA_NAME_3MPM 875 1000 Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); 1001 #endif 1002 #if LGE_EDGE_INTRA 1003 Bool bCodeEdgeIntra = false; 1004 if( pcCU->getSlice()->getSPS()->isDepth() ) 1005 { 1006 UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0); 1007 if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE ) 1008 bCodeEdgeIntra = true; 1009 } 876 1010 #endif 877 1011 … … 932 1066 #if LOGI_INTRA_NAME_3MPM 933 1067 m_pcBinIf->encodeBinsEP( uiDir, 5 ); 1068 #if LGE_EDGE_INTRA 1069 if (bCodeEdgeIntra) 1070 if (uiDir == 31) m_pcBinIf->encodeBinsEP(0,1); 1071 #endif 934 1072 #else 935 1073 if ( uiDir < 31 ) … … 2270 2408 } 2271 2409 2272 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 2410 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC) 2273 2411 Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel ) 2274 2412 { -
branches/HTM-3.1-LG/source/Lib/TLibEncoder/TEncSbac.h
r77 r97 175 175 Void xCodeContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx ); 176 176 #endif 177 #if LGE_EDGE_INTRA 178 Void xCodeEdgeIntraInfo( TComDataCU* pcCU, UInt uiPartIdx ); 179 #endif 177 180 178 181 protected: … … 307 310 ContextModel3DBuffer m_cDmmDataSCModel; 308 311 #endif 312 #if LGE_EDGE_INTRA 313 ContextModel3DBuffer m_cEdgeIntraSCModel; 314 #if LGE_EDGE_INTRA_DELTA_DC 315 ContextModel3DBuffer m_cEdgeIntraDeltaDCSCModel; 316 #endif 317 #endif 309 318 }; 310 319 -
branches/HTM-3.1-LG/source/Lib/TLibEncoder/TEncSearch.cpp
r81 r97 952 952 Void 953 953 TEncSearch::xIntraCodingLumaBlk( TComDataCU* pcCU, 954 UInt uiTrDepth, 955 UInt uiAbsPartIdx, 956 TComYuv* pcOrgYuv, 957 TComYuv* pcPredYuv, 958 TComYuv* pcResiYuv, 959 Dist& ruiDist ) 954 UInt uiTrDepth, 955 UInt uiAbsPartIdx, 956 TComYuv* pcOrgYuv, 957 TComYuv* pcPredYuv, 958 TComYuv* pcResiYuv, 959 Dist& ruiDist 960 #if LG_ZEROINTRADEPTHRESI_M26039 961 ,Bool bZeroResi 962 #endif 963 ) 960 964 { 961 965 UInt uiLumaPredMode = pcCU ->getLumaIntraDir ( uiAbsPartIdx ); … … 988 992 pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); 989 993 pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail ); 994 995 #if LGE_EDGE_INTRA 996 if( uiLumaPredMode >= EDGE_INTRA_IDX ) 997 { 998 #if LGE_EDGE_INTRA_DELTA_DC 999 if( uiLumaPredMode == EDGE_INTRA_DELTA_IDX ) 1000 xAssignEdgeIntraDeltaDCs( pcCU, uiAbsPartIdx, piOrg, uiStride, piPred, uiWidth, uiHeight ); 1001 #endif 1002 1003 predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride 1004 #if LGE_EDGE_INTRA_DELTA_DC 1005 , uiLumaPredMode == EDGE_INTRA_DELTA_IDX 1006 #endif 1007 ); 1008 } 1009 else 1010 #endif 990 1011 991 1012 //===== get prediction signal ===== … … 1020 1041 } 1021 1042 } 1043 #if LG_ZEROINTRADEPTHRESI_M26039 1044 if(bZeroResi) 1045 { 1046 Pel* pResi = piResi; 1047 1048 for( UInt uiY = 0; uiY < uiHeight; uiY++ ) 1049 { 1050 memset( pResi, 0, sizeof( Pel ) * uiWidth ); 1051 pResi += uiStride; 1052 } 1053 } 1054 #endif 1022 1055 1023 1056 //===== transform and quantization ===== … … 1300 1333 Void 1301 1334 TEncSearch::xRecurIntraCodingQT( TComDataCU* pcCU, 1302 1303 1304 1305 1306 1307 1308 1309 1335 UInt uiTrDepth, 1336 UInt uiAbsPartIdx, 1337 Bool bLumaOnly, 1338 TComYuv* pcOrgYuv, 1339 TComYuv* pcPredYuv, 1340 TComYuv* pcResiYuv, 1341 Dist& ruiDistY, 1342 Dist& ruiDistC, 1310 1343 #if HHI_RQT_INTRA_SPEEDUP 1311 Bool bCheckFirst, 1312 #endif 1313 Double& dRDCost ) 1344 Bool bCheckFirst, 1345 #endif 1346 Double& dRDCost 1347 #if LG_ZEROINTRADEPTHRESI_M26039 1348 ,Bool bZeroResi 1349 #endif 1350 ) 1314 1351 { 1315 1352 UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; … … 1328 1365 { 1329 1366 bCheckSplit = false; 1367 } 1368 #endif 1369 #if LGE_EDGE_INTRA 1370 if( pcCU->getLumaIntraDir( uiAbsPartIdx ) >= EDGE_INTRA_IDX ) 1371 { 1372 bCheckSplit = false; 1330 1373 } 1331 1374 #endif … … 1346 1389 //----- code luma block with given intra prediction mode and store Cbf----- 1347 1390 dSingleCost = 0.0; 1348 xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY ); 1391 #if LG_ZEROINTRADEPTHRESI_M26039 1392 xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY, bZeroResi ); 1393 #else 1394 xIntraCodingLumaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcOrgYuv, pcPredYuv, pcResiYuv, uiSingleDistY ); 1395 #endif 1349 1396 if( bCheckSplit ) 1350 1397 { … … 1807 1854 UInt uiRdModeList[FAST_UDI_MAX_RDMODE_NUM]; 1808 1855 Int numModesForFullRD = g_aucIntraModeNumFast[ uiWidthBit ]; 1856 1857 #if LGE_EDGE_INTRA 1858 Bool bTestEdgeIntra = false; 1859 if ( m_pcEncCfg->isDepthCoder() && uiWidth >= LGE_EDGE_INTRA_MIN_SIZE && uiWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiWidth == uiHeight ) 1860 { 1861 bTestEdgeIntra = true; 1862 1863 Bool bEdgeExist; 1864 1865 bEdgeExist = xEdgePartition( pcCU, uiPartOffset, pcCU->getPartitionSize(0) == SIZE_NxN ); 1866 1867 if( !bEdgeExist ) 1868 bTestEdgeIntra = false; 1869 } 1870 #endif 1809 1871 1810 1872 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX … … 1866 1928 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 1867 1929 if( bTestDmm ) bTestDmm = uiSad ? true : false; 1930 #endif 1931 #if LGE_EDGE_INTRA 1932 if ( bTestEdgeIntra ) bTestEdgeIntra = uiSad ? true : false; 1868 1933 #endif 1869 1934 } … … 1974 2039 } 1975 2040 #endif 2041 #if LGE_EDGE_INTRA 2042 if( bTestEdgeIntra ) 2043 { 2044 uiRdModeList[ numModesForFullRD++ ] = EDGE_INTRA_IDX; 2045 #if LGE_EDGE_INTRA_DELTA_DC 2046 uiRdModeList[ numModesForFullRD++ ] = EDGE_INTRA_DELTA_IDX; 2047 #endif 2048 } 2049 #endif 1976 2050 1977 2051 //===== check modes (using r-d costs) ===== … … 1987 2061 for( UInt uiMode = 0; uiMode < numModesForFullRD; uiMode++ ) 1988 2062 { 2063 #if LG_ZEROINTRADEPTHRESI_M26039 2064 Bool bAllowZeroResi = pcCU->getSlice()->getIsDepth() && (pcCU->getSlice()->getPOC()%pcCU->getPic()->getIntraPeriod());// && (uiMode < NUM_INTRA_MODE); 2065 for(UInt uiCnt = 0; uiCnt < (bAllowZeroResi ? 2 : 1); uiCnt++) 2066 { 2067 Bool bZeroResi = uiCnt ? true : false; 2068 #endif 1989 2069 // set luma prediction mode 1990 2070 UInt uiOrgMode = uiRdModeList[uiMode]; 1991 2071 1992 2072 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX 1993 if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight ) ) 1994 { 1995 continue; 1996 } 2073 if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight ) 2074 #if LGE_EDGE_INTRA 2075 && uiOrgMode < EDGE_INTRA_IDX 2076 #endif 2077 ) 2078 { 2079 continue; 2080 } 1997 2081 #endif 1998 2082 … … 2020 2104 2021 2105 #if HHI_RQT_INTRA_SPEEDUP 2022 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost ); 2023 #else 2024 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost ); 2106 #if LG_ZEROINTRADEPTHRESI_M26039 2107 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost, bZeroResi ); 2108 #else 2109 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost ); 2110 #endif 2111 #else 2112 xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost ); 2025 2113 #endif 2026 2114 … … 2053 2141 } 2054 2142 #endif 2055 } // Mode loop 2143 #if LG_ZEROINTRADEPTHRESI_M26039 2144 } 2145 #endif 2146 } // Mode loop 2056 2147 2057 2148 #if HHI_RQT_INTRA_SPEEDUP … … 6207 6298 } 6208 6299 #endif 6300 6301 #if LGE_EDGE_INTRA 6302 Bool TEncSearch::xCheckTerminatedEdge( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight ) 6303 { 6304 if( (iY % 2) == 0 ) // vertical edge 6305 { 6306 Bool bTopConnected = false; 6307 Bool bBottomConnected = false; 6308 6309 if( iY != 0 ) 6310 { 6311 if( pbEdge[ iX + (iY - 2) * 2 * iWidth ] ) 6312 bTopConnected = true; 6313 if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] ) 6314 bTopConnected = true; 6315 if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] ) 6316 bTopConnected = true; 6317 } 6318 else 6319 { 6320 bTopConnected = true; 6321 } 6322 6323 6324 if( iY != 2 * iHeight - 2 ) 6325 { 6326 if( pbEdge[ iX + (iY + 2) * 2 * iWidth ] ) 6327 bBottomConnected = true; 6328 if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] ) 6329 bBottomConnected = true; 6330 if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] ) 6331 bBottomConnected = true; 6332 } 6333 else 6334 { 6335 bBottomConnected = true; 6336 } 6337 6338 6339 if( bTopConnected && bBottomConnected ) 6340 { 6341 return true; 6342 } 6343 else 6344 { 6345 return false; 6346 } 6347 } 6348 else 6349 { 6350 Bool bLeftConnected = false; 6351 Bool bRightConnected = false; 6352 6353 if( iX != 0 ) 6354 { 6355 if( pbEdge[ (iX - 2) + iY * 2 * iWidth ] ) 6356 bLeftConnected = true; 6357 if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] ) 6358 bLeftConnected = true; 6359 if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] ) 6360 bLeftConnected = true; 6361 } 6362 else 6363 { 6364 bLeftConnected = true; 6365 } 6366 6367 if( iX != 2 * iWidth - 2 ) 6368 { 6369 if( pbEdge[ (iX + 2) + iY * 2 * iWidth ] ) 6370 bRightConnected = true; 6371 if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] ) 6372 bRightConnected = true; 6373 if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] ) 6374 bRightConnected = true; 6375 } 6376 else 6377 { 6378 bRightConnected = true; 6379 } 6380 6381 6382 if( bLeftConnected && bRightConnected ) 6383 { 6384 return true; 6385 } 6386 else 6387 { 6388 return false; 6389 } 6390 } 6391 } 6392 6393 #if LGE_EDGE_INTRA_PIXEL_DIFFERENCE 6394 Bool TEncSearch::xEdgePartition( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 ) 6395 { 6396 Pel* pcOrgY = pcCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr()); 6397 UInt uiStride = pcCU->getPic()->getPicYuvOrg()->getStride(); 6398 Int iWidth = pcCU->getWidth(uiPartIdx) >> (bPU4x4 ? 1 : 0); 6399 Int iHeight = pcCU->getHeight(uiPartIdx) >> (bPU4x4 ? 1 : 0); 6400 Bool* pbEdge = (Bool*) xMalloc( Bool, iWidth * iHeight * 4 ); 6401 6402 { 6403 UInt uiOffsetX = 0; 6404 UInt uiOffsetY = 0; 6405 UInt uiAbsPartIdx = pcCU->getZorderIdxInCU() + uiPartIdx; 6406 6407 uiOffsetX = (uiAbsPartIdx & 0x1) | 6408 ((uiAbsPartIdx & 0x4) >> 1) | 6409 ((uiAbsPartIdx & 0x10) >> 2) | 6410 ((uiAbsPartIdx & 0x40) >> 3); 6411 uiOffsetY = ((uiAbsPartIdx & 0x2) >> 1) | 6412 ((uiAbsPartIdx & 0x8) >> 2) | 6413 ((uiAbsPartIdx & 0x20) >> 3) | 6414 ((uiAbsPartIdx & 0x80) >> 4); 6415 uiOffsetX *= 4; 6416 uiOffsetY *= 4; 6417 pcOrgY += (uiOffsetX + uiOffsetY * uiStride); 6418 //printf("OffsetX %2d OffsetY %2d\n",uiOffsetX, uiOffsetY); 6419 } 6420 6421 Short* psDiffX = new Short[ iWidth * iHeight ]; 6422 Short* psDiffY = new Short[ iWidth * iHeight ]; 6423 Bool* pbEdgeX = new Bool [ iWidth * iHeight ]; 6424 Bool* pbEdgeY = new Bool [ iWidth * iHeight ]; 6425 6426 // Find Horizontal Gradient & Edge Detection ((x+1, y) - (x,y)) 6427 for( Int y=0; y<iHeight; y++ ) 6428 { 6429 Short* psDiffXPtr = &psDiffX[ y * iHeight ]; 6430 Bool* pbEdgeXPtr = &pbEdgeX[ y * iHeight ]; 6431 for(Int x=0; x<iWidth-1; x++ ) 6432 { 6433 *psDiffXPtr = pcOrgY[ x+1 + y*uiStride ] - pcOrgY[ x + y*uiStride ]; 6434 if(*psDiffXPtr >= LGE_EDGE_INTRA_THRESHOLD || *psDiffXPtr <= (-1)*LGE_EDGE_INTRA_THRESHOLD) 6435 { 6436 *pbEdgeXPtr = true; 6437 } 6438 else 6439 { 6440 *pbEdgeXPtr = false; 6441 } 6442 6443 psDiffXPtr++; 6444 pbEdgeXPtr++; 6445 } 6446 } 6447 6448 // Find Vertical Gradient & Edge Detection((x,y+1) - (x,y)) 6449 for( Int y=0; y<iHeight-1; y++ ) 6450 { 6451 Short* psDiffYPtr = &psDiffY[ y * iHeight ]; 6452 Bool* pbEdgeYPtr = &pbEdgeY[ y * iHeight ]; 6453 for(Int x=0; x<iWidth; x++ ) 6454 { 6455 *psDiffYPtr = pcOrgY[ x + (y+1)*uiStride ] - pcOrgY [ x + y*uiStride ]; 6456 if(*psDiffYPtr >= LGE_EDGE_INTRA_THRESHOLD || *psDiffYPtr <= (-1)*LGE_EDGE_INTRA_THRESHOLD) 6457 { 6458 *pbEdgeYPtr = true; 6459 } 6460 else 6461 { 6462 *pbEdgeYPtr = false; 6463 } 6464 6465 psDiffYPtr++; 6466 pbEdgeYPtr++; 6467 } 6468 } 6469 6470 // Eliminate local maximum 6471 for( Int y=0; y<iHeight; y++ ) 6472 { 6473 Short* psDiffXPtr = &psDiffX[ y * iHeight ]; 6474 Bool* pbEdgeXPtr = &pbEdgeX[ y * iHeight ]; 6475 for( Int x=0; x<iWidth-1; x++ ) 6476 { 6477 UShort usAbs0=0, usAbs1=0, usAbs2=0; // 0 : left, 1 : current, 2 : right 6478 Bool bSign0=false, bSign1=false, bSign2=false; 6479 if( x > 0 && *(pbEdgeXPtr-1) == true ) 6480 { 6481 if( *(psDiffXPtr-1) >= 0) 6482 { 6483 usAbs0 = *(psDiffXPtr-1); 6484 bSign0 = true; 6485 } 6486 else 6487 { 6488 usAbs0 = (-1) * *(psDiffXPtr-1); 6489 bSign0 = false; 6490 } 6491 } 6492 if( *pbEdgeXPtr == true ) 6493 { 6494 if( *(psDiffXPtr) >= 0) 6495 { 6496 usAbs1 = *(psDiffXPtr); 6497 bSign1 = true; 6498 } 6499 else 6500 { 6501 usAbs1 = (-1) * *(psDiffXPtr); 6502 bSign1 = false; 6503 } 6504 } 6505 if( x < iWidth-2 && *(pbEdgeXPtr+1) == true ) 6506 { 6507 if( *(psDiffXPtr+1) >= 0) 6508 { 6509 usAbs2 = *(psDiffXPtr+1); 6510 bSign2 = true; 6511 } 6512 else 6513 { 6514 usAbs2 = (-1) * *(psDiffXPtr+1); 6515 bSign2 = false; 6516 } 6517 } 6518 6519 if( x == 0 ) 6520 { 6521 if( usAbs1 < usAbs2 ) 6522 { 6523 *pbEdgeXPtr = false; 6524 } 6525 } 6526 else if( x == iWidth-2 ) 6527 { 6528 if( usAbs1 <= usAbs0 ) 6529 *pbEdgeXPtr = false; 6530 } 6531 else 6532 { 6533 if( usAbs2 > usAbs0 ) 6534 { 6535 if( usAbs1 < usAbs2 ) 6536 *pbEdgeXPtr = false; 6537 } 6538 else 6539 { 6540 if( usAbs1 <= usAbs0 ) 6541 *pbEdgeXPtr = false; 6542 } 6543 } 6544 6545 psDiffXPtr++; 6546 pbEdgeXPtr++; 6547 } 6548 } 6549 6550 for( Int y=0; y<iHeight-1; y++ ) 6551 { 6552 Short* psDiffYPtr = &psDiffY[ y * iWidth ]; 6553 Bool* pbEdgeYPtr = &pbEdgeY[ y * iWidth ]; 6554 for( Int x=0; x<iWidth; x++ ) 6555 { 6556 UShort usAbs0=0, usAbs1=0, usAbs2=0; // 0 : upper, 1 : current, 2 : bottom 6557 Bool bSign0=false, bSign1=false, bSign2=false; 6558 if( y > 0 && *(pbEdgeYPtr-iWidth) == true ) 6559 { 6560 if( *(psDiffYPtr-iWidth) >= 0) 6561 { 6562 usAbs0 = *(psDiffYPtr-iWidth); 6563 bSign0 = true; 6564 } 6565 else 6566 { 6567 usAbs0 = (-1) * *(psDiffYPtr-iWidth); 6568 bSign0 = false; 6569 } 6570 } 6571 if( *pbEdgeYPtr == true ) 6572 { 6573 if( *(psDiffYPtr) >= 0) 6574 { 6575 usAbs1 = *(psDiffYPtr); 6576 bSign1 = true; 6577 } 6578 else 6579 { 6580 usAbs1 = (-1) * *(psDiffYPtr); 6581 bSign1 = false; 6582 } 6583 } 6584 if( y < iHeight-2 && *(pbEdgeYPtr+iWidth) == true ) 6585 { 6586 if( *(psDiffYPtr+iWidth) >= 0) 6587 { 6588 usAbs2 = *(psDiffYPtr+iWidth); 6589 bSign2 = true; 6590 } 6591 else 6592 { 6593 usAbs2 = (-1) * *(psDiffYPtr+iWidth); 6594 bSign2 = false; 6595 } 6596 } 6597 6598 if( y == 0 ) 6599 { 6600 if( usAbs1 < usAbs2 ) 6601 *pbEdgeYPtr = false; 6602 } 6603 else if( y == iHeight-2 ) 6604 { 6605 if( usAbs1 <= usAbs0 ) 6606 *pbEdgeYPtr = false; 6607 } 6608 else 6609 { 6610 if( usAbs2 > usAbs0 ) 6611 { 6612 if( usAbs1 < usAbs2 ) 6613 *pbEdgeYPtr = false; 6614 } 6615 else 6616 { 6617 if( usAbs1 <= usAbs0 ) 6618 *pbEdgeYPtr = false; 6619 } 6620 } 6621 6622 psDiffYPtr++; 6623 pbEdgeYPtr++; 6624 } 6625 } 6626 6627 // Edge Merging 6628 for( Int i=0; i< 4 * iWidth * iHeight; i++ ) 6629 pbEdge[ i ] = false; 6630 /// Even Line (0,2,4,6,...) => Vertical Edge 6631 for( Int i=0; i<iHeight; i++) 6632 { 6633 for( Int j=0; j<iWidth-1; j++) 6634 { 6635 pbEdge[ (2 * j + 1) + (2 * i) * 2 * iWidth ] = pbEdgeX[ j + i * iHeight ]; 6636 } 6637 } 6638 /// Odd Line (1,3,5,7,...) => Horizontal Edge 6639 for( Int i=0; i<iHeight-1; i++) 6640 { 6641 for( Int j=0; j<iWidth; j++) 6642 { 6643 pbEdge[ (2 * j) + (2 * i + 1) * 2 * iWidth ] = pbEdgeY[ j + i * iHeight ]; 6644 } 6645 } 6646 6647 // Intersection Filling 6648 /// Vertical Edge between Horizontal Edges 6649 for( Int i = 1; i < 2 * iHeight - 3; i += 2) 6650 { 6651 for( Int j = 0; j < 2 * iWidth - 1; j += 2) 6652 { 6653 if( pbEdge[ j + i * 2 * iWidth ] ) 6654 { 6655 if( j != 0 && pbEdge[ (j - 2) + ((i + 2) * 2 * iWidth) ] ) 6656 { 6657 if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j - 1) + ((i + 3) * 2 * iWidth) ] ) 6658 pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] = true; 6659 } 6660 if( j != 2 * iWidth - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] ) 6661 { 6662 if( !pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 1) + ((i + 3) * 2 * iWidth) ] ) 6663 pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true; 6664 } 6665 } 6666 } 6667 } 6668 /// Horizontal Edge between Vertical Edges 6669 for( Int j = 1; j < 2 * iWidth - 3; j += 2) 6670 { 6671 for( Int i = 0; i < 2 * iHeight - 1; i += 2) 6672 { 6673 if( pbEdge[ j + i * 2 * iWidth ] ) 6674 { 6675 if( i != 0 && pbEdge[ (j + 2) + ((i - 2) * 2 * iWidth) ] ) 6676 { 6677 if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i - 1) * 2 * iWidth) ] ) 6678 pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] = true; 6679 } 6680 if( i != 2 * iHeight - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] ) 6681 { 6682 if( !pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i + 1) * 2 * iWidth) ] ) 6683 pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true; 6684 } 6685 } 6686 } 6687 } 6688 6689 // Static Pruning Unnecessary Edges 6690 /// Step1. Stack push the unconnected edges 6691 UShort* pusUnconnectedEdgeStack = new UShort[ 4 * iWidth * iHeight ]; // approximate size calculation 6692 Int iUnconnectedEdgeStackPtr = 0; 6693 //// Vertical Edges 6694 for( Int i = 0; i < 2 * iHeight - 1; i += 2 ) 6695 { 6696 for( Int j = 1; j < 2 * iWidth - 2; j += 2 ) 6697 { 6698 if( pbEdge[ j + i * 2 * iWidth ] ) 6699 { 6700 if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) ) 6701 { 6702 pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j); 6703 iUnconnectedEdgeStackPtr++; 6704 } 6705 } 6706 } 6707 } 6708 6709 //// Horizontal Edges 6710 for( Int i = 1; i < 2 * iHeight - 2; i += 2 ) 6711 { 6712 for( Int j = 0; j < 2 * iWidth - 1; j += 2 ) 6713 { 6714 if( pbEdge[ j + i * 2 * iWidth ] ) 6715 { 6716 if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) ) 6717 { 6718 pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j); 6719 iUnconnectedEdgeStackPtr++; 6720 } 6721 } 6722 } 6723 } 6724 6725 /// Step2. Remove the edges from the stack and push the new unconnected edges 6726 //// (This step may contain duplicated edges already in the stack) 6727 //// (But it doesn't cause any functional problems) 6728 while( iUnconnectedEdgeStackPtr != 0 ) 6729 { 6730 iUnconnectedEdgeStackPtr--; 6731 Int iX = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] & 0xff; 6732 Int iY = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] >> 8; 6733 6734 pbEdge[ iX + iY * 2 * iWidth ] = false; 6735 6736 if( iY % 2 == 1 && iX > 0 && pbEdge[ iX - 2 + iY * 2 * iWidth ] && 6737 !xCheckTerminatedEdge( pbEdge, iX - 2, iY, iWidth, iHeight ) ) // left 6738 { 6739 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX - 2); 6740 iUnconnectedEdgeStackPtr++; 6741 } 6742 if( iY % 2 == 1 && iX < 2 * iWidth - 2 && pbEdge[ iX + 2 + iY * 2 * iWidth ] && 6743 !xCheckTerminatedEdge( pbEdge, iX + 2, iY, iWidth, iHeight ) ) // right 6744 { 6745 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX + 2); 6746 iUnconnectedEdgeStackPtr++; 6747 } 6748 if( iY % 2 == 0 && iY > 0 && pbEdge[ iX + (iY - 2) * 2 * iWidth ] && 6749 !xCheckTerminatedEdge( pbEdge, iX, iY - 2, iWidth, iHeight ) ) // top 6750 { 6751 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 2) << 8) | (iX + 0); 6752 iUnconnectedEdgeStackPtr++; 6753 } 6754 if( iY % 2 == 0 && iY < 2 * iHeight - 2 && pbEdge[ iX + (iY + 2) * 2 * iWidth ] && 6755 !xCheckTerminatedEdge( pbEdge, iX, iY + 2, iWidth, iHeight ) ) // bottom 6756 { 6757 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 2) << 8) | (iX + 0); 6758 iUnconnectedEdgeStackPtr++; 6759 } 6760 if( iX > 0 && iY > 0 && pbEdge[ iX - 1 + (iY - 1) * 2 * iWidth ] && 6761 !xCheckTerminatedEdge( pbEdge, iX - 1, iY - 1, iWidth, iHeight ) ) // left-top 6762 { 6763 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX - 1); 6764 iUnconnectedEdgeStackPtr++; 6765 } 6766 if( iX < 2 * iWidth - 1 && iY > 0 && pbEdge[ iX + 1 + (iY - 1) * 2 * iWidth ] && 6767 !xCheckTerminatedEdge( pbEdge, iX + 1, iY - 1, iWidth, iHeight ) ) // right-top 6768 { 6769 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX + 1); 6770 iUnconnectedEdgeStackPtr++; 6771 } 6772 if( iX > 0 && iY < 2 * iHeight - 1 && pbEdge[ iX - 1 + (iY + 1) * 2 * iWidth ] && 6773 !xCheckTerminatedEdge( pbEdge, iX - 1, iY + 1, iWidth, iHeight ) ) // left-bottom 6774 { 6775 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX - 1); 6776 iUnconnectedEdgeStackPtr++; 6777 } 6778 if( iX < 2 * iWidth - 1 && iY < 2 * iHeight - 1 && pbEdge[ iX + 1 + (iY + 1) * 2 * iWidth ] && 6779 !xCheckTerminatedEdge( pbEdge, iX + 1, iY + 1, iWidth, iHeight ) ) // right-bottom 6780 { 6781 pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX + 1); 6782 iUnconnectedEdgeStackPtr++; 6783 } 6784 } 6785 6786 #if 0 6787 // Loop Edge Pruning (permit only single chain) 6788 /// Step 1. Stack push the boundary edges 6789 UShort* pusBoundaryStack = new UShort[ iWidth + iHeight ]; 6790 Int iBoundaryStackPtr = 0; 6791 for( Int i = iHeight - 1; i >= 0; i-- ) 6792 { 6793 if( pbCUEdge[ i * iWidth ] ) 6794 { 6795 pusBoundaryStack[iBoundaryStackPtr] = (i << 8); 6796 iBoundaryStackPtr++; 6797 } 6798 } 6799 for( Int i = iWidth - 1; i >= 0; i-- ) 6800 { 6801 if( pbCUEdge[ i ] ) 6802 { 6803 pusBoundaryStack[iBoundaryStackPtr] = i; 6804 iBoundaryStackPtr++; 6805 } 6806 } 6807 6808 /// Step 2. Traverse edges 6809 Bool bFound = false; 6810 //Bool* pbVisit = new Bool[ iWidth * iHeight ]; 6811 6812 for( Int i = iBoundaryStackPtr - 1; i >= 0 && !bFound; i-- ) 6813 { 6814 //Int iX, iY; 6815 Int iStartX, iStartY; 6816 Bool* pbStacked = new Bool[ iWidth * iHeight ]; 6817 UShort* pusStack = new UShort[ iWidth * iHeight ]; 6818 Int iStackPtr = 0; 6819 6820 for( Int ii = 0; ii < iWidth * iHeight; ii++ ) 6821 pbVisit[ii] = false; 6822 for( Int ii = 0; ii < iWidth * iHeight; ii++ ) 6823 pbStacked[ii] = false; 6824 6825 iStartX = iX = *(pusBoundaryStack + i) & 0xff; 6826 iStartY = iY = *(pusBoundaryStack + i) >> 8; 6827 pbStacked[ iX + iY * iWidth ] = true; 6828 pusStack[iStackPtr++] = (iY << 8) | (iX); 6829 6830 while(!bFound) 6831 { 6832 //printf("(%d,%d) StackPtr %d\n",iX,iY,iStackPtr); 6833 // right 6834 if( iX < iWidth - 1 && !pbStacked[ (iX + 1) + iY * iWidth ] && pbCUEdge[ (iX + 1) + iY * iWidth ] ) 6835 { 6836 iX = iX + 1; 6837 pbStacked[ iX + iY * iWidth ] = true; 6838 pusStack[iStackPtr] = (iY << 8) | (iX); 6839 iStackPtr++; 6840 } 6841 // left 6842 else if( iX > 0 && !pbStacked[ (iX - 1) + iY * iWidth ] && pbCUEdge[ (iX - 1) + iY * iWidth ] ) 6843 { 6844 iX = iX - 1; 6845 pbStacked[ iX + iY * iWidth ] = true; 6846 pusStack[iStackPtr] = (iY << 8) | (iX); 6847 iStackPtr++; 6848 } 6849 // bottom 6850 else if( iY < iHeight - 1 && !pbStacked[ iX + (iY + 1) * iWidth ] && pbCUEdge[ iX + (iY + 1) * iWidth ] ) 6851 { 6852 iY = iY + 1; 6853 pbStacked[ iX + iY * iWidth ] = true; 6854 pusStack[iStackPtr] = (iY << 8) | (iX); 6855 iStackPtr++; 6856 } 6857 // top 6858 else if( iY > 0 && !pbStacked[ iX + (iY - 1) * iWidth ] && pbCUEdge[ iX + (iY - 1) * iWidth ] ) 6859 { 6860 iY = iY - 1; 6861 pbStacked[ iX + iY * iWidth ] = true; 6862 pusStack[iStackPtr] = (iY << 8) | (iX); 6863 iStackPtr++; 6864 } 6865 // left-top 6866 else if( iX > 0 && iY > 0 && !pbStacked[ (iX - 1) + (iY - 1) * iWidth ] && pbCUEdge[ (iX - 1) + (iY - 1) * iWidth]) 6867 { 6868 iX = iX - 1; 6869 iY = iY - 1; 6870 pbStacked[ iX + iY * iWidth ] = true; 6871 pusStack[iStackPtr] = (iY << 8) | (iX); 6872 iStackPtr++; 6873 } 6874 // right-top 6875 else if( iX < iWidth - 1 && iY > 0 && !pbStacked[ (iX + 1) + (iY - 1) * iWidth ] && pbCUEdge[ (iX + 1) + (iY - 1) * iWidth]) 6876 { 6877 iX = iX + 1; 6878 iY = iY - 1; 6879 pbStacked[ iX + iY * iWidth ] = true; 6880 pusStack[iStackPtr] = (iY << 8) | (iX); 6881 iStackPtr++; 6882 } 6883 // left-bottom 6884 else if( iX > 0 && iY < iHeight - 1 && !pbStacked[ (iX - 1) + (iY + 1) * iWidth ] && pbCUEdge[ (iX - 1) + (iY + 1) * iWidth]) 6885 { 6886 iX = iX - 1; 6887 iY = iY + 1; 6888 pbStacked[ iX + iY * iWidth ] = true; 6889 pusStack[iStackPtr] = (iY << 8) | (iX); 6890 iStackPtr++; 6891 } 6892 // right-bottom 6893 else if( iX < iWidth - 1 && iY < iHeight - 1 && !pbStacked[ (iX + 1) + (iY + 1) * iWidth ] && pbCUEdge[ (iX + 1) + (iY + 1) * iWidth]) 6894 { 6895 iX = iX + 1; 6896 iY = iY + 1; 6897 pbStacked[ iX + iY * iWidth ] = true; 6898 pusStack[iStackPtr] = (iY << 8) | (iX); 6899 iStackPtr++; 6900 } 6901 else 6902 { 6903 if(iX == 0 || iY == 0 || iX == iWidth - 1 || iY == iHeight - 1 ) // boundary! (finished) 6904 { 6905 if( iX == iStartX && iY == iStartY ) 6906 { 6907 //printf("return back to starting edge\n"); 6908 break; // not found! 6909 } 6910 for( Int ii = 0; ii < iStackPtr; ii++ ) 6911 { 6912 Int iVisitX = pusStack[ii] & 0xff; 6913 Int iVisitY = pusStack[ii] >> 8; 6914 pbVisit[ iVisitX + iVisitY * iWidth ] = true; 6915 } 6916 bFound = true; 6917 //printf("\nEdge Found!!\n"); 6918 } 6919 else 6920 { 6921 pbCUEdge[ iX + iY * iWidth ] = false; // prune! 6922 iStackPtr--; 6923 iX = pusStack[iStackPtr-1] & 0xff; 6924 iY = pusStack[iStackPtr-1] >> 8; 6925 //printf("perform pruning!\n"); 6926 } 6927 } 6928 } 6929 delete pbStacked; 6930 delete pusStack; 6931 } // result : pbVisit[] 6932 6933 // 3. Update Edge variable 6934 for( Int i = 0; i < iWidth * iHeight; i++ ) 6935 { 6936 pbCUEdge[ i ] = pbVisit[ i ]; 6937 } 6938 #endif 6939 6940 // Region Generation ( edge -> region ) 6941 Bool* pbRegion = pcCU->getEdgePartition( uiPartIdx ); 6942 Bool* pbVisit = new Bool[ iWidth * iHeight ]; 6943 6944 for( UInt ui = 0; ui < iWidth * iHeight; ui++ ) 6945 { 6946 pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next) 6947 pbVisit [ ui ] = false; 6948 } 6949 6950 Int* piStack = new Int[ iWidth * iHeight ]; 6951 6952 Int iPtr = 0; 6953 6954 piStack[iPtr++] = (0 << 8) | (0); 6955 pbRegion[ 0 ] = false; 6956 6957 while(iPtr > 0) 6958 { 6959 Int iTmp = piStack[--iPtr]; 6960 Int iX1, iY1; 6961 iX1 = iTmp & 0xff; 6962 iY1 = (iTmp >> 8) & 0xff; 6963 6964 pbVisit[ iX1 + iY1 * iWidth ] = true; 6965 6966 assert( iX1 >= 0 && iX1 < iWidth ); 6967 assert( iY1 >= 0 && iY1 < iHeight ); 6968 6969 if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] ) 6970 { 6971 piStack[iPtr++] = (iY1 << 8) | (iX1 - 1); 6972 pbRegion[ iX1 - 1 + iY1 * iWidth ] = false; 6973 } 6974 if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] ) 6975 { 6976 piStack[iPtr++] = (iY1 << 8) | (iX1 + 1); 6977 pbRegion[ iX1 + 1 + iY1 * iWidth ] = false; 6978 } 6979 if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] ) 6980 { 6981 piStack[iPtr++] = ((iY1 - 1) << 8) | iX1; 6982 pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false; 6983 } 6984 if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] ) 6985 { 6986 piStack[iPtr++] = ((iY1 + 1) << 8) | iX1; 6987 pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false; 6988 } 6989 } 6990 6991 /////////// 6992 iPtr = 0; 6993 for( Int i = 0; i < iWidth * iHeight; i++ ) 6994 pbVisit[ i ] = false; 6995 piStack[ iPtr++ ] = (0 << 8) | (0); // initial seed 6996 while( iPtr > 0 && iPtr < iWidth * iHeight ) 6997 { 6998 Int iX; 6999 Int iY; 7000 iPtr--; 7001 iX = piStack[ iPtr ] & 0xff; 7002 iY = piStack[ iPtr ] >> 8; 7003 pbVisit[ iY * iWidth + iX ] = true; 7004 7005 if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] ) 7006 { 7007 piStack[ iPtr++ ] = ((iY - 1) << 8) | iX; 7008 } 7009 if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] ) 7010 { 7011 piStack[ iPtr++ ] = ((iY + 1) << 8) | iX; 7012 } 7013 if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] ) 7014 { 7015 piStack[ iPtr++ ] = (iY << 8) | (iX - 1); 7016 } 7017 if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] ) 7018 { 7019 piStack[ iPtr++ ] = (iY << 8) | (iX + 1); 7020 } 7021 } 7022 assert( iPtr == 0 || iPtr == iWidth * iHeight ); 7023 7024 Bool bBipartition; 7025 if( iPtr == iWidth * iHeight ) 7026 { 7027 bBipartition = false; // single partition 7028 } 7029 else 7030 { 7031 for( Int i = 0; i < iWidth * iHeight; i++ ) 7032 { 7033 if( !pbVisit[ i ] ) 7034 { 7035 piStack[ iPtr++ ] = (( i / iWidth ) << 8) | ( i % iWidth ); 7036 pbVisit[ i ] = true; 7037 break; 7038 } 7039 } 7040 while( iPtr > 0 ) 7041 { 7042 Int iX; 7043 Int iY; 7044 iPtr--; 7045 iX = piStack[ iPtr ] & 0xff; 7046 iY = piStack[ iPtr ] >> 8; 7047 pbVisit[ iY * iWidth + iX ] = true; 7048 7049 if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] ) 7050 { 7051 piStack[ iPtr++ ] = ((iY - 1) << 8) | iX; 7052 } 7053 if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] ) 7054 { 7055 piStack[ iPtr++ ] = ((iY + 1) << 8) | iX; 7056 } 7057 if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] ) 7058 { 7059 piStack[ iPtr++ ] = (iY << 8) | (iX - 1); 7060 } 7061 if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] ) 7062 { 7063 piStack[ iPtr++ ] = (iY << 8) | (iX + 1); 7064 } 7065 } 7066 bBipartition = true; 7067 for( Int i = 0; i < iWidth * iHeight; i++ ) 7068 { 7069 if( !pbVisit[ i ] ) 7070 { 7071 bBipartition = false; 7072 break; 7073 } 7074 } 7075 } 7076 7077 xFree( pbEdge ); 7078 delete[] pbEdgeX; pbEdgeX = NULL; 7079 delete[] pbEdgeY; pbEdgeY = NULL; 7080 delete[] psDiffX; psDiffX = NULL; 7081 delete[] psDiffY; psDiffY = NULL; 7082 delete[] pusUnconnectedEdgeStack; pusUnconnectedEdgeStack = NULL; 7083 delete[] pbVisit; pbVisit = NULL; 7084 delete[] piStack; piStack = NULL; 7085 7086 Bool bCheckPossibleChain; 7087 7088 if( bBipartition ) 7089 bCheckPossibleChain = xConstructChainCode( pcCU, uiPartIdx, bPU4x4 ); 7090 else 7091 bCheckPossibleChain = false; 7092 7093 return bCheckPossibleChain; 7094 } 7095 7096 #endif 7097 7098 Bool TEncSearch::xConstructChainCode( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 ) 7099 { 7100 UInt uiWidth = pcCU->getWidth( uiPartIdx ) >> (bPU4x4 ? 1 : 0); 7101 UInt uiHeight = pcCU->getHeight( uiPartIdx ) >> (bPU4x4 ? 1 : 0); 7102 Bool* pbEdge = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 ); 7103 Bool* pbVisit = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 ); 7104 UInt uiMaxEdge = uiWidth * (LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 / 4); 7105 Bool* pbRegion = pcCU->getEdgePartition( uiPartIdx ); 7106 UChar* piEdgeCode = pcCU->getEdgeCode( uiPartIdx ); 7107 Bool bStartLeft = false; 7108 Bool bPossible = false; 7109 Bool bFinish = false; 7110 Int iStartPosition = -1; 7111 Int iPtr = 0; 7112 Int iDir = -1, iNextDir = -1; 7113 Int iArrow = -1, iNextArrow = -1; 7114 Int iX = -1, iY = -1; 7115 Int iDiffX = 0, iDiffY = 0; 7116 UChar iCode = 255; 7117 UInt uiWidth2 = uiWidth * 2; 7118 7119 for( Int i = 0; i < uiWidth * uiHeight * 4; i++ ) 7120 pbEdge[ i ] = false; 7121 7122 for( Int i = 0; i < uiHeight; i++ ) 7123 { 7124 for( Int j = 0; j < uiWidth - 1; j++ ) 7125 { 7126 if( pbRegion[ i * uiWidth + j ] != pbRegion[ i * uiWidth + j + 1 ] ) 7127 pbEdge[ i * uiWidth * 4 + j * 2 + 1 ] = true; 7128 } 7129 } 7130 7131 for( Int i = 0; i < uiHeight - 1; i++ ) 7132 { 7133 for( Int j = 0; j < uiWidth; j++ ) 7134 { 7135 if( pbRegion[ (i + 0) * uiWidth + j ] != pbRegion[ (i + 1) * uiWidth + j ] ) 7136 pbEdge[ (2 * i + 1) * 2 * uiWidth + j * 2 ] = true; 7137 } 7138 } 7139 7140 for( Int i = 1; i < uiWidth2 - 2; i+=2 ) 7141 { 7142 if(pbEdge[ i ]) 7143 { 7144 bPossible = true; 7145 bStartLeft = false; 7146 iStartPosition = iX = i; 7147 iY = 0; 7148 iDir = 3; 7149 iArrow = 3; 7150 break; 7151 } 7152 } 7153 7154 if( !bPossible ) 7155 { 7156 for( Int i = 1; i < uiWidth2 - 2; i+=2 ) 7157 { 7158 if(pbEdge[ i * uiWidth2 ]) 7159 { 7160 bPossible = true; 7161 bStartLeft = true; 7162 iX = 0; 7163 iStartPosition = iY = i; 7164 iDir = 1; 7165 iArrow = 1; 7166 break; 7167 } 7168 } 7169 } 7170 7171 if( bPossible ) 7172 { 7173 for( Int i = 0; i < 4 * uiWidth * uiHeight; i++ ) 7174 pbVisit[ i ] = false; 7175 7176 while( !bFinish ) 7177 { 7178 Bool bArrowSkip = false; 7179 pbVisit[ iX + iY * uiWidth2 ] = true; 7180 7181 switch( iDir ) 7182 { 7183 case 0: // left 7184 if( iX > 0 && !pbVisit[ (iX - 2) + iY * uiWidth2 ] && pbEdge[ (iX - 2) + iY * uiWidth2 ] ) // left 7185 { 7186 iDiffX = -2; 7187 iDiffY = 0; 7188 iNextDir = 0; 7189 iNextArrow = 0; 7190 } 7191 else if( iX > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // top 7192 { 7193 iDiffX = -1; 7194 iDiffY = -1; 7195 iNextDir = 2; 7196 iNextArrow = 4; 7197 } 7198 else if( iX > 0 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // bottom 7199 { 7200 iDiffX = -1; 7201 iDiffY = +1; 7202 iNextDir = 3; 7203 iNextArrow = iArrow; 7204 if( !(iPtr == 0 && iX == uiWidth2 - 2 && iY == uiHeight * 2 - 3) ) 7205 bArrowSkip = true; 7206 else 7207 iNextArrow = 3; 7208 } 7209 else if( iX == 0 ) 7210 { 7211 iDiffX = 0; 7212 iDiffY = 0; 7213 iNextDir = iDir; 7214 iNextArrow = iArrow; 7215 bFinish = true; 7216 continue; 7217 } 7218 else 7219 { 7220 iPtr = 0; // edge loop or unwanted case 7221 bFinish = true; 7222 //continue; 7223 assert(false); 7224 } 7225 break; 7226 case 1: // right 7227 if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 2) + iY * uiWidth2 ] && pbEdge[ (iX + 2) + iY * uiWidth2 ] ) // right 7228 { 7229 iDiffX = +2; 7230 iDiffY = 0; 7231 iNextDir = 1; 7232 iNextArrow = 1; 7233 } 7234 else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // top 7235 { 7236 iDiffX = +1; 7237 iDiffY = -1; 7238 iNextDir = 2; 7239 iNextArrow = iArrow; 7240 if( !(iPtr == 0 && iX == 0 && iY == 1) ) 7241 bArrowSkip = true; 7242 else 7243 iNextArrow = 2; 7244 } 7245 else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // bottom 7246 { 7247 iDiffX = +1; 7248 iDiffY = +1; 7249 iNextDir = 3; 7250 iNextArrow = 7; 7251 } 7252 else if( iX == uiWidth2 - 2 ) 7253 { 7254 iDiffX = 0; 7255 iDiffY = 0; 7256 iNextDir = iDir; 7257 iNextArrow = iArrow; 7258 bFinish = true; 7259 continue; 7260 } 7261 else 7262 { 7263 iPtr = 0; // edge loop or unwanted case 7264 bFinish = true; 7265 //continue; 7266 assert(false); 7267 } 7268 break; 7269 case 2: // top 7270 if( iY > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // left 7271 { 7272 iDiffX = -1; 7273 iDiffY = -1; 7274 iNextDir = 0; 7275 iNextArrow = iArrow; 7276 if( !(iPtr == 0 && iX == 1 && iY == uiHeight * 2 - 2) ) 7277 bArrowSkip = true; 7278 else 7279 iNextArrow = 0; 7280 } 7281 else if( iY > 0 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // right 7282 { 7283 iDiffX = +1; 7284 iDiffY = -1; 7285 iNextDir = 1; 7286 iNextArrow = 5; 7287 } 7288 else if( iY > 0 && !pbVisit[ iX + (iY - 2) * uiWidth2 ] && pbEdge[ iX + (iY - 2) * uiWidth2 ] ) // top 7289 { 7290 iDiffX = 0; 7291 iDiffY = -2; 7292 iNextDir = 2; 7293 iNextArrow = 2; 7294 } 7295 else if( iY == 0 ) 7296 { 7297 iDiffX = 0; 7298 iDiffY = 0; 7299 iNextDir = iDir; 7300 iNextArrow = iArrow; 7301 bFinish = true; 7302 continue; 7303 } 7304 else 7305 { 7306 iPtr = 0; // edge loop or unwanted case 7307 bFinish = true; 7308 //continue; 7309 assert(false); 7310 } 7311 break; 7312 case 3: // bottom 7313 if( iY < uiWidth2 - 2 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // left 7314 { 7315 iDiffX = -1; 7316 iDiffY = +1; 7317 iNextDir = 0; 7318 iNextArrow = 6; 7319 } 7320 else if( iY < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // right 7321 { 7322 iDiffX = +1; 7323 iDiffY = +1; 7324 iNextDir = 1; 7325 iNextArrow = iArrow; 7326 if( !(iPtr == 0 && iX == uiWidth * 2 - 3 && iY == 0) ) 7327 bArrowSkip = true; 7328 else 7329 iNextArrow = 1; 7330 } 7331 else if( iY < uiWidth2 - 2 && !pbVisit[ iX + (iY + 2) * uiWidth2 ] && pbEdge[ iX + (iY + 2) * uiWidth2 ] ) // bottom 7332 { 7333 iDiffX = 0; 7334 iDiffY = +2; 7335 iNextDir = 3; 7336 iNextArrow = 3; 7337 } 7338 else if( iY == uiWidth2 - 2 ) 7339 { 7340 iDiffX = 0; 7341 iDiffY = 0; 7342 iNextDir = iDir; 7343 iNextArrow = iArrow; 7344 bFinish = true; 7345 continue; 7346 } 7347 else 7348 { 7349 iPtr = 0; // edge loop or unwanted case 7350 bFinish = true; 7351 //continue; 7352 assert(false); 7353 } 7354 break; 7355 } 7356 7357 const UChar tableCode[8][8] = { { 0, -1, 4, 3, 2, 6, 1, 5 }, // iArrow(current direction), iNextArrow(next direction) 7358 { -1, 0, 3, 4, 5, 1, 6, 2 }, 7359 { 3, 4, 0, -1, 1, 2, 5, 6 }, 7360 { 4, 3, -1, 0, 6, 5, 2, 1 }, 7361 { 1, 6, 2, 5, 0, 4, 3, -1 }, 7362 { 5, 2, 1, 6, 3, 0, -1, 4 }, 7363 { 2, 5, 6, 1, 4, -1, 0, 3 }, 7364 { 6, 1, 5, 2, -1, 3, 4, 0 } }; 7365 7366 iCode = tableCode[iArrow][iNextArrow]; 7367 7368 if(iPtr >= uiMaxEdge) 7369 { 7370 iPtr = 0; // over the maximum number of edge 7371 bPossible = false; 7372 break; 7373 } 7374 7375 if( !bArrowSkip ) 7376 { 7377 piEdgeCode[iPtr++] = iCode; // first edge coding 7378 //printf("xEdgeCoding: (%d,%d)->(%d,%d) code %d\n",iX,iY, iX+iDiffX, iY+iDiffY, iCode); 7379 } 7380 7381 iX += iDiffX; 7382 iY += iDiffY; 7383 iDir = iNextDir; 7384 iArrow = iNextArrow; 7385 } 7386 } 7387 7388 pcCU->setEdgeLeftFirst( uiPartIdx, bStartLeft ); 7389 pcCU->setEdgeStartPos ( uiPartIdx, bStartLeft ? (iStartPosition - 1) >> 1 : (iStartPosition + 1) >> 1); 7390 pcCU->setEdgeNumber ( uiPartIdx, iPtr ); 7391 7392 xFree( pbEdge ); 7393 xFree( pbVisit ); 7394 7395 return (iPtr != 0); 7396 } 7397 7398 #if LGE_EDGE_INTRA_DELTA_DC 7399 Void TEncSearch::xAssignEdgeIntraDeltaDCs( TComDataCU* pcCU, 7400 UInt uiAbsPartIdx, 7401 Pel* piOrig, 7402 UInt uiStride, 7403 Pel* piPredic, 7404 UInt uiWidth, 7405 UInt uiHeight ) 7406 { 7407 Int iDC0 = 0; 7408 Int iDC1 = 0; 7409 Int iPredDC0 = 0; 7410 Int iPredDC1 = 0; 7411 Int iDeltaDC0 = 0; 7412 Int iDeltaDC1 = 0; 7413 7414 Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); 7415 7416 Int* piMask = pcCU->getPattern()->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); 7417 Int iMaskStride = ( uiWidth<<1 ) + 1; 7418 7419 // DC Calculation 7420 { 7421 UInt uiSum0 = 0; 7422 UInt uiSum1 = 0; 7423 UInt uiCount0 = 0; 7424 UInt uiCount1 = 0; 7425 7426 Pel* piTemp = piOrig; 7427 for( UInt ui = 0; ui < uiHeight; ui++ ) 7428 { 7429 for( UInt uii = 0; uii < uiWidth; uii++ ) 7430 { 7431 if( pbRegion[ ui * uiWidth + uii ] == false ) 7432 { 7433 uiSum0 += (piTemp[ uii ]); 7434 uiCount0++; 7435 } 7436 else 7437 { 7438 uiSum1 += (piTemp[ uii ]); 7439 uiCount1++; 7440 } 7441 } 7442 piTemp += uiStride; 7443 } 7444 if( uiCount0 == 0 ) 7445 assert(false); 7446 if( uiCount1 == 0 ) 7447 assert(false); 7448 iDC0 = uiSum0 / uiCount0; // TODO : integer op. 7449 iDC1 = uiSum1 / uiCount1; 7450 } 7451 7452 // PredDC Calculation 7453 { 7454 UInt uiSum0 = 0; 7455 UInt uiSum1 = 0; 7456 UInt uiCount0 = 0; 7457 UInt uiCount1 = 0; 7458 7459 for( UInt ui = 0; ui < uiWidth; ui++ ) 7460 { 7461 if( pbRegion[ ui ] == false ) 7462 { 7463 uiSum0 += (piMask[ ui + 1 ]); 7464 uiCount0++; 7465 } 7466 else 7467 { 7468 uiSum1 += (piMask[ ui + 1 ]); 7469 uiCount1++; 7470 } 7471 } 7472 for( UInt ui = 0; ui < uiHeight; ui++ ) // (0,0) recount (to avoid division) 7473 { 7474 if( pbRegion[ ui * uiWidth ] == false ) 7475 { 7476 uiSum0 += (piMask[ (ui + 1) * iMaskStride ]); 7477 uiCount0++; 7478 } 7479 else 7480 { 7481 uiSum1 += (piMask[ (ui + 1) * iMaskStride ]); 7482 uiCount1++; 7483 } 7484 } 7485 if( uiCount0 == 0 ) 7486 assert(false); 7487 if( uiCount1 == 0 ) 7488 assert(false); 7489 iPredDC0 = uiSum0 / uiCount0; // TODO : integer op. 7490 iPredDC1 = uiSum1 / uiCount1; 7491 } 7492 7493 iDeltaDC0 = iDC0 - iPredDC0; 7494 iDeltaDC1 = iDC1 - iPredDC1; 7495 7496 #if HHI_VSO 7497 if( m_pcRdCost->getUseVSO() ) 7498 { 7499 Int iFullDeltaDC0 = iDeltaDC0; 7500 Int iFullDeltaDC1 = iDeltaDC1; 7501 7502 xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC0 ); 7503 xDeltaDCQuantScaleDown( pcCU, iFullDeltaDC1 ); 7504 7505 Dist uiBestDist = RDO_DIST_MAX; 7506 UInt uiBestQStepDC0 = 0; 7507 UInt uiBestQStepDC1 = 0; 7508 7509 UInt uiDeltaDC0Max = abs(iFullDeltaDC0); 7510 UInt uiDeltaDC1Max = abs(iFullDeltaDC1); 7511 7512 //VSO Level delta DC check range extension 7513 uiDeltaDC0Max += (uiDeltaDC0Max>>1); 7514 uiDeltaDC1Max += (uiDeltaDC1Max>>1); 7515 7516 for( UInt uiQStepDC0 = 1; uiQStepDC0 <= uiDeltaDC0Max; uiQStepDC0++ ) 7517 { 7518 Int iLevelDeltaDC0 = (Int)(uiQStepDC0) * (Int)(( iFullDeltaDC0 < 0 ) ? -1 : 1); 7519 xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC0 ); 7520 7521 Int iTestDC0 = Clip( iPredDC0 + iLevelDeltaDC0 ); 7522 for( UInt uiQStepDC1 = 1; uiQStepDC1 <= uiDeltaDC1Max; uiQStepDC1++ ) 7523 { 7524 Int iLevelDeltaDC1 = (Int)(uiQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1); 7525 xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC1 ); 7526 7527 Int iTestDC1 = Clip( iPredDC1 + iLevelDeltaDC1 ); 7528 7529 Pel* piTemp = piPredic; 7530 for( UInt ui = 0; ui < uiHeight; ui++ ) 7531 { 7532 for( UInt uii = 0; uii < uiWidth; uii++ ) 7533 { 7534 if( pbRegion[ ui * uiWidth + uii ] == false ) 7535 { 7536 piTemp[ uii ] = iTestDC0; 7537 } 7538 else 7539 { 7540 piTemp[ uii ] = iTestDC1; 7541 } 7542 } 7543 piTemp += uiStride; 7544 } 7545 7546 Dist uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false, 0 ); 7547 if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX ) 7548 { 7549 uiBestDist = uiActDist; 7550 uiBestQStepDC0 = uiQStepDC0; 7551 uiBestQStepDC1 = uiQStepDC1; 7552 } 7553 } 7554 } 7555 7556 iFullDeltaDC0 = (Int)(uiBestQStepDC0) * (Int)(( iFullDeltaDC0 < 0 ) ? -1 : 1); 7557 iFullDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( iFullDeltaDC1 < 0 ) ? -1 : 1); 7558 xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC0 ); 7559 xDeltaDCQuantScaleUp( pcCU, iFullDeltaDC1 ); 7560 iDeltaDC0 = iFullDeltaDC0; 7561 iDeltaDC1 = iFullDeltaDC1; 7562 } 7563 #endif 7564 7565 xDeltaDCQuantScaleDown( pcCU, iDeltaDC0 ); 7566 xDeltaDCQuantScaleDown( pcCU, iDeltaDC1 ); 7567 7568 pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 ); 7569 pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 ); 7570 } 7571 #endif 7572 #endif 7573 6209 7574 //! \} -
branches/HTM-3.1-LG/source/Lib/TLibEncoder/TEncSearch.h
r77 r97 254 254 255 255 Void xIntraCodingLumaBlk ( TComDataCU* pcCU, 256 UInt uiTrDepth, 257 UInt uiAbsPartIdx, 258 TComYuv* pcOrgYuv, 259 TComYuv* pcPredYuv, 260 TComYuv* pcResiYuv, 261 Dist& ruiDist ); 256 UInt uiTrDepth, 257 UInt uiAbsPartIdx, 258 TComYuv* pcOrgYuv, 259 TComYuv* pcPredYuv, 260 TComYuv* pcResiYuv, 261 Dist& ruiDist 262 #if LG_ZEROINTRADEPTHRESI_M26039 263 ,Bool bZeroResi = false 264 #endif 265 ); 262 266 Void xIntraCodingChromaBlk ( TComDataCU* pcCU, 263 267 UInt uiTrDepth, … … 269 273 UInt uiChromaId ); 270 274 Void xRecurIntraCodingQT ( TComDataCU* pcCU, 271 272 273 274 275 276 277 278 275 UInt uiTrDepth, 276 UInt uiAbsPartIdx, 277 Bool bLumaOnly, 278 TComYuv* pcOrgYuv, 279 TComYuv* pcPredYuv, 280 TComYuv* pcResiYuv, 281 Dist& ruiDistY, 282 Dist& ruiDistC, 279 283 #if HHI_RQT_INTRA_SPEEDUP 280 Bool bCheckFirst, 281 #endif 282 Double& dRDCost ); 284 Bool bCheckFirst, 285 #endif 286 Double& dRDCost 287 #if LG_ZEROINTRADEPTHRESI_M26039 288 ,Bool bZeroResi = false 289 #endif 290 ); 283 291 284 292 Void xSetIntraResultQT ( TComDataCU* pcCU, … … 321 329 Bool bLeftAvail ); 322 330 #endif 331 332 #if LGE_EDGE_INTRA 333 Bool xEdgePartition ( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 ); 334 Bool xCheckTerminatedEdge ( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight ); 335 Bool xConstructChainCode ( TComDataCU* pcCU, UInt uiPartIdx, Bool bPU4x4 ); 336 #if LGE_EDGE_INTRA_DELTA_DC 337 Void xAssignEdgeIntraDeltaDCs( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piOrig, UInt uiStride, Pel* piPredic, UInt uiWidth, UInt uiHeight ); 338 #endif 339 #endif 340 323 341 #if HHI_DMM_WEDGE_INTRA 324 342 Void findWedgeFullMinDist ( TComDataCU* pcCU, -
branches/HTM-3.1-LG/source/Lib/TLibEncoder/TEncSlice.cpp
r77 r97 627 627 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); 628 628 xDetermineStartAndBoundingCUAddr ( uiStartCUAddr, uiBoundingCUAddr, rpcPic, false ); 629 #if LG_ZEROINTRADEPTHRESI_M26039 630 rpcPic->setIntraPeriod(this->m_pcCfg->getIntraPeriod()); 631 #endif 629 632 630 633 // initialize cost values
Note: See TracChangeset for help on using the changeset viewer.