Changeset 1390 in 3DVCSoftware for branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComDataCU.cpp
- Timestamp:
- 13 Nov 2015, 17:00:20 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComDataCU.cpp
r1386 r1390 55 55 56 56 m_skipFlag = NULL; 57 #if NH_3D_DIS58 m_bDISFlag = NULL;59 m_ucDISType = NULL;60 #endif61 57 m_pePartSize = NULL; 62 58 m_pePredMode = NULL; … … 104 100 } 105 101 106 #if NH_3D_DMM107 for( Int i = 0; i < NUM_DMM; i++ )108 {109 m_dmmDeltaDC[i][0] = NULL;110 m_dmmDeltaDC[i][1] = NULL;111 }112 m_dmm1WedgeTabIdx = NULL;113 #endif114 #if NH_3D_SDC_INTRA115 m_pbSDCFlag = NULL;116 m_apSegmentDCOffset[0] = NULL;117 m_apSegmentDCOffset[1] = NULL;118 #endif119 102 120 103 m_bDecSubCu = false; 121 104 122 #if NH_3D_NBDV123 m_pDvInfo = NULL;124 #endif125 #if NH_3D_VSP126 m_piVSPFlag = NULL;127 #endif128 #if NH_3D_SPIVMP129 m_pbSPIVMPFlag = NULL;130 #endif131 #if NH_3D_ARP132 m_puhARPW = NULL;133 #endif134 #if NH_3D_IC135 m_pbICFlag = NULL;136 #endif137 #if NH_3D_DBBP138 m_pbDBBPFlag = NULL;139 #endif140 105 141 106 } … … 167 132 m_ChromaQpAdj = new UChar[ uiNumPartition ]; 168 133 m_skipFlag = new Bool[ uiNumPartition ]; 169 #if NH_3D_DIS170 m_bDISFlag = new Bool[ uiNumPartition ];171 m_ucDISType = (UChar*)xMalloc(UChar, uiNumPartition);172 #endif173 134 m_pePartSize = new SChar[ uiNumPartition ]; 174 135 memset( m_pePartSize, NUMBER_OF_PART_SIZES,uiNumPartition * sizeof( *m_pePartSize ) ); … … 178 139 m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); 179 140 m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); 180 #if NH_3D_VSP181 m_piVSPFlag = (SChar* )xMalloc(SChar, uiNumPartition);182 #endif183 #if NH_3D_SPIVMP184 m_pbSPIVMPFlag = (Bool* )xMalloc(Bool, uiNumPartition);185 #endif186 141 187 142 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) … … 201 156 } 202 157 203 #if NH_3D_NBDV204 m_pDvInfo = (DisInfo* )xMalloc(DisInfo, uiNumPartition);205 #endif206 158 207 159 … … 242 194 } 243 195 244 #if NH_3D_ARP245 m_puhARPW = (UChar* )xMalloc(UChar, uiNumPartition);246 #endif247 #if NH_3D_IC248 m_pbICFlag = (Bool* )xMalloc(Bool, uiNumPartition);249 #endif250 #if NH_3D_DMM251 for( Int i = 0; i < NUM_DMM; i++ )252 {253 m_dmmDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition);254 m_dmmDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition);255 }256 m_dmm1WedgeTabIdx = (UInt*)xMalloc(UInt, uiNumPartition);257 #endif258 #if NH_3D_SDC_INTRA259 m_pbSDCFlag = (Bool*)xMalloc(Bool, uiNumPartition);260 m_apSegmentDCOffset[0] = (Pel*)xMalloc(Pel, uiNumPartition);261 m_apSegmentDCOffset[1] = (Pel*)xMalloc(Pel, uiNumPartition);262 #endif263 #if NH_3D_DBBP264 m_pbDBBPFlag = (Bool* )xMalloc(Bool, uiNumPartition);265 #endif266 196 267 197 } … … 319 249 } 320 250 321 #if NH_3D_DIS322 if ( m_bDISFlag ) { delete[] m_bDISFlag; m_bDISFlag = NULL; }323 if ( m_ucDISType ) { xFree(m_ucDISType); m_ucDISType = NULL; }324 #endif325 251 326 252 if ( m_pePartSize ) … … 360 286 } 361 287 362 #if NH_3D_VSP363 if ( m_piVSPFlag )364 {365 xFree(m_piVSPFlag);366 m_piVSPFlag = NULL;367 }368 #endif369 #if NH_3D_SPIVMP370 if ( m_pbSPIVMPFlag ) { xFree(m_pbSPIVMPFlag); m_pbSPIVMPFlag = NULL; }371 #endif372 288 373 289 … … 455 371 m_acCUMvField[rpl].destroy(); 456 372 } 457 #if NH_3D_NBDV 458 if ( m_pDvInfo ) { xFree(m_pDvInfo); m_pDvInfo = NULL; } 459 #endif 460 461 462 #if NH_3D_ARP 463 if ( m_puhARPW ) { xFree(m_puhARPW); m_puhARPW = NULL; } 464 #endif 465 #if NH_3D_IC 466 if ( m_pbICFlag ) { xFree(m_pbICFlag); m_pbICFlag = NULL; } 467 #endif 468 469 #if NH_3D_DMM 470 for( Int i = 0; i < NUM_DMM; i++ ) 471 { 472 if ( m_dmmDeltaDC[i][0] ) { xFree( m_dmmDeltaDC[i][0] ); m_dmmDeltaDC[i][0] = NULL; } 473 if ( m_dmmDeltaDC[i][1] ) { xFree( m_dmmDeltaDC[i][1] ); m_dmmDeltaDC[i][1] = NULL; } 474 } 475 if ( m_dmm1WedgeTabIdx ) { xFree( m_dmm1WedgeTabIdx ); m_dmm1WedgeTabIdx = NULL; } 476 #endif 477 #if NH_3D_SDC_INTRA 478 if ( m_pbSDCFlag ) { xFree(m_pbSDCFlag); m_pbSDCFlag = NULL; } 479 if ( m_apSegmentDCOffset[0] ) { xFree(m_apSegmentDCOffset[0]); m_apSegmentDCOffset[0] = NULL; } 480 if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]); m_apSegmentDCOffset[1] = NULL; } 481 #endif 482 #if NH_3D_DBBP 483 if ( m_pbDBBPFlag ) { xFree(m_pbDBBPFlag); m_pbDBBPFlag = NULL; } 484 #endif 373 374 375 485 376 486 377 } … … 572 463 memset( m_skipFlag , false, m_uiNumPartition * sizeof( *m_skipFlag ) ); 573 464 574 #if NH_3D_DIS575 memset( m_bDISFlag , false, m_uiNumPartition * sizeof( *m_bDISFlag ) );576 memset( m_ucDISType , false, m_uiNumPartition * sizeof( *m_ucDISType ) );577 #endif578 465 579 466 memset( m_pePartSize , NUMBER_OF_PART_SIZES, m_uiNumPartition * sizeof( *m_pePartSize ) ); … … 585 472 memset( m_puhHeight , maxCUHeight, m_uiNumPartition * sizeof( *m_puhHeight ) ); 586 473 587 #if NH_3D_IC588 memset( m_pbICFlag , false, m_uiNumPartition * sizeof( *m_pbICFlag ) );589 #endif590 474 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 591 475 { … … 606 490 memset( m_puhMergeIndex , 0, m_uiNumPartition * sizeof( *m_puhMergeIndex ) ); 607 491 608 #if NH_3D_VSP609 memset( m_piVSPFlag , 0, m_uiNumPartition * sizeof( *m_piVSPFlag ) );610 #endif611 #if NH_3D_SPIVMP612 memset( m_pbSPIVMPFlag , 0, m_uiNumPartition * sizeof( *m_pbSPIVMPFlag ) );613 #endif614 #if NH_3D_SDC_INTRA615 memset( m_pbSDCFlag, false, m_uiNumPartition * sizeof( *m_pbSDCFlag ) );616 #endif617 #if NH_3D_DBBP618 memset( m_pbDBBPFlag , false, m_uiNumPartition * sizeof( *m_pbDBBPFlag ));619 #endif620 492 621 493 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) … … 624 496 } 625 497 626 #if NH_3D_ARP 627 memset( m_puhARPW , 0, m_uiNumPartition * sizeof( *m_puhARPW ) ); 628 #endif 629 630 631 #if NH_3D_DMM 632 for( Int i = 0; i < NUM_DMM; i++ ) 633 { 634 memset( m_dmmDeltaDC[i][0], 0, m_uiNumPartition * sizeof( *m_dmmDeltaDC[i][0] ) ); 635 memset( m_dmmDeltaDC[i][1], 0, m_uiNumPartition * sizeof( *m_dmmDeltaDC[i][1] ) ); 636 } 637 memset( m_dmm1WedgeTabIdx, 0, m_uiNumPartition * sizeof( *m_dmm1WedgeTabIdx ) ); 638 #endif 639 #if NH_3D_SDC_INTRA 640 memset( m_pbSDCFlag, false, m_uiNumPartition * sizeof( *m_pbSDCFlag ) ); 641 memset( m_apSegmentDCOffset[0], 0, m_uiNumPartition * sizeof( *m_apSegmentDCOffset[0] ) ); 642 memset( m_apSegmentDCOffset[1], 0, m_uiNumPartition * sizeof( *m_apSegmentDCOffset[1] ) ); 643 #endif 498 499 644 500 645 501 memset( m_puhInterDir , 0, m_uiNumPartition * sizeof( *m_puhInterDir ) ); … … 743 599 } 744 600 m_skipFlag[ui] = false; 745 #if NH_3D_DIS746 m_bDISFlag[ui] = false;747 m_ucDISType[ui] = 0;748 #endif749 601 m_pePartSize[ui] = NUMBER_OF_PART_SIZES; 750 602 m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; … … 755 607 m_pbMergeFlag[ui] = 0; 756 608 m_puhMergeIndex[ui] = 0; 757 #if NH_3D_VSP758 m_piVSPFlag[ui] = 0;759 #endif760 #if NH_3D_SPIVMP761 m_pbSPIVMPFlag[ui] = 0;762 #endif763 609 764 610 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) … … 772 618 m_puhCbf[comp][ui] = 0; 773 619 } 774 #if NH_3D_ARP 775 m_puhARPW[ui] = 0; 776 #endif 777 #if NH_3D_IC 778 m_pbICFlag[ui] = false; 779 #endif 780 781 782 #if NH_3D_DMM 783 for( Int i = 0; i < NUM_DMM; i++ ) 784 { 785 m_dmmDeltaDC[i][0] [ui] = 0; 786 m_dmmDeltaDC[i][1] [ui] = 0; 787 } 788 m_dmm1WedgeTabIdx [ui] = 0; 789 #endif 790 #if NH_3D_SDC_INTRA 791 m_pbSDCFlag [ui] = false; 792 m_apSegmentDCOffset[0][ui] = 0; 793 m_apSegmentDCOffset[1][ui] = 0; 794 #endif 795 #if NH_3D_DBBP 796 m_pbDBBPFlag[ui] = false; 797 #endif 620 621 798 622 } 799 623 … … 849 673 memset( m_pbMergeFlag, 0, iSizeInBool ); 850 674 memset( m_puhMergeIndex, 0, iSizeInUchar ); 851 #if NH_3D_VSP852 memset( m_piVSPFlag, 0, sizeof( SChar ) * m_uiNumPartition );853 #endif854 #if NH_3D_SPIVMP855 memset( m_pbSPIVMPFlag, 0, sizeof( Bool ) * m_uiNumPartition );856 #endif857 675 858 676 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) … … 876 694 memset( m_puhHeight, uhHeight, iSizeInUchar ); 877 695 memset( m_pbIPCMFlag, 0, iSizeInBool ); 878 #if NH_3D_ARP879 memset( m_puhARPW, 0, iSizeInUchar );880 #endif881 #if NH_3D_IC882 memset( m_pbICFlag, 0, iSizeInBool );883 #endif884 #if NH_3D_DMM885 for( Int i = 0; i < NUM_DMM; i++ )886 {887 memset( m_dmmDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition );888 memset( m_dmmDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition );889 }890 memset( m_dmm1WedgeTabIdx, 0, sizeof(UInt) * m_uiNumPartition );891 #endif892 #if NH_3D_SDC_INTRA893 memset( m_pbSDCFlag, 0, sizeof(Bool) * m_uiNumPartition );894 memset( m_apSegmentDCOffset[0], 0, sizeof(Pel) * m_uiNumPartition );895 memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition );896 #endif897 #if NH_3D_DBBP898 memset( m_pbDBBPFlag, 0, sizeof(Bool) * m_uiNumPartition );899 #endif900 696 901 697 for (UInt ui = 0; ui < m_uiNumPartition; ui++) 902 698 { 903 699 m_skipFlag[ui] = false; 904 #if NH_3D_DIS905 m_bDISFlag[ui] = false;906 m_ucDISType[ui] = 0;907 #endif908 700 909 701 m_pePartSize[ui] = NUMBER_OF_PART_SIZES; … … 918 710 m_apiMVPNum[rpl][ui] = -1; 919 711 } 920 #if NH_3D_DIS921 m_bDISFlag[ui] = pcCU->getDISFlag(uiPartOffset+ui);922 m_ucDISType[ui] = pcCU->getDISType(uiPartOffset+ui);923 #endif924 #if NH_3D_VSP925 m_piVSPFlag[ui] = pcCU->m_piVSPFlag[uiPartOffset+ui];926 m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];927 #endif928 #if NH_3D_SPIVMP929 m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];930 #endif931 #if NH_3D_ARP932 m_puhARPW [ui] = pcCU->getARPW( uiPartOffset+ui );933 #endif934 #if NH_3D_IC935 m_pbICFlag [ui] = pcCU->m_pbICFlag[uiPartOffset+ui];936 #endif937 #if NH_3D_DMM938 for( Int i = 0; i < NUM_DMM; i++ )939 {940 m_dmmDeltaDC[i][0] [ui] = pcCU->m_dmmDeltaDC[i][0] [uiPartOffset+ui];941 m_dmmDeltaDC[i][1] [ui] = pcCU->m_dmmDeltaDC[i][1] [uiPartOffset+ui];942 }943 m_dmm1WedgeTabIdx [ui] = pcCU->m_dmm1WedgeTabIdx [uiPartOffset+ui];944 #endif945 #if NH_3D_SDC_INTRA946 m_pbSDCFlag [ui] = pcCU->m_pbSDCFlag [ uiPartOffset + ui ];947 m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ];948 m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ];949 #endif950 #if NH_3D_DBBP951 m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui];952 #endif953 712 } 954 713 … … 1009 768 1010 769 m_skipFlag=pcCU->getSkipFlag() + uiPart; 1011 #if NH_3D_DIS1012 m_bDISFlag = pcCU->getDISFlag() + uiPart;1013 m_ucDISType = pcCU->getDISType() + uiPart;1014 #endif1015 770 1016 771 m_phQP=pcCU->getQP() + uiPart; … … 1019 774 m_pePredMode=pcCU->getPredictionMode() + uiPart; 1020 775 m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; 1021 #if NH_3D_NBDV1022 m_pDvInfo = pcCU->getDvInfo() + uiPart;1023 #endif1024 776 1025 777 m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; 1026 778 m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; 1027 #if NH_3D_VSP1028 m_piVSPFlag = pcCU->getVSPFlag() + uiPart;1029 #endif1030 #if NH_3D_SPIVMP1031 m_pbSPIVMPFlag = pcCU->getSPIVMPFlag() + uiPart;1032 #endif1033 #if NH_3D_ARP1034 m_puhARPW = pcCU->getARPW() + uiPart;1035 #endif1036 #if NH_3D_IC1037 m_pbICFlag = pcCU->getICFlag() + uiPart;1038 #endif1039 779 1040 780 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) … … 1053 793 m_explicitRdpcmMode[comp] = pcCU->getExplicitRdpcmMode(ComponentID(comp)) + uiPart; 1054 794 } 1055 #if NH_3D_DMM1056 for( Int i = 0; i < NUM_DMM; i++ )1057 {1058 m_dmmDeltaDC[i][0] = pcCU->getDmmDeltaDC( (DmmID)i, 0 ) + uiPart;1059 m_dmmDeltaDC[i][1] = pcCU->getDmmDeltaDC( (DmmID)i, 1 ) + uiPart;1060 }1061 m_dmm1WedgeTabIdx = pcCU->getDmm1WedgeTabIdx() + uiPart;1062 #endif1063 #if NH_3D_SDC_INTRA1064 m_pbSDCFlag = pcCU->getSDCFlag() + uiPart;1065 m_apSegmentDCOffset[0] = pcCU->getSDCSegmentDCOffset(0) + uiPart;1066 m_apSegmentDCOffset[1] = pcCU->getSDCSegmentDCOffset(1) + uiPart;1067 #endif1068 #if NH_3D_DBBP1069 m_pbDBBPFlag = pcCU->getDBBPFlag() + uiPart;1070 #endif1071 795 1072 796 m_puhDepth=pcCU->getDepth() + uiPart; … … 1113 837 } 1114 838 1115 #if NH_3D_NBDV1116 Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx)1117 {1118 m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx;1119 }1120 #endif1121 839 1122 840 // Copy inter prediction info from the biggest CU 1123 #if NH_3D_NBDV1124 Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList , Bool bNBDV )1125 #else1126 841 Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ) 1127 #endif1128 842 { 1129 843 m_pcPic = pcCU->getPic(); … … 1147 861 1148 862 m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; 1149 #if NH_3D_DIS1150 m_bDISFlag = pcCU->getDISFlag () + uiAbsPartIdx;1151 m_ucDISType = pcCU->getDISType() + uiAbsPartIdx;1152 #endif1153 863 1154 864 m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; 1155 #if NH_3D_NBDV1156 if(bNBDV == true)1157 {1158 m_puhWidth = pcCU->getWidth () + uiAbsPartIdx;1159 m_puhHeight = pcCU->getHeight() + uiAbsPartIdx;1160 m_puhDepth = pcCU->getDepth () + uiAbsPartIdx;1161 }1162 else1163 {1164 #endif1165 865 m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; 1166 866 m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiAbsPartIdx; … … 1174 874 m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; 1175 875 m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; 1176 #if NH_3D_VSP1177 m_piVSPFlag = pcCU->getVSPFlag() + uiAbsPartIdx;1178 m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx;1179 #endif1180 #if NH_3D_SPIVMP1181 m_pbSPIVMPFlag = pcCU->getSPIVMPFlag() + uiAbsPartIdx;1182 #endif1183 876 1184 877 m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; 1185 878 m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; 1186 #if NH_3D_ARP1187 m_puhARPW = pcCU->getARPW() + uiAbsPartIdx;1188 #endif1189 #if NH_3D_DBBP1190 m_pbDBBPFlag = pcCU->getDBBPFlag() + uiAbsPartIdx;1191 #endif1192 879 1193 880 m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); 1194 #if NH_3D_NBDV1195 }1196 #endif1197 #if NH_3D_IC1198 m_pbICFlag = pcCU->getICFlag() + uiAbsPartIdx;1199 #endif1200 881 1201 882 } … … 1221 902 Int sizeInChar = sizeof( SChar ) * uiNumPartition; 1222 903 memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); 1223 #if NH_3D_DIS1224 memcpy( m_bDISFlag + uiOffset, pcCU->getDISFlag(), sizeof( *m_bDISFlag ) * uiNumPartition );1225 memcpy( m_ucDISType + uiOffset, pcCU->getDISType(), sizeof( *m_ucDISType ) * uiNumPartition);1226 #endif1227 904 memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); 1228 905 memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); … … 1232 909 memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); 1233 910 memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); 1234 #if NH_3D_VSP1235 memcpy( m_piVSPFlag + uiOffset, pcCU->getVSPFlag(), sizeof( SChar ) * uiNumPartition );1236 memcpy( m_pDvInfo + uiOffset, pcCU->getDvInfo(), sizeof( *m_pDvInfo ) * uiNumPartition );1237 #endif1238 #if NH_3D_SPIVMP || NH_3D_DBBP1239 memcpy( m_pbSPIVMPFlag + uiOffset, pcCU->getSPIVMPFlag(), sizeof( Bool ) * uiNumPartition );1240 #endif1241 911 1242 912 for (UInt ch=0; ch<numValidChan; ch++) … … 1255 925 memcpy( m_explicitRdpcmMode[comp] + uiOffset, pcCU->getExplicitRdpcmMode(ComponentID(comp)) , iSizeInUchar ); 1256 926 } 1257 #if NH_3D_DMM1258 for( Int i = 0; i < NUM_DMM; i++ )1259 {1260 memcpy( m_dmmDeltaDC[i][0] + uiOffset, pcCU->getDmmDeltaDC( (DmmID)i, 0 ), sizeof(Pel ) * uiNumPartition );1261 memcpy( m_dmmDeltaDC[i][1] + uiOffset, pcCU->getDmmDeltaDC( (DmmID)i, 1 ), sizeof(Pel ) * uiNumPartition );1262 }1263 memcpy( m_dmm1WedgeTabIdx + uiOffset, pcCU->getDmm1WedgeTabIdx(), sizeof(UInt) * uiNumPartition );1264 #endif1265 #if NH_3D_SDC_INTRA1266 memcpy( m_pbSDCFlag + uiOffset, pcCU->getSDCFlag(), sizeof( *m_pbSDCFlag ) * uiNumPartition );1267 memcpy( m_apSegmentDCOffset[0] + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition);1268 memcpy( m_apSegmentDCOffset[1] + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition);1269 #endif1270 #if NH_3D_DBBP1271 memcpy( m_pbDBBPFlag + uiOffset, pcCU->getDBBPFlag(), iSizeInBool );1272 #endif1273 #if NH_3D_ARP1274 memcpy( m_puhARPW + uiOffset, pcCU->getARPW(), iSizeInUchar );1275 #endif1276 927 1277 928 memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); … … 1314 965 } 1315 966 1316 #if NH_3D_IC1317 memcpy( m_pbICFlag + uiOffset, pcCU->getICFlag(), iSizeInBool );1318 #endif1319 967 1320 968 m_uiTotalBins += pcCU->getTotalBins(); … … 1338 986 1339 987 memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); 1340 #if NH_3D_DIS1341 memcpy( pCtu->getDISFlag() + m_absZIdxInCtu, m_bDISFlag, sizeof( *m_bDISFlag ) * m_uiNumPartition );1342 memcpy( pCtu->getDISType() + m_absZIdxInCtu, m_ucDISType, sizeof( *m_ucDISType ) * m_uiNumPartition );1343 #endif1344 988 1345 989 memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar ); 1346 #if NH_3D_NBDV1347 memcpy( pCtu->getDvInfo() + m_absZIdxInCtu, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition );1348 #endif1349 990 1350 991 memcpy( pCtu->getPartitionSize() + m_absZIdxInCtu, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); … … 1354 995 memcpy( pCtu->getMergeFlag() + m_absZIdxInCtu, m_pbMergeFlag, iSizeInBool ); 1355 996 memcpy( pCtu->getMergeIndex() + m_absZIdxInCtu, m_puhMergeIndex, iSizeInUchar ); 1356 #if NH_3D_VSP1357 memcpy( pCtu->getVSPFlag() + m_absZIdxInCtu, m_piVSPFlag, sizeof( SChar ) * m_uiNumPartition );1358 #endif1359 #if NH_3D_DBBP1360 memcpy( pCtu->getDvInfo() + m_absZIdxInCtu, m_pDvInfo, sizeof( *m_pDvInfo ) * m_uiNumPartition );1361 #endif1362 #if NH_3D_SPIVMP1363 memcpy( pCtu->getSPIVMPFlag() + m_absZIdxInCtu, m_pbSPIVMPFlag, sizeof( Bool ) * m_uiNumPartition );1364 #endif1365 997 1366 998 for (UInt ch=0; ch<numValidChan; ch++) … … 1380 1012 } 1381 1013 1382 #if NH_3D_DMM1383 for( Int i = 0; i < NUM_DMM; i++ )1384 {1385 memcpy( pCtu->getDmmDeltaDC( (DmmID)i, 0 ) + m_absZIdxInCtu, m_dmmDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition );1386 memcpy( pCtu->getDmmDeltaDC( (DmmID)i, 1 ) + m_absZIdxInCtu, m_dmmDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition );1387 }1388 memcpy( pCtu->getDmm1WedgeTabIdx() + m_absZIdxInCtu, m_dmm1WedgeTabIdx, sizeof(UInt) * m_uiNumPartition );1389 #endif1390 #if NH_3D_SDC_INTRA1391 memcpy( pCtu->getSDCFlag() + m_absZIdxInCtu, m_pbSDCFlag, sizeof(Bool) * m_uiNumPartition );1392 memcpy( pCtu->getSDCSegmentDCOffset(0) + m_absZIdxInCtu, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition);1393 memcpy( pCtu->getSDCSegmentDCOffset(1) + m_absZIdxInCtu, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition);1394 #endif1395 #if NH_3D_DBBP1396 memcpy( pCtu->getDBBPFlag() + m_absZIdxInCtu, m_pbDBBPFlag, iSizeInBool );1397 #endif1398 #if NH_3D_ARP1399 memcpy( pCtu->getARPW() + m_absZIdxInCtu, m_puhARPW, iSizeInUchar );1400 #endif1401 1014 1402 1015 memcpy( pCtu->getDepth() + m_absZIdxInCtu, m_puhDepth, iSizeInUchar ); … … 1432 1045 } 1433 1046 1434 #if NH_3D_IC1435 memcpy( pCtu->getICFlag() + m_absZIdxInCtu, m_pbICFlag, sizeof( *m_pbICFlag ) * m_uiNumPartition );1436 #endif1437 1047 pCtu->getTotalBins() = m_uiTotalBins; 1438 1048 } 1439 #if H_3D_SPIVMP1440 memcpy( rpcCU->getSPIVMPFlag() + uiPartOffset, m_pbSPIVMPFlag, sizeof(Bool) * uiQNumPart );1441 #endif1442 1049 1443 1050 … … 1842 1449 } 1843 1450 iLeftIntraDir = pcCULeft ? ( pcCULeft->isIntra( LeftPartIdx ) ? pcCULeft->getIntraDir( chType, LeftPartIdx ) : DC_IDX ) : DC_IDX; 1844 #if NH_3D_DMM1845 mapDmmToIntraDir( iLeftIntraDir );1846 #endif1847 1451 1848 1452 // Get intra direction of above PU … … 1854 1458 } 1855 1459 iAboveIntraDir = pcCUAbove ? ( pcCUAbove->isIntra( AbovePartIdx ) ? pcCUAbove->getIntraDir( chType, AbovePartIdx ) : DC_IDX ) : DC_IDX; 1856 #if NH_3D_DMM1857 mapDmmToIntraDir( iAboveIntraDir );1858 #endif1859 1460 1860 1461 … … 1990 1591 return uiCtx; 1991 1592 } 1992 #if NH_3D_ARP 1993 UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx ) 1994 { 1995 const TComDataCU* pcTempCU; 1996 UInt uiTempPartIdx; 1997 UInt uiCtx = 0; 1998 1999 pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 2000 uiCtx = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0; 2001 return uiCtx; 2002 } 2003 #endif 2004 #if NH_3D_DBBP 2005 Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride) 2006 { 2007 const TComSPS* sps = getSlice()->getSPS(); 2008 UInt uiMaxCUWidth = sps->getMaxCUWidth(); 2009 UInt uiMaxCUHeight = sps->getMaxCUHeight(); 2010 2011 // get coded and reconstructed depth view 2012 TComPicYuv* depthPicYuv = NULL; 2013 Pel* pDepthPels = NULL; 2014 2015 // DBBP is a texture coding tool 2016 assert( !getSlice()->getIsDepth() ); 2017 2018 #if H_3D_FCO 2019 TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); 2020 2021 if( depthPic && depthPic->getPicYuvRec() != NULL && depthPic->getIsDepth() ) // depth first 2022 { 2023 depthPicYuv = depthPic->getPicYuvRec(); 2024 depthPicYuv->extendPicBorder(); 2025 2026 // get collocated depth block for current CU 2027 uiDepthStride = depthPicYuv->getStride(); 2028 pDepthPels = depthPicYuv->getLumaAddr( getAddr(), uiAbsPartIdx ); 2029 } 2030 else // texture first 2031 #else 2032 { 2033 DisInfo DvInfo = getDvInfo(uiAbsPartIdx); 2034 2035 TComPic* baseDepthPic = getSlice()->getIvPic (true, DvInfo.m_aVIdxCan); 2036 2037 if( baseDepthPic == NULL || baseDepthPic->getPicYuvRec() == NULL ) 2038 { 2039 return NULL; 2040 } 2041 2042 depthPicYuv = baseDepthPic->getPicYuvRec(); 2043 depthPicYuv->extendPicBorder(); 2044 uiDepthStride = depthPicYuv->getStride(COMPONENT_Y); 2045 2046 Int iBlkX = ( getCtuRsAddr() % baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ]; 2047 Int iBlkY = ( getCtuRsAddr() / baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ]; 2048 2049 Int iPictureWidth = depthPicYuv->getWidth(COMPONENT_Y); 2050 Int iPictureHeight = depthPicYuv->getHeight(COMPONENT_Y); 2051 2052 2053 Bool depthRefineFlag = false; 2054 #if NH_3D_NBDV_REF 2055 depthRefineFlag = m_pcSlice->getDepthRefinementFlag(); 2056 #endif // NH_3D_NBDV_REF 2057 2058 TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV; 2059 if( depthRefineFlag ) 2060 { 2061 cDv.setVer(0); 2062 } 2063 2064 Int depthPosX = Clip3(0, iPictureWidth - 1, iBlkX + ((cDv.getHor()+2)>>2)); 2065 Int depthPosY = Clip3(0, iPictureHeight - 1, iBlkY + ((cDv.getVer()+2)>>2)); 2066 2067 pDepthPels = depthPicYuv->getAddr(COMPONENT_Y) + depthPosX + depthPosY * uiDepthStride; 2068 } 2069 #endif 2070 2071 AOF( depthPicYuv != NULL ); 2072 AOF( pDepthPels != NULL ); 2073 AOF( uiDepthStride != 0 ); 2074 2075 return pDepthPels; 2076 } 2077 #endif 2078 2079 #if NH_3D_DBBP 2080 Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 2081 { 2082 setSubPart( bDBBPFlag, m_pbDBBPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); 2083 } 2084 #endif 1593 2085 1594 2086 1595 … … 2170 1679 } 2171 1680 2172 #if NH_3D_DIS2173 Void TComDataCU::setDISFlagSubParts( Bool bDIS, UInt uiAbsPartIdx, UInt uiDepth )2174 {2175 assert( sizeof( *m_bDISFlag) == 1 );2176 memset( m_bDISFlag + uiAbsPartIdx, bDIS, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) );2177 }2178 2179 Void TComDataCU::setDISTypeSubParts(UChar ucDISType, UInt uiAbsPartIdx, UInt uiDepth )2180 {2181 assert( sizeof( *m_ucDISType) == 1 );2182 memset( m_ucDISType + uiAbsPartIdx, ucDISType, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) );2183 }2184 #endif2185 1681 2186 1682 Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) … … 2336 1832 } 2337 1833 2338 #if NH_3D_SDC_INTRA2339 Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt absPartIdx, UInt depth )2340 {2341 assert( sizeof( *m_pbSDCFlag) == 1 );2342 memset( m_pbSDCFlag + absPartIdx, bSDCFlag, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) );2343 }2344 2345 Bool TComDataCU::getSDCAvailable( UInt uiAbsPartIdx )2346 {2347 if( getSlice()->getIsDepth() && isIntra(uiAbsPartIdx) && getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N )2348 {2349 UInt lumaPredMode = getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx );2350 if( lumaPredMode < NUM_INTRA_MODE ) { return true; }2351 #if NH_3D_DMM2352 if( isDmmMode( lumaPredMode ) ) { return true; }2353 #endif2354 }2355 return false;2356 }2357 #endif2358 1834 2359 1835 Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) … … 2367 1843 } 2368 1844 2369 #if NH_3D_SPIVMP 2370 Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 2371 { 2372 setSubPart<Bool>( bSPIVMPFlag, m_pbSPIVMPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); 2373 } 2374 #endif 2375 2376 #if NH_3D_VSP 2377 Void TComDataCU::setVSPFlagSubParts( SChar iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 2378 { 2379 setSubPart<SChar>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); 2380 } 2381 template<typename T> 2382 Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) 2383 { 2384 UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2; 2385 switch ( m_pePartSize[ uiCUAddr ] ) 2386 { 2387 case SIZE_2Nx2N: 2388 for (UInt ui = 0; ui < 4 * uiCurrPartNumQ; ui++) 2389 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2390 2391 break; 2392 case SIZE_2NxN: 2393 for (UInt ui = 0; ui < 2 * uiCurrPartNumQ; ui++) 2394 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2395 break; 2396 case SIZE_Nx2N: 2397 for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) 2398 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2399 for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) 2400 puhBaseLCU[uiCUAddr + 2 * uiCurrPartNumQ + ui] = uiParameter; 2401 break; 2402 case SIZE_NxN: 2403 for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) 2404 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2405 break; 2406 case SIZE_2NxnU: 2407 if ( uiPUIdx == 0 ) 2408 { 2409 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) 2410 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2411 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) 2412 puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; 2413 2414 } 2415 else if ( uiPUIdx == 1 ) 2416 { 2417 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) 2418 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2419 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1); ui++) 2420 puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; 2421 2422 } 2423 else 2424 { 2425 assert(0); 2426 } 2427 break; 2428 case SIZE_2NxnD: 2429 if ( uiPUIdx == 0 ) 2430 { 2431 for (UInt ui = 0; ui < ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)); ui++) 2432 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2433 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) 2434 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + ui] = uiParameter; 2435 2436 } 2437 else if ( uiPUIdx == 1 ) 2438 { 2439 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) 2440 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2441 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) 2442 puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; 2443 2444 } 2445 else 2446 { 2447 assert(0); 2448 } 2449 break; 2450 case SIZE_nLx2N: 2451 if ( uiPUIdx == 0 ) 2452 { 2453 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2454 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2455 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2456 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; 2457 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2458 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; 2459 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2460 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; 2461 2462 } 2463 else if ( uiPUIdx == 1 ) 2464 { 2465 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2466 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2467 for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) 2468 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; 2469 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2470 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; 2471 for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) 2472 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; 2473 2474 } 2475 else 2476 { 2477 assert(0); 2478 } 2479 break; 2480 case SIZE_nRx2N: 2481 if ( uiPUIdx == 0 ) 2482 { 2483 for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) 2484 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2485 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2486 puhBaseLCU[uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; 2487 for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) 2488 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; 2489 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2490 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; 2491 2492 } 2493 else if ( uiPUIdx == 1 ) 2494 { 2495 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2496 puhBaseLCU[uiCUAddr + ui] = uiParameter; 2497 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2498 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; 2499 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2500 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; 2501 for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) 2502 puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; 2503 2504 } 2505 else 2506 { 2507 assert(0); 2508 } 2509 break; 2510 default: 2511 assert( 0 ); 2512 } 2513 2514 } 2515 #endif 1845 2516 1846 2517 1847 Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) … … 2599 1929 2600 1930 // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx 2601 #if NH_3D_IC || NH_3D_VSP2602 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) const2603 {2604 UInt uiNumPartition = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition;2605 UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0;2606 2607 switch ( m_pePartSize[uiTmpAbsPartIdx] )2608 {2609 case SIZE_2NxN:2610 riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1;2611 break;2612 case SIZE_Nx2N:2613 riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2;2614 break;2615 case SIZE_NxN:2616 riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx;2617 break;2618 case SIZE_2NxnU:2619 riWidth = getWidth( uiTmpAbsPartIdx );2620 riHeight = ( uiPartIdx == 0 ) ? getHeight( uiTmpAbsPartIdx ) >> 2 : ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 );2621 ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3;2622 break;2623 case SIZE_2NxnD:2624 riWidth = getWidth( uiTmpAbsPartIdx );2625 riHeight = ( uiPartIdx == 0 ) ? ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ) : getHeight( uiTmpAbsPartIdx ) >> 2;2626 ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3);2627 break;2628 case SIZE_nLx2N:2629 riWidth = ( uiPartIdx == 0 ) ? getWidth( uiTmpAbsPartIdx ) >> 2 : ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 );2630 riHeight = getHeight( uiTmpAbsPartIdx );2631 ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4;2632 break;2633 case SIZE_nRx2N:2634 riWidth = ( uiPartIdx == 0 ) ? ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ) : getWidth( uiTmpAbsPartIdx ) >> 2;2635 riHeight = getHeight( uiTmpAbsPartIdx );2636 ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4);2637 break;2638 default:2639 assert ( m_pePartSize[uiTmpAbsPartIdx] == SIZE_2Nx2N );2640 riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = 0;2641 break;2642 }2643 }2644 #else2645 1931 2646 1932 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) const … … 2683 1969 } 2684 1970 } 2685 #endif2686 1971 2687 1972 // static member function … … 2933 2218 } 2934 2219 2935 #if NH_3D 2936 Bool TComDataCU::hasEqualMotion( Int dirA, const TComMvField* mvFieldA, Int dirB, const TComMvField* mvFieldB ) 2937 { 2938 return ( dirA == dirB && 2939 ( ( dirA & 1 ) == 0 || mvFieldA[0] == mvFieldB[0] ) && 2940 ( ( dirA & 2 ) == 0 || mvFieldA[1] == mvFieldB[1] ) 2941 ); 2942 } 2943 #endif 2944 2945 #if NH_3D_VSP 2946 /** Add a VSP merging candidate 2947 * \Inputs 2948 * \param uiPUIdx: PU index within a CU 2949 * \param ucVspMergePos: Specify the VSP merge candidate position 2950 * \param mrgCandIdx: Target merge candidate index. At encoder, it is set equal to -1, such that the whole merge candidate list will be constructed. 2951 * \param pDinfo: The "disparity information" derived from neighboring blocks. Type 1 MV. 2952 * \param uiCount: The next position to add VSP merge candidate 2953 * 2954 * \Outputs 2955 * \param uiCount: The next position to add merge candidate. Will be updated if VSP is successfully added 2956 * \param abCandIsInter: abCandIsInter[iCount] tells that VSP candidate is an Inter candidate, if VSP is successfully added 2957 * \param pcMvFieldNeighbours: Return combined motion information, then stored to a global buffer 2958 * 1) the "disparity vector". Type 1 MV. To be used to fetch a depth block. 2959 * 2) the ref index /list. Type 2 reference picture pointer, typically for texture 2960 * \param puhInterDirNeighbours: Indicate the VSP prediction direction. 2961 * \param vspFlag: vspFlag[iCount] will be set (equal to 1), if VSP is successfully added. To be used to indicate the actual position of the VSP candidate 2962 * 2963 * \Return 2964 * true: if the VSP candidate is added at the target position 2965 * false: otherwise 2966 */ 2967 inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount) 2968 { 2969 if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getViewSynthesisPredFlag( ) || m_pcSlice->getIsDepth() || pDInfo->m_aVIdxCan == -1) 2970 { 2971 return false; 2972 } 2973 2974 Int refViewIdx = pDInfo->m_aVIdxCan; 2975 TComPic* picDepth = getSlice()->getIvPic( true, refViewIdx ); 2976 2977 if( picDepth == NULL ) // No depth reference avail 2978 { 2979 // Is this allowed to happen? When not an assertion should be added here! 2980 return false; 2981 } 2982 2983 TComMvField mvVSP[2]; 2984 UChar dirVSP; 2985 Bool refViewAvailFlag = false; 2986 UChar predFlag[2] = {0, 0}; 2987 2988 for( Int iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ ) 2989 { 2990 RefPicList eRefPicListX = RefPicList( iRefListIdX ); 2991 for ( Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicListX) && !refViewAvailFlag; i++ ) 2992 { 2993 Int viewIdxRefInListX = m_pcSlice->getRefPic(eRefPicListX, i)->getViewIndex(); 2994 if ( viewIdxRefInListX == refViewIdx ) 2995 { 2996 refViewAvailFlag = true; 2997 predFlag[iRefListIdX] = 1; 2998 mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i ); 2999 #if NH_3D_NBDV 3000 mvVSP[0+iRefListIdX].getMv().setIDVFlag (false); 3001 #endif 3002 } 3003 } 3004 } 3005 3006 dirVSP = (predFlag[0] | (predFlag[1] << 1)); 3007 m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true 3008 #if NH_3D_SPIVMP 3009 , false 3010 #endif 3011 ); 3012 if ( mrgCandIdx == iCount ) 3013 { 3014 return true; 3015 } 3016 3017 iCount++; 3018 3019 return false; 3020 } 3021 #endif 3022 3023 #if NH_3D_IV_MERGE 3024 inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx ) 3025 { 3026 for(Int iLoop = 0; iLoop < 2; iLoop ++ ) 3027 { 3028 /// iLoop = 0 --> IvMCShift 3029 /// iLoop = 1 --> IvDCShift (Derived from IvDC) 3030 if(ivCandDir[iLoop + 2]) 3031 { 3032 TComMvField tmpMV[2]; 3033 UChar tmpDir = ivCandDir[iLoop + 2]; 3034 if( ( ivCandDir[iLoop + 2] & 1 ) == 1 ) 3035 { 3036 tmpMV[0].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] ); 3037 } 3038 if( ( ivCandDir[iLoop + 2] & 2 ) == 2 ) 3039 { 3040 tmpMV[1].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] ); 3041 } 3042 3043 // Prune IvMC vs. IvMcShift 3044 Bool bRemove = false; 3045 if( !iLoop && ivCandDir[0] > 0) 3046 { 3047 if( hasEqualMotion(tmpDir, tmpMV, m_mergCands[MRG_IVMC].m_uDir, m_mergCands[MRG_IVMC].m_cMvField )) 3048 { 3049 bRemove = true; 3050 } 3051 } 3052 if(!bRemove) 3053 { 3054 #if NH_3D_NBDV 3055 if(iLoop) // For IvMcShift candidate 3056 { 3057 tmpMV[0].getMv().setIDVFlag (false); 3058 tmpMV[1].getMv().setIDVFlag (false); 3059 } 3060 #endif 3061 m_mergCands[MRG_IVSHIFT].setCand(tmpMV, tmpDir, false, false); 3062 if( mrgCandIdx == iCount ) 3063 { 3064 return true; 3065 } 3066 iCount++; 3067 } 3068 break; 3069 } 3070 } 3071 return false; 3072 } 3073 3074 #endif 3075 #if NH_3D_MLC 3076 /** Construct a extended list of merging candidates 3077 * \param pcMvFieldNeighbours 3078 * \param puhInterDirNeighbours 3079 * \param vspFlag 3080 * \param pbSPIVMPFlag 3081 * \param numValidMergeCand 3082 */ 3083 Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours 3084 #if NH_3D_VSP 3085 , Int* vspFlag 3086 #endif 3087 #if NH_3D_SPIVMP 3088 , Bool* pbSPIVMPFlag 3089 #endif 3090 , Int& numValidMergeCand 3091 ) 3092 { 3093 if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) 3094 { 3095 return; 3096 } 3097 3098 3099 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC 3100 if ( g_traceMergeCandListConst ) 3101 { 3102 for (Int i = 0; i<MRG_IVSHIFT+1; i++) 3103 { 3104 m_mergCands[i].print( i ); 3105 } 3106 } 3107 #endif 3108 3109 3110 Int iCount = 0; 3111 TComMv cZeroMv; 3112 3113 // init temporal list 3114 TComMvField extMergeCandList[MRG_MAX_NUM_CANDS_MEM << 1]; 3115 UChar uhInterDirNeighboursExt[MRG_MAX_NUM_CANDS_MEM]; 3116 for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) 3117 { 3118 uhInterDirNeighboursExt[ui] = puhInterDirNeighbours[ui]; 3119 extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID); 3120 extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID); 3121 #if NH_3D_VSP 3122 vspFlag[ui] = 0; 3123 #endif 3124 } 3125 3126 // insert MPI ... IvShift candidate to extMergeCandList 3127 for (Int i=0; i<=MRG_IVSHIFT; i++) 3128 { 3129 if (m_mergCands[i].m_bAvailable) 3130 { 3131 m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt 3132 #if NH_3D_VSP 3133 , vspFlag 3134 #endif 3135 #if NH_3D_SPIVMP 3136 , pbSPIVMPFlag 3137 #endif 3138 ); 3139 iCount++; 3140 if (iCount >= getSlice()->getMaxNumMergeCand()) 3141 break; 3142 } 3143 } 3144 3145 Int iCountBase = m_numSpatialCands; 3146 // insert remaining base candidates to extMergeCandList 3147 while (iCount < getSlice()->getMaxNumMergeCand() && iCountBase < getSlice()->getMaxNumMergeCand()) 3148 { 3149 uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[iCountBase]; 3150 extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[iCountBase<<1].getMv(), pcMvFieldNeighbours[iCountBase<<1].getRefIdx()); 3151 if ( getSlice()->isInterB() ) 3152 { 3153 extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(iCountBase<<1)+1].getMv(), pcMvFieldNeighbours[(iCountBase<<1)+1].getRefIdx()); 3154 } 3155 iCountBase++; 3156 iCount++; 3157 } 3158 3159 for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ ) 3160 { 3161 puhInterDirNeighbours[ui] = 0; 3162 pcMvFieldNeighbours[ui<<1].setMvField(cZeroMv, NOT_VALID); 3163 pcMvFieldNeighbours[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID); 3164 } 3165 3166 // copy extMergeCandList to output 3167 for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ ) 3168 { 3169 puhInterDirNeighbours[ui] = uhInterDirNeighboursExt[ui]; 3170 pcMvFieldNeighbours[ui<<1].setMvField(extMergeCandList[ui<<1].getMv(), extMergeCandList[ui<<1].getRefIdx()); 3171 3172 if ( getSlice()->isInterB() ) 3173 { 3174 pcMvFieldNeighbours[(ui<<1)+1].setMvField(extMergeCandList[(ui<<1)+1].getMv(), extMergeCandList[(ui<<1)+1].getRefIdx()); 3175 } 3176 } 3177 3178 #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC 3179 if ( g_traceMergeCandListConst ) 3180 { 3181 std::cout << std::setfill(' ') << std::setw( 15 ) 3182 << "Num" << std::setw( 15 ) 3183 << "Dir " << std::setw( 15 ) 3184 << "L0 RefIdx" << std::setw( 15 ) 3185 << "L0 Hor" << std::setw( 15 ) 3186 << "L0 Ver" << std::setw( 15 ) 3187 << "L1 RefIdx" << std::setw( 15 ) 3188 << "L1 Hor" << std::setw( 15 ) 3189 << "L1 Ver" << std::setw( 15 ) 3190 << std::endl; 3191 3192 // copy extMergeCandList to output 3193 for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ ) 3194 { 3195 UChar curDir = puhInterDirNeighbours[ui]; 3196 TComMvField& curf = pcMvFieldNeighbours[ui<<1]; 3197 TComMvField& curf2 = pcMvFieldNeighbours[(ui<<1)+1]; 3198 3199 std::cout << std::setfill(' ') << std::setw( 15 ) 3200 << ui << std::setw( 15 ) 3201 << (UInt) curDir << std::setw( 15 ) 3202 << ((curDir & 1) ? curf.getRefIdx() : MIN_INT) << std::setw( 15 ) 3203 << ((curDir & 1) ? curf.getMv().getHor() : MIN_INT) << std::setw( 15 ) 3204 << ((curDir & 1) ? curf.getMv().getVer() : MIN_INT) << std::setw( 15 ); 3205 3206 if ( getSlice()->isInterB() ) 3207 { 3208 std::cout << ((curDir & 2) ? curf2.getRefIdx() : MIN_INT) << std::setw( 15 ) 3209 << ((curDir & 1) ? curf2.getMv().getHor() : MIN_INT) << std::setw( 15 ) 3210 << ((curDir & 1) ? curf2.getMv().getVer() : MIN_INT) << std::setw( 15 ); 3211 } 3212 std::cout << std::endl; 3213 } 3214 } 3215 #endif 3216 numValidMergeCand = iCount; 3217 assert(iCount == getSlice()->getMaxNumMergeCand()); 3218 } 3219 3220 3221 3222 /** Derive 3D merge candidates 3223 * \param uiAbsPartIdx 3224 * \param uiPUIdx 3225 * \param pcMvFieldNeighbours 3226 * \param puhInterDirNeighbours 3227 * \param pcMvFieldSP 3228 * \param puhInterDirNeighbours 3229 * \param numValidMergeCand 3230 */ 3231 Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours 3232 #if NH_3D_SPIVMP 3233 , TComMvField* pcMvFieldSP, UChar* puhInterDirSP 3234 #endif 3235 , Int& numValidMergeCand, Int mrgCandIdx 3236 ) 3237 { 3238 #if NH_3D_IV_MERGE 3239 TComMv cZeroMv; 3240 TComMvField tmpMV[2]; 3241 #endif 3242 3243 ////////////////////////////////// 3244 //////// GET DISPARITIES //////// 3245 ////////////////////////////////// 3246 #if NH_3D_IV_MERGE 3247 DisInfo cDisInfo = getDvInfo(uiAbsPartIdx); 3248 m_cDefaultDisInfo = cDisInfo; 3249 #elif NH_3D_VSP 3250 // for xAddVspCand() 3251 DisInfo cDisInfo = getDvInfo(uiAbsPartIdx); 3252 #endif 3253 3254 if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) 3255 { 3256 return; 3257 } 3258 numValidMergeCand = getSlice()->getMaxNumMergeCand(); 3259 ////////////////////////////////// 3260 //////// DERIVE LOCATIONS //////// 3261 ////////////////////////////////// 3262 // compute the location of the current PU 3263 Int xP, yP, nPSW, nPSH; 3264 this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); 3265 3266 Int iCount = 0; 3267 UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 3268 deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); 3269 deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); 3270 #if NH_3D_TEXT_MERGE 3271 Bool bMPIFlag = getSlice()->getMpiFlag(); 3272 Int tmpDir; 3273 #endif 3274 #if NH_3D_IV_MERGE || NH_3D_TEXT_MERGE 3275 Bool bIsDepth = getSlice()->getIsDepth(); 3276 #endif 3277 3278 #if NH_3D_IC 3279 Bool bICFlag = getICFlag(uiAbsPartIdx); 3280 #endif 3281 #if NH_3D_ARP 3282 Bool bARPFlag = getARPW(uiAbsPartIdx) > 0; 3283 #endif 3284 #if NH_3D_DBBP 3285 Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx); 3286 assert(bDBBPFlag == getDBBPFlag(0)); 3287 #endif 3288 3289 #if NH_3D_NBDV 3290 for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) 3291 { 3292 pcMFieldNeighbours[i<<1 ].getMv().setIDVFlag (false); 3293 pcMFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false); 3294 } 3295 #endif 3296 // init containers 3297 for (Int i = 0; i<MRG_IVSHIFT+1; i++) 3298 m_mergCands[i].init(); 3299 3300 m_numSpatialCands = 0; 3301 3302 ////////////////////////////////// 3303 ///////// GET VSP FLAGS ////////// 3304 ////////////////////////////////// 3305 //left 3306 UInt uiLeftPartIdx = 0; 3307 const TComDataCU* pcCULeft = 0; 3308 pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); 3309 3310 if (getAvailableFlagA1()) 3311 { 3312 m_mergCands[MRG_A1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands] 3313 #if NH_3D_VSP 3314 , (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0 3315 #if NH_3D_IC 3316 && !bICFlag 3317 #endif 3318 #if NH_3D_ARP 3319 && !bARPFlag 3320 #endif 3321 #if NH_3D_DBBP 3322 && !bDBBPFlag 3323 #endif 3324 ) 3325 #endif 3326 #if NH_3D_SPIVMP 3327 , false 3328 #endif 3329 ); 3330 m_numSpatialCands++; 3331 } 3332 3333 // above 3334 if (getAvailableFlagB1()) 3335 { 3336 m_mergCands[MRG_B1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands] 3337 #if NH_3D_VSP 3338 , false 3339 #endif 3340 #if NH_3D_SPIVMP 3341 , false 3342 #endif 3343 ); 3344 m_numSpatialCands++; 3345 } 3346 3347 // above right 3348 if (getAvailableFlagB0()) 3349 { 3350 m_mergCands[MRG_B0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands] 3351 #if NH_3D_VSP 3352 , false 3353 #endif 3354 #if NH_3D_SPIVMP 3355 , false 3356 #endif 3357 ); 3358 m_numSpatialCands++; 3359 } 3360 3361 // left bottom 3362 if (getAvailableFlagA0()) 3363 { 3364 m_mergCands[MRG_A0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands] 3365 #if NH_3D_VSP 3366 , false 3367 #endif 3368 #if NH_3D_SPIVMP 3369 , false 3370 #endif 3371 ); 3372 m_numSpatialCands++; 3373 } 3374 3375 // above left 3376 if (getAvailableFlagB2()) 3377 { 3378 m_mergCands[MRG_B2].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands] 3379 #if NH_3D_VSP 3380 , false 3381 #endif 3382 #if NH_3D_SPIVMP 3383 , false 3384 #endif 3385 ); 3386 m_numSpatialCands++; 3387 } 3388 3389 3390 #if NH_3D_TEXT_MERGE 3391 3392 ///////////////////////////////////////////// 3393 //////// TEXTURE MERGE CANDIDATE (T) //////// 3394 ///////////////////////////////////////////// 3395 3396 bMPIFlag &= (nPSW + nPSH > 12); 3397 if( bMPIFlag) 3398 { 3399 tmpMV[0].setMvField( cZeroMv, NOT_VALID ); 3400 tmpMV[1].setMvField( cZeroMv, NOT_VALID ); 3401 tmpDir = 0; 3402 3403 Bool bSPIVMPFlag = false; 3404 3405 TComPic * pcTexPic = m_pcSlice->getTexturePic(); 3406 #if H_3D_FCO 3407 if (pcTexPic && pcTexPic->getReconMark()) 3408 { 3409 #endif 3410 TComPicYuv* pcTexRec = pcTexPic->getPicYuvRec (); 3411 UInt uiPartAddr; 3412 Int iWidth, iHeight; 3413 Int iCurrPosX, iCurrPosY; 3414 3415 this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight ); 3416 pcTexRec->getTopLeftSamplePos( this->getCtuRsAddr(), this->getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY ); 3417 3418 Int iPUWidth, iPUHeight, iNumPart, iNumPartLine; 3419 this->getSPPara(iWidth, iHeight, iNumPart, iNumPartLine, iPUWidth, iPUHeight); 3420 3421 for (Int i=0; i<iNumPart; i++) 3422 { 3423 puhInterDirSP[i] = 0; 3424 pcMvFieldSP[2*i].getMv().set(0, 0); 3425 pcMvFieldSP[2*i+1].getMv().set(0, 0); 3426 pcMvFieldSP[2*i].setRefIdx(-1); 3427 pcMvFieldSP[2*i+1].setRefIdx(-1); 3428 } 3429 3430 Int iTexCUAddr; 3431 Int iTexAbsPartIdx; 3432 TComDataCU* pcTexCU; 3433 Int iPartition = 0; 3434 Int iInterDirSaved = 0; 3435 TComMvField cMvFieldSaved[2]; 3436 3437 Int iOffsetX = iPUWidth/2;; 3438 Int iOffsetY = iPUHeight/2; 3439 3440 Int iTexPosX, iTexPosY; 3441 #if NH_3D_INTEGER_MV_DEPTH 3442 const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); 3443 #endif 3444 Int iCenterPosX = iCurrPosX + ( ( iWidth / iPUWidth ) >> 1 ) * iPUWidth + ( iPUWidth >> 1 ); 3445 Int iCenterPosY = iCurrPosY + ( ( iHeight / iPUHeight ) >> 1 ) * iPUHeight + (iPUHeight >> 1); 3446 Int iTexCenterCUAddr, iTexCenterAbsPartIdx; 3447 3448 if(iWidth == iPUWidth && iHeight == iPUHeight) 3449 { 3450 iCenterPosX = iCurrPosX + (iWidth >> 1); 3451 iCenterPosY = iCurrPosY + (iHeight >> 1); 3452 } 3453 3454 // derivation of center motion parameters from the collocated texture CU 3455 3456 pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx ); 3457 TComDataCU* pcDefaultCU = pcTexPic->getCtu( iTexCenterCUAddr ); 3458 3459 if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA ) 3460 { 3461 for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) 3462 { 3463 RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); 3464 3465 TComMvField cDefaultMvField; 3466 pcDefaultCU->getMvField( pcDefaultCU, iTexCenterAbsPartIdx, eCurrRefPicList, cDefaultMvField ); 3467 Int iDefaultRefIdx = cDefaultMvField.getRefIdx(); 3468 if (iDefaultRefIdx >= 0) 3469 { 3470 Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eCurrRefPicList, iDefaultRefIdx); 3471 for (Int iRefPicList = 0; iRefPicList < m_pcSlice->getNumRefIdx( eCurrRefPicList ); iRefPicList++) 3472 { 3473 if (iDefaultRefPOC == m_pcSlice->getRefPOC(eCurrRefPicList, iRefPicList)) 3474 { 3475 bSPIVMPFlag = true; 3476 #if NH_3D_INTEGER_MV_DEPTH 3477 TComMv cMv = cDefaultMvField.getMv() + cMvRounding; 3478 cMv >>= 2; 3479 #else 3480 TComMv cMv = cDefaultMvField.getMv(); 3481 #endif 3482 cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ; 3483 break; 3484 } 3485 } 3486 } 3487 } 3488 } 3489 if ( bSPIVMPFlag == true ) 3490 { 3491 iInterDirSaved = (cMvFieldSaved[0].getRefIdx()!=-1 ? 1: 0) + (cMvFieldSaved[1].getRefIdx()!=-1 ? 2: 0); 3492 tmpDir = iInterDirSaved; 3493 tmpMV[0] = cMvFieldSaved[0]; 3494 tmpMV[1] = cMvFieldSaved[1]; 3495 } 3496 3497 if ( iInterDirSaved != 0 ) 3498 { 3499 for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iPUHeight) 3500 { 3501 for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iPUWidth) 3502 { 3503 iTexPosX = j + iOffsetX; 3504 iTexPosY = i + iOffsetY; 3505 pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx ); 3506 pcTexCU = pcTexPic->getCtu( iTexCUAddr ); 3507 3508 if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) ) 3509 { 3510 for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) 3511 { 3512 RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); 3513 TComMvField cTexMvField; 3514 pcTexCU->getMvField( pcTexCU, iTexAbsPartIdx, eCurrRefPicList, cTexMvField ); 3515 Int iValidDepRef = getPic()->isTextRefValid( eCurrRefPicList, cTexMvField.getRefIdx() ); 3516 if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) ) 3517 { 3518 #if NH_3D_INTEGER_MV_DEPTH 3519 TComMv cMv = cTexMvField.getMv() + cMvRounding; 3520 cMv >>=2; 3521 #else 3522 TComMv cMv = cTexMvField.getMv(); 3523 #endif 3524 pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef); 3525 } 3526 } 3527 } 3528 puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0); 3529 if (puhInterDirSP[iPartition] == 0) 3530 { 3531 if (iInterDirSaved != 0) 3532 { 3533 puhInterDirSP[iPartition] = iInterDirSaved; 3534 pcMvFieldSP[2*iPartition] = cMvFieldSaved[0]; 3535 pcMvFieldSP[2*iPartition + 1] = cMvFieldSaved[1]; 3536 } 3537 } 3538 3539 iPartition ++; 3540 } 3541 } 3542 } 3543 #if H_3D_FCO 3544 } 3545 #endif 3546 if( tmpDir != 0 ) 3547 { 3548 Int iCnloop = 0; 3549 for(iCnloop = 0; iCnloop < 2; iCnloop ++) 3550 { 3551 if ( !m_mergCands[MRG_A1+iCnloop].m_bAvailable ) // pruning to A1, B1 3552 { 3553 continue; 3554 } 3555 if (hasEqualMotion( tmpDir, tmpMV, m_mergCands[MRG_A1+iCnloop].m_uDir, m_mergCands[MRG_A1+iCnloop].m_cMvField ) ) 3556 { 3557 m_mergCands[MRG_A1+iCnloop].m_bAvailable = false; 3558 break; 3559 } 3560 } 3561 m_mergCands[MRG_T].setCand( tmpMV, tmpDir, false, bSPIVMPFlag); 3562 3563 if ( mrgCandIdx == iCount ) 3564 { 3565 return; 3566 } 3567 iCount ++; 3568 } 3569 } 3570 #endif 3571 3572 #if NH_3D_IV_MERGE 3573 ///////////////////////////////////////////////////////////////// 3574 //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC Candidates ///// 3575 ///////////////////////////////////////////////////////////////// 3576 3577 // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift }; 3578 // An enumerator would be appropriate here! 3579 TComMv ivCandMv [8]; 3580 Int ivCandRefIdx[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; 3581 3582 // { IvMC, IvDC, IvMCShift, IvDCShift }; 3583 Int ivCandDir [4] = {0, 0, 0, 0}; 3584 3585 Bool ivMvPredFlag = getSlice()->getIvMvPredFlag(); 3586 3587 ivMvPredFlag &= (nPSW + nPSH > 12); 3588 if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1) 3589 { 3590 #if NH_3D_IC 3591 getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag ); 3592 #else 3593 getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, false ); 3594 #endif 3595 } 3596 3597 /////////////////////////////////////////////// 3598 //////// INTER VIEW MOTION COMP(IvMC) ///////// 3599 /////////////////////////////////////////////// 3600 if( getSlice()->getIsDepth() ) 3601 { 3602 ivCandDir[1] = ivCandDir[2] = ivCandDir[3] = 0; 3603 } 3604 3605 if( ivCandDir[0] ) 3606 { 3607 tmpMV[0].setMvField( cZeroMv, NOT_VALID ); 3608 tmpMV[1].setMvField( cZeroMv, NOT_VALID ); 3609 3610 if( ( ivCandDir[0] & 1 ) == 1 ) 3611 { 3612 tmpMV[0].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] ); 3613 } 3614 if( ( ivCandDir[0] & 2 ) == 2 ) 3615 { 3616 tmpMV[1].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] ); 3617 } 3618 3619 Bool bRemoveSpa = false; //pruning 3620 3621 if (!bIsDepth) 3622 { 3623 for(Int i = 0; i < 2; i ++) 3624 { 3625 if ( !m_mergCands[MRG_A1 + i].m_bAvailable ) // pruning to A1, B1 3626 { 3627 continue; 3628 } 3629 if (hasEqualMotion(ivCandDir[0], tmpMV, m_mergCands[MRG_A1+i].m_uDir, m_mergCands[MRG_A1+i].m_cMvField) ) 3630 { 3631 m_mergCands[MRG_A1+i].m_bAvailable = false; 3632 break; 3633 } 3634 } 3635 } 3636 else 3637 { 3638 if( hasEqualMotion( ivCandDir[0], tmpMV, m_mergCands[MRG_T].m_uDir, m_mergCands[MRG_T].m_cMvField ) ) 3639 { 3640 bRemoveSpa = true; 3641 } 3642 } 3643 if (!bRemoveSpa) 3644 { 3645 Bool spiMvpFlag = false; 3646 if(!m_pcSlice->getIsDepth()) 3647 { 3648 spiMvpFlag = true; 3649 } 3650 #if NH_3D_DBBP 3651 spiMvpFlag &= !bDBBPFlag; 3652 #endif 3653 3654 m_mergCands[MRG_IVMC].setCand( tmpMV, ivCandDir[0], false, spiMvpFlag); 3655 3656 if ( mrgCandIdx == iCount ) 3657 { 3658 return; 3659 } 3660 iCount ++; 3661 } 3662 } 3663 3664 // early termination 3665 if (iCount == getSlice()->getMaxNumMergeCand()) 3666 { 3667 return; 3668 } 3669 #endif 3670 3671 iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable; 3672 3673 #if NH_3D_VSP 3674 ///////////////////////////////////////////////// 3675 //////// VIEW SYNTHESIS PREDICTION (VSP) //////// 3676 ///////////////////////////////////////////////// 3677 if (iCount<getSlice()->getMaxNumMergeCand()) 3678 { 3679 if ( 3680 (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) && 3681 #if NH_3D_IC 3682 !bICFlag && 3683 #endif 3684 #if NH_3D_ARP 3685 !bARPFlag && 3686 #endif 3687 #if NH_3D 3688 (nPSW + nPSH > 12) && 3689 #endif 3690 #if NH_3D_DBBP 3691 !bDBBPFlag && 3692 #endif 3693 xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) ) 3694 { 3695 return; 3696 } 3697 3698 // early termination 3699 if (iCount == getSlice()->getMaxNumMergeCand()) 3700 { 3701 return; 3702 } 3703 } 3704 #endif 3705 3706 iCount += m_mergCands[MRG_B0].m_bAvailable; 3707 3708 #if NH_3D_IV_MERGE 3709 ///////////////////////////////////////////// 3710 //////// INTER VIEW DISP COMP (IvDC) //////// 3711 ///////////////////////////////////////////// 3712 if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 3713 { 3714 assert(iCount < getSlice()->getMaxNumMergeCand()); 3715 3716 tmpMV[0].setMvField( cZeroMv, NOT_VALID ); 3717 tmpMV[1].setMvField( cZeroMv, NOT_VALID ); 3718 if( ( ivCandDir[1] & 1 ) == 1 ) 3719 { 3720 tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] ); 3721 } 3722 if( ( ivCandDir[1] & 2 ) == 2 ) 3723 { 3724 tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] ); 3725 } 3726 3727 Bool bRemoveSpa = false; //pruning to A1, B1 3728 for(Int i = 0; i < 2; i ++) 3729 { 3730 if ( !m_mergCands[MRG_A1+i].m_bAvailable ) 3731 { 3732 continue; 3733 } 3734 if ( hasEqualMotion(ivCandDir[1], tmpMV, m_mergCands[MRG_A1+i].m_uDir, m_mergCands[MRG_A1+i].m_cMvField) ) 3735 { 3736 bRemoveSpa = true; 3737 break; 3738 } 3739 } 3740 if(!bRemoveSpa) 3741 { 3742 #if NH_3D_NBDV 3743 tmpMV[0].getMv().setIDVFlag (false); 3744 tmpMV[1].getMv().setIDVFlag (false); 3745 #endif 3746 m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false); 3747 3748 if ( mrgCandIdx == iCount ) 3749 return; 3750 iCount ++; 3751 3752 // early termination 3753 if (iCount == getSlice()->getMaxNumMergeCand()) 3754 { 3755 return; 3756 } 3757 } 3758 } 3759 #endif // H_3D_IV_MERGE 3760 3761 iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable; 3762 3763 #if NH_3D_IV_MERGE 3764 //////////////////////////////////////////////////// 3765 //////// SHIFTED IV (IvMCShift + IvDCShift) //////// 3766 //////////////////////////////////////////////////// 3767 if( ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 3768 { 3769 if(xAddIvMRGCand( mrgCandIdx, iCount, ivCandDir, ivCandMv, ivCandRefIdx ) ) 3770 { 3771 return; 3772 } 3773 //early termination 3774 if (iCount == getSlice()->getMaxNumMergeCand()) 3775 { 3776 return; 3777 } 3778 } 3779 #endif 3780 } 3781 #endif 2220 2221 3782 2222 3783 2223 //! Construct a list of merging candidates 3784 #if NH_3D3785 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )3786 #else3787 2224 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) const 3788 #endif3789 2225 { 3790 2226 UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx; 3791 #if NH_3D_MLC3792 Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];3793 #else3794 2227 Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; 3795 #endif3796 2228 for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) 3797 2229 { … … 3823 2255 if ( isAvailableA1 ) 3824 2256 { 3825 #if NH_3D_MLC3826 m_bAvailableFlagA1 = 1;3827 #endif3828 2257 abCandIsInter[iCount] = true; 3829 2258 // get Inter Dir … … 3858 2287 if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) 3859 2288 { 3860 #if NH_3D_MLC3861 m_bAvailableFlagB1 = 1;3862 #endif3863 2289 abCandIsInter[iCount] = true; 3864 2290 // get Inter Dir … … 3892 2318 if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) 3893 2319 { 3894 #if NH_3D_MLC3895 m_bAvailableFlagB0 = 1;3896 #endif3897 2320 abCandIsInter[iCount] = true; 3898 2321 // get Inter Dir … … 3926 2349 if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) 3927 2350 { 3928 #if NH_3D_MLC3929 m_bAvailableFlagA0 = 1;3930 #endif3931 2351 abCandIsInter[iCount] = true; 3932 2352 // get Inter Dir … … 3963 2383 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) 3964 2384 { 3965 #if NH_3D_MLC3966 m_bAvailableFlagB2 = 1;3967 #endif3968 2385 abCandIsInter[iCount] = true; 3969 2386 // get Inter Dir … … 4047 2464 if ( getSlice()->isInterB() ) 4048 2465 { 4049 #if NH_3D_TMVP4050 iRefIdx = 0;4051 #endif4052 2466 bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx); 4053 2467 if( bExistMV == false ) … … 4066 2480 puhInterDirNeighbours[uiArrayAddr] = dir; 4067 2481 abCandIsInter[uiArrayAddr] = true; 4068 #if NH_3D_NBDV4069 pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false);4070 pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);4071 #endif4072 2482 4073 2483 if ( mrgCandIdx == iCount ) … … 4087 2497 UInt uiCutoff = uiArrayAddr; 4088 2498 4089 #if NH_3D_MLC4090 if ( getSlice()->isInterB() && iCount<5)4091 #else4092 2499 if ( getSlice()->isInterB() ) 4093 #endif4094 2500 { 4095 2501 static const UInt NUM_PRIORITY_LIST=12; … … 4334 2740 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 4335 2741 const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); 4336 #if NH_3D_TMVP4337 Int refIdx_Col = refIdx;4338 #else4339 2742 const Int refIdx_Col = refIdx; 4340 #endif4341 2743 TComMv cColMv; 4342 2744 UInt partIdxRB; … … 4372 2774 } 4373 2775 } 4374 #if NH_3D_TMVP4375 if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, absPartAddr, cColMv, refIdx_Col , 0 ) )4376 #else4377 2776 if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, absPartAddr, cColMv, refIdx_Col ) ) 4378 #endif4379 2777 { 4380 2778 pInfo->m_acMvCand[pInfo->iN++] = cColMv; … … 4384 2782 UInt uiPartIdxCenter; 4385 2783 xDeriveCenterIdx( partIdx, uiPartIdxCenter ); 4386 #if NH_3D_TMVP4387 if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter, cColMv, refIdx_Col , 0 ))4388 #else4389 2784 if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter, cColMv, refIdx_Col )) 4390 #endif4391 2785 { 4392 2786 pInfo->m_acMvCand[pInfo->iN++] = cColMv; … … 4411 2805 UInt partAddr; 4412 2806 4413 #if NH_3D_DBBP4414 if( getDBBPFlag(0) )4415 {4416 return true;4417 }4418 #endif4419 2807 4420 2808 getPartIndexAndSize( puIdx, partAddr, width, height ); … … 4431 2819 const TComSPS &sps=*(m_pcSlice->getSPS()); 4432 2820 Int iMvShift = 2; 4433 #if NH_3D_INTEGER_MV_DEPTH4434 if( getSlice()->getIsDepth() )4435 iMvShift = 0;4436 #endif4437 2821 4438 2822 Int iOffset = 8; … … 4663 3047 } 4664 3048 4665 #if NH_3D_TMVP4666 Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, Int& refIdx, Bool bMRG ) const4667 #else4668 3049 Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, const Int refIdx ) const 4669 #endif4670 3050 { 4671 3051 const UInt absPartAddr = partUnitIdx; … … 4698 3078 } 4699 3079 4700 #if NH_3D_TMVP4701 Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();4702 #else4703 3080 const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm(); 4704 #endif4705 3081 const Bool bIsColRefLongTerm = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); 4706 3082 4707 3083 if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) 4708 3084 { 4709 #if NH_3D_TMVP4710 Int iAlterRefIdx = m_pcSlice->getAlterRefIdx(eRefPicList);4711 if(bMRG && iAlterRefIdx > 0)4712 {4713 refIdx = iAlterRefIdx;4714 bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();4715 assert(bIsCurrRefLongTerm == bIsColRefLongTerm);4716 }4717 else4718 {4719 #endif4720 3085 return false; 4721 #if NH_3D_TMVP4722 }4723 #endif4724 3086 } 4725 3087 // Scale the vector. 4726 3088 const TComMv &cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr); 4727 3089 4728 #if NH_3D_TMVP4729 if ( bIsCurrRefLongTerm || bIsColRefLongTerm )4730 #else4731 3090 if ( bIsCurrRefLongTerm /*|| bIsColRefLongTerm*/ ) 4732 #endif 4733 { 4734 #if NH_3D_TMVP 4735 const Int iCurrViewId = m_pcSlice->getViewId (); 4736 const Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, refIdx)->getViewId (); 4737 const Int iColViewId = pColCtu->getSlice()->getViewId(); 4738 const Int iColRefViewId = pColCtu->getSlice()->getRefPic( eColRefPicList, pColCtu->getCUMvField(eColRefPicList)->getRefIdx(absPartAddr))->getViewId(); 4739 Int scale = 4096; 4740 if ( iCurrRefViewId != iCurrViewId && iColViewId != iColRefViewId ) 4741 { 4742 scale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId ); 4743 } 4744 if ( bMRG && scale != 4096 && m_pcSlice->getIvMvScalingFlag( ) ) 4745 { 4746 rcMv = cColMv.scaleMv( scale ); 4747 } 4748 else 4749 { 4750 #endif 3091 { 4751 3092 rcMv = cColMv; 4752 #if NH_3D_TMVP4753 }4754 #endif4755 3093 } 4756 3094 else … … 4807 3145 } 4808 3146 4809 #if NH_3D4810 Void TComDataCU::compressMV(Int scale)4811 {4812 Int scaleFactor = (4 / scale ) * AMVP_DECIMATION_FACTOR / m_unitSize;4813 #else4814 3147 Void TComDataCU::compressMV() 4815 3148 { 4816 3149 Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; 4817 #endif4818 3150 if (scaleFactor > 0) 4819 3151 { … … 4824 3156 } 4825 3157 } 4826 #if NH_3D4827 Void TComDataCU::printMV( )4828 {4829 4830 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)4831 {4832 std::cout << "L" << i;4833 m_acCUMvField[i].print(m_pePredMode);4834 }4835 4836 }4837 #endif4838 3158 4839 3159 UInt TComDataCU::getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const … … 4867 3187 4868 3188 UInt uiDirMode = getIntraDir(toChannelType(compID), uiAbsPartIdx); 4869 #if NH_3D_DMM4870 mapDmmToIntraDir( uiDirMode );4871 #endif4872 3189 4873 3190 if (uiDirMode==DM_CHROMA_IDX) … … 4876 3193 const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize())); 4877 3194 uiDirMode = getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, getPic()->getChromaFormat(), partsPerMinCU)); 4878 #if NH_3D_DMM4879 mapDmmToIntraDir( uiDirMode );4880 #endif4881 3195 } 4882 3196 … … 4902 3216 } 4903 3217 4904 #if NH_3D_VSO 4905 Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) const 4906 { 4907 riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX(); 4908 riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); 4909 } 4910 #endif 4911 4912 #if NH_3D_IV_MERGE 4913 Void TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp) 4914 { 4915 assert(getPartitionSize( uiPartAddr ) == SIZE_2Nx2N); 4916 4917 TComMv cMv; 4918 if ( getSlice()->getDefaultRefViewIdxAvailableFlag() ) 4919 { 4920 Int iViewIdx = getSlice()->getDefaultRefViewIdx(); 4921 pDisp->m_aVIdxCan = iViewIdx; 4922 Int iDisp = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 )) ]; 4923 4924 cMv.setHor(iDisp); 4925 cMv.setVer(0); 4926 pDisp->m_acNBDV = cMv; 4927 pDisp->m_aVIdxCan = iViewIdx; 4928 } 4929 } 4930 #endif 4931 4932 #if NH_3D_DIS 4933 Bool TComDataCU::getNeighDepth ( UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index ) 4934 { 4935 assert(uiPartIdx==0); 4936 const UInt uiPartIdxLT = getZorderIdxInCtu() + uiPartAddr; 4937 const Int iPartIdxStride = getPic()->getNumPartInCtuWidth(); 4938 4939 UInt uiMidPart, uiPartNeighbor; 4940 const TComDataCU* pcCUNeighbor; 4941 Bool bDepAvail = false; 4942 Pel *pDepth = this->getPic()->getPicYuvRec()->getAddr(COMPONENT_Y); 4943 Int iDepStride = this->getPic()->getPicYuvRec()->getStride(COMPONENT_Y); 4944 4945 Int xP, yP, nPSW, nPSH; 4946 this->getPartPosition( uiPartIdx, xP, yP, nPSW, nPSH ); 4947 4948 switch( index ) 4949 { 4950 case 0: // Mid Left 4951 uiMidPart = g_auiZscanToRaster[uiPartIdxLT] + (nPSH>>1) / this->getPic()->getMinCUHeight() * iPartIdxStride; 4952 pcCUNeighbor = this->getPULeft( uiPartNeighbor, g_auiRasterToZscan[uiMidPart] ); 4953 if ( pcCUNeighbor ) 4954 { 4955 if( !this->getSlice()->getPPS()->getConstrainedIntraPred() ) 4956 { 4957 *pNeighDepth = pDepth[ (yP+(nPSH>>1)) * iDepStride + (xP-1) ]; 4958 bDepAvail = true; 4959 } 4960 else if ( pcCUNeighbor->getPredictionMode( uiPartNeighbor ) == MODE_INTRA ) 4961 { 4962 *pNeighDepth = pDepth[ (yP+(nPSH>>1)) * iDepStride + (xP-1) ]; 4963 bDepAvail = true; 4964 } 4965 } 4966 break; 4967 case 1: // Mid Above 4968 uiMidPart = g_auiZscanToRaster[uiPartIdxLT] + (nPSW>>1) / this->getPic()->getMinCUWidth(); 4969 pcCUNeighbor = this->getPUAbove( uiPartNeighbor, g_auiRasterToZscan[uiMidPart] ); 4970 if( pcCUNeighbor ) 4971 { 4972 if( !this->getSlice()->getPPS()->getConstrainedIntraPred() ) 4973 { 4974 *pNeighDepth = pDepth[ (yP-1) * iDepStride + (xP + (nPSW>>1)) ]; 4975 bDepAvail = true; 4976 } 4977 else if ( pcCUNeighbor->getPredictionMode( uiPartNeighbor ) == MODE_INTRA ) 4978 { 4979 *pNeighDepth = pDepth[ (yP-1) * iDepStride + (xP + (nPSW>>1)) ]; 4980 bDepAvail = true; 4981 } 4982 } 4983 break; 4984 default: 4985 break; 4986 } 4987 4988 return bDepAvail; 4989 } 4990 #endif 4991 #if NH_3D_NBDV 4992 //Notes from QC: 4993 //TBD#1: DoNBDV related contributions are just partially integrated under the marco of NH_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done 4994 //TBD#2: set of DvMCP values need to be done as part of inter-view motion prediction process. Remove this comment once merge related integration is done 4995 //To be checked: Parallel Merge features for NBDV, related to DV_DERIVATION_PARALLEL_B0096 and LGE_IVMP_PARALLEL_MERGE_B0136 are not integrated. The need of these features due to the adoption of CU-based NBDV is not clear. We need confirmation on this, especially by proponents 4996 Void TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo 4997 #if NH_3D_NBDV_REF 4998 , Bool bDepthRefine 4999 #endif 5000 ) 5001 { 5002 //// ******* Init variables ******* ///// 5003 // Init disparity struct for results 5004 pDInfo->m_aVIdxCan = -1; 5005 5006 // Init struct for disparities from MCP neighboring blocks 5007 IDVInfo cIDVInfo; 5008 cIDVInfo.m_bFound = false; 5009 UInt uiPartIdx = 0; 5010 UInt uiPartAddr = 0; 5011 for (UInt iCurDvMcpCand = 0; iCurDvMcpCand < IDV_CANDS; iCurDvMcpCand++) 5012 { 5013 for (UInt iList = 0; iList < 2; iList++) 5014 { 5015 cIDVInfo.m_acMvCand[iList][iCurDvMcpCand].setZero(); 5016 cIDVInfo.m_aVIdxCan[iList][iCurDvMcpCand] = 0; 5017 cIDVInfo.m_bAvailab[iList][iCurDvMcpCand] = false; 5018 } 5019 } 5020 #if NH_3D_NBDV_REF 5021 if( !m_pcSlice->getDepthRefinementFlag( ) ) 5022 { 5023 bDepthRefine = false; 5024 } 5025 #endif 5026 // Get Positions 5027 PartSize eCUMode = getPartitionSize( uiPartAddr ); 5028 assert(eCUMode == SIZE_2Nx2N); 5029 UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 5030 5031 deriveLeftRightTopIdxGeneral(uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); 5032 deriveLeftBottomIdxGeneral (uiPartAddr, uiPartIdx, uiPartIdxLB ); 5033 5034 //// ******* Get disparity from temporal neighboring blocks ******* ///// 5035 if ( getSlice()->getEnableTMVPFlag() ) 5036 { 5037 TComMv cColMv; 5038 Int iTargetViewIdx = 0; 5039 Int iTStartViewIdx = 0; 5040 5041 ///*** Derive center position *** 5042 UInt uiPartIdxCenter; 5043 Int uiLCUIdx = getCtuRsAddr(); 5044 xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter ); 5045 5046 ///*** Search temporal candidate pictures for disparity vector *** 5047 const Int iNumCandPics = getPic()->getNumDdvCandPics(); 5048 for(Int curCandPic = 0; curCandPic < iNumCandPics; curCandPic++) 5049 { 5050 RefPicList eCurRefPicList = REF_PIC_LIST_0 ; 5051 Int curCandPicRefIdx = 0; 5052 if( curCandPic == 0 ) 5053 { 5054 eCurRefPicList = RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0); 5055 curCandPicRefIdx = getSlice()->getColRefIdx(); 5056 } 5057 else 5058 { 5059 eCurRefPicList = getPic()->getRapRefList(); 5060 curCandPicRefIdx = getPic()->getRapRefIdx(); 5061 } 5062 5063 Bool bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, uiLCUIdx, uiPartIdxCenter, cColMv, iTargetViewIdx, iTStartViewIdx ); 5064 5065 if( bCheck ) 5066 { 5067 pDInfo->m_acNBDV = cColMv; 5068 pDInfo->m_aVIdxCan = iTargetViewIdx; 5069 5070 #if NH_3D_NBDV_REF 5071 TComPic* picDepth = NULL; 5072 #if H_3D_FCO 5073 picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); 5074 if ( picDepth->getPicYuvRec() != NULL ) 5075 { 5076 cColMv.setZero(); 5077 } 5078 else // Go back with virtual depth 5079 { 5080 picDepth = getSlice()->getIvPic( true, iTargetViewIdx ); 5081 } 5082 5083 assert(picDepth != NULL); 5084 #else 5085 picDepth = getSlice()->getIvPic( true, iTargetViewIdx ); 5086 #endif 5087 if (picDepth && bDepthRefine) 5088 { 5089 estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv ); 5090 } 5091 pDInfo->m_acDoNBDV = cColMv; 5092 #endif //NH_3D_NBDV_REF 5093 return; 5094 } 5095 } 5096 } 5097 5098 UInt uiIdx = 0; 5099 Bool bCheckMcpDv = false; 5100 const TComDataCU* pcTmpCU = NULL; 5101 5102 //// ******* Get disparity from left block ******* ///// 5103 #if NH_3D_FIX_TICKET_91 5104 pcTmpCU = getPULeft(uiIdx, uiPartIdxLB); 5105 #else 5106 pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false); 5107 #endif 5108 bCheckMcpDv = true; 5109 if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT 5110 #if NH_3D_NBDV_REF 5111 , bDepthRefine 5112 #endif 5113 ) ) 5114 return; 5115 5116 //// ******* Get disparity from above block ******* ///// 5117 pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true); 5118 if(pcTmpCU != NULL ) 5119 { 5120 bCheckMcpDv = ( ( getCtuRsAddr() - pcTmpCU->getCtuRsAddr() ) == 0); 5121 if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE 5122 #if NH_3D_NBDV_REF 5123 , bDepthRefine 5124 #endif 5125 ) ) 5126 return; 5127 } 5128 5129 //// ******* Search MCP blocks ******* ///// 5130 if( cIDVInfo.m_bFound ) 5131 { 5132 for( Int curPos = 0 ; curPos < IDV_CANDS ; curPos++ ) 5133 { 5134 for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) 5135 { 5136 if( cIDVInfo.m_bAvailab[iList][curPos] ) 5137 { 5138 TComMv cDispVec = cIDVInfo.m_acMvCand[iList][ curPos ]; 5139 pDInfo->m_acNBDV = cDispVec; 5140 pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ]; 5141 #if NH_3D_NBDV_REF 5142 #if H_3D_FCO 5143 TComPic* picDepth = NULL; 5144 5145 picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); 5146 if ( picDepth->getPicYuvRec() != NULL ) 5147 { 5148 cDispVec.setZero(); 5149 } 5150 else // Go back with virtual depth 5151 { 5152 picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan ); 5153 } 5154 5155 assert(picDepth != NULL); 5156 #else 5157 TComPic* picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan ); 5158 #endif 5159 5160 if (picDepth && bDepthRefine) 5161 { 5162 estimateDVFromDM (pDInfo->m_aVIdxCan, uiPartIdx, picDepth, uiPartAddr, &cDispVec); 5163 } 5164 pDInfo->m_acDoNBDV = cDispVec; 5165 #endif 5166 return; 5167 } 5168 } 5169 } 5170 } 5171 5172 TComMv defaultDV(0, 0); 5173 pDInfo->m_acNBDV = defaultDV; 5174 5175 if (getSlice()->getDefaultRefViewIdxAvailableFlag()) 5176 { 5177 pDInfo->m_aVIdxCan = getSlice()->getDefaultRefViewIdx(); 5178 5179 #if NH_3D_NBDV_REF 5180 TComPic* picDepth = NULL; 5181 #if H_3D_FCO 5182 picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); 5183 if ( picDepth->getPicYuvRec() != NULL ) 5184 { 5185 defaultDV.setZero(); 5186 } 5187 else // Go back with virtual depth 5188 { 5189 picDepth = getSlice()->getIvPic( true, getSlice()->getDefaultRefViewIdx()); 5190 } 5191 5192 assert(picDepth != NULL); 5193 #else 5194 picDepth = getSlice()->getIvPic( true, getSlice()->getDefaultRefViewIdx()); 5195 #endif 5196 if (picDepth && bDepthRefine) 5197 { 5198 estimateDVFromDM(getSlice()->getDefaultRefViewIdx(), uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view 5199 } 5200 pDInfo->m_acDoNBDV = defaultDV; 5201 #endif 5202 } 5203 } 5204 5205 #if NH_3D_NBDV_REF 5206 Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT ) 5207 { 5208 Int iPictureWidth = pcBaseViewDepthPicYuv->getWidth(COMPONENT_Y); 5209 Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(COMPONENT_Y); 5210 5211 Int depthStartPosX = Clip3(0, iPictureWidth - 1, iBlkX + ((mv->getHor()+2)>>2)); 5212 Int depthStartPosY = Clip3(0, iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2)); 5213 Int depthEndPosX = Clip3(0, iPictureWidth - 1, iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2)); 5214 Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2)); 5215 5216 Pel* depthTL = pcBaseViewDepthPicYuv->getAddr(COMPONENT_Y); 5217 Int depStride = pcBaseViewDepthPicYuv->getStride(COMPONENT_Y); 5218 5219 Pel maxDepthVal = 0; 5220 maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthStartPosX ]); // Left Top 5221 maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthStartPosX ]); // Left Bottom 5222 maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthEndPosX ]); // Right Top 5223 maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthEndPosX ]); // Right Bottom 5224 5225 return aiShiftLUT[ maxDepthVal ]; 5226 } 5227 5228 Void TComDataCU::estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred ) 5229 { 5230 if (picDepth) 5231 { 5232 UInt uiAbsPartAddrCurrCU = m_absZIdxInCtu + uiPartAddr; 5233 Int iWidth, iHeight; 5234 getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more 5235 5236 TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec(); 5237 const TComSPS &sps =*(getSlice()->getSPS()); 5238 Int iBlkX = ( getCtuRsAddr() % picDepth->getFrameWidthInCtus() ) * sps.getMaxCUWidth() + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; 5239 Int iBlkY = ( getCtuRsAddr() / picDepth->getFrameWidthInCtus() ) * sps.getMaxCUHeight() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; 5240 5241 Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx ); 5242 5243 Pel iDisp = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT ); 5244 cMvPred->setHor( iDisp ); 5245 } 5246 } 5247 #endif //NH_3D_NBDV_REF 5248 5249 5250 Bool TComDataCU::xCheckSpatialNBDV( const TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos 5251 #if NH_3D_NBDV_REF 5252 , Bool bDepthRefine 5253 #endif 5254 ) 5255 { 5256 if( pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) ) 5257 { 5258 Bool bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); 5259 for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) 5260 { 5261 RefPicList eRefPicList = RefPicList(iList); 5262 Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; 5263 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 5264 5265 if( refId >= 0) 5266 { 5267 Int refViewIdx = pcTmpCU->getSlice()->getRefPic(eRefPicList, refId)->getViewIndex(); 5268 if (refViewIdx != m_pcSlice->getViewIndex()) 5269 { 5270 pNbDvInfo->m_acNBDV = cMvPred; 5271 pNbDvInfo->m_aVIdxCan = refViewIdx; 5272 #if NH_3D_NBDV_REF 5273 TComPic* picDepth = NULL; 5274 assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC()); 5275 #if H_3D_FCO 5276 picDepth = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); 5277 if ( picDepth->getPicYuvRec() != NULL ) 5278 { 5279 cMvPred.setZero(); 5280 } 5281 else// Go back with virtual depth 5282 { 5283 picDepth = getSlice()->getIvPic (true, refViewIdx ); 5284 } 5285 assert(picDepth != NULL); 5286 #else 5287 picDepth = getSlice()->getIvPic (true, refViewIdx ); 5288 #endif 5289 UInt uiPartIdx = 0; //Notes from MTK: Please confirm that using 0 as partition index and partition address is correct for CU-level DoNBDV 5290 UInt uiPartAddr = 0; //QC: confirmed 5291 5292 if (picDepth && bDepthRefine) 5293 { 5294 estimateDVFromDM(refViewIdx, uiPartIdx, picDepth, uiPartAddr, &cMvPred ); 5295 } 5296 pNbDvInfo->m_acDoNBDV = cMvPred; 5297 #endif 5298 return true; 5299 } 5300 else if ( bSearchForMvpDv && cMvPred.getIDVFlag() && bTmpIsSkipped ) 5301 { 5302 assert( uiMvpDvPos < IDV_CANDS ); 5303 paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() ); 5304 //Notes from QC: DvMCP is implemented in a way that doesnot carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design. 5305 paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = cMvPred.getIDVVId(); 5306 paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true; 5307 paIDVInfo->m_bFound = true; 5308 } 5309 } 5310 } 5311 } 5312 return false; 5313 } 5314 5315 Void TComDataCU::xDeriveRightBottomNbIdx(Int &riLCUIdxRBNb, Int &riPartIdxRBNb ) 5316 { 5317 UInt uiPartIdx = 0; 5318 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInCtuWidth(); 5319 Int uiLCUIdx = getCtuRsAddr(); 5320 5321 UInt uiPartIdxRB; 5322 deriveRightBottomIdx(uiPartIdx, uiPartIdxRB ); 5323 UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; 5324 5325 if (( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) 5326 { 5327 riLCUIdxRBNb = -1; 5328 riPartIdxRBNb = -1; 5329 } 5330 else if(( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 5331 { 5332 riLCUIdxRBNb = -1; 5333 riPartIdxRBNb = -1; 5334 } 5335 else 5336 { 5337 if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU 5338 ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) ) // is not at the last row of LCU 5339 { 5340 riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; 5341 riLCUIdxRBNb = uiLCUIdx; 5342 } 5343 else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU 5344 { 5345 riPartIdxRBNb = -1; 5346 riLCUIdxRBNb = -1; 5347 } 5348 else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) // is not at the last row of LCU But is last column of LCU 5349 { 5350 riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; 5351 riLCUIdxRBNb = uiLCUIdx + 1; 5352 } 5353 else //is the right bottom corner of LCU 5354 { 5355 riPartIdxRBNb = -1; 5356 riLCUIdxRBNb = -1; 5357 } 5358 } 5359 } 5360 5361 5362 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth ) 5363 { 5364 #if NH_3D_VSP // bug fix 5365 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 5366 assert(m_pcPic->getNumPartitionsInCtu() ==m_pcPic->getNumPartInCtuWidth()*m_pcPic->getNumPartInCtuHeight()); 5367 5368 #else 5369 UInt uiCurrPartNumb = m_pcPic->getNumPartInCtuWidth() >> (uiDepth << 1); 5370 #endif 5371 for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) 5372 { 5373 m_pDvInfo[uiAbsPartIdx + ui] = cDvInfo; 5374 } 5375 } 5376 #if NH_3D_VSP || NH_3D_DBBP 5377 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth ) 5378 { 5379 setSubPartT<DisInfo>( cDvInfo, m_pDvInfo, uiAbsPartIdx, uiDepth, uiPUIdx ); 5380 } 5381 #endif 5382 5383 Bool TComDataCU::xGetColDisMV( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx ) 5384 { 5385 5386 RefPicList eColRefPicList = REF_PIC_LIST_0; 5387 Int iColViewIdx, iColRefViewIdx; 5388 TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx); 5389 TComDataCU *pColCU = pColPic->getCtu( uiCUAddr ); 5390 iColViewIdx = pColCU->getSlice()->getViewIndex(); 5391 if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES||pColCU->isIntra(uiPartUnitIdx)) 5392 { 5393 return false; 5394 } 5395 for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++) 5396 { 5397 if(pColCU->getSlice()->isInterB()) 5398 { 5399 eColRefPicList = RefPicList(ilist); 5400 } 5401 5402 Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartUnitIdx); 5403 5404 if (iColRefIdx < 0) 5405 { 5406 continue; 5407 } 5408 5409 // The picture pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx) might not be in DPB anymore 5410 // So don't access it directly. 5411 iColRefViewIdx = pColCU->getSlice()->getVPS()->getViewOrderIdx( pColCU->getSlice()->getRefLayerId( eColRefPicList, iColRefIdx ) ); 5412 5413 5414 if ( iColViewIdx == iColRefViewIdx ) // temporal vector 5415 { 5416 continue; 5417 } 5418 else 5419 { 5420 if(getPic()->isTempIVRefValid(currCandPic, ilist, iColRefIdx)) 5421 { 5422 rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx); 5423 rcMv.setIDVFlag(0); 5424 iTargetViewIdx = iColRefViewIdx ; 5425 iStartViewIdx = iColViewIdx ; 5426 return true; 5427 } 5428 } 5429 } 5430 5431 return false; 5432 } 5433 #endif 5434 #if NH_3D_FAST_TEXTURE_ENCODING 5435 Void 5436 TComDataCU::getIVNStatus ( UInt uiPartIdx, DisInfo* pDInfo, Bool& bIVFMerge, Int& iIVFMaxD) 5437 { 5438 TComSlice* pcSlice = getSlice (); 5439 Int iViewIndex = pDInfo->m_aVIdxCan; 5440 //--- get base CU/PU and check prediction mode --- 5441 TComPic* pcBasePic = pcSlice->getIvPic( false, iViewIndex ); 5442 TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); 5443 5444 UInt uiPartAddr; 5445 Int iWidth; 5446 Int iHeight; 5447 getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); 5448 5449 Int iCurrPosX, iCurrPosY; 5450 pcBaseRec->getTopLeftSamplePos( this->getCtuRsAddr(), this->getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY ); 5451 5452 iCurrPosX += ( ( iWidth - 1 ) >> 1 ); 5453 iCurrPosY += ( ( iHeight - 1 ) >> 1 ); 5454 5455 Bool depthRefineFlag = false; 5456 #if NH_3D_NBDV_REF 5457 depthRefineFlag = m_pcSlice->getDepthRefinementFlag( ); 5458 #endif // NH_3D_NBDV_REF 5459 5460 TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; 5461 if( depthRefineFlag ) 5462 { 5463 cDv.setVer(0); 5464 } 5465 5466 Int iBasePosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); 5467 Int iBasePosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); 5468 Int iBaseLPosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX - (iWidth >> 1) + ( (cDv.getHor() + 2 ) >> 2 ) ); 5469 Int iBaseLPosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); 5470 Int iBaseRPosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + (iWidth >> 1) + 1 + ( (cDv.getHor() + 2 ) >> 2 ) ); 5471 Int iBaseRPosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); 5472 Int iBaseUPosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); 5473 Int iBaseUPosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY - (iHeight >> 1) + ( (cDv.getVer() + 2 ) >> 2 )); 5474 Int iBaseDPosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); 5475 Int iBaseDPosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + (iHeight >> 1) + 1 + ( (cDv.getVer() + 2 ) >> 2 )); 5476 5477 Int iBaseCUAddr; 5478 Int iBaseAbsPartIdx; 5479 Int iBaseLCUAddr; 5480 Int iBaseLAbsPartIdx; 5481 Int iBaseRCUAddr; 5482 Int iBaseRAbsPartIdx; 5483 Int iBaseUCUAddr; 5484 Int iBaseUAbsPartIdx; 5485 Int iBaseDCUAddr; 5486 Int iBaseDAbsPartIdx; 5487 pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); 5488 pcBaseRec->getCUAddrAndPartIdx( iBaseLPosX , iBaseLPosY , iBaseLCUAddr, iBaseLAbsPartIdx ); 5489 pcBaseRec->getCUAddrAndPartIdx( iBaseRPosX , iBaseRPosY , iBaseRCUAddr, iBaseRAbsPartIdx ); 5490 pcBaseRec->getCUAddrAndPartIdx( iBaseUPosX , iBaseUPosY , iBaseUCUAddr, iBaseUAbsPartIdx ); 5491 pcBaseRec->getCUAddrAndPartIdx( iBaseDPosX , iBaseDPosY , iBaseDCUAddr, iBaseDAbsPartIdx ); 5492 TComDataCU* pcBaseCU = pcBasePic->getCtu( iBaseCUAddr ); 5493 TComDataCU* pcBaseLCU = pcBasePic->getCtu( iBaseLCUAddr ); 5494 TComDataCU* pcBaseRCU = pcBasePic->getCtu( iBaseRCUAddr ); 5495 TComDataCU* pcBaseUCU = pcBasePic->getCtu( iBaseUCUAddr ); 5496 TComDataCU* pcBaseDCU = pcBasePic->getCtu( iBaseDCUAddr ); 5497 bIVFMerge = pcBaseLCU->getMergeFlag( iBaseLAbsPartIdx ) && pcBaseCU->getMergeFlag( iBaseAbsPartIdx ) && pcBaseRCU->getMergeFlag( iBaseRAbsPartIdx ) && pcBaseUCU->getMergeFlag( iBaseUAbsPartIdx ) && pcBaseDCU->getMergeFlag( iBaseDAbsPartIdx ); 5498 Int aiDepthL[5]; //depth level 5499 aiDepthL[0] = pcBaseCU->getDepth(iBaseAbsPartIdx); 5500 aiDepthL[1] = pcBaseLCU->getDepth(iBaseLAbsPartIdx); 5501 aiDepthL[2] = pcBaseRCU->getDepth(iBaseRAbsPartIdx); 5502 aiDepthL[3] = pcBaseUCU->getDepth(iBaseUAbsPartIdx); 5503 aiDepthL[4] = pcBaseDCU->getDepth(iBaseDAbsPartIdx); 5504 for (Int i = 0; i < 5; i++) 5505 { 5506 if (iIVFMaxD < aiDepthL[i]) 5507 iIVFMaxD = aiDepthL[i]; 5508 } 5509 } 5510 #endif 5511 5512 #if NH_3D_SPIVMP 5513 Void TComDataCU::getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight) 5514 { 5515 Int iSubPUSize = ( getSlice()->getIsDepth() ? getSlice()->getMpiSubPbSize() : getSlice()->getSubPbSize() ); 5516 5517 iNumSPInOneLine = iPUWidth/iSubPUSize; 5518 Int iNumSPInOneColumn = iPUHeight/iSubPUSize; 5519 iNumSPInOneLine = (iPUHeight % iSubPUSize != 0 || iPUWidth % iSubPUSize != 0 ) ? 1 : iNumSPInOneLine; 5520 iNumSPInOneColumn = (iPUHeight % iSubPUSize != 0 || iPUWidth % iSubPUSize != 0 ) ? 1 : iNumSPInOneColumn; 5521 iNumSP = iNumSPInOneLine * iNumSPInOneColumn; 5522 5523 iSPWidth = iNumSPInOneLine == 1 ? iPUWidth: iSubPUSize; 5524 iSPHeight = iNumSPInOneColumn == 1 ? iPUHeight: iSubPUSize; 5525 } 5526 5527 Void TComDataCU::getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr ) 5528 { 5529 uiBaseAbsPartIdx += m_absZIdxInCtu; 5530 Int iBasePelX = g_auiRasterToPelX[g_auiZscanToRaster[uiBaseAbsPartIdx]]; 5531 Int iBasePelY = g_auiRasterToPelY[g_auiZscanToRaster[uiBaseAbsPartIdx]]; 5532 Int iCurrPelX = iBasePelX + iPartIdx%iNumPartLine * iWidth; 5533 Int iCurrPelY = iBasePelY + iPartIdx/iNumPartLine * iHeight; 5534 Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + iCurrPelX/getPic()->getMinCUWidth(); 5535 ruiPartAddr = g_auiRasterToZscan[iCurrRaster]; 5536 ruiPartAddr -= m_absZIdxInCtu; 5537 } 5538 5539 Void TComDataCU::setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight ) 5540 { 5541 uiAbsPartIdx += getZorderIdxInCtu(); 5542 Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]]; 5543 Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]]; 5544 Int iEndPelX = iStartPelX + iWidth; 5545 Int iEndPelY = iStartPelY + iHeight; 5546 5547 Int iCurrRaster, uiPartAddr; 5548 5549 for (Int i=iStartPelY; i<iEndPelY; i+=getPic()->getMinCUHeight()) 5550 { 5551 for (Int j=iStartPelX; j < iEndPelX; j += getPic()->getMinCUWidth()) 5552 { 5553 iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + j/getPic()->getMinCUWidth(); 5554 uiPartAddr = g_auiRasterToZscan[iCurrRaster]; 5555 uiPartAddr -= getZorderIdxInCtu(); 5556 5557 m_puhInterDir[uiPartAddr] = uiDir; 5558 } 5559 } 5560 } 5561 #endif 5562 5563 #if NH_3D_IV_MERGE 5564 Bool 5565 TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc , Bool bIsDepth 5566 #if NH_3D_SPIVMP 5567 , TComMvField* pcMvFieldSP, UChar* puhInterDirSP 5568 #endif 5569 , Bool bICFlag 5570 ) 5571 { 5572 TComSlice* pcSlice = getSlice (); 5573 Int iViewIndex = pDInfo->m_aVIdxCan; 5574 5575 //--- get base CU/PU and check prediction mode --- 5576 TComPic* pcBasePic = pcSlice->getIvPic( bIsDepth, iViewIndex ); 5577 TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); 5578 5579 UInt uiPartAddr; 5580 Int iWidth; 5581 Int iHeight; 5582 getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); 5583 5584 Int iCurrPosX, iCurrPosY; 5585 pcBaseRec->getTopLeftSamplePos( getCtuRsAddr(), getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY ); 5586 5587 #if !NH_3D_SPIVMP 5588 iCurrPosX += ( iWidth >> 1 ); 5589 iCurrPosY += ( iHeight >> 1 ); 5590 #endif 5591 5592 Bool depthRefineFlag = false; 5593 #if NH_3D_NBDV_REF 5594 depthRefineFlag = m_pcSlice->getDepthRefinementFlag( ); 5595 #endif // NH_3D_NBDV_REF 5596 5597 TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; 5598 if( depthRefineFlag ) 5599 { 5600 cDv.setVer(0); 5601 } 5602 5603 Bool abPdmAvailable[8] = {false, false, false, false, false, false, false, false}; 5604 #if NH_3D_NBDV 5605 for( Int i = 0; i < 8; i++) 5606 { 5607 pacPdmMv[i].setIDVFlag (false); 5608 } 5609 #endif 5610 5611 if(!bICFlag) 5612 { 5613 5614 #if NH_3D_SPIVMP 5615 //////////////////////////////// 5616 //////////sub-PU IvMC/////////// 5617 //////////////////////////////// 5618 if(!m_pcSlice->getIsDepth()) 5619 { 5620 #if NH_3D_DBBP 5621 if (!getDBBPFlag(0)) 5622 #else 5623 if (1) 5624 #endif 5625 { 5626 Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; 5627 getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); 5628 5629 for (Int i=0; i<iNumSP; i++) 5630 { 5631 puhInterDirSP[i] = 0; 5632 pcMvFieldSP[2*i].getMv().set(0, 0); 5633 pcMvFieldSP[2*i+1].getMv().set(0,0); 5634 pcMvFieldSP[2*i].setRefIdx(-1); 5635 pcMvFieldSP[2*i+1].setRefIdx(-1); 5636 } 5637 5638 Int iBaseCUAddr; 5639 Int iBaseAbsPartIdx; 5640 TComDataCU* pcBaseCU; 5641 Int iPartition = 0; 5642 5643 Int iDelX = iSPWidth/2; 5644 Int iDelY = iSPHeight/2; 5645 5646 Int iCenterPosX = iCurrPosX + ( ( iWidth / iSPWidth ) >> 1 ) * iSPWidth + ( iSPWidth >> 1 ); 5647 Int iCenterPosY = iCurrPosY + ( ( iHeight / iSPHeight ) >> 1 ) * iSPHeight + (iSPHeight >> 1); 5648 Int iRefCenterCUAddr, iRefCenterAbsPartIdx; 5649 5650 if(iWidth == iSPWidth && iHeight == iSPHeight) 5651 { 5652 iCenterPosX = iCurrPosX + (iWidth >> 1); 5653 iCenterPosY = iCurrPosY + (iHeight >> 1); 5654 } 5655 5656 Int iRefCenterPosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); 5657 Int iRefCenterPosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) ); 5658 5659 pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx ); 5660 TComDataCU* pcDefaultCU = pcBasePic->getCtu( iRefCenterCUAddr ); 5661 if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA )) 5662 { 5663 for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) 5664 { 5665 RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); 5666 Bool stopLoop = false; 5667 for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop) 5668 { 5669 RefPicList eDefaultRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); 5670 TComMvField cDefaultMvField; 5671 pcDefaultCU->getMvField( pcDefaultCU, iRefCenterAbsPartIdx, eDefaultRefPicList, cDefaultMvField ); 5672 Int iDefaultRefIdx = cDefaultMvField.getRefIdx(); 5673 if (iDefaultRefIdx >= 0) 5674 { 5675 Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eDefaultRefPicList, iDefaultRefIdx); 5676 if (iDefaultRefPOC != pcSlice->getPOC()) 5677 { 5678 for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) 5679 { 5680 if (iDefaultRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) 5681 { 5682 abPdmAvailable[ uiCurrRefListId ] = true; 5683 TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer()); 5684 #if NH_3D_NBDV 5685 #if NH_3D_IV_MERGE 5686 if( !bIsDepth ) 5687 { 5688 #endif 5689 cMv.setIDVFlag (true); 5690 cMv.setIDVHor (cDv.getHor()); 5691 cMv.setIDVVer (cDv.getVer()); 5692 cMv.setIDVVId (iViewIndex); 5693 #if NH_3D_IV_MERGE 5694 } 5695 #endif 5696 #endif 5697 paiPdmRefIdx [ uiCurrRefListId ] = iPdmRefIdx; 5698 pacPdmMv [ uiCurrRefListId ] = cMv; 5699 stopLoop = true; 5700 break; 5701 } 5702 } 5703 } 5704 } 5705 } 5706 } 5707 } 5708 availableMcDc[0] = ( abPdmAvailable[0]? 1 : 0) + (abPdmAvailable[1]? 2 : 0); 5709 5710 if(availableMcDc[0]) 5711 { 5712 5713 Int iBasePosX, iBasePosY; 5714 for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iSPHeight) 5715 { 5716 for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth) 5717 { 5718 iBasePosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 )); 5719 iBasePosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 )); 5720 5721 pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx ); 5722 pcBaseCU = pcBasePic->getCtu( iBaseCUAddr ); 5723 if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) 5724 { 5725 for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) 5726 { 5727 RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); 5728 Bool bLoopStop = false; 5729 for(Int iLoop = 0; iLoop < 2 && !bLoopStop; ++iLoop) 5730 { 5731 RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); 5732 TComMvField cBaseMvField; 5733 pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); 5734 Int iBaseRefIdx = cBaseMvField.getRefIdx(); 5735 if (iBaseRefIdx >= 0) 5736 { 5737 Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx); 5738 if (iBaseRefPOC != pcSlice->getPOC()) 5739 { 5740 for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) 5741 { 5742 if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) 5743 { 5744 abPdmAvailable[ uiCurrRefListId ] = true; 5745 TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); 5746 5747 if( !bIsDepth ) 5748 { 5749 cMv.setIDVFlag (true); 5750 cMv.setIDVHor (cDv.getHor()); 5751 cMv.setIDVVer (cDv.getVer()); 5752 cMv.setIDVVId (iViewIndex); 5753 } 5754 5755 bLoopStop = true; 5756 5757 pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iPdmRefIdx); 5758 break; 5759 } 5760 } 5761 } 5762 } 5763 } 5764 } 5765 } 5766 5767 puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0); 5768 if (puhInterDirSP[iPartition] == 0) 5769 { 5770 puhInterDirSP[iPartition] = availableMcDc[0]; 5771 pcMvFieldSP[2*iPartition].setMvField(pacPdmMv[0], paiPdmRefIdx[0]); 5772 pcMvFieldSP[2*iPartition + 1].setMvField(pacPdmMv[1], paiPdmRefIdx[1]); 5773 5774 } 5775 iPartition ++; 5776 } 5777 } 5778 } 5779 } 5780 5781 iCurrPosX += ( iWidth >> 1 ); 5782 iCurrPosY += ( iHeight >> 1 ); 5783 } 5784 #endif 5785 5786 //////////////////////////////// 5787 /////// IvMC + IvMCShift /////// 5788 //////////////////////////////// 5789 5790 #if NH_3D_SPIVMP 5791 if(m_pcSlice->getIsDepth()) 5792 { 5793 iCurrPosX += ( iWidth >> 1 ); 5794 iCurrPosY += ( iHeight >> 1 ); 5795 } 5796 #if NH_3D_DBBP 5797 for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 5798 #else 5799 for(Int iLoopCan = ( m_pcSlice->getIsDepth() ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 5800 #endif 5801 #else 5802 for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) 5803 #endif 5804 { 5805 // iLoopCan == 0 --> IvMC 5806 // iLoopCan == 1 --> IvMCShift 5807 5808 Int iBaseCUAddr; 5809 Int iBaseAbsPartIdx; 5810 5811 Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth * 2); 5812 Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2); 5813 5814 Int iBasePosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) ); 5815 Int iBasePosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); 5816 pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); 5817 5818 TComDataCU* pcBaseCU = pcBasePic->getCtu( iBaseCUAddr ); 5819 if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) 5820 { 5821 // Loop reference picture list of current slice (X in spec). 5822 for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) 5823 { 5824 RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); 5825 5826 Bool stopLoop = false; 5827 // Loop reference picture list of candidate slice (Y in spec) 5828 for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop) 5829 { 5830 RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); 5831 TComMvField cBaseMvField; 5832 pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); 5833 Int iBaseRefIdx = cBaseMvField.getRefIdx(); 5834 if (iBaseRefIdx >= 0) 5835 { 5836 Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx); 5837 if (iBaseRefPOC != pcSlice->getPOC()) 5838 { 5839 for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) 5840 { 5841 if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) 5842 { 5843 abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true; 5844 TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); 5845 #if NH_3D_NBDV 5846 #if NH_3D_IV_MERGE 5847 if( !bIsDepth ) 5848 { 5849 #endif 5850 cMv.setIDVFlag (true); 5851 cMv.setIDVHor (cDv.getHor()); 5852 cMv.setIDVVer (cDv.getVer()); 5853 cMv.setIDVVId (iViewIndex); 5854 #if NH_3D_IV_MERGE 5855 } 5856 #endif 5857 #endif 5858 paiPdmRefIdx [ (uiCurrRefListId + (iLoopCan<<2)) ] = iPdmRefIdx; 5859 pacPdmMv [ (uiCurrRefListId + (iLoopCan<<2)) ] = cMv; 5860 stopLoop = true; 5861 break; 5862 } 5863 } 5864 } 5865 } 5866 } 5867 } 5868 } 5869 } 5870 #if NH_3D_SPIVMP 5871 #if NH_3D_DBBP 5872 for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 5873 #else 5874 for(Int iLoopCan = ( m_pcSlice->getIsDepth() ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 5875 #endif 5876 #else 5877 for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) 5878 #endif 5879 { 5880 availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0); 5881 } 5882 5883 } 5884 5885 //////////////////////////////// 5886 /////// IvDC + IvDCShift /////// 5887 //////////////////////////////// 5888 5889 if( !getSlice()->getIsDepth() ) 5890 { 5891 for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ ) 5892 { 5893 RefPicList eRefPicListDMV = RefPicList( iRefListId ); 5894 Int iNumRefPics = pcSlice->getNumRefIdx( eRefPicListDMV ); 5895 for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ ) 5896 { 5897 if(( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC()) && (pcSlice->getRefPic( eRefPicListDMV, iPdmRefIdx )->getViewIndex() == pDInfo->m_aVIdxCan)) 5898 { 5899 for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) 5900 { 5901 Int ioffsetDV = (iLoopCan == 0) ? 0 : 4; 5902 abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true; 5903 paiPdmRefIdx [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx; 5904 #if NH_3D_NBDV_REF 5905 TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; 5906 #endif 5907 cMv.setHor( cMv.getHor() + ioffsetDV ); 5908 #if NH_3D_IV_MERGE 5909 if( bIsDepth ) 5910 { 5911 cMv.setHor((cMv.getHor()+2)>>2); 5912 } 5913 #endif 5914 cMv.setVer( 0 ); 5915 pacPdmMv [iRefListId + 2 + (iLoopCan<<2)] = cMv; 5916 } 5917 break; 5918 } 5919 } 5920 } 5921 for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) 5922 { 5923 availableMcDc[1 + (iLoopCan << 1)] = ( abPdmAvailable[2 + (iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[3 + (iLoopCan<<2)] ? 2 : 0 ); 5924 } 5925 } 5926 return false; 5927 } 5928 #endif 5929 #if NH_3D_ARP 5930 Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth ) 5931 { 5932 setSubPart<UChar>( w, m_puhARPW, uiAbsPartIdx, uiDepth, 0 ); 5933 } 5934 #endif 5935 5936 #if NH_3D_IC 5937 Void TComDataCU::setICFlagSubParts( Bool bICFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 5938 { 5939 memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ))*sizeof(Bool) ); 5940 } 5941 5942 Bool TComDataCU::isICFlagRequired( UInt uiAbsPartIdx ) 5943 { 5944 UInt uiPartAddr; 5945 UInt iNumbPart; 5946 5947 if( !( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ) 5948 { 5949 return false; 5950 } 5951 5952 if( getSlice()->getIcSkipParseFlag() ) 5953 { 5954 if( getMergeFlag( uiAbsPartIdx ) && getMergeIndex( uiAbsPartIdx ) == 0 ) 5955 { 5956 return false; 5957 } 5958 } 5959 5960 if( getMergeFlag( uiAbsPartIdx ) ) 5961 { 5962 return true; 5963 } 5964 5965 5966 Int iWidth, iHeight; 5967 5968 iNumbPart = ( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ? 1 : ( getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 ) ); 5969 5970 for(UInt i = 0; i < iNumbPart; i++) 5971 { 5972 getPartIndexAndSize( i, uiPartAddr, iWidth, iHeight, uiAbsPartIdx, true ); 5973 uiPartAddr += uiAbsPartIdx; 5974 5975 for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++) 5976 { 5977 RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0; 5978 Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr); 5979 5980 if( ( getInterDir( uiPartAddr ) & ( uiRefIdx+1 ) ) && iBestRefIdx >= 0 && getSlice()->getViewIndex() != getSlice()->getRefPic( eRefList, iBestRefIdx )->getViewIndex() ) 5981 { 5982 return true; 5983 } 5984 } 5985 } 5986 5987 return false; 5988 } 5989 #endif 5990 #if NH_3D_DMM 5991 Void TComDataCU::setDmm1WedgeTabIdxSubParts( UInt tabIdx, UInt uiAbsPartIdx, UInt uiDepth ) 5992 { 5993 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 5994 for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm1WedgeTabIdx[uiAbsPartIdx+ui] = tabIdx; } 5995 } 5996 #endif 5997 5998 #if NH_3D_VSP 5999 Void TComDataCU::setMvFieldPUForVSP( TComDataCU* pcCU, UInt partAddr, Int width, Int height, RefPicList eRefPicList, Int iRefIdx, Int &vspSize ) 6000 { 6001 // Get depth reference 6002 Int depthRefViewIdx = pcCU->getDvInfo(partAddr).m_aVIdxCan; 6003 6004 #if H_3D_FCO 6005 TComPic* pRefPicBaseDepth = 0; 6006 Bool bIsCurrDepthCoded = false; 6007 pRefPicBaseDepth = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() ); 6008 if ( pRefPicBaseDepth->getPicYuvRec() != NULL ) 6009 { 6010 bIsCurrDepthCoded = true; 6011 } 6012 else 6013 { 6014 pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); 6015 } 6016 #else 6017 TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); 6018 #endif 6019 assert(pRefPicBaseDepth != NULL); 6020 TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); 6021 assert(pcBaseViewDepthPicYuv != NULL); 6022 pcBaseViewDepthPicYuv->extendPicBorder(); 6023 6024 // Get texture reference 6025 assert(iRefIdx >= 0); 6026 TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); 6027 TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); 6028 assert(pcBaseViewTxtPicYuv != NULL); 6029 6030 // Initialize LUT according to the reference viewIdx 6031 Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex(); 6032 Int* pShiftLUT = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx ); 6033 assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() ); 6034 6035 // prepare Dv to access depth map or reference view 6036 TComMv cDv = pcCU->getDvInfo(partAddr).m_acNBDV; 6037 pcCU->clipMv(cDv); 6038 6039 #if H_3D_FCO 6040 if ( bIsCurrDepthCoded ) 6041 { 6042 cDv.setZero(); 6043 } 6044 #endif 6045 6046 // fetch virtual depth map & convert depth to motion vector, which are stored in the motion memory 6047 xSetMvFieldForVSP( pcCU, pcBaseViewDepthPicYuv, &cDv, partAddr, width, height, pShiftLUT, eRefPicList, iRefIdx, pcCU->getSlice()->getIsDepth(), vspSize ); 6048 } 6049 6050 Void TComDataCU::xSetMvFieldForVSP( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, Int *shiftLUT, RefPicList refPicList, Int refIdx, Bool isDepth, Int &vspSize ) 6051 { 6052 TComCUMvField *cuMvField = cu->getCUMvField( refPicList ); 6053 Int partAddrRasterSubPULine = g_auiZscanToRaster[ partAddr ]; 6054 Int numPartsLine = cu->getPic()->getNumPartInCtuWidth(); 6055 6056 Int nTxtPerMvInfoX = 4; // cu->getPic()->getMinCUWidth(); 6057 Int nTxtPerMvInfoY = 4; // cu->getPic()->getMinCUHeight(); 6058 6059 Int refDepStride = picRefDepth->getStride( COMPONENT_Y ); 6060 6061 TComMv tmpMv(0, 0); 6062 tmpMv.setIDVFlag(false); 6063 6064 Int refDepOffset = ( (dv->getHor()+2) >> 2 ) + ( (dv->getVer()+2) >> 2 ) * refDepStride; 6065 Pel *refDepth = picRefDepth->getAddr( COMPONENT_Y, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refDepOffset; 6066 6067 if ((height % 8)) 6068 { 6069 vspSize = 1; // 8x4 6070 } 6071 else if ((width % 8)) 6072 { 6073 vspSize = 0; // 4x8 6074 } 6075 else 6076 { 6077 Bool ULvsBR, URvsBL; 6078 ULvsBR = refDepth[0] < refDepth[refDepStride * (height-1) + width-1]; 6079 URvsBL = refDepth[width-1] < refDepth[refDepStride * (height-1)]; 6080 vspSize = ( ULvsBR ^ URvsBL ) ? 0 : 1; 6081 } 6082 6083 Int subBlockW, subBlockH; 6084 if (vspSize) 6085 { 6086 subBlockW = 8; 6087 subBlockH = 4; 6088 } 6089 else 6090 { 6091 subBlockW = 4; 6092 subBlockH = 8; 6093 } 6094 6095 Int numPartsInSubPUW = subBlockW / nTxtPerMvInfoX; 6096 Int numPartsInSubPUH = subBlockH / nTxtPerMvInfoY * numPartsLine; 6097 6098 for( Int y=0; y<height; y+=subBlockH, partAddrRasterSubPULine+=numPartsInSubPUH ) 6099 { 6100 Pel *refDepthTmp[4]; 6101 refDepthTmp[0] = refDepth + refDepStride * y; 6102 refDepthTmp[1] = refDepthTmp[0] + subBlockW - 1; 6103 refDepthTmp[2] = refDepthTmp[0] + refDepStride * (subBlockH - 1); 6104 refDepthTmp[3] = refDepthTmp[2] + subBlockW - 1; 6105 6106 Int partAddrRasterSubPU = partAddrRasterSubPULine; 6107 for( Int x=0; x<width; x+=subBlockW, partAddrRasterSubPU+=numPartsInSubPUW ) 6108 { 6109 Pel maxDepthVal; 6110 maxDepthVal = refDepthTmp[0][x]; 6111 maxDepthVal = std::max( maxDepthVal, refDepthTmp[1][x]); 6112 maxDepthVal = std::max( maxDepthVal, refDepthTmp[2][x]); 6113 maxDepthVal = std::max( maxDepthVal, refDepthTmp[3][x]); 6114 tmpMv.setHor( (Short) shiftLUT[ maxDepthVal ] ); 6115 6116 Int partAddrRasterPartLine = partAddrRasterSubPU; 6117 for( Int sY=0; sY<numPartsInSubPUH; sY+=numPartsLine, partAddrRasterPartLine += numPartsLine ) 6118 { 6119 Int partAddrRasterPart = partAddrRasterPartLine; 6120 for( Int sX=0; sX<numPartsInSubPUW; sX+=1, partAddrRasterPart++ ) 6121 { 6122 cuMvField->setMv ( g_auiRasterToZscan[ partAddrRasterPart ], tmpMv ); 6123 cuMvField->setRefIdx( g_auiRasterToZscan[ partAddrRasterPart ], refIdx ); 6124 } 6125 } 6126 } 6127 } 6128 6129 vspSize = (vspSize<<2)+1; 6130 6131 } 6132 #endif 3218 3219 3220 3221 3222 3223 6133 3224 6134 3225 //! \}
Note: See TracChangeset for help on using the changeset viewer.