[324] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TComPrediction.cpp |
---|
| 35 | \brief prediction class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include <memory.h> |
---|
| 39 | #include "TComPrediction.h" |
---|
| 40 | |
---|
| 41 | //! \ingroup TLibCommon |
---|
| 42 | //! \{ |
---|
| 43 | |
---|
| 44 | // ==================================================================================================================== |
---|
| 45 | // Constructor / destructor / initialize |
---|
| 46 | // ==================================================================================================================== |
---|
| 47 | |
---|
| 48 | TComPrediction::TComPrediction() |
---|
| 49 | : m_pLumaRecBuffer(0) |
---|
| 50 | , m_iLumaRecStride(0) |
---|
| 51 | { |
---|
| 52 | m_piYuvExt = NULL; |
---|
[510] | 53 | #if H_3D_VSP |
---|
| 54 | m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int)); |
---|
| 55 | if (m_pDepthBlock == NULL) |
---|
| 56 | printf("ERROR: UKTGHU, No memory allocated.\n"); |
---|
| 57 | #endif |
---|
[324] | 58 | } |
---|
| 59 | |
---|
| 60 | TComPrediction::~TComPrediction() |
---|
| 61 | { |
---|
[510] | 62 | #if H_3D_VSP |
---|
| 63 | if (m_pDepthBlock != NULL) |
---|
| 64 | free(m_pDepthBlock); |
---|
[576] | 65 | #if NTT_VSP_COMMON_E0207_E0208 |
---|
| 66 | m_cYuvDepthOnVsp.destroy(); |
---|
[510] | 67 | #endif |
---|
[576] | 68 | #endif |
---|
[510] | 69 | |
---|
[324] | 70 | delete[] m_piYuvExt; |
---|
| 71 | |
---|
| 72 | m_acYuvPred[0].destroy(); |
---|
| 73 | m_acYuvPred[1].destroy(); |
---|
| 74 | |
---|
| 75 | m_cYuvPredTemp.destroy(); |
---|
| 76 | |
---|
[504] | 77 | #if H_3D_ARP |
---|
| 78 | m_acYuvPredBase[0].destroy(); |
---|
| 79 | m_acYuvPredBase[1].destroy(); |
---|
| 80 | #endif |
---|
[324] | 81 | if( m_pLumaRecBuffer ) |
---|
| 82 | { |
---|
| 83 | delete [] m_pLumaRecBuffer; |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | Int i, j; |
---|
| 87 | for (i = 0; i < 4; i++) |
---|
| 88 | { |
---|
| 89 | for (j = 0; j < 4; j++) |
---|
| 90 | { |
---|
| 91 | m_filteredBlock[i][j].destroy(); |
---|
| 92 | } |
---|
| 93 | m_filteredBlockTmp[i].destroy(); |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | Void TComPrediction::initTempBuff() |
---|
| 98 | { |
---|
| 99 | if( m_piYuvExt == NULL ) |
---|
| 100 | { |
---|
[446] | 101 | Int extWidth = MAX_CU_SIZE + 16; |
---|
| 102 | Int extHeight = MAX_CU_SIZE + 1; |
---|
[324] | 103 | Int i, j; |
---|
| 104 | for (i = 0; i < 4; i++) |
---|
| 105 | { |
---|
| 106 | m_filteredBlockTmp[i].create(extWidth, extHeight + 7); |
---|
| 107 | for (j = 0; j < 4; j++) |
---|
| 108 | { |
---|
| 109 | m_filteredBlock[i][j].create(extWidth, extHeight); |
---|
| 110 | } |
---|
| 111 | } |
---|
[446] | 112 | m_iYuvExtHeight = ((MAX_CU_SIZE + 2) << 4); |
---|
| 113 | m_iYuvExtStride = ((MAX_CU_SIZE + 8) << 4); |
---|
[324] | 114 | m_piYuvExt = new Int[ m_iYuvExtStride * m_iYuvExtHeight ]; |
---|
| 115 | |
---|
| 116 | // new structure |
---|
[446] | 117 | m_acYuvPred[0] .create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
| 118 | m_acYuvPred[1] .create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
[324] | 119 | |
---|
[446] | 120 | m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
[504] | 121 | #if H_3D_ARP |
---|
| 122 | m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 123 | m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 124 | #endif |
---|
[576] | 125 | #if NTT_VSP_COMMON_E0207_E0208 |
---|
| 126 | m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 127 | #endif |
---|
[324] | 128 | } |
---|
| 129 | |
---|
[446] | 130 | if (m_iLumaRecStride != (MAX_CU_SIZE>>1) + 1) |
---|
[324] | 131 | { |
---|
[446] | 132 | m_iLumaRecStride = (MAX_CU_SIZE>>1) + 1; |
---|
[324] | 133 | if (!m_pLumaRecBuffer) |
---|
| 134 | { |
---|
| 135 | m_pLumaRecBuffer = new Pel[ m_iLumaRecStride * m_iLumaRecStride ]; |
---|
| 136 | } |
---|
| 137 | } |
---|
[504] | 138 | #if H_3D_IC |
---|
| 139 | for( Int i = 1; i < 64; i++ ) |
---|
| 140 | { |
---|
| 141 | m_uiaShift[i-1] = ( (1 << 15) + i/2 ) / i; |
---|
| 142 | } |
---|
| 143 | #endif |
---|
[324] | 144 | } |
---|
| 145 | |
---|
| 146 | // ==================================================================================================================== |
---|
| 147 | // Public member functions |
---|
| 148 | // ==================================================================================================================== |
---|
| 149 | |
---|
| 150 | // Function for calculating DC value of the reference samples used in Intra prediction |
---|
| 151 | Pel TComPrediction::predIntraGetPredValDC( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ) |
---|
| 152 | { |
---|
[537] | 153 | assert(iWidth > 0 && iHeight > 0); |
---|
[324] | 154 | Int iInd, iSum = 0; |
---|
| 155 | Pel pDcVal; |
---|
| 156 | |
---|
| 157 | if (bAbove) |
---|
| 158 | { |
---|
| 159 | for (iInd = 0;iInd < iWidth;iInd++) |
---|
| 160 | { |
---|
| 161 | iSum += pSrc[iInd-iSrcStride]; |
---|
| 162 | } |
---|
| 163 | } |
---|
| 164 | if (bLeft) |
---|
| 165 | { |
---|
| 166 | for (iInd = 0;iInd < iHeight;iInd++) |
---|
| 167 | { |
---|
| 168 | iSum += pSrc[iInd*iSrcStride-1]; |
---|
| 169 | } |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | if (bAbove && bLeft) |
---|
| 173 | { |
---|
| 174 | pDcVal = (iSum + iWidth) / (iWidth + iHeight); |
---|
| 175 | } |
---|
| 176 | else if (bAbove) |
---|
| 177 | { |
---|
| 178 | pDcVal = (iSum + iWidth/2) / iWidth; |
---|
| 179 | } |
---|
| 180 | else if (bLeft) |
---|
| 181 | { |
---|
| 182 | pDcVal = (iSum + iHeight/2) / iHeight; |
---|
| 183 | } |
---|
| 184 | else |
---|
| 185 | { |
---|
| 186 | pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | return pDcVal; |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | // Function for deriving the angular Intra predictions |
---|
| 193 | |
---|
| 194 | /** Function for deriving the simplified angular intra predictions. |
---|
| 195 | * \param pSrc pointer to reconstructed sample array |
---|
| 196 | * \param srcStride the stride of the reconstructed sample array |
---|
| 197 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 198 | * \param dstStride the stride of the prediction sample array |
---|
| 199 | * \param width the width of the block |
---|
| 200 | * \param height the height of the block |
---|
| 201 | * \param dirMode the intra prediction mode index |
---|
| 202 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
| 203 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
| 204 | * |
---|
| 205 | * This function derives the prediction samples for the angular mode based on the prediction direction indicated by |
---|
| 206 | * the prediction mode index. The prediction direction is given by the displacement of the bottom row of the block and |
---|
| 207 | * the reference row above the block in the case of vertical prediction or displacement of the rightmost column |
---|
| 208 | * of the block and reference column left from the block in the case of the horizontal prediction. The displacement |
---|
| 209 | * is signalled at 1/32 pixel accuracy. When projection of the predicted pixel falls inbetween reference samples, |
---|
| 210 | * the predicted value for the pixel is linearly interpolated from the reference samples. All reference samples are taken |
---|
| 211 | * from the extended main reference. |
---|
| 212 | */ |
---|
| 213 | Void TComPrediction::xPredIntraAng(Int bitDepth, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable, Bool bFilter ) |
---|
| 214 | { |
---|
| 215 | Int k,l; |
---|
| 216 | Int blkSize = width; |
---|
| 217 | Pel* pDst = rpDst; |
---|
| 218 | |
---|
| 219 | // Map the mode index to main prediction direction and angle |
---|
| 220 | assert( dirMode > 0 ); //no planar |
---|
| 221 | Bool modeDC = dirMode < 2; |
---|
| 222 | Bool modeHor = !modeDC && (dirMode < 18); |
---|
| 223 | Bool modeVer = !modeDC && !modeHor; |
---|
| 224 | Int intraPredAngle = modeVer ? (Int)dirMode - VER_IDX : modeHor ? -((Int)dirMode - HOR_IDX) : 0; |
---|
| 225 | Int absAng = abs(intraPredAngle); |
---|
| 226 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
| 227 | |
---|
| 228 | // Set bitshifts and scale the angle parameter to block size |
---|
| 229 | Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
| 230 | Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle |
---|
| 231 | Int invAngle = invAngTable[absAng]; |
---|
| 232 | absAng = angTable[absAng]; |
---|
| 233 | intraPredAngle = signAng * absAng; |
---|
| 234 | |
---|
| 235 | // Do the DC prediction |
---|
| 236 | if (modeDC) |
---|
| 237 | { |
---|
| 238 | Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height, blkAboveAvailable, blkLeftAvailable); |
---|
| 239 | |
---|
| 240 | for (k=0;k<blkSize;k++) |
---|
| 241 | { |
---|
| 242 | for (l=0;l<blkSize;l++) |
---|
| 243 | { |
---|
| 244 | pDst[k*dstStride+l] = dcval; |
---|
| 245 | } |
---|
| 246 | } |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | // Do angular predictions |
---|
| 250 | else |
---|
| 251 | { |
---|
| 252 | Pel* refMain; |
---|
| 253 | Pel* refSide; |
---|
| 254 | Pel refAbove[2*MAX_CU_SIZE+1]; |
---|
| 255 | Pel refLeft[2*MAX_CU_SIZE+1]; |
---|
| 256 | |
---|
| 257 | // Initialise the Main and Left reference array. |
---|
| 258 | if (intraPredAngle < 0) |
---|
| 259 | { |
---|
| 260 | for (k=0;k<blkSize+1;k++) |
---|
| 261 | { |
---|
| 262 | refAbove[k+blkSize-1] = pSrc[k-srcStride-1]; |
---|
| 263 | } |
---|
| 264 | for (k=0;k<blkSize+1;k++) |
---|
| 265 | { |
---|
| 266 | refLeft[k+blkSize-1] = pSrc[(k-1)*srcStride-1]; |
---|
| 267 | } |
---|
| 268 | refMain = (modeVer ? refAbove : refLeft) + (blkSize-1); |
---|
| 269 | refSide = (modeVer ? refLeft : refAbove) + (blkSize-1); |
---|
| 270 | |
---|
| 271 | // Extend the Main reference to the left. |
---|
| 272 | Int invAngleSum = 128; // rounding for (shift by 8) |
---|
| 273 | for (k=-1; k>blkSize*intraPredAngle>>5; k--) |
---|
| 274 | { |
---|
| 275 | invAngleSum += invAngle; |
---|
| 276 | refMain[k] = refSide[invAngleSum>>8]; |
---|
| 277 | } |
---|
| 278 | } |
---|
| 279 | else |
---|
| 280 | { |
---|
| 281 | for (k=0;k<2*blkSize+1;k++) |
---|
| 282 | { |
---|
| 283 | refAbove[k] = pSrc[k-srcStride-1]; |
---|
| 284 | } |
---|
| 285 | for (k=0;k<2*blkSize+1;k++) |
---|
| 286 | { |
---|
| 287 | refLeft[k] = pSrc[(k-1)*srcStride-1]; |
---|
| 288 | } |
---|
| 289 | refMain = modeVer ? refAbove : refLeft; |
---|
| 290 | refSide = modeVer ? refLeft : refAbove; |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | if (intraPredAngle == 0) |
---|
| 294 | { |
---|
| 295 | for (k=0;k<blkSize;k++) |
---|
| 296 | { |
---|
| 297 | for (l=0;l<blkSize;l++) |
---|
| 298 | { |
---|
| 299 | pDst[k*dstStride+l] = refMain[l+1]; |
---|
| 300 | } |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | if ( bFilter ) |
---|
| 304 | { |
---|
| 305 | for (k=0;k<blkSize;k++) |
---|
| 306 | { |
---|
| 307 | pDst[k*dstStride] = Clip3(0, (1<<bitDepth)-1, pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) ); |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | } |
---|
| 311 | else |
---|
| 312 | { |
---|
| 313 | Int deltaPos=0; |
---|
| 314 | Int deltaInt; |
---|
| 315 | Int deltaFract; |
---|
| 316 | Int refMainIndex; |
---|
| 317 | |
---|
| 318 | for (k=0;k<blkSize;k++) |
---|
| 319 | { |
---|
| 320 | deltaPos += intraPredAngle; |
---|
| 321 | deltaInt = deltaPos >> 5; |
---|
| 322 | deltaFract = deltaPos & (32 - 1); |
---|
| 323 | |
---|
| 324 | if (deltaFract) |
---|
| 325 | { |
---|
| 326 | // Do linear filtering |
---|
| 327 | for (l=0;l<blkSize;l++) |
---|
| 328 | { |
---|
| 329 | refMainIndex = l+deltaInt+1; |
---|
| 330 | pDst[k*dstStride+l] = (Pel) ( ((32-deltaFract)*refMain[refMainIndex]+deltaFract*refMain[refMainIndex+1]+16) >> 5 ); |
---|
| 331 | } |
---|
| 332 | } |
---|
| 333 | else |
---|
| 334 | { |
---|
| 335 | // Just copy the integer samples |
---|
| 336 | for (l=0;l<blkSize;l++) |
---|
| 337 | { |
---|
| 338 | pDst[k*dstStride+l] = refMain[l+deltaInt+1]; |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | } |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | // Flip the block if this is the horizontal mode |
---|
| 345 | if (modeHor) |
---|
| 346 | { |
---|
| 347 | Pel tmp; |
---|
| 348 | for (k=0;k<blkSize-1;k++) |
---|
| 349 | { |
---|
| 350 | for (l=k+1;l<blkSize;l++) |
---|
| 351 | { |
---|
| 352 | tmp = pDst[k*dstStride+l]; |
---|
| 353 | pDst[k*dstStride+l] = pDst[l*dstStride+k]; |
---|
| 354 | pDst[l*dstStride+k] = tmp; |
---|
| 355 | } |
---|
| 356 | } |
---|
| 357 | } |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | |
---|
| 361 | Void TComPrediction::predIntraLumaAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ) |
---|
| 362 | { |
---|
| 363 | Pel *pDst = piPred; |
---|
| 364 | Int *ptrSrc; |
---|
| 365 | |
---|
| 366 | assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 |
---|
| 367 | assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 |
---|
| 368 | assert( iWidth == iHeight ); |
---|
| 369 | |
---|
| 370 | ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
| 371 | |
---|
| 372 | // get starting pixel in block |
---|
| 373 | Int sw = 2 * iWidth + 1; |
---|
| 374 | |
---|
| 375 | // Create the prediction |
---|
| 376 | if ( uiDirMode == PLANAR_IDX ) |
---|
| 377 | { |
---|
| 378 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
| 379 | } |
---|
| 380 | else |
---|
| 381 | { |
---|
| 382 | if ( (iWidth > 16) || (iHeight > 16) ) |
---|
| 383 | { |
---|
| 384 | xPredIntraAng(g_bitDepthY, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); |
---|
| 385 | } |
---|
| 386 | else |
---|
| 387 | { |
---|
| 388 | xPredIntraAng(g_bitDepthY, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, true ); |
---|
| 389 | |
---|
| 390 | if( (uiDirMode == DC_IDX ) && bAbove && bLeft ) |
---|
| 391 | { |
---|
| 392 | xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight); |
---|
| 393 | } |
---|
| 394 | } |
---|
| 395 | } |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | // Angular chroma |
---|
| 399 | Void TComPrediction::predIntraChromaAng( Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ) |
---|
| 400 | { |
---|
| 401 | Pel *pDst = piPred; |
---|
| 402 | Int *ptrSrc = piSrc; |
---|
| 403 | |
---|
| 404 | // get starting pixel in block |
---|
| 405 | Int sw = 2 * iWidth + 1; |
---|
| 406 | |
---|
| 407 | if ( uiDirMode == PLANAR_IDX ) |
---|
| 408 | { |
---|
| 409 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
| 410 | } |
---|
| 411 | else |
---|
| 412 | { |
---|
| 413 | // Create the prediction |
---|
| 414 | xPredIntraAng(g_bitDepthC, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); |
---|
| 415 | } |
---|
| 416 | } |
---|
| 417 | |
---|
[531] | 418 | #if H_3D_DIM |
---|
| 419 | Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc ) |
---|
| 420 | { |
---|
| 421 | assert( iWidth == iHeight ); |
---|
| 422 | assert( iWidth >= DIM_MIN_SIZE && iWidth <= DIM_MAX_SIZE ); |
---|
| 423 | assert( isDimMode( uiIntraMode ) ); |
---|
| 424 | |
---|
| 425 | UInt dimType = getDimType ( uiIntraMode ); |
---|
| 426 | Bool dimDeltaDC = isDimDeltaDC( uiIntraMode ); |
---|
| 427 | Bool isDmmMode = (dimType < DMM_NUM_TYPE); |
---|
| 428 | Bool isRbcMode = (dimType == RBC_IDX); |
---|
| 429 | |
---|
| 430 | Bool* biSegPattern = NULL; |
---|
| 431 | UInt patternStride = 0; |
---|
| 432 | |
---|
| 433 | // get partiton |
---|
| 434 | #if H_3D_DIM_DMM |
---|
| 435 | TComWedgelet* dmmSegmentation = NULL; |
---|
| 436 | if( isDmmMode ) |
---|
| 437 | { |
---|
| 438 | switch( dimType ) |
---|
| 439 | { |
---|
| 440 | case( DMM1_IDX ): |
---|
| 441 | { |
---|
| 442 | dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]); |
---|
| 443 | } break; |
---|
| 444 | case( DMM2_IDX ): |
---|
| 445 | { |
---|
| 446 | UInt uiTabIdx = 0; |
---|
| 447 | if( bFastEnc ) { uiTabIdx = pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ); } |
---|
| 448 | else |
---|
| 449 | { |
---|
| 450 | uiTabIdx = xPredWedgeFromIntra( pcCU, uiAbsPartIdx, iWidth, iHeight, pcCU->getDmm2DeltaEnd( uiAbsPartIdx ) ); |
---|
| 451 | pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, uiAbsPartIdx, (pcCU->getDepth(0) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1)) ); |
---|
| 452 | } |
---|
| 453 | dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ uiTabIdx ]); |
---|
| 454 | } break; |
---|
| 455 | case( DMM3_IDX ): |
---|
| 456 | { |
---|
| 457 | UInt uiTabIdx = 0; |
---|
| 458 | if( bFastEnc ) { uiTabIdx = pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ); } |
---|
| 459 | else |
---|
| 460 | { |
---|
| 461 | uiTabIdx = xPredWedgeFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, pcCU->getDmm3IntraTabIdx( uiAbsPartIdx ) ); |
---|
| 462 | pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, uiAbsPartIdx, (pcCU->getDepth(0) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1)) ); |
---|
| 463 | } |
---|
| 464 | dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ uiTabIdx ]); |
---|
| 465 | } break; |
---|
| 466 | case( DMM4_IDX ): |
---|
| 467 | { |
---|
| 468 | dmmSegmentation = new TComWedgelet( iWidth, iHeight ); |
---|
| 469 | xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation ); |
---|
| 470 | } break; |
---|
| 471 | default: assert(0); |
---|
| 472 | } |
---|
| 473 | assert( dmmSegmentation ); |
---|
| 474 | biSegPattern = dmmSegmentation->getPattern(); |
---|
| 475 | patternStride = dmmSegmentation->getStride (); |
---|
| 476 | } |
---|
| 477 | #endif |
---|
| 478 | #if H_3D_DIM_RBC |
---|
| 479 | if( isRbcMode ) |
---|
| 480 | { |
---|
| 481 | biSegPattern = pcCU->getEdgePartition( uiAbsPartIdx ); |
---|
| 482 | patternStride = iWidth; |
---|
| 483 | } |
---|
| 484 | #endif |
---|
| 485 | |
---|
| 486 | // get predicted partition values |
---|
| 487 | assert( biSegPattern ); |
---|
| 488 | Int* piMask = NULL; |
---|
| 489 | if( isDmmMode ) piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering for DMM |
---|
| 490 | else piMask = pcCU->getPattern()->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
| 491 | assert( piMask ); |
---|
| 492 | Int maskStride = 2*iWidth + 1; |
---|
| 493 | Int* ptrSrc = piMask+maskStride+1; |
---|
| 494 | Pel predDC1 = 0; Pel predDC2 = 0; |
---|
| 495 | xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 ); |
---|
| 496 | |
---|
| 497 | // set segment values with deltaDC offsets |
---|
| 498 | Pel segDC1 = 0; |
---|
| 499 | Pel segDC2 = 0; |
---|
| 500 | if( dimDeltaDC ) |
---|
| 501 | { |
---|
| 502 | Pel deltaDC1 = pcCU->getDimDeltaDC( dimType, 0, uiAbsPartIdx ); |
---|
| 503 | Pel deltaDC2 = pcCU->getDimDeltaDC( dimType, 1, uiAbsPartIdx ); |
---|
| 504 | #if H_3D_DIM_DMM |
---|
| 505 | if( isDmmMode ) |
---|
| 506 | { |
---|
| 507 | #if H_3D_DIM_DLT |
---|
| 508 | segDC1 = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 ); |
---|
| 509 | segDC2 = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 ); |
---|
| 510 | #else |
---|
| 511 | segDC1 = ClipY( predDC1 + deltaDC1 ); |
---|
| 512 | segDC2 = ClipY( predDC2 + deltaDC2 ); |
---|
| 513 | #endif |
---|
| 514 | } |
---|
| 515 | #endif |
---|
| 516 | #if H_3D_DIM_RBC |
---|
| 517 | if( isRbcMode ) |
---|
| 518 | { |
---|
| 519 | xDeltaDCQuantScaleUp( pcCU, deltaDC1 ); |
---|
| 520 | xDeltaDCQuantScaleUp( pcCU, deltaDC2 ); |
---|
| 521 | segDC1 = ClipY( predDC1 + deltaDC1 ); |
---|
| 522 | segDC2 = ClipY( predDC2 + deltaDC2 ); |
---|
| 523 | } |
---|
| 524 | #endif |
---|
| 525 | } |
---|
| 526 | else |
---|
| 527 | { |
---|
| 528 | segDC1 = predDC1; |
---|
| 529 | segDC2 = predDC2; |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | // set prediction signal |
---|
| 533 | Pel* pDst = piPred; |
---|
| 534 | xAssignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 ); |
---|
| 535 | |
---|
| 536 | #if H_3D_DIM_DMM |
---|
| 537 | if( dimType == DMM4_IDX ) { dmmSegmentation->destroy(); delete dmmSegmentation; } |
---|
| 538 | #endif |
---|
| 539 | } |
---|
| 540 | #endif |
---|
| 541 | |
---|
[324] | 542 | /** Function for checking identical motion. |
---|
| 543 | * \param TComDataCU* pcCU |
---|
| 544 | * \param UInt PartAddr |
---|
| 545 | */ |
---|
| 546 | Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) |
---|
| 547 | { |
---|
| 548 | if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getPPS()->getWPBiPred() ) |
---|
| 549 | { |
---|
| 550 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0) |
---|
| 551 | { |
---|
| 552 | Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); |
---|
| 553 | Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); |
---|
| 554 | if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
| 555 | { |
---|
| 556 | return true; |
---|
| 557 | } |
---|
| 558 | } |
---|
| 559 | } |
---|
| 560 | return false; |
---|
| 561 | } |
---|
| 562 | |
---|
| 563 | |
---|
| 564 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) |
---|
| 565 | { |
---|
| 566 | Int iWidth; |
---|
| 567 | Int iHeight; |
---|
| 568 | UInt uiPartAddr; |
---|
| 569 | |
---|
| 570 | if ( iPartIdx >= 0 ) |
---|
| 571 | { |
---|
| 572 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
[510] | 573 | #if H_3D_VSP |
---|
| 574 | if ( 0 == pcCU->getVSPFlag(uiPartAddr) ) |
---|
[324] | 575 | { |
---|
[510] | 576 | #endif |
---|
| 577 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
[324] | 578 | { |
---|
[510] | 579 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
| 580 | { |
---|
| 581 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
| 582 | } |
---|
| 583 | else |
---|
| 584 | { |
---|
| 585 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 586 | } |
---|
| 587 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
| 588 | { |
---|
| 589 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 590 | } |
---|
[324] | 591 | } |
---|
| 592 | else |
---|
| 593 | { |
---|
[510] | 594 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
| 595 | { |
---|
| 596 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
| 597 | } |
---|
| 598 | else |
---|
| 599 | { |
---|
| 600 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
| 601 | } |
---|
[324] | 602 | } |
---|
[510] | 603 | #if H_3D_VSP |
---|
[324] | 604 | } |
---|
| 605 | else |
---|
| 606 | { |
---|
| 607 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
[519] | 608 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
[324] | 609 | else |
---|
[519] | 610 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
[324] | 611 | } |
---|
[510] | 612 | #endif |
---|
[324] | 613 | return; |
---|
| 614 | } |
---|
| 615 | |
---|
| 616 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ ) |
---|
| 617 | { |
---|
| 618 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
| 619 | |
---|
[510] | 620 | #if H_3D_VSP |
---|
| 621 | if ( 0 == pcCU->getVSPFlag(uiPartAddr) ) |
---|
[324] | 622 | { |
---|
[510] | 623 | #endif |
---|
| 624 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
[324] | 625 | { |
---|
[510] | 626 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
| 627 | { |
---|
| 628 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
| 629 | } |
---|
| 630 | else |
---|
| 631 | { |
---|
| 632 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 633 | } |
---|
| 634 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
| 635 | { |
---|
| 636 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 637 | } |
---|
[324] | 638 | } |
---|
| 639 | else |
---|
| 640 | { |
---|
[510] | 641 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
| 642 | { |
---|
| 643 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
| 644 | } |
---|
| 645 | else |
---|
| 646 | { |
---|
| 647 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
| 648 | } |
---|
[324] | 649 | } |
---|
[510] | 650 | #if H_3D_VSP |
---|
[324] | 651 | } |
---|
| 652 | else |
---|
| 653 | { |
---|
| 654 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
[519] | 655 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
[324] | 656 | else |
---|
[519] | 657 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
[324] | 658 | } |
---|
[510] | 659 | #endif |
---|
[324] | 660 | } |
---|
| 661 | return; |
---|
| 662 | } |
---|
| 663 | |
---|
| 664 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
| 665 | { |
---|
| 666 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
| 667 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 668 | pcCU->clipMv(cMv); |
---|
[504] | 669 | #if H_3D_ARP |
---|
| 670 | if( pcCU->getARPW( uiPartAddr ) > 0 |
---|
| 671 | && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N |
---|
| 672 | && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() |
---|
| 673 | ) |
---|
| 674 | { |
---|
| 675 | xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi ); |
---|
| 676 | } |
---|
| 677 | else |
---|
| 678 | { |
---|
| 679 | #endif |
---|
| 680 | #if H_3D_IC |
---|
| 681 | Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ); |
---|
| 682 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
| 683 | #if H_3D_ARP |
---|
| 684 | , false |
---|
| 685 | #endif |
---|
| 686 | , bICFlag ); |
---|
| 687 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
| 688 | #if H_3D_ARP |
---|
| 689 | , false |
---|
| 690 | #endif |
---|
| 691 | , bICFlag ); |
---|
| 692 | #else |
---|
[324] | 693 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
| 694 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
[504] | 695 | #endif |
---|
| 696 | #if H_3D_ARP |
---|
| 697 | } |
---|
| 698 | #endif |
---|
[324] | 699 | } |
---|
| 700 | |
---|
[510] | 701 | #if H_3D_VSP |
---|
[519] | 702 | Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
[510] | 703 | { |
---|
[529] | 704 | // Get depth reference |
---|
[566] | 705 | #if MTK_VSP_FIX_E0172 |
---|
| 706 | Int vspDir = pcCU->getVSPDir( uiPartAddr ); |
---|
| 707 | RefPicList privateRefPicList = (vspDir == 0) ? REF_PIC_LIST_0 : REF_PIC_LIST_1; |
---|
| 708 | Int privateRefIdx = pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 709 | Int depthRefViewIdx = pcCU->getSlice()->getRefPic(privateRefPicList, privateRefIdx)->getViewIndex(); |
---|
| 710 | #else |
---|
[510] | 711 | Int depthRefViewIdx = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
[566] | 712 | #endif |
---|
[510] | 713 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
| 714 | assert(pRefPicBaseDepth != NULL); |
---|
| 715 | TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
| 716 | assert(pcBaseViewDepthPicYuv != NULL); |
---|
| 717 | |
---|
[529] | 718 | // Get texture reference |
---|
[510] | 719 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 720 | assert(iRefIdx >= 0); |
---|
| 721 | TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); |
---|
| 722 | TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
| 723 | assert(pcBaseViewTxtPicYuv != NULL); |
---|
| 724 | |
---|
[529] | 725 | // Initialize LUT according to the reference viewIdx |
---|
[510] | 726 | Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex(); |
---|
| 727 | Int* pShiftLUT = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx ); |
---|
[519] | 728 | assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() ); |
---|
[510] | 729 | |
---|
[529] | 730 | // Do compensation |
---|
[566] | 731 | #if MTK_VSP_FIX_E0172 |
---|
| 732 | TComMv cDv = pcCU->getCUMvField( privateRefPicList )->getMv( uiPartAddr ); |
---|
| 733 | #else |
---|
[519] | 734 | TComMv cDv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); // cDv is the disparity vector derived from the neighbors |
---|
[566] | 735 | #endif |
---|
[519] | 736 | pcCU->clipMv(cDv); |
---|
[576] | 737 | |
---|
| 738 | #if NTT_VSP_COMMON_E0207_E0208 |
---|
| 739 | // fetch virtual depth map |
---|
| 740 | #if NTT_VSP_VECTOR_CLIP_E0208 |
---|
| 741 | pcBaseViewDepthPicYuv->extendPicBorder(); |
---|
| 742 | #endif |
---|
| 743 | xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp ); |
---|
| 744 | // sub-PU based compensation |
---|
| 745 | xPredInterLumaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
| 746 | xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
| 747 | #else |
---|
[529] | 748 | UInt uiAbsPartIdx = pcCU->getZorderIdxInCU(); |
---|
[510] | 749 | Int iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
| 750 | Int iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
[519] | 751 | xPredInterLumaBlkFromDM ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, &cDv, uiPartAddr, iBlkX, iBlkY, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
| 752 | xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, &cDv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
[576] | 753 | #endif |
---|
| 754 | |
---|
[510] | 755 | } |
---|
| 756 | #endif |
---|
| 757 | |
---|
[504] | 758 | #if H_3D_ARP |
---|
| 759 | Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled ) |
---|
| 760 | { |
---|
| 761 | Int iRefIdx = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 762 | TComMv cMv = pNewMvFiled ? pNewMvFiled->getMv() : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 763 | Bool bTobeScaled = false; |
---|
| 764 | TComPic* pcPicYuvBaseCol = NULL; |
---|
| 765 | TComPic* pcPicYuvBaseRef = NULL; |
---|
| 766 | |
---|
| 767 | #if H_3D_NBDV |
---|
| 768 | DisInfo cDistparity; |
---|
| 769 | cDistparity.bDV = pcCU->getDvInfo(uiPartAddr).bDV; |
---|
| 770 | if( cDistparity.bDV ) |
---|
| 771 | { |
---|
| 772 | cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV; |
---|
| 773 | assert(pcCU->getDvInfo(uiPartAddr).bDV == pcCU->getDvInfo(0).bDV); |
---|
| 774 | cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
| 775 | } |
---|
| 776 | #else |
---|
| 777 | assert(0); // ARP can be applied only when a DV is available |
---|
| 778 | #endif |
---|
| 779 | |
---|
| 780 | UChar dW = cDistparity.bDV ? pcCU->getARPW ( uiPartAddr ) : 0; |
---|
| 781 | |
---|
| 782 | if( cDistparity.bDV ) |
---|
| 783 | { |
---|
| 784 | if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC()!= pcCU->getSlice()->getPOC() ) |
---|
| 785 | { |
---|
| 786 | bTobeScaled = true; |
---|
| 787 | } |
---|
| 788 | |
---|
| 789 | pcPicYuvBaseCol = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(), cDistparity.m_aVIdxCan ); |
---|
| 790 | pcPicYuvBaseRef = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC(), cDistparity.m_aVIdxCan ); |
---|
| 791 | |
---|
| 792 | if( ( !pcPicYuvBaseCol || pcPicYuvBaseCol->getPOC() != pcCU->getSlice()->getPOC() ) || ( !pcPicYuvBaseRef || pcPicYuvBaseRef->getPOC() != pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ) ) |
---|
| 793 | { |
---|
| 794 | dW = 0; |
---|
| 795 | bTobeScaled = false; |
---|
| 796 | } |
---|
| 797 | else |
---|
| 798 | { |
---|
| 799 | assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ); |
---|
| 800 | } |
---|
| 801 | |
---|
| 802 | if(bTobeScaled) |
---|
| 803 | { |
---|
| 804 | Int iCurrPOC = pcCU->getSlice()->getPOC(); |
---|
| 805 | Int iColRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx ); |
---|
| 806 | Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, 0); |
---|
| 807 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC); |
---|
| 808 | if ( iScale != 4096 ) |
---|
| 809 | { |
---|
| 810 | cMv = cMv.scaleMv( iScale ); |
---|
| 811 | } |
---|
| 812 | iRefIdx = 0; |
---|
| 813 | } |
---|
| 814 | } |
---|
| 815 | |
---|
| 816 | pcCU->clipMv(cMv); |
---|
| 817 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(); |
---|
| 818 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true ); |
---|
| 819 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true ); |
---|
| 820 | |
---|
| 821 | if( dW > 0 ) |
---|
| 822 | { |
---|
| 823 | TComYuv * pYuvB0 = &m_acYuvPredBase[0]; |
---|
| 824 | TComYuv * pYuvB1 = &m_acYuvPredBase[1]; |
---|
| 825 | |
---|
| 826 | TComMv cMVwithDisparity = cMv + cDistparity.m_acNBDV; |
---|
| 827 | pcCU->clipMv(cMVwithDisparity); |
---|
| 828 | |
---|
| 829 | assert ( cDistparity.bDV ); |
---|
| 830 | |
---|
| 831 | pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec(); |
---|
| 832 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true ); |
---|
| 833 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true ); |
---|
| 834 | |
---|
| 835 | pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec(); |
---|
| 836 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true ); |
---|
| 837 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true ); |
---|
| 838 | |
---|
| 839 | pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight ); |
---|
| 840 | |
---|
| 841 | if( 2 == dW ) |
---|
| 842 | { |
---|
| 843 | pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); |
---|
| 844 | } |
---|
| 845 | rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi ); |
---|
| 846 | } |
---|
| 847 | } |
---|
| 848 | #endif |
---|
| 849 | |
---|
[324] | 850 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
| 851 | { |
---|
| 852 | TComYuv* pcMbYuv; |
---|
| 853 | Int iRefIdx[2] = {-1, -1}; |
---|
| 854 | |
---|
| 855 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
| 856 | { |
---|
| 857 | RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
| 858 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 859 | |
---|
| 860 | if ( iRefIdx[iRefList] < 0 ) |
---|
| 861 | { |
---|
| 862 | continue; |
---|
| 863 | } |
---|
| 864 | |
---|
| 865 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
| 866 | |
---|
| 867 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
| 868 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
| 869 | { |
---|
| 870 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
| 871 | } |
---|
| 872 | else |
---|
| 873 | { |
---|
| 874 | if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || |
---|
| 875 | ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) ) |
---|
| 876 | { |
---|
| 877 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
| 878 | } |
---|
| 879 | else |
---|
| 880 | { |
---|
| 881 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv ); |
---|
| 882 | } |
---|
| 883 | } |
---|
| 884 | } |
---|
| 885 | |
---|
| 886 | if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) |
---|
| 887 | { |
---|
| 888 | xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 889 | } |
---|
| 890 | else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) |
---|
| 891 | { |
---|
| 892 | xWeightedPredictionUni( pcCU, &m_acYuvPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred ); |
---|
| 893 | } |
---|
| 894 | else |
---|
| 895 | { |
---|
| 896 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 897 | } |
---|
| 898 | } |
---|
| 899 | |
---|
[510] | 900 | #if H_3D_VSP |
---|
| 901 | |
---|
[519] | 902 | Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
[510] | 903 | { |
---|
| 904 | TComYuv* pcMbYuv; |
---|
| 905 | Int iRefIdx[2] = {-1, -1}; |
---|
[529] | 906 | Bool bi = (pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0); |
---|
[510] | 907 | |
---|
| 908 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
| 909 | { |
---|
| 910 | RefPicList eRefPicList = RefPicList(iRefList); |
---|
| 911 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 912 | |
---|
| 913 | if ( iRefIdx[iRefList] < 0 ) |
---|
| 914 | continue; |
---|
| 915 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
| 916 | |
---|
| 917 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
[529] | 918 | xPredInterUniVSP ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, bi ); |
---|
[510] | 919 | } |
---|
| 920 | |
---|
| 921 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 922 | } |
---|
| 923 | |
---|
| 924 | #endif |
---|
| 925 | |
---|
[324] | 926 | /** |
---|
| 927 | * \brief Generate motion-compensated luma block |
---|
| 928 | * |
---|
| 929 | * \param cu Pointer to current CU |
---|
| 930 | * \param refPic Pointer to reference picture |
---|
| 931 | * \param partAddr Address of block within CU |
---|
| 932 | * \param mv Motion vector |
---|
| 933 | * \param width Width of block |
---|
| 934 | * \param height Height of block |
---|
| 935 | * \param dstPic Pointer to destination picture |
---|
| 936 | * \param bi Flag indicating whether bipred is used |
---|
| 937 | */ |
---|
[504] | 938 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
| 939 | #if H_3D_ARP |
---|
| 940 | , Bool filterType |
---|
| 941 | #endif |
---|
| 942 | #if H_3D_IC |
---|
| 943 | , Bool bICFlag |
---|
| 944 | #endif |
---|
| 945 | ) |
---|
[324] | 946 | { |
---|
| 947 | Int refStride = refPic->getStride(); |
---|
| 948 | Int refOffset = ( mv->getHor() >> 2 ) + ( mv->getVer() >> 2 ) * refStride; |
---|
| 949 | Pel *ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 950 | |
---|
| 951 | Int dstStride = dstPic->getStride(); |
---|
| 952 | Pel *dst = dstPic->getLumaAddr( partAddr ); |
---|
| 953 | |
---|
| 954 | Int xFrac = mv->getHor() & 0x3; |
---|
| 955 | Int yFrac = mv->getVer() & 0x3; |
---|
| 956 | |
---|
[504] | 957 | #if H_3D_IC |
---|
| 958 | if( cu->getSlice()->getIsDepth() ) |
---|
| 959 | { |
---|
| 960 | refOffset = mv->getHor() + mv->getVer() * refStride; |
---|
| 961 | ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 962 | xFrac = 0; |
---|
| 963 | yFrac = 0; |
---|
| 964 | } |
---|
| 965 | #endif |
---|
[324] | 966 | if ( yFrac == 0 ) |
---|
| 967 | { |
---|
[504] | 968 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi |
---|
| 969 | #if H_3D_ARP |
---|
| 970 | , filterType |
---|
| 971 | #endif |
---|
| 972 | ); |
---|
[324] | 973 | } |
---|
| 974 | else if ( xFrac == 0 ) |
---|
| 975 | { |
---|
[504] | 976 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi |
---|
| 977 | #if H_3D_ARP |
---|
| 978 | , filterType |
---|
| 979 | #endif |
---|
| 980 | ); |
---|
[324] | 981 | } |
---|
| 982 | else |
---|
| 983 | { |
---|
| 984 | Int tmpStride = m_filteredBlockTmp[0].getStride(); |
---|
| 985 | Short *tmp = m_filteredBlockTmp[0].getLumaAddr(); |
---|
| 986 | |
---|
| 987 | Int filterSize = NTAPS_LUMA; |
---|
| 988 | Int halfFilterSize = ( filterSize >> 1 ); |
---|
| 989 | |
---|
[504] | 990 | m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false |
---|
| 991 | #if H_3D_ARP |
---|
| 992 | , filterType |
---|
| 993 | #endif |
---|
| 994 | ); |
---|
| 995 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi |
---|
| 996 | #if H_3D_ARP |
---|
| 997 | , filterType |
---|
| 998 | #endif |
---|
| 999 | ); |
---|
[324] | 1000 | } |
---|
[504] | 1001 | |
---|
| 1002 | #if H_3D_IC |
---|
| 1003 | if( bICFlag ) |
---|
| 1004 | { |
---|
| 1005 | Int a, b, iShift, i, j; |
---|
| 1006 | |
---|
| 1007 | xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_LUMA ); |
---|
| 1008 | |
---|
| 1009 | for ( i = 0; i < height; i++ ) |
---|
| 1010 | { |
---|
| 1011 | for ( j = 0; j < width; j++ ) |
---|
| 1012 | { |
---|
| 1013 | if( bi ) |
---|
| 1014 | { |
---|
| 1015 | Int iIFshift = IF_INTERNAL_PREC - g_bitDepthY; |
---|
| 1016 | dst[j] = ( ( a*dst[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1 << iIFshift ) - IF_INTERNAL_OFFS; |
---|
| 1017 | } |
---|
| 1018 | else |
---|
| 1019 | dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b ); |
---|
| 1020 | } |
---|
| 1021 | dst += dstStride; |
---|
| 1022 | } |
---|
| 1023 | } |
---|
| 1024 | #endif |
---|
[324] | 1025 | } |
---|
| 1026 | |
---|
| 1027 | /** |
---|
| 1028 | * \brief Generate motion-compensated chroma block |
---|
| 1029 | * |
---|
| 1030 | * \param cu Pointer to current CU |
---|
| 1031 | * \param refPic Pointer to reference picture |
---|
| 1032 | * \param partAddr Address of block within CU |
---|
| 1033 | * \param mv Motion vector |
---|
| 1034 | * \param width Width of block |
---|
| 1035 | * \param height Height of block |
---|
| 1036 | * \param dstPic Pointer to destination picture |
---|
| 1037 | * \param bi Flag indicating whether bipred is used |
---|
| 1038 | */ |
---|
[504] | 1039 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
| 1040 | #if H_3D_ARP |
---|
| 1041 | , Bool filterType |
---|
| 1042 | #endif |
---|
| 1043 | #if H_3D_IC |
---|
| 1044 | , Bool bICFlag |
---|
| 1045 | #endif |
---|
| 1046 | ) |
---|
[324] | 1047 | { |
---|
| 1048 | Int refStride = refPic->getCStride(); |
---|
| 1049 | Int dstStride = dstPic->getCStride(); |
---|
| 1050 | |
---|
| 1051 | Int refOffset = (mv->getHor() >> 3) + (mv->getVer() >> 3) * refStride; |
---|
| 1052 | |
---|
| 1053 | Pel* refCb = refPic->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1054 | Pel* refCr = refPic->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1055 | |
---|
| 1056 | Pel* dstCb = dstPic->getCbAddr( partAddr ); |
---|
| 1057 | Pel* dstCr = dstPic->getCrAddr( partAddr ); |
---|
| 1058 | |
---|
| 1059 | Int xFrac = mv->getHor() & 0x7; |
---|
| 1060 | Int yFrac = mv->getVer() & 0x7; |
---|
| 1061 | UInt cxWidth = width >> 1; |
---|
| 1062 | UInt cxHeight = height >> 1; |
---|
| 1063 | |
---|
| 1064 | Int extStride = m_filteredBlockTmp[0].getStride(); |
---|
| 1065 | Short* extY = m_filteredBlockTmp[0].getLumaAddr(); |
---|
| 1066 | |
---|
| 1067 | Int filterSize = NTAPS_CHROMA; |
---|
| 1068 | |
---|
| 1069 | Int halfFilterSize = (filterSize>>1); |
---|
| 1070 | |
---|
| 1071 | if ( yFrac == 0 ) |
---|
| 1072 | { |
---|
[504] | 1073 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
| 1074 | #if H_3D_ARP |
---|
| 1075 | , filterType |
---|
| 1076 | #endif |
---|
| 1077 | ); |
---|
| 1078 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
| 1079 | #if H_3D_ARP |
---|
| 1080 | , filterType |
---|
| 1081 | #endif |
---|
| 1082 | ); |
---|
[324] | 1083 | } |
---|
| 1084 | else if ( xFrac == 0 ) |
---|
| 1085 | { |
---|
[504] | 1086 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
| 1087 | #if H_3D_ARP |
---|
| 1088 | , filterType |
---|
| 1089 | #endif |
---|
| 1090 | ); |
---|
| 1091 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
| 1092 | #if H_3D_ARP |
---|
| 1093 | , filterType |
---|
| 1094 | #endif |
---|
| 1095 | ); |
---|
[324] | 1096 | } |
---|
| 1097 | else |
---|
| 1098 | { |
---|
[504] | 1099 | m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
| 1100 | #if H_3D_ARP |
---|
| 1101 | , filterType |
---|
| 1102 | #endif |
---|
| 1103 | ); |
---|
| 1104 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
| 1105 | #if H_3D_ARP |
---|
| 1106 | , filterType |
---|
| 1107 | #endif |
---|
| 1108 | ); |
---|
[324] | 1109 | |
---|
[504] | 1110 | m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
| 1111 | #if H_3D_ARP |
---|
| 1112 | , filterType |
---|
| 1113 | #endif |
---|
| 1114 | ); |
---|
| 1115 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
| 1116 | #if H_3D_ARP |
---|
| 1117 | , filterType |
---|
| 1118 | #endif |
---|
| 1119 | ); |
---|
[324] | 1120 | } |
---|
[504] | 1121 | |
---|
| 1122 | #if H_3D_IC |
---|
| 1123 | if( bICFlag ) |
---|
| 1124 | { |
---|
| 1125 | Int a, b, iShift, i, j; |
---|
| 1126 | xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_CHROMA_U ); // Cb |
---|
| 1127 | for ( i = 0; i < cxHeight; i++ ) |
---|
| 1128 | { |
---|
| 1129 | for ( j = 0; j < cxWidth; j++ ) |
---|
| 1130 | { |
---|
| 1131 | if( bi ) |
---|
| 1132 | { |
---|
| 1133 | Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC; |
---|
| 1134 | dstCb[j] = ( ( a*dstCb[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1<<iIFshift ) - IF_INTERNAL_OFFS; |
---|
| 1135 | } |
---|
| 1136 | else |
---|
| 1137 | dstCb[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b ); |
---|
| 1138 | } |
---|
| 1139 | dstCb += dstStride; |
---|
| 1140 | } |
---|
| 1141 | xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_CHROMA_V ); // Cr |
---|
| 1142 | for ( i = 0; i < cxHeight; i++ ) |
---|
| 1143 | { |
---|
| 1144 | for ( j = 0; j < cxWidth; j++ ) |
---|
| 1145 | { |
---|
| 1146 | if( bi ) |
---|
| 1147 | { |
---|
| 1148 | Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC; |
---|
| 1149 | dstCr[j] = ( ( a*dstCr[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1<<iIFshift ) - IF_INTERNAL_OFFS; |
---|
| 1150 | } |
---|
| 1151 | else |
---|
| 1152 | dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b ); |
---|
| 1153 | } |
---|
| 1154 | dstCr += dstStride; |
---|
| 1155 | } |
---|
| 1156 | } |
---|
| 1157 | #endif |
---|
[324] | 1158 | } |
---|
| 1159 | |
---|
| 1160 | Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) |
---|
| 1161 | { |
---|
| 1162 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
| 1163 | { |
---|
| 1164 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); |
---|
| 1165 | } |
---|
| 1166 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
| 1167 | { |
---|
| 1168 | pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
| 1169 | } |
---|
| 1170 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
| 1171 | { |
---|
| 1172 | pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
| 1173 | } |
---|
| 1174 | } |
---|
| 1175 | |
---|
| 1176 | // AMVP |
---|
| 1177 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred ) |
---|
| 1178 | { |
---|
| 1179 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
| 1180 | if( pcAMVPInfo->iN <= 1 ) |
---|
| 1181 | { |
---|
| 1182 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
| 1183 | |
---|
| 1184 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 1185 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 1186 | return; |
---|
| 1187 | } |
---|
| 1188 | |
---|
| 1189 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
| 1190 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
| 1191 | return; |
---|
| 1192 | } |
---|
| 1193 | |
---|
| 1194 | /** Function for deriving planar intra prediction. |
---|
| 1195 | * \param pSrc pointer to reconstructed sample array |
---|
| 1196 | * \param srcStride the stride of the reconstructed sample array |
---|
| 1197 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 1198 | * \param dstStride the stride of the prediction sample array |
---|
| 1199 | * \param width the width of the block |
---|
| 1200 | * \param height the height of the block |
---|
| 1201 | * |
---|
| 1202 | * This function derives the prediction samples for planar mode (intra coding). |
---|
| 1203 | */ |
---|
| 1204 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
| 1205 | { |
---|
| 1206 | assert(width == height); |
---|
| 1207 | |
---|
| 1208 | Int k, l, bottomLeft, topRight; |
---|
| 1209 | Int horPred; |
---|
| 1210 | Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
| 1211 | UInt blkSize = width; |
---|
| 1212 | UInt offset2D = width; |
---|
| 1213 | UInt shift1D = g_aucConvertToBit[ width ] + 2; |
---|
| 1214 | UInt shift2D = shift1D + 1; |
---|
| 1215 | |
---|
| 1216 | // Get left and above reference column and row |
---|
| 1217 | for(k=0;k<blkSize+1;k++) |
---|
| 1218 | { |
---|
| 1219 | topRow[k] = pSrc[k-srcStride]; |
---|
| 1220 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
| 1221 | } |
---|
| 1222 | |
---|
| 1223 | // Prepare intermediate variables used in interpolation |
---|
| 1224 | bottomLeft = leftColumn[blkSize]; |
---|
| 1225 | topRight = topRow[blkSize]; |
---|
| 1226 | for (k=0;k<blkSize;k++) |
---|
| 1227 | { |
---|
| 1228 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
| 1229 | rightColumn[k] = topRight - leftColumn[k]; |
---|
| 1230 | topRow[k] <<= shift1D; |
---|
| 1231 | leftColumn[k] <<= shift1D; |
---|
| 1232 | } |
---|
| 1233 | |
---|
| 1234 | // Generate prediction signal |
---|
| 1235 | for (k=0;k<blkSize;k++) |
---|
| 1236 | { |
---|
| 1237 | horPred = leftColumn[k] + offset2D; |
---|
| 1238 | for (l=0;l<blkSize;l++) |
---|
| 1239 | { |
---|
| 1240 | horPred += rightColumn[k]; |
---|
| 1241 | topRow[l] += bottomRow[l]; |
---|
| 1242 | rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); |
---|
| 1243 | } |
---|
| 1244 | } |
---|
| 1245 | } |
---|
| 1246 | |
---|
| 1247 | /** Function for filtering intra DC predictor. |
---|
| 1248 | * \param pSrc pointer to reconstructed sample array |
---|
| 1249 | * \param iSrcStride the stride of the reconstructed sample array |
---|
| 1250 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 1251 | * \param iDstStride the stride of the prediction sample array |
---|
| 1252 | * \param iWidth the width of the block |
---|
| 1253 | * \param iHeight the height of the block |
---|
| 1254 | * |
---|
| 1255 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
| 1256 | */ |
---|
| 1257 | Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) |
---|
| 1258 | { |
---|
| 1259 | Pel* pDst = rpDst; |
---|
| 1260 | Int x, y, iDstStride2, iSrcStride2; |
---|
| 1261 | |
---|
| 1262 | // boundary pixels processing |
---|
| 1263 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
| 1264 | |
---|
| 1265 | for ( x = 1; x < iWidth; x++ ) |
---|
| 1266 | { |
---|
| 1267 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
| 1268 | } |
---|
| 1269 | |
---|
| 1270 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
| 1271 | { |
---|
| 1272 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
| 1273 | } |
---|
| 1274 | |
---|
| 1275 | return; |
---|
| 1276 | } |
---|
[504] | 1277 | #if H_3D_IC |
---|
| 1278 | /** Function for deriving the position of first non-zero binary bit of a value |
---|
| 1279 | * \param x input value |
---|
| 1280 | * |
---|
| 1281 | * This function derives the position of first non-zero binary bit of a value |
---|
| 1282 | */ |
---|
| 1283 | Int GetMSB( UInt x ) |
---|
| 1284 | { |
---|
| 1285 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
| 1286 | |
---|
| 1287 | while( x > 1 ) |
---|
| 1288 | { |
---|
| 1289 | bits >>= 1; |
---|
| 1290 | y = x >> bits; |
---|
| 1291 | |
---|
| 1292 | if( y ) |
---|
| 1293 | { |
---|
| 1294 | x = y; |
---|
| 1295 | iMSB += bits; |
---|
| 1296 | } |
---|
| 1297 | } |
---|
| 1298 | |
---|
| 1299 | iMSB+=y; |
---|
| 1300 | |
---|
| 1301 | return iMSB; |
---|
| 1302 | } |
---|
| 1303 | |
---|
| 1304 | /** Function for counting leading number of zeros/ones |
---|
| 1305 | * \param x input value |
---|
| 1306 | \ This function counts leading number of zeros for positive numbers and |
---|
| 1307 | \ leading number of ones for negative numbers. This can be implemented in |
---|
| 1308 | \ single instructure cycle on many processors. |
---|
| 1309 | */ |
---|
| 1310 | |
---|
| 1311 | Short CountLeadingZerosOnes (Short x) |
---|
| 1312 | { |
---|
| 1313 | Short clz; |
---|
| 1314 | Short i; |
---|
| 1315 | |
---|
| 1316 | if(x == 0) |
---|
| 1317 | { |
---|
| 1318 | clz = 0; |
---|
| 1319 | } |
---|
| 1320 | else |
---|
| 1321 | { |
---|
| 1322 | if (x == -1) |
---|
| 1323 | { |
---|
| 1324 | clz = 15; |
---|
| 1325 | } |
---|
| 1326 | else |
---|
| 1327 | { |
---|
| 1328 | if(x < 0) |
---|
| 1329 | { |
---|
| 1330 | x = ~x; |
---|
| 1331 | } |
---|
| 1332 | clz = 15; |
---|
| 1333 | for(i = 0;i < 15;++i) |
---|
| 1334 | { |
---|
| 1335 | if(x) |
---|
| 1336 | { |
---|
| 1337 | clz --; |
---|
| 1338 | } |
---|
| 1339 | x = x >> 1; |
---|
| 1340 | } |
---|
| 1341 | } |
---|
| 1342 | } |
---|
| 1343 | return clz; |
---|
| 1344 | } |
---|
| 1345 | |
---|
| 1346 | /** Function for deriving LM illumination compensation. |
---|
| 1347 | */ |
---|
| 1348 | Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift, TextType eType ) |
---|
| 1349 | { |
---|
| 1350 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
| 1351 | Pel *pRec = NULL, *pRef = NULL; |
---|
| 1352 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
| 1353 | Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride(); |
---|
| 1354 | Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride(); |
---|
| 1355 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset, iHor, iVer; |
---|
| 1356 | |
---|
| 1357 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1358 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1359 | iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 ); |
---|
| 1360 | iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 ); |
---|
| 1361 | iRefX = iCUPelX + iHor; |
---|
| 1362 | iRefY = iCUPelY + iVer; |
---|
| 1363 | if( eType != TEXT_LUMA ) |
---|
| 1364 | { |
---|
| 1365 | iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 ); |
---|
| 1366 | iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 ); |
---|
| 1367 | } |
---|
| 1368 | uiWidth = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 ) : ( pcCU->getWidth( 0 ) >> 1 ); |
---|
| 1369 | uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1 ); |
---|
| 1370 | |
---|
| 1371 | Int i, j, iCountShift = 0; |
---|
| 1372 | |
---|
| 1373 | // LLS parameters estimation --> |
---|
| 1374 | |
---|
| 1375 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
| 1376 | |
---|
| 1377 | if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelY > 0 && iRefY > 0 ) |
---|
| 1378 | { |
---|
| 1379 | iRefOffset = iHor + iVer * iRefStride - iRefStride; |
---|
| 1380 | if( eType == TEXT_LUMA ) |
---|
| 1381 | { |
---|
| 1382 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1383 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1384 | } |
---|
| 1385 | else if( eType == TEXT_CHROMA_U ) |
---|
| 1386 | { |
---|
| 1387 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1388 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1389 | } |
---|
| 1390 | else |
---|
| 1391 | { |
---|
| 1392 | assert( eType == TEXT_CHROMA_V ); |
---|
| 1393 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1394 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1395 | } |
---|
| 1396 | |
---|
| 1397 | for( j = 0; j < uiWidth; j++ ) |
---|
| 1398 | { |
---|
| 1399 | x += pRef[j]; |
---|
| 1400 | y += pRec[j]; |
---|
| 1401 | xx += pRef[j] * pRef[j]; |
---|
| 1402 | xy += pRef[j] * pRec[j]; |
---|
| 1403 | } |
---|
| 1404 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
| 1405 | } |
---|
| 1406 | |
---|
| 1407 | |
---|
| 1408 | if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelX > 0 && iRefX > 0 ) |
---|
| 1409 | { |
---|
| 1410 | iRefOffset = iHor + iVer * iRefStride - 1; |
---|
| 1411 | if( eType == TEXT_LUMA ) |
---|
| 1412 | { |
---|
| 1413 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1414 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1415 | } |
---|
| 1416 | else if( eType == TEXT_CHROMA_U ) |
---|
| 1417 | { |
---|
| 1418 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1419 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1420 | } |
---|
| 1421 | else |
---|
| 1422 | { |
---|
| 1423 | assert( eType == TEXT_CHROMA_V ); |
---|
| 1424 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1425 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1426 | } |
---|
| 1427 | |
---|
| 1428 | for( i = 0; i < uiHeight; i++ ) |
---|
| 1429 | { |
---|
| 1430 | x += pRef[0]; |
---|
| 1431 | y += pRec[0]; |
---|
| 1432 | xx += pRef[0] * pRef[0]; |
---|
| 1433 | xy += pRef[0] * pRec[0]; |
---|
| 1434 | |
---|
| 1435 | pRef += iRefStride; |
---|
| 1436 | pRec += iRecStride; |
---|
| 1437 | } |
---|
| 1438 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
| 1439 | } |
---|
| 1440 | |
---|
| 1441 | Int iTempShift = ( ( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
| 1442 | |
---|
| 1443 | if( iTempShift > 0 ) |
---|
| 1444 | { |
---|
| 1445 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1446 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1447 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1448 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1449 | iCountShift -= iTempShift; |
---|
| 1450 | } |
---|
| 1451 | |
---|
| 1452 | iShift = 13; |
---|
| 1453 | |
---|
| 1454 | if( iCountShift == 0 ) |
---|
| 1455 | { |
---|
| 1456 | a = 1; |
---|
| 1457 | b = 0; |
---|
| 1458 | iShift = 0; |
---|
| 1459 | } |
---|
| 1460 | else |
---|
| 1461 | { |
---|
| 1462 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
| 1463 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
| 1464 | |
---|
| 1465 | { |
---|
| 1466 | const Int iShiftA2 = 6; |
---|
| 1467 | const Int iShiftA1 = 15; |
---|
| 1468 | const Int iAccuracyShift = 15; |
---|
| 1469 | |
---|
| 1470 | Int iScaleShiftA2 = 0; |
---|
| 1471 | Int iScaleShiftA1 = 0; |
---|
| 1472 | Int a1s = a1; |
---|
| 1473 | Int a2s = a2; |
---|
| 1474 | |
---|
| 1475 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
| 1476 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
| 1477 | |
---|
| 1478 | if( iScaleShiftA1 < 0 ) |
---|
| 1479 | { |
---|
| 1480 | iScaleShiftA1 = 0; |
---|
| 1481 | } |
---|
| 1482 | |
---|
| 1483 | if( iScaleShiftA2 < 0 ) |
---|
| 1484 | { |
---|
| 1485 | iScaleShiftA2 = 0; |
---|
| 1486 | } |
---|
| 1487 | |
---|
| 1488 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
| 1489 | |
---|
| 1490 | a2s = a2 >> iScaleShiftA2; |
---|
| 1491 | |
---|
| 1492 | a1s = a1 >> iScaleShiftA1; |
---|
| 1493 | |
---|
| 1494 | if (a2s >= 1) |
---|
| 1495 | { |
---|
| 1496 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
| 1497 | } |
---|
| 1498 | else |
---|
| 1499 | { |
---|
| 1500 | a = 0; |
---|
| 1501 | } |
---|
| 1502 | |
---|
| 1503 | if( iScaleShiftA < 0 ) |
---|
| 1504 | { |
---|
| 1505 | a = a << -iScaleShiftA; |
---|
| 1506 | } |
---|
| 1507 | else |
---|
| 1508 | { |
---|
| 1509 | a = a >> iScaleShiftA; |
---|
| 1510 | } |
---|
| 1511 | |
---|
| 1512 | a = Clip3( -( 1 << 15 ), ( 1 << 15 ) - 1, a ); |
---|
| 1513 | |
---|
| 1514 | Int minA = -(1 << (6)); |
---|
| 1515 | Int maxA = (1 << 6) - 1; |
---|
| 1516 | if( a <= maxA && a >= minA ) |
---|
| 1517 | { |
---|
| 1518 | // do nothing |
---|
| 1519 | } |
---|
| 1520 | else |
---|
| 1521 | { |
---|
| 1522 | Short n = CountLeadingZerosOnes( a ); |
---|
| 1523 | a = a >> (9-n); |
---|
| 1524 | iShift -= (9-n); |
---|
| 1525 | } |
---|
| 1526 | |
---|
| 1527 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 1528 | } |
---|
| 1529 | } |
---|
| 1530 | } |
---|
| 1531 | #endif |
---|
[510] | 1532 | |
---|
| 1533 | #if H_3D_VSP |
---|
[576] | 1534 | |
---|
| 1535 | #if NTT_VSP_COMMON_E0207_E0208 |
---|
| 1536 | // not fully support iRatioTxtPerDepth* != 1 |
---|
[578] | 1537 | Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY ) |
---|
[576] | 1538 | { |
---|
| 1539 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE; |
---|
| 1540 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE; |
---|
| 1541 | |
---|
[578] | 1542 | Int refDepStride = picRefDepth->getStride(); |
---|
[576] | 1543 | |
---|
| 1544 | #if NTT_VSP_VECTOR_CLIP_E0208 |
---|
| 1545 | |
---|
[578] | 1546 | Int refDepOffset = ( (mv->getHor()+2) >> 2 ) + ( (mv->getVer()+2) >> 2 ) * refDepStride; |
---|
| 1547 | Pel *refDepth = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
[576] | 1548 | |
---|
[578] | 1549 | if( ratioTxtPerDepthX!=1 || ratioTxtPerDepthY!=1 ) |
---|
| 1550 | { |
---|
| 1551 | Int posX, posY; |
---|
| 1552 | refDepth = picRefDepth->getLumaAddr( ); |
---|
| 1553 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
| 1554 | posX /= ratioTxtPerDepthX; // texture position -> depth postion |
---|
| 1555 | posY /= ratioTxtPerDepthY; |
---|
| 1556 | refDepOffset += posX + posY * refDepStride; |
---|
[576] | 1557 | |
---|
[578] | 1558 | width /= ratioTxtPerDepthX; // texture size -> depth size |
---|
| 1559 | height /= ratioTxtPerDepthY; |
---|
| 1560 | } |
---|
[576] | 1561 | |
---|
| 1562 | refDepth += refDepOffset; |
---|
| 1563 | |
---|
| 1564 | #else // NTT_VSP_VECTOR_CLIP_E0208 |
---|
| 1565 | |
---|
[578] | 1566 | Int widthDepth = picRefDepth->getWidth(); |
---|
| 1567 | Int heightDepth = picRefDepth->getHeight(); |
---|
| 1568 | Int posX, posY; |
---|
| 1569 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
| 1570 | posX /= ratioTxtPerDepthX; // texture position -> depth postion |
---|
| 1571 | posY /= ratioTxtPerDepthY; |
---|
[576] | 1572 | |
---|
[578] | 1573 | posX = Clip3(0, widthDepth-width, posX + ((mv->getHor()+2)>>2)); |
---|
| 1574 | posY = Clip3(0, heightDepth-height, posY + ((mv->getVer()+2)>>2)); |
---|
[576] | 1575 | |
---|
[578] | 1576 | Pel *refDepth = picRefDepth->getLumaAddr() + posX + posY * refDepStride; |
---|
[576] | 1577 | |
---|
| 1578 | #endif // NTT_VSP_VECTOR_CLIP_E0208 |
---|
| 1579 | |
---|
[578] | 1580 | Int depStride = yuvDepth->getStride(); |
---|
| 1581 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
[576] | 1582 | |
---|
| 1583 | #if NTT_VSP_ADAPTIVE_SPLIT_E0207 |
---|
| 1584 | |
---|
[578] | 1585 | if( width<8 || height<8 ) |
---|
[576] | 1586 | { // no split |
---|
[578] | 1587 | Int rightOffset = width - 1; |
---|
[576] | 1588 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
| 1589 | Pel *refDepthTop = refDepth; |
---|
[578] | 1590 | Pel *refDepthBot = refDepthTop + (height-1)*refDepStride; |
---|
[576] | 1591 | |
---|
| 1592 | Pel maxDepth = refDepthTop[0] > refDepthBot[0] ? refDepthTop[0] : refDepthBot[0]; |
---|
[578] | 1593 | if( maxDepth < refDepthTop[rightOffset] ) { maxDepth = refDepthTop[rightOffset]; } |
---|
| 1594 | if( maxDepth < refDepthBot[rightOffset] ) { maxDepth = refDepthBot[rightOffset]; } |
---|
[576] | 1595 | |
---|
[578] | 1596 | for( Int sY=0; sY<height; sY+=nTxtPerDepthY ) |
---|
[576] | 1597 | { |
---|
[578] | 1598 | for( Int sX=0; sX<width; sX+=nTxtPerDepthX ) |
---|
[576] | 1599 | { |
---|
| 1600 | depth[sX] = maxDepth; |
---|
| 1601 | } |
---|
| 1602 | depth += depStrideBlock; |
---|
| 1603 | } |
---|
| 1604 | } |
---|
| 1605 | else |
---|
| 1606 | { // split to 4x8, or 8x4 |
---|
| 1607 | Int blocksize = 8; |
---|
| 1608 | Int subblocksize = 4; |
---|
| 1609 | Int depStrideBlock = depStride * blocksize; |
---|
| 1610 | Pel *depthTmp = NULL; |
---|
| 1611 | Int depStrideTmp = depStride * nTxtPerDepthY; |
---|
| 1612 | Int offset[4] = { 0, subblocksize-1, subblocksize, blocksize-1 }; |
---|
| 1613 | Pel *refDepthTmp[4] = { NULL, NULL, NULL, NULL }; |
---|
| 1614 | Pel repDepth4x8[2] = {0, 0}; |
---|
| 1615 | Pel repDepth8x4[2] = {0, 0}; |
---|
| 1616 | |
---|
| 1617 | Int refDepStrideBlock = refDepStride * blocksize; |
---|
| 1618 | Int refDepStrideSubBlock = refDepStride * subblocksize; |
---|
| 1619 | |
---|
| 1620 | refDepthTmp[0] = refDepth; |
---|
| 1621 | refDepthTmp[2] = refDepthTmp[0] + refDepStrideSubBlock; |
---|
| 1622 | refDepthTmp[1] = refDepthTmp[2] - refDepStride; |
---|
| 1623 | refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock; |
---|
| 1624 | |
---|
[578] | 1625 | for( Int y=0; y<height; y+=blocksize ) |
---|
[576] | 1626 | { |
---|
[578] | 1627 | for( Int x=0; x<width; x+=blocksize ) |
---|
[576] | 1628 | { |
---|
| 1629 | Bool ULvsBR = false, URvsBL = false; |
---|
| 1630 | |
---|
| 1631 | ULvsBR = refDepthTmp[0][x+offset[0]] < refDepthTmp[3][x+offset[3]]; |
---|
| 1632 | URvsBL = refDepthTmp[0][x+offset[3]] < refDepthTmp[3][x+offset[0]]; |
---|
| 1633 | |
---|
| 1634 | if( ULvsBR ^ URvsBL ) |
---|
| 1635 | { // 4x8 |
---|
| 1636 | repDepth4x8[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[1]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[1]]; |
---|
[578] | 1637 | if( repDepth4x8[0] < refDepthTmp[3][x+offset[0]] ) |
---|
| 1638 | { |
---|
| 1639 | repDepth4x8[0] = refDepthTmp[3][x+offset[0]]; |
---|
| 1640 | } |
---|
| 1641 | if( repDepth4x8[0] < refDepthTmp[3][x+offset[1]] ) |
---|
| 1642 | { |
---|
| 1643 | repDepth4x8[0] = refDepthTmp[3][x+offset[1]]; |
---|
| 1644 | } |
---|
[576] | 1645 | repDepth4x8[1] = refDepthTmp[0][x+offset[2]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[2]] : refDepthTmp[0][x+offset[3]]; |
---|
[578] | 1646 | if( repDepth4x8[1] < refDepthTmp[3][x+offset[2]] ) |
---|
| 1647 | { |
---|
| 1648 | repDepth4x8[1] = refDepthTmp[3][x+offset[2]]; |
---|
| 1649 | } |
---|
| 1650 | if( repDepth4x8[1] < refDepthTmp[3][x+offset[3]] ) |
---|
| 1651 | { |
---|
| 1652 | repDepth4x8[1] = refDepthTmp[3][x+offset[3]]; |
---|
| 1653 | } |
---|
[576] | 1654 | |
---|
| 1655 | depthTmp = &depth[x]; |
---|
| 1656 | for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY ) |
---|
| 1657 | { |
---|
| 1658 | for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX ) |
---|
| 1659 | { |
---|
| 1660 | depthTmp[sX] = repDepth4x8[0]; |
---|
| 1661 | } |
---|
| 1662 | depthTmp += depStrideTmp; |
---|
| 1663 | } |
---|
| 1664 | depthTmp = &depth[x+subblocksize]; |
---|
| 1665 | for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY ) |
---|
| 1666 | { |
---|
| 1667 | for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX ) |
---|
| 1668 | { |
---|
| 1669 | depthTmp[sX] = repDepth4x8[1]; |
---|
| 1670 | } |
---|
| 1671 | depthTmp += depStrideTmp; |
---|
| 1672 | } |
---|
| 1673 | } |
---|
| 1674 | else |
---|
| 1675 | { // 8x4 |
---|
| 1676 | repDepth8x4[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[3]]; |
---|
[578] | 1677 | if( repDepth8x4[0] < refDepthTmp[1][x+offset[0]] ) |
---|
| 1678 | { |
---|
| 1679 | repDepth8x4[0] = refDepthTmp[1][x+offset[0]]; |
---|
| 1680 | } |
---|
| 1681 | if( repDepth8x4[0] < refDepthTmp[1][x+offset[3]] ) |
---|
| 1682 | { |
---|
| 1683 | repDepth8x4[0] = refDepthTmp[1][x+offset[3]]; |
---|
| 1684 | } |
---|
[576] | 1685 | repDepth8x4[1] = refDepthTmp[2][x+offset[0]] > refDepthTmp[2][x+offset[3]] ? refDepthTmp[2][x+offset[0]] : refDepthTmp[2][x+offset[3]]; |
---|
[578] | 1686 | if( repDepth8x4[1] < refDepthTmp[3][x+offset[0]] ) |
---|
| 1687 | { |
---|
| 1688 | repDepth8x4[1] = refDepthTmp[3][x+offset[0]]; |
---|
| 1689 | } |
---|
| 1690 | if( repDepth8x4[1] < refDepthTmp[3][x+offset[3]] ) |
---|
| 1691 | { |
---|
| 1692 | repDepth8x4[1] = refDepthTmp[3][x+offset[3]]; |
---|
| 1693 | } |
---|
[576] | 1694 | |
---|
| 1695 | depthTmp = &depth[x]; |
---|
| 1696 | for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY ) |
---|
| 1697 | { |
---|
| 1698 | for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX ) |
---|
| 1699 | { |
---|
| 1700 | depthTmp[sX] = repDepth8x4[0]; |
---|
| 1701 | } |
---|
| 1702 | depthTmp += depStrideTmp; |
---|
| 1703 | } |
---|
| 1704 | for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY ) |
---|
| 1705 | { |
---|
| 1706 | for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX ) |
---|
| 1707 | { |
---|
| 1708 | depthTmp[sX] = repDepth8x4[1]; |
---|
| 1709 | } |
---|
| 1710 | depthTmp += depStrideTmp; |
---|
| 1711 | } |
---|
| 1712 | } |
---|
| 1713 | } |
---|
| 1714 | refDepthTmp[0] += refDepStrideBlock; |
---|
| 1715 | refDepthTmp[1] += refDepStrideBlock; |
---|
| 1716 | refDepthTmp[2] += refDepStrideBlock; |
---|
| 1717 | refDepthTmp[3] += refDepStrideBlock; |
---|
| 1718 | depth += depStrideBlock; |
---|
| 1719 | } |
---|
| 1720 | } |
---|
| 1721 | |
---|
| 1722 | #else // NTT_VSP_ADAPTIVE_SPLIT_E0207 |
---|
| 1723 | |
---|
| 1724 | Int rightOffset = nTxtPerDepthX - 1; |
---|
| 1725 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
| 1726 | Int refDepStrideBlock = refDepStride * nTxtPerDepthY; |
---|
| 1727 | Pel *refDepthTop = refDepth; |
---|
| 1728 | Pel *refDepthBot = refDepthTop + (nTxtPerDepthY-1)*refDepStride; |
---|
| 1729 | |
---|
[578] | 1730 | for( Int y=0; y<height; y+= nTxtPerDepthY ) |
---|
[576] | 1731 | { |
---|
[578] | 1732 | for( Int x=0; x<width; x+=nTxtPerDepthX ) |
---|
[576] | 1733 | { |
---|
| 1734 | Pel maxDepth = refDepthTop[x] > refDepthBot[x] ? refDepthTop[x] : refDepthBot[x]; |
---|
| 1735 | |
---|
[578] | 1736 | if( maxDepth < refDepthTop[x+rightOffset] ) |
---|
| 1737 | { |
---|
| 1738 | maxDepth = refDepthTop[x+rightOffset]; |
---|
| 1739 | } |
---|
| 1740 | if( maxDepth < refDepthBot[x+rightOffset] ) |
---|
| 1741 | { |
---|
| 1742 | maxDepth = refDepthBot[x+rightOffset]; |
---|
| 1743 | } |
---|
[576] | 1744 | |
---|
| 1745 | depth[x] = maxDepth; |
---|
| 1746 | |
---|
| 1747 | } |
---|
| 1748 | refDepthTop += refDepStrideBlock; |
---|
| 1749 | refDepthBot += refDepStrideBlock; |
---|
| 1750 | depth += depStrideBlock; |
---|
| 1751 | } |
---|
| 1752 | |
---|
| 1753 | #endif // NTT_VSP_ADAPTIVE_SPLIT_E0207 |
---|
| 1754 | } |
---|
| 1755 | |
---|
[578] | 1756 | 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 ) |
---|
[576] | 1757 | { |
---|
| 1758 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE; |
---|
| 1759 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE; |
---|
| 1760 | |
---|
[578] | 1761 | Int refStride = picRef->getStride(); |
---|
| 1762 | Int dstStride = yuvDst->getStride(); |
---|
| 1763 | Int depStride = yuvDepth->getStride(); |
---|
[576] | 1764 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
| 1765 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
| 1766 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
| 1767 | |
---|
[578] | 1768 | Pel *ref = picRef->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
| 1769 | Pel *dst = yuvDst->getLumaAddr(partAddr); |
---|
| 1770 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
[576] | 1771 | |
---|
| 1772 | #if !(NTT_VSP_DC_BUGFIX_E0208) |
---|
[578] | 1773 | Int widthLuma = picRef->getWidth(); |
---|
| 1774 | Int posX, posY; |
---|
| 1775 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
[576] | 1776 | #endif |
---|
| 1777 | |
---|
| 1778 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 1779 | #if H_3D_VSP_CONSTRAINED |
---|
| 1780 | //get LUT based horizontal reference range |
---|
[578] | 1781 | Int range = xGetConstrainedSize(width, height); |
---|
[576] | 1782 | |
---|
| 1783 | // The minimum depth value |
---|
| 1784 | Int minRelativePos = MAX_INT; |
---|
| 1785 | Int maxRelativePos = MIN_INT; |
---|
| 1786 | |
---|
| 1787 | Pel* depthTemp, *depthInitial=depth; |
---|
[578] | 1788 | for (Int yTxt = 0; yTxt < height; yTxt++) |
---|
[576] | 1789 | { |
---|
[578] | 1790 | for (Int xTxt = 0; xTxt < width; xTxt++) |
---|
[576] | 1791 | { |
---|
| 1792 | if (depthPosX+xTxt < widthDepth) |
---|
[578] | 1793 | { |
---|
[576] | 1794 | depthTemp = depthInitial + xTxt; |
---|
[578] | 1795 | } |
---|
[576] | 1796 | else |
---|
[578] | 1797 | { |
---|
[576] | 1798 | depthTemp = depthInitial + (widthDepth - depthPosX - 1); |
---|
[578] | 1799 | } |
---|
[576] | 1800 | |
---|
[578] | 1801 | Int disparity = shiftLUT[ *depthTemp ]; // << iShiftPrec; |
---|
[576] | 1802 | Int disparityInt = disparity >> 2; |
---|
| 1803 | |
---|
| 1804 | if( disparity <= 0) |
---|
| 1805 | { |
---|
| 1806 | if (minRelativePos > disparityInt+xTxt) |
---|
[578] | 1807 | { |
---|
| 1808 | minRelativePos = disparityInt+xTxt; |
---|
| 1809 | } |
---|
[576] | 1810 | } |
---|
| 1811 | else |
---|
| 1812 | { |
---|
| 1813 | if (maxRelativePos < disparityInt+xTxt) |
---|
[578] | 1814 | { |
---|
| 1815 | maxRelativePos = disparityInt+xTxt; |
---|
| 1816 | } |
---|
[576] | 1817 | } |
---|
| 1818 | } |
---|
| 1819 | if (depthPosY+yTxt < heightDepth) |
---|
[578] | 1820 | { |
---|
[576] | 1821 | depthInitial = depthInitial + depStride; |
---|
[578] | 1822 | } |
---|
[576] | 1823 | } |
---|
| 1824 | |
---|
[578] | 1825 | Int disparity_tmp = shiftLUT[ *depth ]; // << iShiftPrec; |
---|
[576] | 1826 | if (disparity_tmp <= 0) |
---|
[578] | 1827 | { |
---|
[576] | 1828 | maxRelativePos = minRelativePos + range -1 ; |
---|
[578] | 1829 | } |
---|
[576] | 1830 | else |
---|
[578] | 1831 | { |
---|
[576] | 1832 | minRelativePos = maxRelativePos - range +1 ; |
---|
[578] | 1833 | } |
---|
[576] | 1834 | #endif |
---|
| 1835 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
| 1836 | |
---|
[578] | 1837 | TComMv dv(0, 0); |
---|
[576] | 1838 | |
---|
[578] | 1839 | for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY ) |
---|
[576] | 1840 | { |
---|
[578] | 1841 | for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX ) |
---|
[576] | 1842 | { |
---|
| 1843 | Pel repDepth = depth[ xTxt ]; |
---|
| 1844 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
| 1845 | |
---|
[578] | 1846 | Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec ?? |
---|
[576] | 1847 | Int xFrac = disparity & 0x3; |
---|
| 1848 | |
---|
| 1849 | #if NTT_VSP_DC_BUGFIX_E0208 |
---|
| 1850 | |
---|
[578] | 1851 | dv.setHor( disparity ); |
---|
| 1852 | cu->clipMv( dv ); |
---|
[576] | 1853 | |
---|
[578] | 1854 | Int refOffset = xTxt + (dv.getHor() >> 2); |
---|
[576] | 1855 | |
---|
| 1856 | #if H_3D_VSP_CONSTRAINED |
---|
| 1857 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
[578] | 1858 | { |
---|
[576] | 1859 | xFrac = 0; |
---|
[578] | 1860 | } |
---|
[576] | 1861 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
| 1862 | #endif |
---|
| 1863 | |
---|
| 1864 | assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 ); |
---|
[578] | 1865 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
[576] | 1866 | |
---|
| 1867 | #else // NTT_VSP_DC_BUGFIX_E0208 |
---|
| 1868 | |
---|
| 1869 | for( Int j=0; j < nTxtPerDepthX; j++ ) |
---|
| 1870 | { |
---|
| 1871 | Int refOffset = xTxt+j + (disparity >> 2); |
---|
| 1872 | #if H_3D_VSP_CONSTRAINED |
---|
| 1873 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
[578] | 1874 | { |
---|
[576] | 1875 | xFrac = 0; |
---|
[578] | 1876 | } |
---|
[576] | 1877 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
| 1878 | #endif |
---|
[578] | 1879 | Int absX = posX + refOffset; |
---|
[576] | 1880 | |
---|
| 1881 | if (xFrac == 0) |
---|
[578] | 1882 | { |
---|
[576] | 1883 | absX = Clip3(0, widthLuma-1, absX); |
---|
[578] | 1884 | } |
---|
[576] | 1885 | else |
---|
[578] | 1886 | { |
---|
[576] | 1887 | absX = Clip3(4, widthLuma-5, absX); |
---|
[578] | 1888 | } |
---|
[576] | 1889 | |
---|
[578] | 1890 | refOffset = absX - posX; |
---|
[576] | 1891 | assert( ref[refOffset] >= 0 && ref[refOffset] <= 255 ); |
---|
| 1892 | |
---|
[578] | 1893 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi ); |
---|
[576] | 1894 | } |
---|
| 1895 | |
---|
| 1896 | #endif // NTT_VSP_DC_BUGFIX_E0208 |
---|
| 1897 | |
---|
| 1898 | } |
---|
| 1899 | ref += refStrideBlock; |
---|
| 1900 | dst += dstStrideBlock; |
---|
| 1901 | depth += depStrideBlock; |
---|
| 1902 | } |
---|
| 1903 | |
---|
| 1904 | } |
---|
| 1905 | |
---|
[578] | 1906 | 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 ) |
---|
[576] | 1907 | { |
---|
| 1908 | #if (H_3D_VSP_BLOCKSIZE==1) |
---|
| 1909 | Int nTxtPerDepthX = 1; |
---|
| 1910 | Int nTxtPerDepthY = 1; |
---|
| 1911 | #else |
---|
| 1912 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE >> 1; |
---|
| 1913 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE >> 1; |
---|
| 1914 | #endif |
---|
| 1915 | |
---|
[578] | 1916 | Int refStride = picRef->getCStride(); |
---|
| 1917 | Int dstStride = yuvDst->getCStride(); |
---|
| 1918 | Int depStride = yuvDepth->getStride(); |
---|
[576] | 1919 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
| 1920 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
| 1921 | Int depStrideBlock = depStride * (nTxtPerDepthY<<1); |
---|
| 1922 | |
---|
[578] | 1923 | Pel *refCb = picRef->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
| 1924 | Pel *refCr = picRef->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
| 1925 | Pel *dstCb = yuvDst->getCbAddr(partAddr); |
---|
| 1926 | Pel *dstCr = yuvDst->getCrAddr(partAddr); |
---|
| 1927 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
[576] | 1928 | |
---|
| 1929 | #if !(NTT_VSP_DC_BUGFIX_E0208) |
---|
[578] | 1930 | Int widthChroma = picRef->getWidth() >> 1; |
---|
| 1931 | Int posX, posY; |
---|
| 1932 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
| 1933 | posX >>= 1; |
---|
| 1934 | posY >>= 1; |
---|
[576] | 1935 | #endif |
---|
| 1936 | |
---|
| 1937 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 1938 | #if H_3D_VSP_CONSTRAINED |
---|
| 1939 | //get LUT based horizontal reference range |
---|
[578] | 1940 | Int range = xGetConstrainedSize(width, height, false); |
---|
[576] | 1941 | |
---|
| 1942 | // The minimum depth value |
---|
| 1943 | Int minRelativePos = MAX_INT; |
---|
| 1944 | Int maxRelativePos = MIN_INT; |
---|
| 1945 | |
---|
| 1946 | Int depthTmp; |
---|
[578] | 1947 | for (Int yTxt=0; yTxt<height; yTxt++) |
---|
[576] | 1948 | { |
---|
[578] | 1949 | for (Int xTxt=0; xTxt<width; xTxt++) |
---|
[576] | 1950 | { |
---|
[578] | 1951 | depthTmp = m_pDepthBlock[xTxt+yTxt*width]; |
---|
| 1952 | Int disparity = shiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
[576] | 1953 | Int disparityInt = disparity >> 3;//in chroma resolution |
---|
| 1954 | |
---|
| 1955 | if (disparityInt < 0) |
---|
| 1956 | { |
---|
| 1957 | if (minRelativePos > disparityInt+xTxt) |
---|
[578] | 1958 | { |
---|
| 1959 | minRelativePos = disparityInt+xTxt; |
---|
| 1960 | } |
---|
[576] | 1961 | } |
---|
| 1962 | else |
---|
| 1963 | { |
---|
| 1964 | if (maxRelativePos < disparityInt+xTxt) |
---|
[578] | 1965 | { |
---|
| 1966 | maxRelativePos = disparityInt+xTxt; |
---|
| 1967 | } |
---|
[576] | 1968 | } |
---|
| 1969 | } |
---|
| 1970 | } |
---|
| 1971 | |
---|
| 1972 | depthTmp = m_pDepthBlock[0]; |
---|
[578] | 1973 | Int disparity_tmp = shiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
[576] | 1974 | if ( disparity_tmp < 0 ) |
---|
[578] | 1975 | { |
---|
[576] | 1976 | maxRelativePos = minRelativePos + range - 1; |
---|
[578] | 1977 | } |
---|
[576] | 1978 | else |
---|
[578] | 1979 | { |
---|
[576] | 1980 | minRelativePos = maxRelativePos - range + 1; |
---|
[578] | 1981 | } |
---|
[576] | 1982 | |
---|
| 1983 | #endif // H_3D_VSP_CONSTRAINED |
---|
| 1984 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
| 1985 | |
---|
[578] | 1986 | TComMv dv(0, 0); |
---|
[576] | 1987 | // luma size -> chroma size |
---|
[578] | 1988 | height >>= 1; |
---|
| 1989 | width >>= 1; |
---|
[576] | 1990 | |
---|
[578] | 1991 | for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY ) |
---|
[576] | 1992 | { |
---|
[578] | 1993 | for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX ) |
---|
[576] | 1994 | { |
---|
| 1995 | Pel repDepth = depth[ xTxt<<1 ]; |
---|
| 1996 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
| 1997 | |
---|
[578] | 1998 | Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec; |
---|
[576] | 1999 | Int xFrac = disparity & 0x7; |
---|
| 2000 | |
---|
| 2001 | #if NTT_VSP_DC_BUGFIX_E0208 |
---|
| 2002 | |
---|
[578] | 2003 | dv.setHor( disparity ); |
---|
| 2004 | cu->clipMv( dv ); |
---|
[576] | 2005 | |
---|
[578] | 2006 | Int refOffset = xTxt + (dv.getHor() >> 3); |
---|
[576] | 2007 | |
---|
| 2008 | #if H_3D_VSP_CONSTRAINED |
---|
| 2009 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
[578] | 2010 | { |
---|
[576] | 2011 | xFrac = 0; |
---|
[578] | 2012 | } |
---|
[576] | 2013 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
| 2014 | #endif |
---|
| 2015 | |
---|
| 2016 | assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 ); |
---|
| 2017 | assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 ); |
---|
| 2018 | |
---|
[578] | 2019 | m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
| 2020 | m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
[576] | 2021 | |
---|
| 2022 | #else // NTT_VSP_DC_BUGFIX_E0208 |
---|
| 2023 | |
---|
| 2024 | for( Int j=0; j < nTxtPerDepthX; j++ ) |
---|
| 2025 | { |
---|
| 2026 | Int refOffset = xTxt+j + (disparity >> 3); |
---|
| 2027 | #if H_3D_VSP_CONSTRAINED |
---|
| 2028 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
[578] | 2029 | { |
---|
[576] | 2030 | xFrac = 0; |
---|
[578] | 2031 | } |
---|
[576] | 2032 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
| 2033 | #endif |
---|
[578] | 2034 | Int absX = posX + refOffset; |
---|
[576] | 2035 | |
---|
| 2036 | if (xFrac == 0) |
---|
[578] | 2037 | { |
---|
[576] | 2038 | absX = Clip3(0, widthChroma-1, absX); |
---|
[578] | 2039 | } |
---|
[576] | 2040 | else |
---|
[578] | 2041 | { |
---|
[576] | 2042 | absX = Clip3(4, widthChroma-5, absX); |
---|
[578] | 2043 | } |
---|
[576] | 2044 | |
---|
[578] | 2045 | refOffset = absX - posX; |
---|
[576] | 2046 | assert( refCb[refOffset] >= 0 && refCb[refOffset] <= 255 ); |
---|
| 2047 | assert( refCr[refOffset] >= 0 && refCr[refOffset] <= 255 ); |
---|
| 2048 | |
---|
[578] | 2049 | m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi ); |
---|
| 2050 | m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi ); |
---|
[576] | 2051 | } |
---|
| 2052 | |
---|
| 2053 | #endif // NTT_VSP_DC_BUGFIX_E0208 |
---|
| 2054 | } |
---|
| 2055 | refCb += refStrideBlock; |
---|
| 2056 | refCr += refStrideBlock; |
---|
| 2057 | dstCb += dstStrideBlock; |
---|
| 2058 | dstCr += dstStrideBlock; |
---|
| 2059 | depth += depStrideBlock; |
---|
| 2060 | } |
---|
| 2061 | |
---|
| 2062 | } |
---|
| 2063 | #else // NTT_VSP_COMMON_E0207_E0208 |
---|
| 2064 | |
---|
[510] | 2065 | // Input: |
---|
| 2066 | // refPic: Ref picture. Full picture, with padding |
---|
| 2067 | // posX, posY: PU position, texture |
---|
| 2068 | // sizeX, sizeY: PU size |
---|
| 2069 | // partAddr: z-order index |
---|
[519] | 2070 | // dv: disparity vector. derived from neighboring blocks |
---|
[510] | 2071 | // |
---|
| 2072 | // Output: dstPic, PU predictor 64x64 |
---|
[519] | 2073 | Void TComPrediction::xPredInterLumaBlkFromDM( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, TComMv* dv, UInt partAddr,Int posX, Int posY |
---|
[510] | 2074 | , Int sizeX, Int sizeY, Bool isDepth, TComYuv *&dstPic, Bool bi ) |
---|
| 2075 | { |
---|
| 2076 | Int widthLuma; |
---|
| 2077 | Int heightLuma; |
---|
| 2078 | |
---|
| 2079 | if (isDepth) |
---|
| 2080 | { |
---|
| 2081 | widthLuma = pPicBaseDepth->getWidth(); |
---|
| 2082 | heightLuma = pPicBaseDepth->getHeight(); |
---|
| 2083 | } |
---|
| 2084 | else |
---|
| 2085 | { |
---|
| 2086 | widthLuma = refPic->getWidth(); |
---|
| 2087 | heightLuma = refPic->getHeight(); |
---|
| 2088 | } |
---|
| 2089 | |
---|
| 2090 | #if H_3D_VSP_BLOCKSIZE != 1 |
---|
| 2091 | Int widthDepth = pPicBaseDepth->getWidth(); |
---|
| 2092 | Int heightDepth = pPicBaseDepth->getHeight(); |
---|
| 2093 | #endif |
---|
| 2094 | |
---|
| 2095 | #if H_3D_VSP_CONSTRAINED |
---|
| 2096 | Int widthDepth = pPicBaseDepth->getWidth(); |
---|
| 2097 | Int heightDepth = pPicBaseDepth->getHeight(); |
---|
| 2098 | #endif |
---|
| 2099 | |
---|
| 2100 | Int nTxtPerDepthX = widthLuma / ( pPicBaseDepth->getWidth() ); // texture pixel # per depth pixel |
---|
| 2101 | Int nTxtPerDepthY = heightLuma / ( pPicBaseDepth->getHeight() ); |
---|
| 2102 | |
---|
| 2103 | Int refStride = refPic->getStride(); |
---|
| 2104 | Int dstStride = dstPic->getStride(); |
---|
| 2105 | Int depStride = pPicBaseDepth->getStride(); |
---|
[519] | 2106 | Int depthPosX = Clip3(0, widthLuma - sizeX, (posX/nTxtPerDepthX) + ((dv->getHor()+2)>>2)); |
---|
| 2107 | Int depthPosY = Clip3(0, heightLuma- sizeY, (posY/nTxtPerDepthY) + ((dv->getVer()+2)>>2)); |
---|
[510] | 2108 | Pel *ref = refPic->getLumaAddr() + posX + posY * refStride; |
---|
| 2109 | Pel *dst = dstPic->getLumaAddr(partAddr); |
---|
| 2110 | Pel *depth = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride; |
---|
| 2111 | |
---|
| 2112 | #if H_3D_VSP_BLOCKSIZE != 1 |
---|
| 2113 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
| 2114 | Int dW = sizeX>>1; |
---|
| 2115 | Int dH = sizeY>>1; |
---|
| 2116 | #endif |
---|
| 2117 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
| 2118 | Int dW = sizeX>>2; |
---|
| 2119 | Int dH = sizeY>>2; |
---|
| 2120 | #endif |
---|
| 2121 | { |
---|
| 2122 | Pel* depthi = depth; |
---|
| 2123 | for (Int j = 0; j < dH; j++) |
---|
| 2124 | { |
---|
| 2125 | for (Int i = 0; i < dW; i++) |
---|
| 2126 | { |
---|
| 2127 | Pel* depthTmp; |
---|
| 2128 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
| 2129 | if (depthPosX + (i<<1) < widthDepth) |
---|
| 2130 | depthTmp = depthi + (i << 1); |
---|
| 2131 | else |
---|
| 2132 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
| 2133 | #endif |
---|
| 2134 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
| 2135 | if (depthPosX + (i<<2) < widthDepth) |
---|
| 2136 | depthTmp = depthi + (i << 2); |
---|
| 2137 | else |
---|
| 2138 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
| 2139 | #endif |
---|
| 2140 | Int maxV = 0; |
---|
| 2141 | for (Int blockj = 0; blockj < H_3D_VSP_BLOCKSIZE; blockj+=(H_3D_VSP_BLOCKSIZE-1)) |
---|
| 2142 | { |
---|
| 2143 | Int iX = 0; |
---|
| 2144 | for (Int blocki = 0; blocki < H_3D_VSP_BLOCKSIZE; blocki+=(H_3D_VSP_BLOCKSIZE-1)) |
---|
| 2145 | { |
---|
| 2146 | if (maxV < depthTmp[iX]) |
---|
| 2147 | maxV = depthTmp[iX]; |
---|
| 2148 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
| 2149 | if (depthPosX + (i<<1) + blocki < widthDepth - 1) |
---|
| 2150 | #else // H_3D_VSP_BLOCKSIZE == 4 |
---|
| 2151 | if (depthPosX + (i<<2) + blocki < widthDepth - 1) |
---|
| 2152 | #endif |
---|
| 2153 | iX = (H_3D_VSP_BLOCKSIZE-1); |
---|
| 2154 | } |
---|
| 2155 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
| 2156 | if (depthPosY + (j<<1) + blockj < heightDepth - 1) |
---|
| 2157 | #else // H_3D_VSP_BLOCKSIZE == 4 |
---|
| 2158 | if (depthPosY + (j<<2) + blockj < heightDepth - 1) |
---|
| 2159 | #endif |
---|
| 2160 | depthTmp += depStride * (H_3D_VSP_BLOCKSIZE-1); |
---|
| 2161 | } |
---|
| 2162 | m_pDepthBlock[i+j*dW] = maxV; |
---|
| 2163 | } // end of i < dW |
---|
| 2164 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
| 2165 | if (depthPosY + ((j+1)<<1) < heightDepth) |
---|
| 2166 | depthi += (depStride << 1); |
---|
| 2167 | else |
---|
| 2168 | depthi = depth + (heightDepth-depthPosY-1)*depStride; |
---|
| 2169 | #endif |
---|
| 2170 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
| 2171 | if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1 |
---|
| 2172 | depthi += (depStride << 2); |
---|
| 2173 | else |
---|
| 2174 | depthi = depth + (heightDepth-depthPosY-1)*depStride; // the last line |
---|
| 2175 | #endif |
---|
| 2176 | } |
---|
| 2177 | } |
---|
| 2178 | #endif // H_3D_VSP_BLOCKSIZE != 1 |
---|
| 2179 | |
---|
| 2180 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2181 | #if H_3D_VSP_CONSTRAINED |
---|
| 2182 | //get LUT based horizontal reference range |
---|
| 2183 | Int range = xGetConstrainedSize(sizeX, sizeY); |
---|
| 2184 | |
---|
| 2185 | // The minimum depth value |
---|
| 2186 | Int minRelativePos = MAX_INT; |
---|
| 2187 | Int maxRelativePos = MIN_INT; |
---|
| 2188 | |
---|
| 2189 | Pel* depthTemp, *depthInitial=depth; |
---|
[512] | 2190 | for (Int yTxt = 0; yTxt < sizeY; yTxt++) |
---|
[510] | 2191 | { |
---|
[512] | 2192 | for (Int xTxt = 0; xTxt < sizeX; xTxt++) |
---|
[510] | 2193 | { |
---|
| 2194 | if (depthPosX+xTxt < widthDepth) |
---|
| 2195 | depthTemp = depthInitial + xTxt; |
---|
| 2196 | else |
---|
| 2197 | depthTemp = depthInitial + (widthDepth - depthPosX - 1); |
---|
| 2198 | |
---|
| 2199 | Int disparity = pShiftLUT[ *depthTemp ]; // << iShiftPrec; |
---|
| 2200 | Int disparityInt = disparity >> 2; |
---|
| 2201 | |
---|
| 2202 | if( disparity <= 0) |
---|
| 2203 | { |
---|
| 2204 | if (minRelativePos > disparityInt+xTxt) |
---|
| 2205 | minRelativePos = disparityInt+xTxt; |
---|
| 2206 | } |
---|
| 2207 | else |
---|
| 2208 | { |
---|
| 2209 | if (maxRelativePos < disparityInt+xTxt) |
---|
| 2210 | maxRelativePos = disparityInt+xTxt; |
---|
| 2211 | } |
---|
| 2212 | } |
---|
| 2213 | if (depthPosY+yTxt < heightDepth) |
---|
| 2214 | depthInitial = depthInitial + depStride; |
---|
| 2215 | } |
---|
| 2216 | |
---|
| 2217 | Int disparity_tmp = pShiftLUT[ *depth ]; // << iShiftPrec; |
---|
| 2218 | if (disparity_tmp <= 0) |
---|
| 2219 | maxRelativePos = minRelativePos + range -1 ; |
---|
| 2220 | else |
---|
| 2221 | minRelativePos = maxRelativePos - range +1 ; |
---|
| 2222 | #endif |
---|
| 2223 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2224 | |
---|
| 2225 | #if H_3D_VSP_BLOCKSIZE != 1 |
---|
| 2226 | Int yDepth = 0; |
---|
| 2227 | #endif |
---|
| 2228 | for ( Int yTxt = 0; yTxt < sizeY; yTxt += nTxtPerDepthY ) |
---|
| 2229 | { |
---|
| 2230 | for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth++ ) |
---|
| 2231 | { |
---|
| 2232 | Pel repDepth = 0; // to store the depth value used for warping |
---|
| 2233 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2234 | repDepth = depth[xDepth]; |
---|
| 2235 | #endif |
---|
| 2236 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
| 2237 | repDepth = m_pDepthBlock[(xTxt>>1) + (yTxt>>1)*dW]; |
---|
| 2238 | #endif |
---|
| 2239 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
| 2240 | repDepth = m_pDepthBlock[(xTxt>>2) + (yTxt>>2)*dW]; |
---|
| 2241 | #endif |
---|
| 2242 | |
---|
| 2243 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
| 2244 | Int disparity = pShiftLUT[ repDepth ]; // remove << iShiftPrec ?? |
---|
| 2245 | Int refOffset = xTxt + (disparity >> 2); |
---|
| 2246 | Int xFrac = disparity & 0x3; |
---|
| 2247 | #if H_3D_VSP_CONSTRAINED |
---|
| 2248 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
| 2249 | xFrac = 0; |
---|
| 2250 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
| 2251 | #endif |
---|
| 2252 | Int absX = posX + refOffset; |
---|
| 2253 | |
---|
| 2254 | if (xFrac == 0) |
---|
| 2255 | absX = Clip3(0, widthLuma-1, absX); |
---|
| 2256 | else |
---|
| 2257 | absX = Clip3(4, widthLuma-5, absX); |
---|
| 2258 | |
---|
| 2259 | refOffset = absX - posX; |
---|
| 2260 | |
---|
| 2261 | assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 ); |
---|
| 2262 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi ); |
---|
| 2263 | } |
---|
| 2264 | ref += refStride*nTxtPerDepthY; |
---|
| 2265 | dst += dstStride*nTxtPerDepthY; |
---|
| 2266 | depth += depStride; |
---|
| 2267 | #if H_3D_VSP_BLOCKSIZE != 1 |
---|
| 2268 | yDepth++; |
---|
| 2269 | #endif |
---|
| 2270 | |
---|
| 2271 | } |
---|
| 2272 | } |
---|
| 2273 | |
---|
[519] | 2274 | Void TComPrediction::xPredInterChromaBlkFromDM ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, TComMv*dv, UInt partAddr, Int posX, Int posY |
---|
[510] | 2275 | , Int sizeX, Int sizeY, Bool isDepth, TComYuv *&dstPic, Bool bi) |
---|
| 2276 | { |
---|
| 2277 | Int refStride = refPic->getCStride(); |
---|
| 2278 | Int dstStride = dstPic->getCStride(); |
---|
| 2279 | Int depStride = pPicBaseDepth->getStride(); |
---|
| 2280 | |
---|
| 2281 | Int widthChroma, heightChroma; |
---|
| 2282 | if( isDepth) |
---|
| 2283 | { |
---|
| 2284 | widthChroma = pPicBaseDepth->getWidth()>>1; |
---|
| 2285 | heightChroma = pPicBaseDepth->getHeight()>>1; |
---|
| 2286 | } |
---|
| 2287 | else |
---|
| 2288 | { |
---|
| 2289 | widthChroma = refPic->getWidth()>>1; |
---|
| 2290 | heightChroma = refPic->getHeight()>>1; |
---|
| 2291 | } |
---|
| 2292 | |
---|
| 2293 | // Below is only for Texture chroma component |
---|
| 2294 | |
---|
| 2295 | Int widthDepth = pPicBaseDepth->getWidth(); |
---|
| 2296 | Int heightDepth = pPicBaseDepth->getHeight(); |
---|
| 2297 | |
---|
| 2298 | Int nTxtPerDepthX, nTxtPerDepthY; // Number of texture samples per one depth sample |
---|
| 2299 | Int nDepthPerTxtX, nDepthPerTxtY; // Number of depth samples per one texture sample |
---|
| 2300 | |
---|
| 2301 | Int depthPosX; // Starting position in depth image |
---|
| 2302 | Int depthPosY; |
---|
| 2303 | |
---|
| 2304 | if ( widthChroma > widthDepth ) |
---|
| 2305 | { |
---|
| 2306 | nTxtPerDepthX = widthChroma / widthDepth; |
---|
| 2307 | nDepthPerTxtX = 1; |
---|
[519] | 2308 | depthPosX = posX / nTxtPerDepthX + ((dv->getHor()+2)>>2); |
---|
[510] | 2309 | } |
---|
| 2310 | else |
---|
| 2311 | { |
---|
| 2312 | nTxtPerDepthX = 1; |
---|
| 2313 | nDepthPerTxtX = widthDepth / widthChroma; |
---|
[519] | 2314 | depthPosX = posX * nDepthPerTxtX + ((dv->getHor()+2)>>2); |
---|
[510] | 2315 | } |
---|
| 2316 | depthPosX = Clip3(0, widthDepth - (sizeX<<1), depthPosX); |
---|
| 2317 | if ( heightChroma > heightDepth ) |
---|
| 2318 | { |
---|
| 2319 | nTxtPerDepthY = heightChroma / heightDepth; |
---|
| 2320 | nDepthPerTxtY = 1; |
---|
[519] | 2321 | depthPosY = posY / nTxtPerDepthY + ((dv->getVer()+2)>>2); |
---|
[510] | 2322 | } |
---|
| 2323 | else |
---|
| 2324 | { |
---|
| 2325 | nTxtPerDepthY = 1; |
---|
| 2326 | nDepthPerTxtY = heightDepth / heightChroma; |
---|
[519] | 2327 | depthPosY = posY * nDepthPerTxtY + ((dv->getVer()+2)>>2); |
---|
[510] | 2328 | } |
---|
| 2329 | depthPosY = Clip3(0, heightDepth - (sizeY<<1), depthPosY); |
---|
| 2330 | |
---|
| 2331 | Pel *refCb = refPic->getCbAddr() + posX + posY * refStride; |
---|
| 2332 | Pel *refCr = refPic->getCrAddr() + posX + posY * refStride; |
---|
| 2333 | Pel *dstCb = dstPic->getCbAddr(partAddr); |
---|
| 2334 | Pel *dstCr = dstPic->getCrAddr(partAddr); |
---|
| 2335 | Pel *depth = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride; // move the pointer to the current depth pixel position |
---|
| 2336 | |
---|
| 2337 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
| 2338 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
| 2339 | Int depStrideBlock = depStride * nDepthPerTxtY; |
---|
| 2340 | |
---|
| 2341 | if ( widthChroma > widthDepth ) // We assume |
---|
| 2342 | { |
---|
| 2343 | assert( heightChroma > heightDepth ); |
---|
| 2344 | printf("This branch should never been reached.\n"); |
---|
| 2345 | exit(0); |
---|
| 2346 | } |
---|
| 2347 | else |
---|
| 2348 | { |
---|
| 2349 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2350 | Int dW = sizeX; |
---|
| 2351 | Int dH = sizeY; |
---|
| 2352 | Int sW = 2; // search window size |
---|
| 2353 | Int sH = 2; |
---|
| 2354 | #endif |
---|
| 2355 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
| 2356 | Int dW = sizeX; |
---|
| 2357 | Int dH = sizeY; |
---|
| 2358 | Int sW = 2; // search window size |
---|
| 2359 | Int sH = 2; |
---|
| 2360 | #endif |
---|
| 2361 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
| 2362 | Int dW = sizeX>>1; |
---|
| 2363 | Int dH = sizeY>>1; |
---|
| 2364 | Int sW = 4; // search window size |
---|
| 2365 | Int sH = 4; |
---|
| 2366 | #endif |
---|
| 2367 | |
---|
| 2368 | { |
---|
| 2369 | Pel* depthi = depth; |
---|
| 2370 | for (Int j = 0; j < dH; j++) |
---|
| 2371 | { |
---|
| 2372 | for (Int i = 0; i < dW; i++) |
---|
| 2373 | { |
---|
| 2374 | Pel* depthTmp; |
---|
| 2375 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2376 | depthTmp = depthi + (i << 1); |
---|
| 2377 | #endif |
---|
| 2378 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
| 2379 | if (depthPosX + (i<<1) < widthDepth) |
---|
| 2380 | depthTmp = depthi + (i << 1); |
---|
| 2381 | else |
---|
| 2382 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
| 2383 | #endif |
---|
| 2384 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
| 2385 | if (depthPosX + (i<<2) < widthDepth) |
---|
| 2386 | depthTmp = depthi + (i << 2); |
---|
| 2387 | else |
---|
| 2388 | depthTmp = depthi + (widthDepth - depthPosX - 1); |
---|
| 2389 | #endif |
---|
| 2390 | Int maxV = 0; |
---|
| 2391 | for (Int blockj = 0; blockj < sH; blockj+=(sH-1)) |
---|
| 2392 | { |
---|
| 2393 | Int iX = 0; |
---|
| 2394 | for (Int blocki = 0; blocki < sW; blocki+=(sW-1)) |
---|
| 2395 | { |
---|
| 2396 | if (maxV < depthTmp[iX]) |
---|
| 2397 | maxV = depthTmp[iX]; |
---|
| 2398 | if (depthPosX + i*sW + blocki < widthDepth - 1) |
---|
| 2399 | iX = (sW-1); |
---|
| 2400 | } |
---|
| 2401 | if (depthPosY + j*sH + blockj < heightDepth - 1) |
---|
| 2402 | depthTmp += depStride * (sH-1); |
---|
| 2403 | } |
---|
| 2404 | m_pDepthBlock[i+j*dW] = maxV; |
---|
| 2405 | } // end of i < dW |
---|
| 2406 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2407 | if (depthPosY + ((j+1)<<1) < heightDepth) |
---|
| 2408 | depthi += (depStride << 1); |
---|
| 2409 | else |
---|
| 2410 | depthi = depth + (heightDepth-1)*depStride; |
---|
| 2411 | #endif |
---|
| 2412 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
| 2413 | if (depthPosY + ((j+1)<<1) < heightDepth) |
---|
| 2414 | depthi += (depStride << 1); |
---|
| 2415 | else |
---|
| 2416 | depthi = depth + (heightDepth-depthPosY-1)*depStride; |
---|
| 2417 | #endif |
---|
| 2418 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
| 2419 | if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1 |
---|
| 2420 | depthi += (depStride << 2); |
---|
| 2421 | else |
---|
| 2422 | depthi = depth + (heightDepth-depthPosY-1)*depStride; // the last line |
---|
| 2423 | #endif |
---|
| 2424 | } |
---|
| 2425 | } |
---|
| 2426 | |
---|
| 2427 | |
---|
| 2428 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2429 | #if H_3D_VSP_CONSTRAINED |
---|
| 2430 | //get LUT based horizontal reference range |
---|
| 2431 | Int range = xGetConstrainedSize(sizeX, sizeY, false); |
---|
| 2432 | |
---|
| 2433 | // The minimum depth value |
---|
| 2434 | Int minRelativePos = MAX_INT; |
---|
| 2435 | Int maxRelativePos = MIN_INT; |
---|
| 2436 | |
---|
| 2437 | Int depthTmp; |
---|
| 2438 | for (Int yTxt=0; yTxt<sizeY; yTxt++) |
---|
| 2439 | { |
---|
| 2440 | for (Int xTxt=0; xTxt<sizeX; xTxt++) |
---|
| 2441 | { |
---|
| 2442 | depthTmp = m_pDepthBlock[xTxt+yTxt*dW]; |
---|
| 2443 | Int disparity = pShiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
| 2444 | Int disparityInt = disparity >> 3;//in chroma resolution |
---|
| 2445 | |
---|
| 2446 | if (disparityInt < 0) |
---|
| 2447 | { |
---|
| 2448 | if (minRelativePos > disparityInt+xTxt) |
---|
| 2449 | minRelativePos = disparityInt+xTxt; |
---|
| 2450 | } |
---|
| 2451 | else |
---|
| 2452 | { |
---|
| 2453 | if (maxRelativePos < disparityInt+xTxt) |
---|
| 2454 | maxRelativePos = disparityInt+xTxt; |
---|
| 2455 | } |
---|
| 2456 | } |
---|
| 2457 | } |
---|
| 2458 | |
---|
| 2459 | depthTmp = m_pDepthBlock[0]; |
---|
| 2460 | Int disparity_tmp = pShiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
| 2461 | if ( disparity_tmp < 0 ) |
---|
| 2462 | maxRelativePos = minRelativePos + range - 1; |
---|
| 2463 | else |
---|
| 2464 | minRelativePos = maxRelativePos - range + 1; |
---|
| 2465 | |
---|
| 2466 | #endif // H_3D_VSP_CONSTRAINED |
---|
| 2467 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2468 | |
---|
| 2469 | // (sizeX, sizeY) is Chroma block size |
---|
| 2470 | for ( Int yTxt = 0, yDepth = 0; yTxt < sizeY; yTxt += nTxtPerDepthY, yDepth += nDepthPerTxtY ) |
---|
| 2471 | { |
---|
| 2472 | for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth += nDepthPerTxtX ) |
---|
| 2473 | { |
---|
| 2474 | Pel repDepth = 0; // to store the depth value used for warping |
---|
| 2475 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2476 | repDepth = m_pDepthBlock[(xTxt) + (yTxt)*dW]; |
---|
| 2477 | #endif |
---|
| 2478 | #if H_3D_VSP_BLOCKSIZE == 2 |
---|
| 2479 | repDepth = m_pDepthBlock[(xTxt) + (yTxt)*dW]; |
---|
| 2480 | #endif |
---|
| 2481 | #if H_3D_VSP_BLOCKSIZE == 4 |
---|
| 2482 | repDepth = m_pDepthBlock[(xTxt>>1) + (yTxt>>1)*dW]; |
---|
| 2483 | #endif |
---|
| 2484 | |
---|
| 2485 | // calculate the offset in the reference picture |
---|
| 2486 | Int disparity = pShiftLUT[ repDepth ]; // Remove << iShiftPrec; |
---|
| 2487 | Int refOffset = xTxt + (disparity >> 3); // in integer pixel in chroma image |
---|
| 2488 | Int xFrac = disparity & 0x7; |
---|
| 2489 | #if H_3D_VSP_CONSTRAINED |
---|
| 2490 | if(refOffset < minRelativePos || refOffset > maxRelativePos) |
---|
| 2491 | xFrac = 0; |
---|
| 2492 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
| 2493 | #endif |
---|
| 2494 | Int absX = posX + refOffset; |
---|
| 2495 | |
---|
| 2496 | if (xFrac == 0) |
---|
| 2497 | absX = Clip3(0, widthChroma-1, absX); |
---|
| 2498 | else |
---|
| 2499 | absX = Clip3(4, widthChroma-5, absX); |
---|
| 2500 | |
---|
| 2501 | refOffset = absX - posX; |
---|
| 2502 | |
---|
| 2503 | assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 ); |
---|
| 2504 | assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 ); |
---|
| 2505 | m_if.filterHorChroma(&refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi); |
---|
| 2506 | m_if.filterHorChroma(&refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi); |
---|
| 2507 | } |
---|
| 2508 | refCb += refStrideBlock; |
---|
| 2509 | refCr += refStrideBlock; |
---|
| 2510 | dstCb += dstStrideBlock; |
---|
| 2511 | dstCr += dstStrideBlock; |
---|
| 2512 | depth += depStrideBlock; |
---|
| 2513 | } |
---|
| 2514 | } |
---|
| 2515 | |
---|
| 2516 | } |
---|
| 2517 | |
---|
[576] | 2518 | #endif // NTT_VSP_COMMON_E0207_E0208 |
---|
| 2519 | |
---|
[510] | 2520 | #if H_3D_VSP_CONSTRAINED |
---|
| 2521 | Int TComPrediction::xGetConstrainedSize(Int nPbW, Int nPbH, Bool bLuma) |
---|
| 2522 | { |
---|
| 2523 | Int iSize = 0; |
---|
| 2524 | if (bLuma) |
---|
| 2525 | { |
---|
| 2526 | Int iArea = (nPbW+7) * (nPbH+7); |
---|
| 2527 | Int iAlpha = iArea / nPbH - nPbW - 7; |
---|
| 2528 | iSize = iAlpha + nPbW; |
---|
| 2529 | } |
---|
| 2530 | else // chroma |
---|
| 2531 | { |
---|
| 2532 | Int iArea = (nPbW+2) * (nPbH+2); |
---|
| 2533 | Int iAlpha = iArea / nPbH - nPbW - 4; |
---|
| 2534 | iSize = iAlpha + nPbW; |
---|
| 2535 | } |
---|
| 2536 | return iSize; |
---|
| 2537 | } |
---|
[530] | 2538 | #endif // H_3D_VSP_CONSTRAINED |
---|
[510] | 2539 | |
---|
[530] | 2540 | #endif // H_3D_VSP |
---|
[510] | 2541 | |
---|
[531] | 2542 | #if H_3D_DIM |
---|
| 2543 | Void TComPrediction::xPredBiSegDCs( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ) |
---|
| 2544 | { |
---|
| 2545 | Int refDC1, refDC2; |
---|
| 2546 | const Int iTR = ( patternStride - 1 ) - srcStride; |
---|
| 2547 | const Int iTM = ( ( patternStride - 1 ) >> 1 ) - srcStride; |
---|
| 2548 | const Int iLB = ( patternStride - 1 ) * srcStride - 1; |
---|
| 2549 | const Int iLM = ( ( patternStride - 1 ) >> 1 ) * srcStride - 1; |
---|
| 2550 | |
---|
| 2551 | Bool bL = ( biSegPattern[0] != biSegPattern[(patternStride-1)*patternStride] ); |
---|
| 2552 | Bool bT = ( biSegPattern[0] != biSegPattern[(patternStride-1)] ); |
---|
| 2553 | |
---|
| 2554 | if( bL == bT ) |
---|
| 2555 | { |
---|
| 2556 | refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : 1<<( g_bitDepthY - 1 ); |
---|
| 2557 | refDC2 = ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1; |
---|
| 2558 | } |
---|
| 2559 | else |
---|
| 2560 | { |
---|
| 2561 | refDC1 = bL ? ptrSrc[iLB] : ptrSrc[iTR]; |
---|
| 2562 | refDC2 = bL ? ptrSrc[iTM] : ptrSrc[iLM]; |
---|
| 2563 | } |
---|
| 2564 | |
---|
| 2565 | predDC1 = biSegPattern[0] ? refDC1 : refDC2; |
---|
| 2566 | predDC2 = biSegPattern[0] ? refDC2 : refDC1; |
---|
| 2567 | } |
---|
| 2568 | |
---|
| 2569 | Void TComPrediction::xAssignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 ) |
---|
| 2570 | { |
---|
| 2571 | if( dstStride == patternStride ) |
---|
| 2572 | { |
---|
| 2573 | for( UInt k = 0; k < (patternStride * patternStride); k++ ) |
---|
| 2574 | { |
---|
| 2575 | if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; } |
---|
| 2576 | else { ptrDst[k] = valDC1; } |
---|
| 2577 | } |
---|
| 2578 | } |
---|
| 2579 | else |
---|
| 2580 | { |
---|
| 2581 | Pel* piTemp = ptrDst; |
---|
| 2582 | for( UInt uiY = 0; uiY < patternStride; uiY++ ) |
---|
| 2583 | { |
---|
| 2584 | for( UInt uiX = 0; uiX < patternStride; uiX++ ) |
---|
| 2585 | { |
---|
| 2586 | if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; } |
---|
| 2587 | else { piTemp[uiX] = valDC1; } |
---|
| 2588 | } |
---|
| 2589 | piTemp += dstStride; |
---|
| 2590 | biSegPattern += patternStride; |
---|
| 2591 | } |
---|
| 2592 | } |
---|
| 2593 | } |
---|
| 2594 | |
---|
| 2595 | #if H_3D_DIM_DMM |
---|
| 2596 | UInt TComPrediction::xPredWedgeFromIntra( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd ) |
---|
| 2597 | { |
---|
| 2598 | UInt uiThisBlockSize = uiWidth; |
---|
| 2599 | |
---|
| 2600 | TComDataCU* pcTempCU; |
---|
| 2601 | UInt uiTempPartIdx; |
---|
| 2602 | // 1st: try continue above wedgelet |
---|
| 2603 | pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 2604 | if( pcTempCU && isDimMode( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ) ) |
---|
| 2605 | { |
---|
| 2606 | UInt dimType = getDimType( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ); |
---|
| 2607 | if( DMM1_IDX == dimType || DMM2_IDX == dimType || DMM3_IDX == dimType ) |
---|
| 2608 | { |
---|
| 2609 | // get offset between current and reference block |
---|
| 2610 | UInt uiOffsetX = 0, uiOffsetY = 0; |
---|
| 2611 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
| 2612 | |
---|
| 2613 | // get reference wedgelet |
---|
| 2614 | WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[(pcTempCU->getWidth( uiTempPartIdx )>>((pcTempCU->getPartitionSize( uiTempPartIdx ) == SIZE_NxN) ? 1 : 0))])]; |
---|
| 2615 | TComWedgelet* pcRefWedgelet = &(pacWedgeList->at( pcTempCU->getDmmWedgeTabIdx( dimType, uiTempPartIdx ) ) ); |
---|
| 2616 | |
---|
| 2617 | // find wedgelet, if direction is suitable for continue wedge |
---|
| 2618 | if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) ) |
---|
| 2619 | { |
---|
| 2620 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
| 2621 | pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd ); |
---|
| 2622 | return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
| 2623 | } |
---|
| 2624 | } |
---|
| 2625 | } |
---|
| 2626 | |
---|
| 2627 | // 2nd: try continue left wedglelet |
---|
| 2628 | pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 2629 | if( pcTempCU && isDimMode( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ) ) |
---|
| 2630 | { |
---|
| 2631 | UInt dimType = getDimType( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ); |
---|
| 2632 | if( DMM1_IDX == dimType || DMM2_IDX == dimType || DMM3_IDX == dimType ) |
---|
| 2633 | { |
---|
| 2634 | // get offset between current and reference block |
---|
| 2635 | UInt uiOffsetX = 0, uiOffsetY = 0; |
---|
| 2636 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
| 2637 | |
---|
| 2638 | // get reference wedgelet |
---|
| 2639 | WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[(pcTempCU->getWidth( uiTempPartIdx )>>((pcTempCU->getPartitionSize( uiTempPartIdx ) == SIZE_NxN) ? 1 : 0))])]; |
---|
| 2640 | TComWedgelet* pcRefWedgelet = &(pacWedgeList->at( pcTempCU->getDmmWedgeTabIdx( dimType, uiTempPartIdx ) ) ); |
---|
| 2641 | |
---|
| 2642 | // find wedgelet, if direction is suitable for continue wedge |
---|
| 2643 | if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) ) |
---|
| 2644 | { |
---|
| 2645 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
| 2646 | pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd ); |
---|
| 2647 | return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
| 2648 | } |
---|
| 2649 | } |
---|
| 2650 | } |
---|
| 2651 | |
---|
| 2652 | // 3rd: (default) make wedglet from intra dir and max slope point |
---|
| 2653 | Int iSlopeX = 0, iSlopeY = 0; |
---|
| 2654 | UInt uiStartPosX = 0, uiStartPosY = 0; |
---|
| 2655 | if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) ) |
---|
| 2656 | { |
---|
| 2657 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
| 2658 | xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd ); |
---|
| 2659 | return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
| 2660 | } |
---|
| 2661 | |
---|
| 2662 | return 0; |
---|
| 2663 | } |
---|
| 2664 | |
---|
| 2665 | UInt TComPrediction::xPredWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx ) |
---|
| 2666 | { |
---|
[532] | 2667 | TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); |
---|
[531] | 2668 | assert( pcPicTex != NULL ); |
---|
| 2669 | TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); |
---|
| 2670 | UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 2671 | Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; |
---|
| 2672 | |
---|
| 2673 | if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) { return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx); } |
---|
| 2674 | else { return g_dmmWedgeNodeLists[(g_aucConvertToBit[uiWidth])].at(intraTabIdx).getPatternIdx(); } |
---|
| 2675 | } |
---|
| 2676 | |
---|
| 2677 | Void TComPrediction::xPredContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) |
---|
| 2678 | { |
---|
| 2679 | pcContourWedge->clear(); |
---|
| 2680 | |
---|
| 2681 | // get copy of co-located texture luma block |
---|
| 2682 | TComYuv cTempYuv; |
---|
| 2683 | cTempYuv.create( uiWidth, uiHeight ); |
---|
| 2684 | cTempYuv.clear(); |
---|
| 2685 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2686 | xCopyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
| 2687 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2688 | |
---|
| 2689 | // find contour for texture luma block |
---|
| 2690 | UInt iDC = 0; |
---|
| 2691 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
| 2692 | { |
---|
| 2693 | iDC += piRefBlkY[k]; |
---|
| 2694 | } |
---|
| 2695 | iDC /= (uiWidth*uiHeight); |
---|
| 2696 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2697 | |
---|
| 2698 | Bool* pabContourPattern = pcContourWedge->getPattern(); |
---|
| 2699 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
| 2700 | { |
---|
| 2701 | pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; |
---|
| 2702 | } |
---|
| 2703 | |
---|
| 2704 | cTempYuv.destroy(); |
---|
| 2705 | } |
---|
| 2706 | |
---|
| 2707 | |
---|
| 2708 | Void TComPrediction::xCopyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) |
---|
| 2709 | { |
---|
[532] | 2710 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
[531] | 2711 | assert( pcPicYuvRef != NULL ); |
---|
| 2712 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
| 2713 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 2714 | |
---|
| 2715 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
| 2716 | { |
---|
| 2717 | ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); |
---|
| 2718 | piDestBlockY += uiWidth; |
---|
| 2719 | piRefY += iRefStride; |
---|
| 2720 | } |
---|
| 2721 | } |
---|
| 2722 | |
---|
| 2723 | Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ) |
---|
| 2724 | { |
---|
| 2725 | ruiOffsetX = 0; |
---|
| 2726 | ruiOffsetY = 0; |
---|
| 2727 | |
---|
| 2728 | // get offset between current and above/left block |
---|
| 2729 | UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 2730 | UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 2731 | |
---|
| 2732 | UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart(); |
---|
| 2733 | UInt uiMaxDepthRefCU = 0; |
---|
| 2734 | while( uiNumPartInRefCU > 1 ) |
---|
| 2735 | { |
---|
| 2736 | uiNumPartInRefCU >>= 2; |
---|
| 2737 | uiMaxDepthRefCU++; |
---|
| 2738 | } |
---|
| 2739 | |
---|
| 2740 | UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1); |
---|
| 2741 | UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2; |
---|
| 2742 | UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts; |
---|
| 2743 | |
---|
| 2744 | UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
| 2745 | UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
| 2746 | |
---|
| 2747 | if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); } |
---|
| 2748 | if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); } |
---|
| 2749 | } |
---|
| 2750 | |
---|
| 2751 | Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ) |
---|
| 2752 | { |
---|
| 2753 | riSlopeX = 0, riSlopeY = 0, ruiStartPosX = 0, ruiStartPosY = 0; |
---|
| 2754 | |
---|
| 2755 | // 1st step: get wedge start point (max. slope) |
---|
| 2756 | Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt ); |
---|
| 2757 | Int iSourceStride = ( uiBlockSize<<1 ) + 1; |
---|
| 2758 | |
---|
| 2759 | UInt uiSlopeMaxAbove = 0, uiPosSlopeMaxAbove = 0; |
---|
| 2760 | for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ ) |
---|
| 2761 | { |
---|
| 2762 | if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove ) |
---|
| 2763 | { |
---|
| 2764 | uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] ); |
---|
| 2765 | uiPosSlopeMaxAbove = uiPosHor; |
---|
| 2766 | } |
---|
| 2767 | } |
---|
| 2768 | |
---|
| 2769 | UInt uiSlopeMaxLeft = 0, uiPosSlopeMaxLeft = 0; |
---|
| 2770 | for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ ) |
---|
| 2771 | { |
---|
| 2772 | if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft ) |
---|
| 2773 | { |
---|
| 2774 | uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ); |
---|
| 2775 | uiPosSlopeMaxLeft = uiPosVer; |
---|
| 2776 | } |
---|
| 2777 | } |
---|
| 2778 | |
---|
| 2779 | if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 ) |
---|
| 2780 | { |
---|
| 2781 | return false; |
---|
| 2782 | } |
---|
| 2783 | |
---|
| 2784 | ruiStartPosX = ( uiSlopeMaxAbove > uiSlopeMaxLeft ) ? uiPosSlopeMaxAbove : 0; |
---|
| 2785 | ruiStartPosY = ( uiSlopeMaxLeft >= uiSlopeMaxAbove ) ? uiPosSlopeMaxLeft : 0; |
---|
| 2786 | |
---|
| 2787 | // 2nd step: derive wedge direction |
---|
| 2788 | Int uiPreds[3] = {-1, -1, -1}; |
---|
| 2789 | Int iMode = -1; |
---|
| 2790 | Int iPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds, &iMode ); |
---|
| 2791 | |
---|
| 2792 | UInt uiDirMode = 0; |
---|
| 2793 | if( iMode >= 0 ) { iPredNum = iMode; } |
---|
| 2794 | if( iPredNum == 1 ) { uiDirMode = uiPreds[0]; } |
---|
| 2795 | if( iPredNum == 2 ) { uiDirMode = uiPreds[1]; } |
---|
| 2796 | |
---|
| 2797 | if( uiDirMode < 2 ) { return false; } // no planar & DC |
---|
| 2798 | |
---|
| 2799 | Bool modeHor = (uiDirMode < 18); |
---|
| 2800 | Bool modeVer = !modeHor; |
---|
| 2801 | Int intraPredAngle = modeVer ? (Int)uiDirMode - VER_IDX : modeHor ? -((Int)uiDirMode - HOR_IDX) : 0; |
---|
| 2802 | Int absAng = abs(intraPredAngle); |
---|
| 2803 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
| 2804 | Int angTable[9] = {0,2,5,9,13,17,21,26,32}; |
---|
| 2805 | absAng = angTable[absAng]; |
---|
| 2806 | intraPredAngle = signAng * absAng; |
---|
| 2807 | |
---|
| 2808 | // 3rd step: set slope for direction |
---|
| 2809 | if( modeHor ) |
---|
| 2810 | { |
---|
| 2811 | riSlopeX = ( intraPredAngle > 0 ) ? -32 : 32; |
---|
| 2812 | riSlopeY = ( intraPredAngle > 0 ) ? intraPredAngle : -intraPredAngle; |
---|
| 2813 | } |
---|
| 2814 | else if( modeVer ) |
---|
| 2815 | { |
---|
| 2816 | riSlopeX = ( intraPredAngle > 0 ) ? intraPredAngle : -intraPredAngle; |
---|
| 2817 | riSlopeY = ( intraPredAngle > 0 ) ? -32 : 32; |
---|
| 2818 | } |
---|
| 2819 | |
---|
| 2820 | return true; |
---|
| 2821 | } |
---|
| 2822 | |
---|
| 2823 | Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd ) |
---|
| 2824 | { |
---|
| 2825 | ruhXs = 0; |
---|
| 2826 | ruhYs = 0; |
---|
| 2827 | ruhXe = 0; |
---|
| 2828 | ruhYe = 0; |
---|
| 2829 | |
---|
| 2830 | // scaling of start pos and block size to wedge resolution |
---|
| 2831 | UInt uiScaledStartPosX = 0; |
---|
| 2832 | UInt uiScaledStartPosY = 0; |
---|
| 2833 | UInt uiScaledBlockSize = 0; |
---|
| 2834 | WedgeResolution eWedgeRes = g_dmmWedgeResolution[(UInt)g_aucConvertToBit[uiBlockSize]]; |
---|
| 2835 | switch( eWedgeRes ) |
---|
| 2836 | { |
---|
| 2837 | case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; } |
---|
| 2838 | case( FULL_PEL ): { uiScaledStartPosX = uiPMSPosX; uiScaledStartPosY = uiPMSPosY; uiScaledBlockSize = uiBlockSize; break; } |
---|
| 2839 | case( HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; } |
---|
| 2840 | } |
---|
| 2841 | Int iMaxPos = (Int)uiScaledBlockSize - 1; |
---|
| 2842 | |
---|
| 2843 | // case above |
---|
| 2844 | if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 ) |
---|
| 2845 | { |
---|
| 2846 | ruhXs = (UChar)uiScaledStartPosX; |
---|
| 2847 | ruhYs = 0; |
---|
| 2848 | |
---|
| 2849 | if( iDeltaY == 0 ) |
---|
| 2850 | { |
---|
| 2851 | if( iDeltaX < 0 ) |
---|
| 2852 | { |
---|
| 2853 | ruhXe = 0; |
---|
| 2854 | ruhYe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); |
---|
| 2855 | return; |
---|
| 2856 | } |
---|
| 2857 | else |
---|
| 2858 | { |
---|
| 2859 | ruhXe = (UChar)iMaxPos; |
---|
| 2860 | ruhYe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); |
---|
| 2861 | std::swap( ruhXs, ruhXe ); |
---|
| 2862 | std::swap( ruhYs, ruhYe ); |
---|
| 2863 | return; |
---|
| 2864 | } |
---|
| 2865 | } |
---|
| 2866 | |
---|
| 2867 | // regular case |
---|
| 2868 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
| 2869 | |
---|
| 2870 | if( iVirtualEndX < 0 ) |
---|
| 2871 | { |
---|
| 2872 | Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd; |
---|
| 2873 | if( iYe < (Int)uiScaledBlockSize ) |
---|
| 2874 | { |
---|
| 2875 | ruhXe = 0; |
---|
| 2876 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
| 2877 | return; |
---|
| 2878 | } |
---|
| 2879 | else |
---|
| 2880 | { |
---|
| 2881 | ruhXe = (UChar)std::min( (iYe - iMaxPos), iMaxPos ); |
---|
| 2882 | ruhYe = (UChar)iMaxPos; |
---|
| 2883 | return; |
---|
| 2884 | } |
---|
| 2885 | } |
---|
| 2886 | else if( iVirtualEndX > iMaxPos ) |
---|
| 2887 | { |
---|
| 2888 | Int iYe = roftoi( (Double)(iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
| 2889 | if( iYe < (Int)uiScaledBlockSize ) |
---|
| 2890 | { |
---|
| 2891 | ruhXe = (UChar)iMaxPos; |
---|
| 2892 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
| 2893 | std::swap( ruhXs, ruhXe ); |
---|
| 2894 | std::swap( ruhYs, ruhYe ); |
---|
| 2895 | return; |
---|
| 2896 | } |
---|
| 2897 | else |
---|
| 2898 | { |
---|
| 2899 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
| 2900 | ruhYe = (UChar)iMaxPos; |
---|
| 2901 | return; |
---|
| 2902 | } |
---|
| 2903 | } |
---|
| 2904 | else |
---|
| 2905 | { |
---|
| 2906 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
| 2907 | if( iXe < 0 ) |
---|
| 2908 | { |
---|
| 2909 | ruhXe = 0; |
---|
| 2910 | ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); |
---|
| 2911 | return; |
---|
| 2912 | } |
---|
| 2913 | else if( iXe > iMaxPos ) |
---|
| 2914 | { |
---|
| 2915 | ruhXe = (UChar)iMaxPos; |
---|
| 2916 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
| 2917 | std::swap( ruhXs, ruhXe ); |
---|
| 2918 | std::swap( ruhYs, ruhYe ); |
---|
| 2919 | return; |
---|
| 2920 | } |
---|
| 2921 | else |
---|
| 2922 | { |
---|
| 2923 | ruhXe = (UChar)iXe; |
---|
| 2924 | ruhYe = (UChar)iMaxPos; |
---|
| 2925 | return; |
---|
| 2926 | } |
---|
| 2927 | } |
---|
| 2928 | } |
---|
| 2929 | |
---|
| 2930 | // case left |
---|
| 2931 | if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 ) |
---|
| 2932 | { |
---|
| 2933 | ruhXs = 0; |
---|
| 2934 | ruhYs = (UChar)uiScaledStartPosY; |
---|
| 2935 | |
---|
| 2936 | if( iDeltaX == 0 ) |
---|
| 2937 | { |
---|
| 2938 | if( iDeltaY < 0 ) |
---|
| 2939 | { |
---|
| 2940 | ruhXe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); |
---|
| 2941 | ruhYe = 0; |
---|
| 2942 | std::swap( ruhXs, ruhXe ); |
---|
| 2943 | std::swap( ruhYs, ruhYe ); |
---|
| 2944 | return; |
---|
| 2945 | } |
---|
| 2946 | else |
---|
| 2947 | { |
---|
| 2948 | ruhXe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); |
---|
| 2949 | ruhYe = (UChar)iMaxPos; |
---|
| 2950 | return; |
---|
| 2951 | } |
---|
| 2952 | } |
---|
| 2953 | |
---|
| 2954 | // regular case |
---|
| 2955 | Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iMaxPos * ((Double)iDeltaY / (Double)iDeltaX) ); |
---|
| 2956 | |
---|
| 2957 | if( iVirtualEndY < 0 ) |
---|
| 2958 | { |
---|
| 2959 | Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd; |
---|
| 2960 | if( iXe < (Int)uiScaledBlockSize ) |
---|
| 2961 | { |
---|
| 2962 | ruhXe = (UChar)std::max( iXe, 0 ); |
---|
| 2963 | ruhYe = 0; |
---|
| 2964 | std::swap( ruhXs, ruhXe ); |
---|
| 2965 | std::swap( ruhYs, ruhYe ); |
---|
| 2966 | return; |
---|
| 2967 | } |
---|
| 2968 | else |
---|
| 2969 | { |
---|
| 2970 | ruhXe = (UChar)iMaxPos; |
---|
| 2971 | ruhYe = (UChar)std::min( (iXe - iMaxPos), iMaxPos ); |
---|
| 2972 | std::swap( ruhXs, ruhXe ); |
---|
| 2973 | std::swap( ruhYs, ruhYe ); |
---|
| 2974 | return; |
---|
| 2975 | } |
---|
| 2976 | } |
---|
| 2977 | else if( iVirtualEndY > (uiScaledBlockSize-1) ) |
---|
| 2978 | { |
---|
| 2979 | Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd; |
---|
| 2980 | if( iXe < (Int)uiScaledBlockSize ) |
---|
| 2981 | { |
---|
| 2982 | ruhXe = (UChar)std::max( iXe, 0 ); |
---|
| 2983 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
| 2984 | return; |
---|
| 2985 | } |
---|
| 2986 | else |
---|
| 2987 | { |
---|
| 2988 | ruhXe = (UChar)iMaxPos; |
---|
| 2989 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
| 2990 | std::swap( ruhXs, ruhXe ); |
---|
| 2991 | std::swap( ruhYs, ruhYe ); |
---|
| 2992 | return; |
---|
| 2993 | } |
---|
| 2994 | } |
---|
| 2995 | else |
---|
| 2996 | { |
---|
| 2997 | Int iYe = iVirtualEndY - iDeltaEnd; |
---|
| 2998 | if( iYe < 0 ) |
---|
| 2999 | { |
---|
| 3000 | ruhXe = (UChar)std::max( (iMaxPos + iYe), 0 ); |
---|
| 3001 | ruhYe = 0; |
---|
| 3002 | std::swap( ruhXs, ruhXe ); |
---|
| 3003 | std::swap( ruhYs, ruhYe ); |
---|
| 3004 | return; |
---|
| 3005 | } |
---|
| 3006 | else if( iYe > iMaxPos ) |
---|
| 3007 | { |
---|
| 3008 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
| 3009 | ruhYe = (UChar)iMaxPos; |
---|
| 3010 | return; |
---|
| 3011 | } |
---|
| 3012 | else |
---|
| 3013 | { |
---|
| 3014 | ruhXe = (UChar)iMaxPos; |
---|
| 3015 | ruhYe = (UChar)iYe; |
---|
| 3016 | std::swap( ruhXs, ruhXe ); |
---|
| 3017 | std::swap( ruhYs, ruhYe ); |
---|
| 3018 | return; |
---|
| 3019 | } |
---|
| 3020 | } |
---|
| 3021 | } |
---|
| 3022 | |
---|
| 3023 | // case origin |
---|
| 3024 | if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 ) |
---|
| 3025 | { |
---|
| 3026 | if( iDeltaX*iDeltaY < 0 ) |
---|
| 3027 | { |
---|
| 3028 | return; |
---|
| 3029 | } |
---|
| 3030 | |
---|
| 3031 | ruhXs = 0; |
---|
| 3032 | ruhYs = 0; |
---|
| 3033 | |
---|
| 3034 | if( iDeltaY == 0 ) |
---|
| 3035 | { |
---|
| 3036 | ruhXe = (UChar)iMaxPos; |
---|
| 3037 | ruhYe = 0; |
---|
| 3038 | std::swap( ruhXs, ruhXe ); |
---|
| 3039 | std::swap( ruhYs, ruhYe ); |
---|
| 3040 | return; |
---|
| 3041 | } |
---|
| 3042 | |
---|
| 3043 | if( iDeltaX == 0 ) |
---|
| 3044 | { |
---|
| 3045 | ruhXe = 0; |
---|
| 3046 | ruhYe = (UChar)iMaxPos; |
---|
| 3047 | return; |
---|
| 3048 | } |
---|
| 3049 | |
---|
| 3050 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
| 3051 | |
---|
| 3052 | if( iVirtualEndX > iMaxPos ) |
---|
| 3053 | { |
---|
| 3054 | Int iYe = roftoi( (Double)((Int)iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
| 3055 | if( iYe < (Int)uiScaledBlockSize ) |
---|
| 3056 | { |
---|
| 3057 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
| 3058 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
| 3059 | std::swap( ruhXs, ruhXe ); |
---|
| 3060 | std::swap( ruhYs, ruhYe ); |
---|
| 3061 | return; |
---|
| 3062 | } |
---|
| 3063 | else |
---|
| 3064 | { |
---|
| 3065 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
| 3066 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
| 3067 | return; |
---|
| 3068 | } |
---|
| 3069 | } |
---|
| 3070 | else |
---|
| 3071 | { |
---|
| 3072 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
| 3073 | if( iXe < 0 ) |
---|
| 3074 | { |
---|
| 3075 | ruhXe = 0; |
---|
| 3076 | ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); |
---|
| 3077 | return; |
---|
| 3078 | } |
---|
| 3079 | else if( iXe > iMaxPos ) |
---|
| 3080 | { |
---|
| 3081 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
| 3082 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
| 3083 | std::swap( ruhXs, ruhXe ); |
---|
| 3084 | std::swap( ruhYs, ruhYe ); |
---|
| 3085 | return; |
---|
| 3086 | } |
---|
| 3087 | else |
---|
| 3088 | { |
---|
| 3089 | ruhXe = (UChar)iXe; |
---|
| 3090 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
| 3091 | return; |
---|
| 3092 | } |
---|
| 3093 | } |
---|
| 3094 | } |
---|
| 3095 | } |
---|
| 3096 | |
---|
| 3097 | UInt TComPrediction::xGetWedgePatternIdx( UInt uiBlockSize, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ) |
---|
| 3098 | { |
---|
| 3099 | WedgeRefList* pcWedgeRefList = &g_dmmWedgeRefLists[(g_aucConvertToBit[uiBlockSize])]; |
---|
| 3100 | for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ ) |
---|
| 3101 | { |
---|
| 3102 | TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx)); |
---|
| 3103 | if( pcTestWedgeRef->getStartX() == uhXs && pcTestWedgeRef->getStartY() == uhYs && pcTestWedgeRef->getEndX() == uhXe && pcTestWedgeRef->getEndY() == uhYe ) |
---|
| 3104 | { |
---|
| 3105 | return pcTestWedgeRef->getRefIdx(); |
---|
| 3106 | } |
---|
| 3107 | } |
---|
| 3108 | return 0; |
---|
| 3109 | } |
---|
| 3110 | #endif |
---|
| 3111 | #if H_3D_DIM_RBC |
---|
| 3112 | Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Pel& rDeltaDC ) |
---|
| 3113 | { |
---|
| 3114 | Int iSign = rDeltaDC < 0 ? -1 : 1; |
---|
| 3115 | UInt uiAbs = abs( rDeltaDC ); |
---|
| 3116 | |
---|
| 3117 | Int iQp = pcCU->getQP(0); |
---|
| 3118 | Double dMax = (Double)( 1<<( g_bitDepthY - 1 ) ); |
---|
| 3119 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 - 2.0 ) ); |
---|
| 3120 | |
---|
| 3121 | rDeltaDC = iSign * roftoi( uiAbs * dStepSize ); |
---|
| 3122 | return; |
---|
| 3123 | } |
---|
| 3124 | |
---|
| 3125 | Void TComPrediction::xDeltaDCQuantScaleDown( TComDataCU* pcCU, Pel& rDeltaDC ) |
---|
| 3126 | { |
---|
| 3127 | Int iSign = rDeltaDC < 0 ? -1 : 1; |
---|
| 3128 | UInt uiAbs = abs( rDeltaDC ); |
---|
| 3129 | |
---|
| 3130 | Int iQp = pcCU->getQP(0); |
---|
| 3131 | Double dMax = (Double)( 1<<( g_bitDepthY - 1 ) ); |
---|
| 3132 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 - 2.0 ) ); |
---|
| 3133 | |
---|
| 3134 | rDeltaDC = iSign * roftoi( uiAbs / dStepSize ); |
---|
| 3135 | return; |
---|
| 3136 | } |
---|
| 3137 | #endif |
---|
| 3138 | #if H_3D_DIM_SDC |
---|
| 3139 | Void TComPrediction::analyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride ) |
---|
| 3140 | { |
---|
| 3141 | Int iSumDepth[2]; |
---|
| 3142 | memset(iSumDepth, 0, sizeof(Int)*2); |
---|
| 3143 | Int iSumPix[2]; |
---|
| 3144 | memset(iSumPix, 0, sizeof(Int)*2); |
---|
| 3145 | |
---|
| 3146 | Int subSamplePix; |
---|
| 3147 | if ( uiSize == 64 || uiSize == 32 ) |
---|
| 3148 | { |
---|
| 3149 | subSamplePix = 2; |
---|
| 3150 | } |
---|
| 3151 | else |
---|
| 3152 | { |
---|
| 3153 | subSamplePix = 1; |
---|
| 3154 | } |
---|
| 3155 | for (Int y=0; y<uiSize; y+=subSamplePix) |
---|
| 3156 | { |
---|
| 3157 | for (Int x=0; x<uiSize; x+=subSamplePix) |
---|
| 3158 | { |
---|
| 3159 | UChar ucSegment = pMask?(UChar)pMask[x]:0; |
---|
| 3160 | assert( ucSegment < uiNumSegments ); |
---|
| 3161 | |
---|
| 3162 | iSumDepth[ucSegment] += pOrig[x]; |
---|
| 3163 | iSumPix[ucSegment] += 1; |
---|
| 3164 | } |
---|
| 3165 | |
---|
| 3166 | pOrig += uiStride*subSamplePix; |
---|
| 3167 | pMask += uiMaskStride*subSamplePix; |
---|
| 3168 | } |
---|
| 3169 | |
---|
| 3170 | // compute mean for each segment |
---|
| 3171 | for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ ) |
---|
| 3172 | { |
---|
| 3173 | if( iSumPix[ucSeg] > 0 ) |
---|
| 3174 | rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg]; |
---|
| 3175 | else |
---|
| 3176 | rpSegMeans[ucSeg] = 0; // this happens for zero-segments |
---|
| 3177 | } |
---|
| 3178 | } |
---|
| 3179 | #endif // H_3D_DIM_SDC |
---|
| 3180 | #endif |
---|
[324] | 3181 | //! \} |
---|