Changeset 1225 in 3DVCSoftware for branches/HTM-14.1-update-dev2-Sharp/source/Lib/TLibCommon/TComPrediction.cpp
- Timestamp:
- 22 May 2015, 05:38:04 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-14.1-update-dev2-Sharp/source/Lib/TLibCommon/TComPrediction.cpp
r1200 r1225 201 201 } 202 202 } 203 #if H_3D_IC203 #if NH_3D_IC 204 204 m_uiaShift[0] = 0; 205 205 for( Int i = 1; i < 64; i++ ) … … 1398 1398 { 1399 1399 #endif 1400 #if H_3D_IC 1401 Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ); 1402 xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi 1400 for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++) 1401 { 1402 const ComponentID compID=ComponentID(comp); 1403 #if NH_3D_IC 1404 Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ) && ( isLuma(compID) || (iWidth > 8) ); 1405 xPredInterBlk(compID, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) 1403 1406 #if H_3D_ARP 1404 1407 , false 1405 1408 #endif 1406 1409 , bICFlag ); 1407 bICFlag = bICFlag && (iWidth > 8);1408 xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi1409 #if H_3D_ARP1410 , false1411 #endif1412 , bICFlag );1413 1410 #else 1414 1415 for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)1416 {1417 const ComponentID compID=ComponentID(comp);1418 1411 xPredInterBlk (compID, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) ); 1419 } 1420 #endif 1412 #endif 1413 } 1421 1414 #if H_3D_ARP 1422 1415 } … … 1902 1895 , Bool filterType 1903 1896 #endif 1904 #if H_3D_IC1897 #if NH_3D_IC 1905 1898 , Bool bICFlag 1906 1899 #endif … … 1925 1918 { 1926 1919 refOffset = mv->getHor() + mv->getVer() * refStride; 1927 ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; 1920 ref = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset; 1921 1928 1922 xFrac = 0; 1929 1923 yFrac = 0; … … 1938 1932 if ( yFrac == 0 ) 1939 1933 { 1940 #if H_3D_IC1941 m_if.filterHor Luma( ref, refStride, dst, dstStride, width, height, xFrac, !bi || bICFlag1934 #if NH_3D_IC 1935 m_if.filterHor(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag, chFmt, bitDepth 1942 1936 #else 1943 1937 m_if.filterHor(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth … … 1950 1944 else if ( xFrac == 0 ) 1951 1945 { 1952 #if H_3D_IC1953 m_if.filterVer Luma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag1946 #if NH_3D_IC 1947 m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag, chFmt, bitDepth 1954 1948 #else 1955 1949 m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth … … 1972 1966 #endif 1973 1967 ); 1974 #if H_3D_IC1975 m_if.filterVer Luma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi || bICFlag1968 #if NH_3D_IC 1969 m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight, yFrac, false, !bi || bICFlag, chFmt, bitDepth 1976 1970 #else 1977 1971 m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight, yFrac, false, !bi, chFmt, bitDepth … … 1983 1977 } 1984 1978 1985 #if H_3D_IC1979 #if NH_3D_IC 1986 1980 if( bICFlag ) 1987 1981 { 1988 1982 Int a, b, i, j; 1989 1983 const Int iShift = IC_CONST_SHIFT; 1990 1991 xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA ); 1992 1993 1994 for ( i = 0; i < height; i++ )1995 { 1996 for ( j = 0; j < width; j++ )1997 { 1998 dst[j] = Clip3( 0, ( 1 << g_bitDepthY) - 1, ( ( a*dst[j] ) >> iShift ) + b );1984 Pel *dst2 = dst; 1985 1986 xGetLLSICPrediction( compID, cu, mv, refPic, a, b, bitDepth ); 1987 1988 for ( i = 0; i < cxHeight; i++ ) 1989 { 1990 for ( j = 0; j < cxWidth; j++ ) 1991 { 1992 dst[j] = Clip3( 0, ( 1 << bitDepth ) - 1, ( ( a*dst[j] ) >> iShift ) + b ); 1999 1993 } 2000 1994 dst += dstStride; … … 2003 1997 if(bi) 2004 1998 { 2005 Pel *dst2 = dstPic->getLumaAddr( partAddr ); 2006 Int shift = IF_INTERNAL_PREC - g_bitDepthY; 2007 for (i = 0; i < height; i++) 2008 { 2009 for (j = 0; j < width; j++) 1999 Int shift = IF_INTERNAL_PREC - bitDepth; 2000 for (i = 0; i < cxHeight; i++) 2001 { 2002 for (j = 0; j < cxWidth; j++) 2010 2003 { 2011 Shortval = dst2[j] << shift;2012 dst2[j] = val - ( Short)IF_INTERNAL_OFFS;2004 Pel val = dst2[j] << shift; 2005 dst2[j] = val - (Pel)IF_INTERNAL_OFFS; 2013 2006 } 2014 2007 dst2 += dstStride; … … 2020 2013 } 2021 2014 2022 2023 #if H_3D_ARP2024 , Bool filterType2025 #endif2026 #if H_3D_IC2027 , Bool bICFlag2028 #endif2029 #if H_3D_IC2030 m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag2031 #else2032 #endif2033 #if H_3D_ARP2034 , filterType2035 #endif2036 #if H_3D_IC2037 m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag2038 #else2039 #endif2040 #if H_3D_ARP2041 , filterType2042 #endif2043 #if H_3D_IC2044 m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag2045 #else2046 #endif2047 #if H_3D_ARP2048 , filterType2049 #endif2050 #if H_3D_IC2051 m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag2052 #else2053 #endif2054 #if H_3D_ARP2055 , filterType2056 #endif2057 #if H_3D_ARP2058 , filterType2059 #endif2060 #if H_3D_IC2061 m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag2062 #else2063 #endif2064 #if H_3D_ARP2065 , filterType2066 #endif2067 #if H_3D_ARP2068 , filterType2069 #endif2070 #if H_3D_IC2071 m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag2072 #else2073 #endif2074 #if H_3D_ARP2075 , filterType2076 #endif2077 #if H_3D_IC2078 if( bICFlag )2079 {2080 Int a, b, i, j;2081 const Int iShift = IC_CONST_SHIFT;2082 2083 xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb2084 for ( i = 0; i < cxHeight; i++ )2085 {2086 for ( j = 0; j < cxWidth; j++ )2087 {2088 dstCb[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b );2089 }2090 dstCb += dstStride;2091 }2092 xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr2093 for ( i = 0; i < cxHeight; i++ )2094 {2095 for ( j = 0; j < cxWidth; j++ )2096 {2097 dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b );2098 }2099 dstCr += dstStride;2100 }2101 2102 if(bi)2103 {2104 Pel* dstCb2 = dstPic->getCbAddr( partAddr );2105 Pel* dstCr2 = dstPic->getCrAddr( partAddr );2106 Int shift = IF_INTERNAL_PREC - g_bitDepthC;2107 for (i = 0; i < cxHeight; i++)2108 {2109 for (j = 0; j < cxWidth; j++)2110 {2111 Short val = dstCb2[j] << shift;2112 dstCb2[j] = val - (Short)IF_INTERNAL_OFFS;2113 2114 val = dstCr2[j] << shift;2115 dstCr2[j] = val - (Short)IF_INTERNAL_OFFS;2116 }2117 dstCb2 += dstStride;2118 dstCr2 += dstStride;2119 }2120 }2121 }2122 #endif2123 2015 Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths 2124 2016 ) … … 2265 2157 (uiDirMode==HOR_IDX || uiDirMode==VER_IDX); 2266 2158 } 2267 #if H_3D_IC2159 #if NH_3D_IC 2268 2160 /** Function for deriving the position of first non-zero binary bit of a value 2269 2161 * \param x input value … … 2295 2187 /** Function for deriving LM illumination compensation. 2296 2188 */ 2297 Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType)2189 Void TComPrediction::xGetLLSICPrediction( const ComponentID compID, TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, const Int bitDepth ) 2298 2190 { 2299 2191 TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); 2300 2192 Pel *pRec = NULL, *pRef = NULL; 2301 2193 UInt uiWidth, uiHeight, uiTmpPartIdx; 2302 Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride();2303 Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride();2194 Int iRecStride = pRecPic->getStride(compID); 2195 Int iRefStride = pRefPic->getStride(compID); 2304 2196 Int iRefOffset, iHor, iVer; 2305 2197 iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 ); 2306 2198 iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 ); 2307 if( eType != TEXT_LUMA)2199 if( !isLuma(compID) ) 2308 2200 { 2309 2201 iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 ); 2310 2202 iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 ); 2311 2203 } 2312 uiWidth = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 ) : ( pcCU->getWidth( 0 ) >> 1);2313 uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1);2204 uiWidth = pcCU->getWidth( 0 ) >> pRefPic->getComponentScaleX(compID); 2205 uiHeight = pcCU->getHeight( 0 ) >> pRefPic->getComponentScaleY(compID); 2314 2206 2315 2207 Int i, j, iCountShift = 0; 2316 2208 2317 // LLS parameters estimation --> 2318 2209 // LLS parameters estimation 2319 2210 Int x = 0, y = 0, xx = 0, xy = 0; 2320 Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12); 2321 2322 if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) ) 2211 Int precShift = std::max(0, bitDepth - 12); 2212 2213 UInt partAddr = 0; 2214 if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCtu() ) ) 2323 2215 { 2324 2216 iRefOffset = iHor + iVer * iRefStride - iRefStride; 2325 if( eType == TEXT_LUMA ) 2326 { 2327 pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2328 pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; 2329 } 2330 else if( eType == TEXT_CHROMA_U ) 2331 { 2332 pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2333 pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; 2334 } 2335 else 2336 { 2337 assert( eType == TEXT_CHROMA_V ); 2338 pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2339 pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; 2340 } 2341 2217 pRef = pRefPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) + iRefOffset; 2218 pRec = pRecPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) - iRecStride; 2342 2219 for( j = 0; j < uiWidth; j+=2 ) 2343 2220 { 2344 2221 x += pRef[j]; 2345 2222 y += pRec[j]; 2346 if ( eType == TEXT_LUMA)2223 if( isLuma(compID) ) 2347 2224 { 2348 2225 xx += (pRef[j] * pRef[j])>>precShift; … … 2353 2230 } 2354 2231 2355 if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInC U() ) )2232 if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCtu() ) ) 2356 2233 { 2357 2234 iRefOffset = iHor + iVer * iRefStride - 1; 2358 if( eType == TEXT_LUMA ) 2359 { 2360 pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2361 pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; 2362 } 2363 else if( eType == TEXT_CHROMA_U ) 2364 { 2365 pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2366 pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; 2367 } 2368 else 2369 { 2370 assert( eType == TEXT_CHROMA_V ); 2371 pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2372 pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; 2373 } 2374 2235 pRef = pRefPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) + iRefOffset; 2236 pRec = pRecPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) - 1; 2375 2237 for( i = 0; i < uiHeight; i+=2 ) 2376 2238 { 2377 2239 x += pRef[0]; 2378 2240 y += pRec[0]; 2379 if ( eType == TEXT_LUMA)2241 if( isLuma(compID) ) 2380 2242 { 2381 2243 xx += (pRef[0] * pRef[0])>>precShift; … … 2395 2257 } 2396 2258 2397 if ( eType != TEXT_LUMA)2398 { 2399 a = 32;2259 if( !isLuma(compID) ) 2260 { 2261 a = ( 1 << IC_CONST_SHIFT ); 2400 2262 b = ( y - x + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; 2401 2263 } 2402 2264 else 2403 2265 { 2404 xy += xx >> IC_REG_COST_SHIFT; 2405 xx += xx >> IC_REG_COST_SHIFT; 2406 Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift); 2407 Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift); 2408 const Int iShift = IC_CONST_SHIFT; 2409 { 2410 { 2411 const Int iShiftA2 = 6; 2412 const Int iAccuracyShift = 15; 2413 2414 Int iScaleShiftA2 = 0; 2415 Int iScaleShiftA1 = 0; 2416 Int a1s = a1; 2417 Int a2s = a2; 2418 2419 a1 = Clip3(0, 2*a2, a1); 2420 iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; 2421 iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF; 2422 2423 if( iScaleShiftA1 < 0 ) 2424 { 2425 iScaleShiftA1 = 0; 2426 } 2427 2428 if( iScaleShiftA2 < 0 ) 2429 { 2430 iScaleShiftA2 = 0; 2431 } 2432 2433 Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; 2434 2435 2436 a2s = a2 >> iScaleShiftA2; 2437 2438 a1s = a1 >> iScaleShiftA1; 2439 2440 a = a1s * m_uiaShift[ a2s ]; 2441 a = a >> iScaleShiftA; 2442 b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; 2443 } 2444 } 2266 xy += xx >> IC_REG_COST_SHIFT; 2267 xx += xx >> IC_REG_COST_SHIFT; 2268 Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift); 2269 Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift); 2270 const Int iShift = IC_CONST_SHIFT; 2271 const Int iShiftA2 = 6; 2272 const Int iAccuracyShift = 15; 2273 Int iScaleShiftA2 = 0; 2274 Int iScaleShiftA1 = 0; 2275 Int a1s; 2276 Int a2s; 2277 2278 a1 = Clip3(0, 2*a2, a1); 2279 iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; 2280 iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF; 2281 2282 if( iScaleShiftA1 < 0 ) 2283 { 2284 iScaleShiftA1 = 0; 2285 } 2286 if( iScaleShiftA2 < 0 ) 2287 { 2288 iScaleShiftA2 = 0; 2289 } 2290 2291 Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; 2292 2293 a2s = a2 >> iScaleShiftA2; 2294 a1s = a1 >> iScaleShiftA1; 2295 2296 a = a1s * m_uiaShift[ a2s ]; 2297 a = a >> iScaleShiftA; 2298 b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; 2445 2299 } 2446 2300 }
Note: See TracChangeset for help on using the changeset viewer.