Changeset 884 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPrediction.cpp
- Timestamp:
- 29 Mar 2014, 18:55:16 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComPrediction.cpp
r872 r884 416 416 417 417 #if H_3D_DIM 418 Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc 419 #if QC_GENERIC_SDC_G0122 420 , TComWedgelet* dmm4Segmentation 421 #endif 422 ) 418 Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc, TComWedgelet* dmm4Segmentation ) 423 419 { 424 420 assert( iWidth == iHeight ); … … 446 442 case( DMM4_IDX ): 447 443 { 448 #if QC_GENERIC_SDC_G0122449 444 if( dmm4Segmentation == NULL ) 450 445 { … … 457 452 dmmSegmentation = dmm4Segmentation; 458 453 } 459 #else460 dmmSegmentation = new TComWedgelet( iWidth, iHeight );461 xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation );462 #endif463 454 } break; 464 455 default: assert(0); … … 511 502 512 503 #if H_3D_DIM_DMM 513 #if QC_GENERIC_SDC_G0122514 504 if( dimType == DMM4_IDX && dmm4Segmentation == NULL ) { dmmSegmentation->destroy(); delete dmmSegmentation; } 515 #else516 if( dimType == DMM4_IDX ) { dmmSegmentation->destroy(); delete dmmSegmentation; }517 #endif518 505 #endif 519 506 } … … 1103 1090 pcCU->clipMv(cMv); 1104 1091 1105 #if MTK_DDD_G00631092 #if H_3D_DDD 1106 1093 if( pcCU->getUseDDD( uiPartAddr ) ) 1107 1094 { … … 1182 1169 Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) 1183 1170 { 1184 #if NTT_STORE_SPDV_VSP_G01481185 1171 Int vspSize = pcCU->getVSPFlag( uiPartAddr ) >> 1; 1186 1172 … … 1197 1183 } 1198 1184 xPredInterUniSubPU( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi, widthSubPU, heightSubPU ); 1199 1200 #else // NTT_STORE_SPDV_VSP_G0148 1201 // Get depth reference 1202 Int depthRefViewIdx = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; 1203 #if H_3D_FCO_VSP_DONBDV_E0163 1204 TComPic* pRefPicBaseDepth = 0; 1205 Bool bIsCurrDepthCoded = false; 1206 pRefPicBaseDepth = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() ); 1207 if ( pRefPicBaseDepth->getPicYuvRec() != NULL ) 1208 { 1209 bIsCurrDepthCoded = true; 1210 } 1211 else 1212 { 1213 pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); 1214 } 1215 #else 1216 TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); 1217 #endif 1218 assert(pRefPicBaseDepth != NULL); 1219 TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); 1220 assert(pcBaseViewDepthPicYuv != NULL); 1221 1222 // Get texture reference 1223 Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); 1224 assert(iRefIdx >= 0); 1225 TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); 1226 TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); 1227 assert(pcBaseViewTxtPicYuv != NULL); 1228 1229 // Initialize LUT according to the reference viewIdx 1230 Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex(); 1231 Int* pShiftLUT = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx ); 1232 assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() ); 1233 1234 // Do compensation 1235 TComMv cDv = pcCU->getDvInfo(uiPartAddr).m_acNBDV; 1236 pcCU->clipMv(cDv); 1237 1238 #if H_3D_FCO_VSP_DONBDV_E0163 1239 if ( bIsCurrDepthCoded ) 1240 { 1241 cDv.setZero(); 1242 } 1243 #endif 1244 // fetch virtual depth map 1245 pcBaseViewDepthPicYuv->extendPicBorder(); 1246 1247 Int vspSize=0; 1248 xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp,vspSize ); 1249 // sub-PU based compensation 1250 xPredInterLumaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi, vspSize); 1251 xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi, vspSize); 1252 #endif // NTT_STORE_SPDV_VSP_G0148 1253 } 1254 1255 #if NTT_STORE_SPDV_VSP_G0148 1185 } 1186 1256 1187 Void TComPrediction::xPredInterUniSubPU( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU, Int heightSubPU ) 1257 1188 { … … 1278 1209 } 1279 1210 } 1280 #endif // NTT_STORE_SPDV_VSP_G01481281 1211 1282 1212 #endif … … 2133 2063 #endif 2134 2064 2135 #if H_3D_VSP2136 #if !(NTT_STORE_SPDV_VSP_G0148)2137 // not fully support iRatioTxtPerDepth* != 12138 Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int &vspSize, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY )2139 {2140 Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE;2141 Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE;2142 2143 Int refDepStride = picRefDepth->getStride();2144 2145 Int refDepOffset = ( (mv->getHor()+2) >> 2 ) + ( (mv->getVer()+2) >> 2 ) * refDepStride;2146 Pel *refDepth = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr );2147 2148 if( ratioTxtPerDepthX!=1 || ratioTxtPerDepthY!=1 )2149 {2150 Int posX, posY;2151 refDepth = picRefDepth->getLumaAddr( );2152 cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture2153 posX /= ratioTxtPerDepthX; // texture position -> depth postion2154 posY /= ratioTxtPerDepthY;2155 refDepOffset += posX + posY * refDepStride;2156 2157 width /= ratioTxtPerDepthX; // texture size -> depth size2158 height /= ratioTxtPerDepthY;2159 }2160 2161 refDepth += refDepOffset;2162 2163 Int depStride = yuvDepth->getStride();2164 Pel *depth = yuvDepth->getLumaAddr();2165 2166 if ((height % 8))2167 {2168 vspSize = 1; // 8x42169 }2170 else if ((width % 8))2171 {2172 vspSize = 0; // 4x82173 }2174 else2175 {2176 Bool ULvsBR, URvsBL;2177 ULvsBR = refDepth[0] < refDepth[refDepStride * (height-1) + width-1];2178 URvsBL = refDepth[width-1] < refDepth[refDepStride * (height-1)];2179 vspSize = ( ULvsBR ^ URvsBL ) ? 0 : 1;2180 }2181 Int subBlockW, subBlockH;2182 Int depStrideTmp = depStride * nTxtPerDepthY;2183 if (vspSize)2184 {2185 subBlockW = 8;2186 subBlockH = 4;2187 }2188 else2189 {2190 subBlockW = 4;2191 subBlockH = 8;2192 }2193 for( Int y=0; y<height; y+=subBlockH )2194 {2195 Pel *refDepthTmp[4];2196 refDepthTmp[0] = refDepth + refDepStride * y;2197 refDepthTmp[1] = refDepthTmp[0] + subBlockW - 1;2198 refDepthTmp[2] = refDepthTmp[0] + refDepStride * (subBlockH - 1);2199 refDepthTmp[3] = refDepthTmp[2] + subBlockW - 1;2200 for( Int x=0; x<width; x+=subBlockW )2201 {2202 Pel maxDepthVal;2203 maxDepthVal = refDepthTmp[0][x];2204 maxDepthVal = std::max( maxDepthVal, refDepthTmp[1][x]);2205 maxDepthVal = std::max( maxDepthVal, refDepthTmp[2][x]);2206 maxDepthVal = std::max( maxDepthVal, refDepthTmp[3][x]);2207 Pel *depthTmp = &depth[x+y*depStride];2208 for( Int sY=0; sY<subBlockH; sY+=nTxtPerDepthY )2209 {2210 for( Int sX=0; sX<subBlockW; sX+=nTxtPerDepthX )2211 {2212 depthTmp[sX] = maxDepthVal;2213 }2214 depthTmp += depStrideTmp;2215 }2216 }2217 }2218 }2219 2220 Void TComPrediction::xPredInterLumaBlkFromDM( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi, Int vspSize)2221 {2222 Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE;2223 Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE;2224 2225 nTxtPerDepthX = nTxtPerDepthX << vspSize;2226 nTxtPerDepthY = nTxtPerDepthY << (1-vspSize);2227 2228 Int refStride = picRef->getStride();2229 Int dstStride = yuvDst->getStride();2230 Int depStride = yuvDepth->getStride();2231 Int refStrideBlock = refStride * nTxtPerDepthY;2232 Int dstStrideBlock = dstStride * nTxtPerDepthY;2233 Int depStrideBlock = depStride * nTxtPerDepthY;2234 2235 Pel *ref = picRef->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr );2236 Pel *dst = yuvDst->getLumaAddr(partAddr);2237 Pel *depth = yuvDepth->getLumaAddr();2238 2239 #if H_3D_VSP_BLOCKSIZE == 12240 #if H_3D_VSP_CONSTRAINED2241 //get LUT based horizontal reference range2242 Int range = xGetConstrainedSize(width, height);2243 2244 // The minimum depth value2245 Int minRelativePos = MAX_INT;2246 Int maxRelativePos = MIN_INT;2247 2248 Pel* depthTemp, *depthInitial=depth;2249 for (Int yTxt = 0; yTxt < height; yTxt++)2250 {2251 for (Int xTxt = 0; xTxt < width; xTxt++)2252 {2253 if (depthPosX+xTxt < widthDepth)2254 {2255 depthTemp = depthInitial + xTxt;2256 }2257 else2258 {2259 depthTemp = depthInitial + (widthDepth - depthPosX - 1);2260 }2261 2262 Int disparity = shiftLUT[ *depthTemp ]; // << iShiftPrec;2263 Int disparityInt = disparity >> 2;2264 2265 if( disparity <= 0)2266 {2267 if (minRelativePos > disparityInt+xTxt)2268 {2269 minRelativePos = disparityInt+xTxt;2270 }2271 }2272 else2273 {2274 if (maxRelativePos < disparityInt+xTxt)2275 {2276 maxRelativePos = disparityInt+xTxt;2277 }2278 }2279 }2280 if (depthPosY+yTxt < heightDepth)2281 {2282 depthInitial = depthInitial + depStride;2283 }2284 }2285 2286 Int disparity_tmp = shiftLUT[ *depth ]; // << iShiftPrec;2287 if (disparity_tmp <= 0)2288 {2289 maxRelativePos = minRelativePos + range -1 ;2290 }2291 else2292 {2293 minRelativePos = maxRelativePos - range +1 ;2294 }2295 #endif2296 #endif // H_3D_VSP_BLOCKSIZE == 12297 2298 TComMv dv(0, 0);2299 2300 for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY )2301 {2302 for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX )2303 {2304 Pel repDepth = depth[ xTxt ];2305 assert( repDepth >= 0 && repDepth <= 255 );2306 2307 Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec ??2308 Int xFrac = disparity & 0x3;2309 2310 dv.setHor( disparity );2311 cu->clipMv( dv );2312 2313 Int refOffset = xTxt + (dv.getHor() >> 2);2314 2315 #if H_3D_VSP_CONSTRAINED2316 if(refOffset<minRelativePos || refOffset>maxRelativePos)2317 {2318 xFrac = 0;2319 }2320 refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);2321 #endif2322 2323 assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 );2324 m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi );2325 }2326 ref += refStrideBlock;2327 dst += dstStrideBlock;2328 depth += depStrideBlock;2329 }2330 2331 }2332 2333 Void TComPrediction::xPredInterChromaBlkFromDM ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi, Int vspSize)2334 {2335 #if (H_3D_VSP_BLOCKSIZE==1)2336 Int nTxtPerDepthX = 1;2337 Int nTxtPerDepthY = 1;2338 #else2339 Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE >> 1;2340 Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE >> 1;2341 #endif2342 2343 nTxtPerDepthX = nTxtPerDepthX << vspSize;2344 nTxtPerDepthY = nTxtPerDepthY << (1-vspSize);2345 2346 Int refStride = picRef->getCStride();2347 Int dstStride = yuvDst->getCStride();2348 Int depStride = yuvDepth->getStride();2349 Int refStrideBlock = refStride * nTxtPerDepthY;2350 Int dstStrideBlock = dstStride * nTxtPerDepthY;2351 Int depStrideBlock = depStride * (nTxtPerDepthY<<1);2352 2353 Pel *refCb = picRef->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr );2354 Pel *refCr = picRef->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr );2355 Pel *dstCb = yuvDst->getCbAddr(partAddr);2356 Pel *dstCr = yuvDst->getCrAddr(partAddr);2357 Pel *depth = yuvDepth->getLumaAddr();2358 2359 #if H_3D_VSP_BLOCKSIZE == 12360 #if H_3D_VSP_CONSTRAINED2361 //get LUT based horizontal reference range2362 Int range = xGetConstrainedSize(width, height, false);2363 2364 // The minimum depth value2365 Int minRelativePos = MAX_INT;2366 Int maxRelativePos = MIN_INT;2367 2368 Int depthTmp;2369 for (Int yTxt=0; yTxt<height; yTxt++)2370 {2371 for (Int xTxt=0; xTxt<width; xTxt++)2372 {2373 depthTmp = m_pDepthBlock[xTxt+yTxt*width];2374 Int disparity = shiftLUT[ depthTmp ]; // << iShiftPrec;2375 Int disparityInt = disparity >> 3;//in chroma resolution2376 2377 if (disparityInt < 0)2378 {2379 if (minRelativePos > disparityInt+xTxt)2380 {2381 minRelativePos = disparityInt+xTxt;2382 }2383 }2384 else2385 {2386 if (maxRelativePos < disparityInt+xTxt)2387 {2388 maxRelativePos = disparityInt+xTxt;2389 }2390 }2391 }2392 }2393 2394 depthTmp = m_pDepthBlock[0];2395 Int disparity_tmp = shiftLUT[ depthTmp ]; // << iShiftPrec;2396 if ( disparity_tmp < 0 )2397 {2398 maxRelativePos = minRelativePos + range - 1;2399 }2400 else2401 {2402 minRelativePos = maxRelativePos - range + 1;2403 }2404 2405 #endif // H_3D_VSP_CONSTRAINED2406 #endif // H_3D_VSP_BLOCKSIZE == 12407 2408 TComMv dv(0, 0);2409 // luma size -> chroma size2410 height >>= 1;2411 width >>= 1;2412 2413 for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY )2414 {2415 for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX )2416 {2417 Pel repDepth = depth[ xTxt<<1 ];2418 assert( repDepth >= 0 && repDepth <= 255 );2419 2420 Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec;2421 Int xFrac = disparity & 0x7;2422 2423 dv.setHor( disparity );2424 cu->clipMv( dv );2425 2426 Int refOffset = xTxt + (dv.getHor() >> 3);2427 2428 #if H_3D_VSP_CONSTRAINED2429 if(refOffset<minRelativePos || refOffset>maxRelativePos)2430 {2431 xFrac = 0;2432 }2433 refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);2434 #endif2435 2436 assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 );2437 assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 );2438 2439 m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi );2440 m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi );2441 }2442 refCb += refStrideBlock;2443 refCr += refStrideBlock;2444 dstCb += dstStrideBlock;2445 dstCr += dstStrideBlock;2446 depth += depStrideBlock;2447 }2448 }2449 #endif2450 2451 #if H_3D_VSP_CONSTRAINED2452 Int TComPrediction::xGetConstrainedSize(Int nPbW, Int nPbH, Bool bLuma)2453 {2454 Int iSize = 0;2455 if (bLuma)2456 {2457 Int iArea = (nPbW+7) * (nPbH+7);2458 Int iAlpha = iArea / nPbH - nPbW - 7;2459 iSize = iAlpha + nPbW;2460 }2461 else // chroma2462 {2463 Int iArea = (nPbW+2) * (nPbH+2);2464 Int iAlpha = iArea / nPbH - nPbW - 4;2465 iSize = iAlpha + nPbW;2466 }2467 return iSize;2468 }2469 #endif // H_3D_VSP_CONSTRAINED2470 2471 #endif // H_3D_VSP2472 2473 2065 #if H_3D_DIM 2474 2066 Void TComPrediction::xPredBiSegDCs( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ) … … 2485 2077 if( bL == bT ) 2486 2078 { 2487 #if SCU_HS_DEPTH_DC_PRED_G01432488 2079 const Int iTRR = ( patternStride * 2 - 1 ) - srcStride; 2489 2080 const Int iLBB = ( patternStride * 2 - 1 ) * srcStride - 1; 2490 2081 refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : (abs(ptrSrc[iTRR] - ptrSrc[-(Int)srcStride]) > abs(ptrSrc[iLBB] - ptrSrc[ -1]) ? ptrSrc[iTRR] : ptrSrc[iLBB]); 2491 #else2492 refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : 1<<( g_bitDepthY - 1 );2493 #endif2494 2082 refDC2 = ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1; 2495 2083 } … … 2593 2181 Int iSumPix[2]; 2594 2182 memset(iSumPix, 0, sizeof(Int)*2); 2595 #if QC_GENERIC_SDC_G01222596 2183 for( Int i = 0; i < uiNumSegments; i++ ) 2597 2184 { 2598 2185 rpSegMeans[i] = 0; 2599 2186 } 2600 #endif2601 2187 if (orgDC == false) 2602 2188 { … … 2613 2199 rpSegMeans[ucSegmentRB] = pOrig[uiStride * (uiSize-1) + (uiSize-1) ]; 2614 2200 } 2615 #if QC_GENERIC_SDC_G01222616 2201 else if( getDimType( uiIntraMode ) == DMM4_IDX ) 2617 2202 { … … 2647 2232 } 2648 2233 else 2649 #else2650 else if (uiIntraMode == PLANAR_IDX)2651 #endif2652 2234 { 2653 2235 Pel* pLeftTop = pOrig;
Note: See TracChangeset for help on using the changeset viewer.