Changeset 468 in 3DVCSoftware for branches/HTM-DEV-0.3-dev2a/source/Lib/TLibCommon/TComPrediction.cpp
- Timestamp:
- 16 Jun 2013, 05:33:39 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-DEV-0.3-dev2a/source/Lib/TLibCommon/TComPrediction.cpp
r464 r468 122 122 } 123 123 } 124 #if H_3D_IC 125 for( Int i = 1; i < 64; i++ ) 126 { 127 m_uiaShift[i-1] = ( (1 << 15) + i/2 ) / i; 128 } 129 #endif 124 130 } 125 131 … … 505 511 { 506 512 #endif 513 #if H_3D_IC 514 Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ); 515 xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi 516 #if H_3D_ARP 517 , false 518 #endif 519 , bICFlag ); 520 xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi 521 #if H_3D_ARP 522 , false 523 #endif 524 , bICFlag ); 525 #else 507 526 xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); 508 527 xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); 528 #endif 509 529 #if H_3D_ARP 510 530 } … … 671 691 , Bool filterType 672 692 #endif 693 #if H_3D_IC 694 , Bool bICFlag 695 #endif 673 696 ) 674 697 { … … 683 706 Int yFrac = mv->getVer() & 0x3; 684 707 708 #if H_3D_IC 709 if( cu->getSlice()->getIsDepth() ) 710 { 711 refOffset = mv->getHor() + mv->getVer() * refStride; 712 ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; 713 xFrac = 0; 714 yFrac = 0; 715 } 716 #endif 717 685 718 if ( yFrac == 0 ) 686 719 { … … 718 751 ); 719 752 } 753 754 #if H_3D_IC 755 if( bICFlag ) 756 { 757 Int a, b, iShift, i, j; 758 759 xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_LUMA ); 760 761 for ( i = 0; i < height; i++ ) 762 { 763 for ( j = 0; j < width; j++ ) 764 { 765 if( bi ) 766 { 767 Int iIFshift = IF_INTERNAL_PREC - g_bitDepthY; 768 dst[j] = ( ( a*dst[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1 << iIFshift ) - IF_INTERNAL_OFFS; 769 } 770 else 771 dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b ); 772 } 773 dst += dstStride; 774 } 775 } 776 #endif 720 777 } 721 778 … … 735 792 #if H_3D_ARP 736 793 , Bool filterType 737 #endif 794 #endif 795 #if H_3D_IC 796 , Bool bICFlag 797 #endif 738 798 ) 739 799 { … … 811 871 ); 812 872 } 873 874 #if H_3D_IC 875 if( bICFlag ) 876 { 877 Int a, b, iShift, i, j; 878 xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_CHROMA_U ); // Cb 879 for ( i = 0; i < cxHeight; i++ ) 880 { 881 for ( j = 0; j < cxWidth; j++ ) 882 { 883 if( bi ) 884 { 885 Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC; 886 dstCb[j] = ( ( a*dstCb[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1<<iIFshift ) - IF_INTERNAL_OFFS; 887 } 888 else 889 dstCb[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b ); 890 } 891 dstCb += dstStride; 892 } 893 xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_CHROMA_V ); // Cr 894 for ( i = 0; i < cxHeight; i++ ) 895 { 896 for ( j = 0; j < cxWidth; j++ ) 897 { 898 if( bi ) 899 { 900 Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC; 901 dstCr[j] = ( ( a*dstCr[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1<<iIFshift ) - IF_INTERNAL_OFFS; 902 } 903 else 904 dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b ); 905 } 906 dstCr += dstStride; 907 } 908 } 909 #endif 813 910 } 814 911 … … 930 1027 return; 931 1028 } 1029 1030 #if H_3D_IC 1031 /** Function for deriving the position of first non-zero binary bit of a value 1032 * \param x input value 1033 * 1034 * This function derives the position of first non-zero binary bit of a value 1035 */ 1036 Int GetMSB( UInt x ) 1037 { 1038 Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; 1039 1040 while( x > 1 ) 1041 { 1042 bits >>= 1; 1043 y = x >> bits; 1044 1045 if( y ) 1046 { 1047 x = y; 1048 iMSB += bits; 1049 } 1050 } 1051 1052 iMSB+=y; 1053 1054 return iMSB; 1055 } 1056 1057 /** Function for counting leading number of zeros/ones 1058 * \param x input value 1059 \ This function counts leading number of zeros for positive numbers and 1060 \ leading number of ones for negative numbers. This can be implemented in 1061 \ single instructure cycle on many processors. 1062 */ 1063 1064 Short CountLeadingZerosOnes (Short x) 1065 { 1066 Short clz; 1067 Short i; 1068 1069 if(x == 0) 1070 { 1071 clz = 0; 1072 } 1073 else 1074 { 1075 if (x == -1) 1076 { 1077 clz = 15; 1078 } 1079 else 1080 { 1081 if(x < 0) 1082 { 1083 x = ~x; 1084 } 1085 clz = 15; 1086 for(i = 0;i < 15;++i) 1087 { 1088 if(x) 1089 { 1090 clz --; 1091 } 1092 x = x >> 1; 1093 } 1094 } 1095 } 1096 return clz; 1097 } 1098 1099 /** Function for deriving LM illumination compensation. 1100 */ 1101 Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift, TextType eType ) 1102 { 1103 TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); 1104 Pel *pRec = NULL, *pRef = NULL; 1105 UInt uiWidth, uiHeight, uiTmpPartIdx; 1106 Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride(); 1107 Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride(); 1108 Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset, iHor, iVer; 1109 1110 iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; 1111 iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; 1112 iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 ); 1113 iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 ); 1114 iRefX = iCUPelX + iHor; 1115 iRefY = iCUPelY + iVer; 1116 if( eType != TEXT_LUMA ) 1117 { 1118 iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 ); 1119 iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 ); 1120 } 1121 uiWidth = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 ) : ( pcCU->getWidth( 0 ) >> 1 ); 1122 uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1 ); 1123 1124 Int i, j, iCountShift = 0; 1125 1126 // LLS parameters estimation --> 1127 1128 Int x = 0, y = 0, xx = 0, xy = 0; 1129 1130 if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelY > 0 && iRefY > 0 ) 1131 { 1132 iRefOffset = iHor + iVer * iRefStride - iRefStride; 1133 if( eType == TEXT_LUMA ) 1134 { 1135 pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 1136 pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; 1137 } 1138 else if( eType == TEXT_CHROMA_U ) 1139 { 1140 pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 1141 pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; 1142 } 1143 else 1144 { 1145 assert( eType == TEXT_CHROMA_V ); 1146 pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 1147 pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; 1148 } 1149 1150 for( j = 0; j < uiWidth; j++ ) 1151 { 1152 x += pRef[j]; 1153 y += pRec[j]; 1154 xx += pRef[j] * pRef[j]; 1155 xy += pRef[j] * pRec[j]; 1156 } 1157 iCountShift += g_aucConvertToBit[ uiWidth ] + 2; 1158 } 1159 1160 1161 if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelX > 0 && iRefX > 0 ) 1162 { 1163 iRefOffset = iHor + iVer * iRefStride - 1; 1164 if( eType == TEXT_LUMA ) 1165 { 1166 pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 1167 pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; 1168 } 1169 else if( eType == TEXT_CHROMA_U ) 1170 { 1171 pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 1172 pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; 1173 } 1174 else 1175 { 1176 assert( eType == TEXT_CHROMA_V ); 1177 pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 1178 pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; 1179 } 1180 1181 for( i = 0; i < uiHeight; i++ ) 1182 { 1183 x += pRef[0]; 1184 y += pRec[0]; 1185 xx += pRef[0] * pRef[0]; 1186 xy += pRef[0] * pRec[0]; 1187 1188 pRef += iRefStride; 1189 pRec += iRecStride; 1190 } 1191 iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); 1192 } 1193 1194 Int iTempShift = ( ( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; 1195 1196 if( iTempShift > 0 ) 1197 { 1198 x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; 1199 y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; 1200 xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; 1201 xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; 1202 iCountShift -= iTempShift; 1203 } 1204 1205 iShift = 13; 1206 1207 if( iCountShift == 0 ) 1208 { 1209 a = 1; 1210 b = 0; 1211 iShift = 0; 1212 } 1213 else 1214 { 1215 Int a1 = ( xy << iCountShift ) - y * x; 1216 Int a2 = ( xx << iCountShift ) - x * x; 1217 1218 { 1219 const Int iShiftA2 = 6; 1220 const Int iShiftA1 = 15; 1221 const Int iAccuracyShift = 15; 1222 1223 Int iScaleShiftA2 = 0; 1224 Int iScaleShiftA1 = 0; 1225 Int a1s = a1; 1226 Int a2s = a2; 1227 1228 iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; 1229 iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; 1230 1231 if( iScaleShiftA1 < 0 ) 1232 { 1233 iScaleShiftA1 = 0; 1234 } 1235 1236 if( iScaleShiftA2 < 0 ) 1237 { 1238 iScaleShiftA2 = 0; 1239 } 1240 1241 Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; 1242 1243 a2s = a2 >> iScaleShiftA2; 1244 1245 a1s = a1 >> iScaleShiftA1; 1246 1247 if (a2s >= 1) 1248 { 1249 a = a1s * m_uiaShift[ a2s - 1]; 1250 } 1251 else 1252 { 1253 a = 0; 1254 } 1255 1256 if( iScaleShiftA < 0 ) 1257 { 1258 a = a << -iScaleShiftA; 1259 } 1260 else 1261 { 1262 a = a >> iScaleShiftA; 1263 } 1264 1265 a = Clip3( -( 1 << 15 ), ( 1 << 15 ) - 1, a ); 1266 1267 Int minA = -(1 << (6)); 1268 Int maxA = (1 << 6) - 1; 1269 if( a <= maxA && a >= minA ) 1270 { 1271 // do nothing 1272 } 1273 else 1274 { 1275 Short n = CountLeadingZerosOnes( a ); 1276 a = a >> (9-n); 1277 iShift -= (9-n); 1278 } 1279 1280 b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; 1281 } 1282 } 1283 } 1284 #endif 932 1285 //! \}
Note: See TracChangeset for help on using the changeset viewer.