[5] | 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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[608] | 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TComPrediction.cpp |
---|
| 35 | \brief prediction class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include <memory.h> |
---|
| 39 | #include "TComPrediction.h" |
---|
| 40 | |
---|
[56] | 41 | //! \ingroup TLibCommon |
---|
| 42 | //! \{ |
---|
| 43 | |
---|
[2] | 44 | // ==================================================================================================================== |
---|
| 45 | // Constructor / destructor / initialize |
---|
| 46 | // ==================================================================================================================== |
---|
| 47 | |
---|
| 48 | TComPrediction::TComPrediction() |
---|
| 49 | : m_pLumaRecBuffer(0) |
---|
[608] | 50 | , m_iLumaRecStride(0) |
---|
[2] | 51 | { |
---|
| 52 | m_piYuvExt = NULL; |
---|
[608] | 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) |
---|
[296] | 56 | printf("ERROR: UKTGHU, No memory allocated.\n"); |
---|
| 57 | #endif |
---|
[2] | 58 | } |
---|
| 59 | |
---|
| 60 | TComPrediction::~TComPrediction() |
---|
| 61 | { |
---|
[608] | 62 | #if H_3D_VSP |
---|
| 63 | if (m_pDepthBlock != NULL) |
---|
| 64 | free(m_pDepthBlock); |
---|
| 65 | m_cYuvDepthOnVsp.destroy(); |
---|
[296] | 66 | #endif |
---|
[608] | 67 | |
---|
[2] | 68 | delete[] m_piYuvExt; |
---|
| 69 | |
---|
| 70 | m_acYuvPred[0].destroy(); |
---|
| 71 | m_acYuvPred[1].destroy(); |
---|
| 72 | |
---|
| 73 | m_cYuvPredTemp.destroy(); |
---|
[608] | 74 | |
---|
| 75 | #if H_3D_ARP |
---|
[443] | 76 | m_acYuvPredBase[0].destroy(); |
---|
| 77 | m_acYuvPredBase[1].destroy(); |
---|
| 78 | #endif |
---|
[2] | 79 | if( m_pLumaRecBuffer ) |
---|
[56] | 80 | { |
---|
| 81 | delete [] m_pLumaRecBuffer; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | Int i, j; |
---|
| 85 | for (i = 0; i < 4; i++) |
---|
| 86 | { |
---|
| 87 | for (j = 0; j < 4; j++) |
---|
| 88 | { |
---|
| 89 | m_filteredBlock[i][j].destroy(); |
---|
| 90 | } |
---|
| 91 | m_filteredBlockTmp[i].destroy(); |
---|
| 92 | } |
---|
[2] | 93 | } |
---|
| 94 | |
---|
| 95 | Void TComPrediction::initTempBuff() |
---|
| 96 | { |
---|
| 97 | if( m_piYuvExt == NULL ) |
---|
| 98 | { |
---|
[608] | 99 | Int extWidth = MAX_CU_SIZE + 16; |
---|
| 100 | Int extHeight = MAX_CU_SIZE + 1; |
---|
[56] | 101 | Int i, j; |
---|
| 102 | for (i = 0; i < 4; i++) |
---|
| 103 | { |
---|
| 104 | m_filteredBlockTmp[i].create(extWidth, extHeight + 7); |
---|
| 105 | for (j = 0; j < 4; j++) |
---|
| 106 | { |
---|
| 107 | m_filteredBlock[i][j].create(extWidth, extHeight); |
---|
| 108 | } |
---|
| 109 | } |
---|
[608] | 110 | m_iYuvExtHeight = ((MAX_CU_SIZE + 2) << 4); |
---|
| 111 | m_iYuvExtStride = ((MAX_CU_SIZE + 8) << 4); |
---|
[2] | 112 | m_piYuvExt = new Int[ m_iYuvExtStride * m_iYuvExtHeight ]; |
---|
| 113 | |
---|
| 114 | // new structure |
---|
[608] | 115 | m_acYuvPred[0] .create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
| 116 | m_acYuvPred[1] .create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
[2] | 117 | |
---|
[608] | 118 | m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE ); |
---|
| 119 | #if H_3D_ARP |
---|
[443] | 120 | m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 121 | m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 122 | #endif |
---|
[655] | 123 | #if H_3D_VSP |
---|
[608] | 124 | m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 125 | #endif |
---|
[2] | 126 | } |
---|
| 127 | |
---|
[608] | 128 | if (m_iLumaRecStride != (MAX_CU_SIZE>>1) + 1) |
---|
| 129 | { |
---|
| 130 | m_iLumaRecStride = (MAX_CU_SIZE>>1) + 1; |
---|
| 131 | if (!m_pLumaRecBuffer) |
---|
| 132 | { |
---|
| 133 | m_pLumaRecBuffer = new Pel[ m_iLumaRecStride * m_iLumaRecStride ]; |
---|
| 134 | } |
---|
| 135 | } |
---|
| 136 | #if H_3D_IC |
---|
| 137 | m_uiaShift[0] = 0; |
---|
[56] | 138 | for( Int i = 1; i < 64; i++ ) |
---|
| 139 | { |
---|
[608] | 140 | m_uiaShift[i] = ( (1 << 15) + i/2 ) / i; |
---|
| 141 | } |
---|
| 142 | #endif |
---|
[2] | 143 | } |
---|
| 144 | |
---|
| 145 | // ==================================================================================================================== |
---|
| 146 | // Public member functions |
---|
| 147 | // ==================================================================================================================== |
---|
| 148 | |
---|
| 149 | // Function for calculating DC value of the reference samples used in Intra prediction |
---|
| 150 | Pel TComPrediction::predIntraGetPredValDC( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ) |
---|
| 151 | { |
---|
[608] | 152 | assert(iWidth > 0 && iHeight > 0); |
---|
[2] | 153 | Int iInd, iSum = 0; |
---|
| 154 | Pel pDcVal; |
---|
| 155 | |
---|
| 156 | if (bAbove) |
---|
| 157 | { |
---|
| 158 | for (iInd = 0;iInd < iWidth;iInd++) |
---|
[56] | 159 | { |
---|
[2] | 160 | iSum += pSrc[iInd-iSrcStride]; |
---|
[56] | 161 | } |
---|
[2] | 162 | } |
---|
| 163 | if (bLeft) |
---|
| 164 | { |
---|
| 165 | for (iInd = 0;iInd < iHeight;iInd++) |
---|
[56] | 166 | { |
---|
[2] | 167 | iSum += pSrc[iInd*iSrcStride-1]; |
---|
[56] | 168 | } |
---|
[2] | 169 | } |
---|
| 170 | |
---|
| 171 | if (bAbove && bLeft) |
---|
[56] | 172 | { |
---|
[2] | 173 | pDcVal = (iSum + iWidth) / (iWidth + iHeight); |
---|
[56] | 174 | } |
---|
[2] | 175 | else if (bAbove) |
---|
[56] | 176 | { |
---|
[2] | 177 | pDcVal = (iSum + iWidth/2) / iWidth; |
---|
[56] | 178 | } |
---|
[2] | 179 | else if (bLeft) |
---|
[56] | 180 | { |
---|
[2] | 181 | pDcVal = (iSum + iHeight/2) / iHeight; |
---|
[56] | 182 | } |
---|
[2] | 183 | else |
---|
[56] | 184 | { |
---|
[2] | 185 | pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available |
---|
[56] | 186 | } |
---|
| 187 | |
---|
[2] | 188 | return pDcVal; |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | // Function for deriving the angular Intra predictions |
---|
| 192 | |
---|
| 193 | /** Function for deriving the simplified angular intra predictions. |
---|
| 194 | * \param pSrc pointer to reconstructed sample array |
---|
| 195 | * \param srcStride the stride of the reconstructed sample array |
---|
| 196 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 197 | * \param dstStride the stride of the prediction sample array |
---|
| 198 | * \param width the width of the block |
---|
| 199 | * \param height the height of the block |
---|
| 200 | * \param dirMode the intra prediction mode index |
---|
| 201 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
| 202 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
| 203 | * |
---|
| 204 | * This function derives the prediction samples for the angular mode based on the prediction direction indicated by |
---|
| 205 | * the prediction mode index. The prediction direction is given by the displacement of the bottom row of the block and |
---|
| 206 | * the reference row above the block in the case of vertical prediction or displacement of the rightmost column |
---|
| 207 | * of the block and reference column left from the block in the case of the horizontal prediction. The displacement |
---|
| 208 | * is signalled at 1/32 pixel accuracy. When projection of the predicted pixel falls inbetween reference samples, |
---|
| 209 | * the predicted value for the pixel is linearly interpolated from the reference samples. All reference samples are taken |
---|
| 210 | * from the extended main reference. |
---|
| 211 | */ |
---|
[608] | 212 | 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 ) |
---|
[2] | 213 | { |
---|
| 214 | Int k,l; |
---|
| 215 | Int blkSize = width; |
---|
| 216 | Pel* pDst = rpDst; |
---|
| 217 | |
---|
| 218 | // Map the mode index to main prediction direction and angle |
---|
[56] | 219 | assert( dirMode > 0 ); //no planar |
---|
| 220 | Bool modeDC = dirMode < 2; |
---|
| 221 | Bool modeHor = !modeDC && (dirMode < 18); |
---|
| 222 | Bool modeVer = !modeDC && !modeHor; |
---|
| 223 | Int intraPredAngle = modeVer ? (Int)dirMode - VER_IDX : modeHor ? -((Int)dirMode - HOR_IDX) : 0; |
---|
[2] | 224 | Int absAng = abs(intraPredAngle); |
---|
| 225 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
| 226 | |
---|
| 227 | // Set bitshifts and scale the angle parameter to block size |
---|
| 228 | Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
| 229 | Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle |
---|
| 230 | Int invAngle = invAngTable[absAng]; |
---|
| 231 | absAng = angTable[absAng]; |
---|
| 232 | intraPredAngle = signAng * absAng; |
---|
| 233 | |
---|
| 234 | // Do the DC prediction |
---|
| 235 | if (modeDC) |
---|
| 236 | { |
---|
| 237 | Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height, blkAboveAvailable, blkLeftAvailable); |
---|
| 238 | |
---|
| 239 | for (k=0;k<blkSize;k++) |
---|
| 240 | { |
---|
| 241 | for (l=0;l<blkSize;l++) |
---|
| 242 | { |
---|
| 243 | pDst[k*dstStride+l] = dcval; |
---|
| 244 | } |
---|
| 245 | } |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | // Do angular predictions |
---|
| 249 | else |
---|
| 250 | { |
---|
| 251 | Pel* refMain; |
---|
| 252 | Pel* refSide; |
---|
| 253 | Pel refAbove[2*MAX_CU_SIZE+1]; |
---|
| 254 | Pel refLeft[2*MAX_CU_SIZE+1]; |
---|
| 255 | |
---|
| 256 | // Initialise the Main and Left reference array. |
---|
| 257 | if (intraPredAngle < 0) |
---|
| 258 | { |
---|
| 259 | for (k=0;k<blkSize+1;k++) |
---|
| 260 | { |
---|
| 261 | refAbove[k+blkSize-1] = pSrc[k-srcStride-1]; |
---|
| 262 | } |
---|
| 263 | for (k=0;k<blkSize+1;k++) |
---|
| 264 | { |
---|
| 265 | refLeft[k+blkSize-1] = pSrc[(k-1)*srcStride-1]; |
---|
| 266 | } |
---|
| 267 | refMain = (modeVer ? refAbove : refLeft) + (blkSize-1); |
---|
| 268 | refSide = (modeVer ? refLeft : refAbove) + (blkSize-1); |
---|
| 269 | |
---|
| 270 | // Extend the Main reference to the left. |
---|
| 271 | Int invAngleSum = 128; // rounding for (shift by 8) |
---|
| 272 | for (k=-1; k>blkSize*intraPredAngle>>5; k--) |
---|
| 273 | { |
---|
| 274 | invAngleSum += invAngle; |
---|
| 275 | refMain[k] = refSide[invAngleSum>>8]; |
---|
| 276 | } |
---|
| 277 | } |
---|
| 278 | else |
---|
| 279 | { |
---|
| 280 | for (k=0;k<2*blkSize+1;k++) |
---|
| 281 | { |
---|
| 282 | refAbove[k] = pSrc[k-srcStride-1]; |
---|
| 283 | } |
---|
| 284 | for (k=0;k<2*blkSize+1;k++) |
---|
| 285 | { |
---|
| 286 | refLeft[k] = pSrc[(k-1)*srcStride-1]; |
---|
| 287 | } |
---|
| 288 | refMain = modeVer ? refAbove : refLeft; |
---|
[56] | 289 | refSide = modeVer ? refLeft : refAbove; |
---|
[2] | 290 | } |
---|
| 291 | |
---|
| 292 | if (intraPredAngle == 0) |
---|
| 293 | { |
---|
| 294 | for (k=0;k<blkSize;k++) |
---|
| 295 | { |
---|
| 296 | for (l=0;l<blkSize;l++) |
---|
| 297 | { |
---|
| 298 | pDst[k*dstStride+l] = refMain[l+1]; |
---|
| 299 | } |
---|
| 300 | } |
---|
[56] | 301 | |
---|
| 302 | if ( bFilter ) |
---|
| 303 | { |
---|
| 304 | for (k=0;k<blkSize;k++) |
---|
| 305 | { |
---|
[608] | 306 | pDst[k*dstStride] = Clip3(0, (1<<bitDepth)-1, pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) ); |
---|
[56] | 307 | } |
---|
| 308 | } |
---|
[2] | 309 | } |
---|
| 310 | else |
---|
| 311 | { |
---|
| 312 | Int deltaPos=0; |
---|
| 313 | Int deltaInt; |
---|
| 314 | Int deltaFract; |
---|
| 315 | Int refMainIndex; |
---|
| 316 | |
---|
| 317 | for (k=0;k<blkSize;k++) |
---|
| 318 | { |
---|
| 319 | deltaPos += intraPredAngle; |
---|
| 320 | deltaInt = deltaPos >> 5; |
---|
| 321 | deltaFract = deltaPos & (32 - 1); |
---|
| 322 | |
---|
| 323 | if (deltaFract) |
---|
| 324 | { |
---|
| 325 | // Do linear filtering |
---|
| 326 | for (l=0;l<blkSize;l++) |
---|
| 327 | { |
---|
| 328 | refMainIndex = l+deltaInt+1; |
---|
| 329 | pDst[k*dstStride+l] = (Pel) ( ((32-deltaFract)*refMain[refMainIndex]+deltaFract*refMain[refMainIndex+1]+16) >> 5 ); |
---|
| 330 | } |
---|
| 331 | } |
---|
| 332 | else |
---|
| 333 | { |
---|
| 334 | // Just copy the integer samples |
---|
| 335 | for (l=0;l<blkSize;l++) |
---|
| 336 | { |
---|
| 337 | pDst[k*dstStride+l] = refMain[l+deltaInt+1]; |
---|
| 338 | } |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | // Flip the block if this is the horizontal mode |
---|
| 344 | if (modeHor) |
---|
| 345 | { |
---|
| 346 | Pel tmp; |
---|
| 347 | for (k=0;k<blkSize-1;k++) |
---|
| 348 | { |
---|
| 349 | for (l=k+1;l<blkSize;l++) |
---|
| 350 | { |
---|
| 351 | tmp = pDst[k*dstStride+l]; |
---|
| 352 | pDst[k*dstStride+l] = pDst[l*dstStride+k]; |
---|
| 353 | pDst[l*dstStride+k] = tmp; |
---|
| 354 | } |
---|
| 355 | } |
---|
| 356 | } |
---|
| 357 | } |
---|
| 358 | } |
---|
| 359 | |
---|
[608] | 360 | Void TComPrediction::predIntraLumaAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ) |
---|
[2] | 361 | { |
---|
| 362 | Pel *pDst = piPred; |
---|
| 363 | Int *ptrSrc; |
---|
| 364 | |
---|
[56] | 365 | assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 |
---|
| 366 | assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 |
---|
[2] | 367 | assert( iWidth == iHeight ); |
---|
| 368 | |
---|
[56] | 369 | ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
| 370 | |
---|
| 371 | // get starting pixel in block |
---|
| 372 | Int sw = 2 * iWidth + 1; |
---|
| 373 | |
---|
| 374 | // Create the prediction |
---|
| 375 | if ( uiDirMode == PLANAR_IDX ) |
---|
| 376 | { |
---|
| 377 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
| 378 | } |
---|
| 379 | else |
---|
| 380 | { |
---|
[608] | 381 | if ( (iWidth > 16) || (iHeight > 16) ) |
---|
[56] | 382 | { |
---|
[608] | 383 | xPredIntraAng(g_bitDepthY, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); |
---|
[56] | 384 | } |
---|
[608] | 385 | else |
---|
| 386 | { |
---|
| 387 | xPredIntraAng(g_bitDepthY, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, true ); |
---|
| 388 | |
---|
| 389 | if( (uiDirMode == DC_IDX ) && bAbove && bLeft ) |
---|
| 390 | { |
---|
| 391 | xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight); |
---|
| 392 | } |
---|
| 393 | } |
---|
[56] | 394 | } |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | // Angular chroma |
---|
[608] | 398 | Void TComPrediction::predIntraChromaAng( Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ) |
---|
[56] | 399 | { |
---|
| 400 | Pel *pDst = piPred; |
---|
| 401 | Int *ptrSrc = piSrc; |
---|
| 402 | |
---|
[2] | 403 | // get starting pixel in block |
---|
[56] | 404 | Int sw = 2 * iWidth + 1; |
---|
[2] | 405 | |
---|
| 406 | if ( uiDirMode == PLANAR_IDX ) |
---|
| 407 | { |
---|
| 408 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
[56] | 409 | } |
---|
| 410 | else |
---|
| 411 | { |
---|
| 412 | // Create the prediction |
---|
[608] | 413 | xPredIntraAng(g_bitDepthC, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); |
---|
[56] | 414 | } |
---|
| 415 | } |
---|
| 416 | |
---|
[608] | 417 | #if H_3D_DIM |
---|
| 418 | Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc ) |
---|
[56] | 419 | { |
---|
[608] | 420 | assert( iWidth == iHeight ); |
---|
| 421 | assert( iWidth >= DIM_MIN_SIZE && iWidth <= DIM_MAX_SIZE ); |
---|
| 422 | assert( isDimMode( uiIntraMode ) ); |
---|
[56] | 423 | |
---|
[608] | 424 | UInt dimType = getDimType ( uiIntraMode ); |
---|
| 425 | Bool dimDeltaDC = isDimDeltaDC( uiIntraMode ); |
---|
| 426 | Bool isDmmMode = (dimType < DMM_NUM_TYPE); |
---|
[100] | 427 | |
---|
[608] | 428 | Bool* biSegPattern = NULL; |
---|
| 429 | UInt patternStride = 0; |
---|
[100] | 430 | |
---|
[608] | 431 | // get partiton |
---|
| 432 | #if H_3D_DIM_DMM |
---|
| 433 | TComWedgelet* dmmSegmentation = NULL; |
---|
| 434 | if( isDmmMode ) |
---|
[100] | 435 | { |
---|
[608] | 436 | switch( dimType ) |
---|
[100] | 437 | { |
---|
[608] | 438 | case( DMM1_IDX ): |
---|
[100] | 439 | { |
---|
[608] | 440 | dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]); |
---|
| 441 | } break; |
---|
| 442 | case( DMM4_IDX ): |
---|
[100] | 443 | { |
---|
[608] | 444 | dmmSegmentation = new TComWedgelet( iWidth, iHeight ); |
---|
| 445 | xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation ); |
---|
| 446 | } break; |
---|
| 447 | default: assert(0); |
---|
[100] | 448 | } |
---|
[608] | 449 | assert( dmmSegmentation ); |
---|
| 450 | biSegPattern = dmmSegmentation->getPattern(); |
---|
| 451 | patternStride = dmmSegmentation->getStride (); |
---|
[100] | 452 | } |
---|
[608] | 453 | #endif |
---|
[100] | 454 | |
---|
[608] | 455 | // get predicted partition values |
---|
| 456 | assert( biSegPattern ); |
---|
| 457 | Int* piMask = NULL; |
---|
[724] | 458 | piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering |
---|
[608] | 459 | assert( piMask ); |
---|
| 460 | Int maskStride = 2*iWidth + 1; |
---|
| 461 | Int* ptrSrc = piMask+maskStride+1; |
---|
| 462 | Pel predDC1 = 0; Pel predDC2 = 0; |
---|
| 463 | xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 ); |
---|
| 464 | |
---|
| 465 | // set segment values with deltaDC offsets |
---|
| 466 | Pel segDC1 = 0; |
---|
| 467 | Pel segDC2 = 0; |
---|
| 468 | if( dimDeltaDC ) |
---|
[100] | 469 | { |
---|
[608] | 470 | Pel deltaDC1 = pcCU->getDimDeltaDC( dimType, 0, uiAbsPartIdx ); |
---|
| 471 | Pel deltaDC2 = pcCU->getDimDeltaDC( dimType, 1, uiAbsPartIdx ); |
---|
| 472 | #if H_3D_DIM_DMM |
---|
| 473 | if( isDmmMode ) |
---|
| 474 | { |
---|
| 475 | #if H_3D_DIM_DLT |
---|
[758] | 476 | segDC1 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 ); |
---|
| 477 | segDC2 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 ); |
---|
| 478 | #else |
---|
[608] | 479 | segDC1 = ClipY( predDC1 + deltaDC1 ); |
---|
| 480 | segDC2 = ClipY( predDC2 + deltaDC2 ); |
---|
| 481 | #endif |
---|
| 482 | } |
---|
| 483 | #endif |
---|
[100] | 484 | } |
---|
[608] | 485 | else |
---|
[100] | 486 | { |
---|
[608] | 487 | segDC1 = predDC1; |
---|
| 488 | segDC2 = predDC2; |
---|
[100] | 489 | } |
---|
| 490 | |
---|
[608] | 491 | // set prediction signal |
---|
| 492 | Pel* pDst = piPred; |
---|
| 493 | xAssignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 ); |
---|
[100] | 494 | |
---|
[608] | 495 | #if H_3D_DIM_DMM |
---|
| 496 | if( dimType == DMM4_IDX ) { dmmSegmentation->destroy(); delete dmmSegmentation; } |
---|
| 497 | #endif |
---|
[100] | 498 | } |
---|
[608] | 499 | #endif |
---|
[100] | 500 | |
---|
[608] | 501 | /** Function for checking identical motion. |
---|
| 502 | * \param TComDataCU* pcCU |
---|
| 503 | * \param UInt PartAddr |
---|
| 504 | */ |
---|
| 505 | Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) |
---|
[100] | 506 | { |
---|
[608] | 507 | if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getPPS()->getWPBiPred() ) |
---|
[100] | 508 | { |
---|
[608] | 509 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0) |
---|
[100] | 510 | { |
---|
[608] | 511 | Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); |
---|
| 512 | Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); |
---|
| 513 | if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
[100] | 514 | { |
---|
[608] | 515 | return true; |
---|
[100] | 516 | } |
---|
| 517 | } |
---|
| 518 | } |
---|
[608] | 519 | return false; |
---|
[100] | 520 | } |
---|
| 521 | |
---|
[773] | 522 | #if H_3D_SPIVMP |
---|
[724] | 523 | Void TComPrediction::xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr ) |
---|
| 524 | { |
---|
| 525 | for (Int i = 0; i < iNumSP; i++) |
---|
| 526 | { |
---|
| 527 | uiMergedSPW[i] = iSPWidth; |
---|
| 528 | uiMergedSPH[i] = iSPHeight; |
---|
| 529 | pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]); |
---|
| 530 | } |
---|
| 531 | // horizontal sub-PU merge |
---|
| 532 | for (Int i=0; i<iNumSP; i++) |
---|
| 533 | { |
---|
| 534 | if (i % iNumSPInOneLine == iNumSPInOneLine - 1 || uiMergedSPW[i]==0 || uiMergedSPH[i]==0) |
---|
| 535 | { |
---|
| 536 | continue; |
---|
| 537 | } |
---|
| 538 | for (Int j=i+1; j<i+iNumSPInOneLine-i%iNumSPInOneLine; j++) |
---|
| 539 | { |
---|
| 540 | if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j])) |
---|
| 541 | { |
---|
| 542 | uiMergedSPW[i] += iSPWidth; |
---|
| 543 | uiMergedSPW[j] = uiMergedSPH[j] = 0; |
---|
| 544 | } |
---|
| 545 | else |
---|
| 546 | { |
---|
| 547 | break; |
---|
| 548 | } |
---|
| 549 | } |
---|
| 550 | } |
---|
| 551 | //vertical sub-PU merge |
---|
| 552 | for (Int i=0; i<iNumSP-iNumSPInOneLine; i++) |
---|
| 553 | { |
---|
| 554 | if (uiMergedSPW[i]==0 || uiMergedSPH[i]==0) |
---|
| 555 | { |
---|
| 556 | continue; |
---|
| 557 | } |
---|
| 558 | for (Int j=i+iNumSPInOneLine; j<iNumSP; j+=iNumSPInOneLine) |
---|
| 559 | { |
---|
| 560 | if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j]) && uiMergedSPW[i]==uiMergedSPW[j]) |
---|
| 561 | { |
---|
| 562 | uiMergedSPH[i] += iSPHeight; |
---|
| 563 | uiMergedSPH[j] = uiMergedSPW[j] = 0; |
---|
| 564 | } |
---|
| 565 | else |
---|
| 566 | { |
---|
| 567 | break; |
---|
| 568 | } |
---|
| 569 | } |
---|
| 570 | } |
---|
| 571 | } |
---|
[608] | 572 | |
---|
[724] | 573 | Bool TComPrediction::xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 ) |
---|
| 574 | { |
---|
| 575 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr1)) |
---|
| 576 | { |
---|
| 577 | return false; |
---|
| 578 | } |
---|
| 579 | if( pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr1)) |
---|
| 580 | { |
---|
| 581 | return false; |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | if (pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) >= 0) |
---|
| 585 | { |
---|
| 586 | if (pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr1)) |
---|
| 587 | { |
---|
| 588 | return false; |
---|
| 589 | } |
---|
| 590 | } |
---|
| 591 | |
---|
| 592 | if (pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) >= 0) |
---|
| 593 | { |
---|
| 594 | if (pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr1)) |
---|
| 595 | { |
---|
| 596 | return false; |
---|
| 597 | } |
---|
| 598 | } |
---|
| 599 | return true; |
---|
| 600 | } |
---|
| 601 | #endif |
---|
| 602 | |
---|
[56] | 603 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) |
---|
| 604 | { |
---|
| 605 | Int iWidth; |
---|
| 606 | Int iHeight; |
---|
| 607 | UInt uiPartAddr; |
---|
| 608 | |
---|
| 609 | if ( iPartIdx >= 0 ) |
---|
| 610 | { |
---|
| 611 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
[608] | 612 | #if H_3D_VSP |
---|
[622] | 613 | if ( pcCU->getVSPFlag(uiPartAddr) == 0) |
---|
[56] | 614 | { |
---|
| 615 | #endif |
---|
[608] | 616 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
[56] | 617 | { |
---|
[608] | 618 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
| 619 | { |
---|
| 620 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
| 621 | } |
---|
| 622 | else |
---|
| 623 | { |
---|
| 624 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 625 | } |
---|
| 626 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
| 627 | { |
---|
| 628 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 629 | } |
---|
[56] | 630 | } |
---|
| 631 | else |
---|
| 632 | { |
---|
[773] | 633 | #if H_3D_SPIVMP |
---|
[724] | 634 | if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0) |
---|
[608] | 635 | { |
---|
[724] | 636 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 637 | |
---|
| 638 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 639 | |
---|
| 640 | UInt uiW[256], uiH[256]; |
---|
| 641 | UInt uiSPAddr[256]; |
---|
| 642 | |
---|
| 643 | xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr); |
---|
| 644 | |
---|
| 645 | //MC |
---|
| 646 | for (Int i = 0; i < iNumSP; i++) |
---|
| 647 | { |
---|
| 648 | if (uiW[i]==0 || uiH[i]==0) |
---|
| 649 | { |
---|
| 650 | continue; |
---|
| 651 | } |
---|
| 652 | if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] )) |
---|
| 653 | { |
---|
| 654 | xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred ); |
---|
| 655 | } |
---|
| 656 | else |
---|
| 657 | { |
---|
| 658 | xPredInterBi (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred); |
---|
| 659 | } |
---|
| 660 | } |
---|
[608] | 661 | } |
---|
| 662 | else |
---|
| 663 | { |
---|
[724] | 664 | #endif |
---|
| 665 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
| 666 | { |
---|
| 667 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
| 668 | } |
---|
| 669 | else |
---|
| 670 | { |
---|
| 671 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
| 672 | } |
---|
[773] | 673 | #if H_3D_SPIVMP |
---|
[608] | 674 | } |
---|
[724] | 675 | #endif |
---|
[56] | 676 | } |
---|
[608] | 677 | #if H_3D_VSP |
---|
[56] | 678 | } |
---|
| 679 | else |
---|
| 680 | { |
---|
[608] | 681 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
[622] | 682 | { |
---|
[608] | 683 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
[622] | 684 | } |
---|
[56] | 685 | else |
---|
[622] | 686 | { |
---|
[608] | 687 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
[622] | 688 | } |
---|
[608] | 689 | } |
---|
[296] | 690 | #endif |
---|
[2] | 691 | return; |
---|
| 692 | } |
---|
[56] | 693 | |
---|
| 694 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ ) |
---|
| 695 | { |
---|
| 696 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
| 697 | |
---|
[608] | 698 | #if H_3D_VSP |
---|
[622] | 699 | if ( pcCU->getVSPFlag(uiPartAddr) == 0 ) |
---|
[56] | 700 | { |
---|
[189] | 701 | #endif |
---|
[608] | 702 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
[56] | 703 | { |
---|
[608] | 704 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
| 705 | { |
---|
| 706 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
| 707 | } |
---|
| 708 | else |
---|
| 709 | { |
---|
| 710 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 711 | } |
---|
| 712 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
| 713 | { |
---|
| 714 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 715 | } |
---|
[56] | 716 | } |
---|
[608] | 717 | else |
---|
[56] | 718 | { |
---|
[773] | 719 | #if H_3D_SPIVMP |
---|
[724] | 720 | if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) |
---|
| 721 | { |
---|
| 722 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 723 | |
---|
| 724 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 725 | |
---|
| 726 | UInt uiW[256], uiH[256]; |
---|
| 727 | UInt uiSPAddr[256]; |
---|
| 728 | |
---|
| 729 | xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr); |
---|
| 730 | //MC |
---|
| 731 | for (Int i = 0; i < iNumSP; i++) |
---|
| 732 | { |
---|
| 733 | if (uiW[i]==0 || uiH[i]==0) |
---|
| 734 | { |
---|
| 735 | continue; |
---|
| 736 | } |
---|
| 737 | if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] )) |
---|
| 738 | { |
---|
| 739 | xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred ); |
---|
| 740 | } |
---|
| 741 | else |
---|
| 742 | { |
---|
| 743 | xPredInterBi (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred); |
---|
| 744 | } |
---|
| 745 | } |
---|
| 746 | } |
---|
| 747 | else |
---|
| 748 | { |
---|
| 749 | #endif |
---|
[608] | 750 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
| 751 | { |
---|
| 752 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
| 753 | } |
---|
| 754 | else |
---|
| 755 | { |
---|
| 756 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
| 757 | } |
---|
[773] | 758 | #if H_3D_SPIVMP |
---|
[724] | 759 | } |
---|
| 760 | #endif |
---|
[56] | 761 | } |
---|
[608] | 762 | #if H_3D_VSP |
---|
[56] | 763 | } |
---|
| 764 | else |
---|
| 765 | { |
---|
| 766 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
[622] | 767 | { |
---|
[608] | 768 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
[622] | 769 | } |
---|
[56] | 770 | else |
---|
[622] | 771 | { |
---|
[608] | 772 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
[622] | 773 | } |
---|
[56] | 774 | } |
---|
[608] | 775 | #endif |
---|
[56] | 776 | } |
---|
| 777 | return; |
---|
| 778 | } |
---|
[2] | 779 | |
---|
[608] | 780 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
[296] | 781 | { |
---|
[608] | 782 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
| 783 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 784 | pcCU->clipMv(cMv); |
---|
| 785 | #if H_3D_ARP |
---|
[724] | 786 | if(pcCU->getARPW( uiPartAddr ) > 0 && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC()) |
---|
| 787 | { |
---|
[773] | 788 | xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi ); |
---|
[724] | 789 | } |
---|
| 790 | else |
---|
[443] | 791 | { |
---|
[773] | 792 | if( pcCU->getARPW( uiPartAddr ) > 0 |
---|
| 793 | && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N |
---|
| 794 | && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() |
---|
| 795 | ) |
---|
| 796 | { |
---|
| 797 | xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi ); |
---|
| 798 | } |
---|
| 799 | else |
---|
| 800 | { |
---|
[443] | 801 | #endif |
---|
[608] | 802 | #if H_3D_IC |
---|
[773] | 803 | Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ); |
---|
| 804 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
[608] | 805 | #if H_3D_ARP |
---|
[773] | 806 | , false |
---|
[443] | 807 | #endif |
---|
[773] | 808 | , bICFlag ); |
---|
| 809 | bICFlag = bICFlag && (iWidth > 8); |
---|
| 810 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
[608] | 811 | #if H_3D_ARP |
---|
[773] | 812 | , false |
---|
[443] | 813 | #endif |
---|
[773] | 814 | , bICFlag ); |
---|
[443] | 815 | #else |
---|
[773] | 816 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
| 817 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
[443] | 818 | #endif |
---|
[608] | 819 | #if H_3D_ARP |
---|
[773] | 820 | } |
---|
[443] | 821 | } |
---|
| 822 | #endif |
---|
| 823 | } |
---|
| 824 | |
---|
[608] | 825 | #if H_3D_VSP |
---|
| 826 | Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
[56] | 827 | { |
---|
[608] | 828 | // Get depth reference |
---|
[622] | 829 | Int depthRefViewIdx = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
[655] | 830 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
| 831 | TComPic* pRefPicBaseDepth = 0; |
---|
| 832 | Bool bIsCurrDepthCoded = false; |
---|
| 833 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() ); |
---|
| 834 | if ( pRefPicBaseDepth->getPicYuvRec() != NULL ) |
---|
| 835 | { |
---|
| 836 | bIsCurrDepthCoded = true; |
---|
| 837 | } |
---|
| 838 | else |
---|
| 839 | { |
---|
| 840 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
| 841 | } |
---|
| 842 | #else |
---|
[608] | 843 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
[655] | 844 | #endif |
---|
[608] | 845 | assert(pRefPicBaseDepth != NULL); |
---|
| 846 | TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
| 847 | assert(pcBaseViewDepthPicYuv != NULL); |
---|
[296] | 848 | |
---|
[608] | 849 | // Get texture reference |
---|
| 850 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 851 | assert(iRefIdx >= 0); |
---|
| 852 | TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); |
---|
| 853 | TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
| 854 | assert(pcBaseViewTxtPicYuv != NULL); |
---|
[56] | 855 | |
---|
[608] | 856 | // Initialize LUT according to the reference viewIdx |
---|
| 857 | Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex(); |
---|
| 858 | Int* pShiftLUT = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx ); |
---|
| 859 | assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() ); |
---|
[100] | 860 | |
---|
[608] | 861 | // Do compensation |
---|
| 862 | TComMv cDv = pcCU->getDvInfo(uiPartAddr).m_acNBDV; |
---|
| 863 | pcCU->clipMv(cDv); |
---|
[296] | 864 | |
---|
[655] | 865 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
| 866 | if ( bIsCurrDepthCoded ) |
---|
| 867 | { |
---|
| 868 | cDv.setZero(); |
---|
| 869 | } |
---|
| 870 | #endif |
---|
[608] | 871 | // fetch virtual depth map |
---|
| 872 | pcBaseViewDepthPicYuv->extendPicBorder(); |
---|
[724] | 873 | |
---|
| 874 | Int vspSize=0; |
---|
| 875 | xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp,vspSize ); |
---|
| 876 | // sub-PU based compensation |
---|
| 877 | xPredInterLumaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi, vspSize); |
---|
| 878 | xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi, vspSize); |
---|
[608] | 879 | } |
---|
[296] | 880 | #endif |
---|
[189] | 881 | |
---|
[608] | 882 | #if H_3D_ARP |
---|
| 883 | Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled ) |
---|
| 884 | { |
---|
| 885 | Int iRefIdx = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 886 | TComMv cMv = pNewMvFiled ? pNewMvFiled->getMv() : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 887 | Bool bTobeScaled = false; |
---|
| 888 | TComPic* pcPicYuvBaseCol = NULL; |
---|
| 889 | TComPic* pcPicYuvBaseRef = NULL; |
---|
[2] | 890 | |
---|
[608] | 891 | #if H_3D_NBDV |
---|
[443] | 892 | DisInfo cDistparity; |
---|
| 893 | cDistparity.bDV = pcCU->getDvInfo(uiPartAddr).bDV; |
---|
| 894 | if( cDistparity.bDV ) |
---|
| 895 | { |
---|
[608] | 896 | cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV; |
---|
[443] | 897 | assert(pcCU->getDvInfo(uiPartAddr).bDV == pcCU->getDvInfo(0).bDV); |
---|
[608] | 898 | cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
[443] | 899 | } |
---|
| 900 | #else |
---|
[608] | 901 | assert(0); // ARP can be applied only when a DV is available |
---|
[443] | 902 | #endif |
---|
| 903 | |
---|
[608] | 904 | UChar dW = cDistparity.bDV ? pcCU->getARPW ( uiPartAddr ) : 0; |
---|
| 905 | |
---|
| 906 | if( cDistparity.bDV ) |
---|
[443] | 907 | { |
---|
[724] | 908 | Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList); |
---|
| 909 | if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() ) |
---|
[608] | 910 | { |
---|
[443] | 911 | bTobeScaled = true; |
---|
[608] | 912 | } |
---|
| 913 | |
---|
| 914 | pcPicYuvBaseCol = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(), cDistparity.m_aVIdxCan ); |
---|
[724] | 915 | |
---|
| 916 | pcPicYuvBaseRef = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan ); |
---|
| 917 | |
---|
| 918 | if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan)) |
---|
[443] | 919 | { |
---|
| 920 | dW = 0; |
---|
| 921 | bTobeScaled = false; |
---|
| 922 | } |
---|
| 923 | else |
---|
[608] | 924 | { |
---|
[724] | 925 | assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() ); |
---|
[608] | 926 | } |
---|
| 927 | |
---|
[443] | 928 | if(bTobeScaled) |
---|
| 929 | { |
---|
[608] | 930 | Int iCurrPOC = pcCU->getSlice()->getPOC(); |
---|
[443] | 931 | Int iColRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx ); |
---|
| 932 | Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, 0); |
---|
| 933 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC); |
---|
| 934 | if ( iScale != 4096 ) |
---|
[608] | 935 | { |
---|
[443] | 936 | cMv = cMv.scaleMv( iScale ); |
---|
[608] | 937 | } |
---|
[443] | 938 | iRefIdx = 0; |
---|
| 939 | } |
---|
| 940 | } |
---|
[608] | 941 | |
---|
[443] | 942 | pcCU->clipMv(cMv); |
---|
| 943 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(); |
---|
[608] | 944 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true ); |
---|
| 945 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true ); |
---|
| 946 | |
---|
[443] | 947 | if( dW > 0 ) |
---|
| 948 | { |
---|
[608] | 949 | TComYuv * pYuvB0 = &m_acYuvPredBase[0]; |
---|
[443] | 950 | TComYuv * pYuvB1 = &m_acYuvPredBase[1]; |
---|
[608] | 951 | |
---|
| 952 | TComMv cMVwithDisparity = cMv + cDistparity.m_acNBDV; |
---|
| 953 | pcCU->clipMv(cMVwithDisparity); |
---|
| 954 | |
---|
| 955 | assert ( cDistparity.bDV ); |
---|
| 956 | |
---|
[443] | 957 | pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec(); |
---|
[608] | 958 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true ); |
---|
| 959 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true ); |
---|
| 960 | |
---|
[443] | 961 | pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec(); |
---|
[608] | 962 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true ); |
---|
| 963 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true ); |
---|
| 964 | |
---|
| 965 | pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight ); |
---|
| 966 | |
---|
| 967 | if( 2 == dW ) |
---|
| 968 | { |
---|
| 969 | pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); |
---|
| 970 | } |
---|
| 971 | rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi ); |
---|
[443] | 972 | } |
---|
| 973 | } |
---|
[724] | 974 | Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled ) |
---|
| 975 | { |
---|
| 976 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 977 | TComMv cDMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 978 | TComMv cTempDMv = cDMv; |
---|
| 979 | UChar dW = pcCU->getARPW ( uiPartAddr ); |
---|
| 980 | |
---|
| 981 | TComPic* pcPicYuvBaseTRef = NULL; |
---|
| 982 | TComPic* pcPicYuvCurrTRef = NULL; |
---|
| 983 | TComPic* pcPicYuvBaseCol = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); |
---|
| 984 | TComPicYuv* pcYuvBaseCol = pcPicYuvBaseCol->getPicYuvRec(); |
---|
| 985 | Bool bTMVAvai = false; |
---|
| 986 | TComMv cBaseTMV; |
---|
| 987 | if( pNewMvFiled ) |
---|
| 988 | { |
---|
| 989 | iRefIdx = pNewMvFiled->getRefIdx(); |
---|
| 990 | cDMv = pNewMvFiled->getMv(); |
---|
| 991 | } |
---|
| 992 | pcCU->clipMv(cTempDMv); |
---|
| 993 | |
---|
| 994 | assert(dW > 0); |
---|
| 995 | if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex())) |
---|
| 996 | { |
---|
| 997 | dW = 0; |
---|
| 998 | } |
---|
| 999 | Int uiLCUAddr,uiAbsPartAddr; |
---|
| 1000 | Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2 + ((cDMv.getHor() + 2)>>2); |
---|
| 1001 | Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2); |
---|
[443] | 1002 | |
---|
[724] | 1003 | irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX); |
---|
| 1004 | irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); |
---|
| 1005 | pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr); |
---|
| 1006 | TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr ); |
---|
| 1007 | |
---|
| 1008 | if(!pColCU->isIntra(uiAbsPartAddr)) |
---|
| 1009 | { |
---|
| 1010 | TComMvField puMVField; |
---|
| 1011 | for(Int iList = 0; iList < (pColCU->getSlice()->isInterB() ? 2: 1) && !bTMVAvai; iList ++) |
---|
| 1012 | { |
---|
| 1013 | RefPicList eRefPicListCurr = RefPicList(iList); |
---|
| 1014 | Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr); |
---|
| 1015 | if( iRef != -1) |
---|
| 1016 | { |
---|
| 1017 | pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); |
---|
| 1018 | Int iCurrPOC = pColCU->getSlice()->getPOC(); |
---|
| 1019 | Int iCurrRefPOC = pcPicYuvBaseTRef->getPOC(); |
---|
| 1020 | Int iCurrRef = pcCU->getSlice()->getFirstTRefIdx(eRefPicListCurr); |
---|
| 1021 | if( iCurrRef >= 0) |
---|
| 1022 | { |
---|
| 1023 | pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic(eRefPicListCurr,iCurrRef); |
---|
| 1024 | Int iTargetPOC = pcPicYuvCurrTRef->getPOC(); |
---|
| 1025 | { |
---|
| 1026 | pcPicYuvBaseTRef = pcCU->getSlice()->getBaseViewRefPic(iTargetPOC, pcPicYuvBaseCol->getViewIndex() ); |
---|
| 1027 | if(pcPicYuvBaseTRef) |
---|
| 1028 | { |
---|
| 1029 | cBaseTMV = pColCU->getCUMvField(eRefPicListCurr)->getMv(uiAbsPartAddr); |
---|
| 1030 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC); |
---|
| 1031 | if ( iScale != 4096 ) |
---|
| 1032 | cBaseTMV = cBaseTMV.scaleMv( iScale ); |
---|
| 1033 | bTMVAvai = true; |
---|
| 1034 | break; |
---|
| 1035 | } |
---|
| 1036 | } |
---|
| 1037 | } |
---|
| 1038 | } |
---|
| 1039 | } |
---|
| 1040 | } |
---|
| 1041 | if (bTMVAvai == false) |
---|
| 1042 | { |
---|
| 1043 | bTMVAvai = true; |
---|
| 1044 | cBaseTMV.set(0, 0); |
---|
| 1045 | pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicList, pcCU->getSlice()->getFirstTRefIdx(eRefPicList)); |
---|
| 1046 | pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic (eRefPicList, pcCU->getSlice()->getFirstTRefIdx(eRefPicList)); |
---|
| 1047 | } |
---|
| 1048 | |
---|
| 1049 | xPredInterLumaBlk ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi, bTMVAvai); |
---|
| 1050 | xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi, bTMVAvai); |
---|
| 1051 | |
---|
| 1052 | if( dW > 0 && bTMVAvai ) |
---|
| 1053 | { |
---|
| 1054 | TComYuv* pYuvCurrTRef = &m_acYuvPredBase[0]; |
---|
| 1055 | TComYuv* pYuvBaseTRef = &m_acYuvPredBase[1]; |
---|
| 1056 | TComPicYuv* pcYuvCurrTref = pcPicYuvCurrTRef->getPicYuvRec(); |
---|
| 1057 | TComPicYuv* pcYuvBaseTref = pcPicYuvBaseTRef->getPicYuvRec(); |
---|
| 1058 | TComMv cTempMv = cDMv + cBaseTMV; |
---|
| 1059 | |
---|
| 1060 | pcCU->clipMv(cBaseTMV); |
---|
| 1061 | pcCU->clipMv(cTempMv); |
---|
| 1062 | |
---|
| 1063 | xPredInterLumaBlk ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, bi, true); |
---|
| 1064 | xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, bi, true); |
---|
| 1065 | xPredInterLumaBlk ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, bi, true); |
---|
| 1066 | xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, bi, true); |
---|
| 1067 | |
---|
| 1068 | pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight ); |
---|
| 1069 | if(dW == 2) |
---|
| 1070 | { |
---|
| 1071 | pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); |
---|
| 1072 | } |
---|
| 1073 | rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi ); |
---|
| 1074 | } |
---|
| 1075 | } |
---|
| 1076 | |
---|
| 1077 | #endif |
---|
| 1078 | |
---|
[608] | 1079 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
[2] | 1080 | { |
---|
[56] | 1081 | TComYuv* pcMbYuv; |
---|
| 1082 | Int iRefIdx[2] = {-1, -1}; |
---|
| 1083 | |
---|
| 1084 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
| 1085 | { |
---|
| 1086 | RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
| 1087 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 1088 | |
---|
| 1089 | if ( iRefIdx[iRefList] < 0 ) |
---|
| 1090 | { |
---|
| 1091 | continue; |
---|
| 1092 | } |
---|
| 1093 | |
---|
| 1094 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
| 1095 | |
---|
| 1096 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
| 1097 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
| 1098 | { |
---|
[608] | 1099 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
[56] | 1100 | } |
---|
| 1101 | else |
---|
| 1102 | { |
---|
[608] | 1103 | if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || |
---|
| 1104 | ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) ) |
---|
[56] | 1105 | { |
---|
[608] | 1106 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
[56] | 1107 | } |
---|
| 1108 | else |
---|
| 1109 | { |
---|
[608] | 1110 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv ); |
---|
[56] | 1111 | } |
---|
| 1112 | } |
---|
| 1113 | } |
---|
[608] | 1114 | |
---|
| 1115 | if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) |
---|
[56] | 1116 | { |
---|
| 1117 | xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
[608] | 1118 | } |
---|
[313] | 1119 | else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) |
---|
| 1120 | { |
---|
[608] | 1121 | xWeightedPredictionUni( pcCU, &m_acYuvPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred ); |
---|
[313] | 1122 | } |
---|
[56] | 1123 | else |
---|
| 1124 | { |
---|
[608] | 1125 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
[56] | 1126 | } |
---|
[2] | 1127 | } |
---|
| 1128 | |
---|
[608] | 1129 | #if H_3D_VSP |
---|
[296] | 1130 | |
---|
[608] | 1131 | Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
| 1132 | { |
---|
| 1133 | TComYuv* pcMbYuv; |
---|
| 1134 | Int iRefIdx[2] = {-1, -1}; |
---|
| 1135 | Bool bi = (pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0); |
---|
[296] | 1136 | |
---|
[608] | 1137 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
[2] | 1138 | { |
---|
[608] | 1139 | RefPicList eRefPicList = RefPicList(iRefList); |
---|
| 1140 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
[56] | 1141 | |
---|
[608] | 1142 | if ( iRefIdx[iRefList] < 0 ) |
---|
[622] | 1143 | { |
---|
[608] | 1144 | continue; |
---|
[622] | 1145 | } |
---|
[608] | 1146 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
[56] | 1147 | |
---|
[608] | 1148 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
| 1149 | xPredInterUniVSP ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, bi ); |
---|
[2] | 1150 | } |
---|
[296] | 1151 | |
---|
[608] | 1152 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 1153 | } |
---|
[296] | 1154 | |
---|
| 1155 | #endif |
---|
[56] | 1156 | |
---|
| 1157 | /** |
---|
| 1158 | * \brief Generate motion-compensated luma block |
---|
| 1159 | * |
---|
| 1160 | * \param cu Pointer to current CU |
---|
| 1161 | * \param refPic Pointer to reference picture |
---|
| 1162 | * \param partAddr Address of block within CU |
---|
| 1163 | * \param mv Motion vector |
---|
| 1164 | * \param width Width of block |
---|
| 1165 | * \param height Height of block |
---|
| 1166 | * \param dstPic Pointer to destination picture |
---|
| 1167 | * \param bi Flag indicating whether bipred is used |
---|
| 1168 | */ |
---|
[608] | 1169 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
| 1170 | #if H_3D_ARP |
---|
| 1171 | , Bool filterType |
---|
[189] | 1172 | #endif |
---|
[608] | 1173 | #if H_3D_IC |
---|
| 1174 | , Bool bICFlag |
---|
| 1175 | #endif |
---|
| 1176 | ) |
---|
[56] | 1177 | { |
---|
| 1178 | Int refStride = refPic->getStride(); |
---|
| 1179 | Int refOffset = ( mv->getHor() >> 2 ) + ( mv->getVer() >> 2 ) * refStride; |
---|
| 1180 | Pel *ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1181 | |
---|
| 1182 | Int dstStride = dstPic->getStride(); |
---|
| 1183 | Pel *dst = dstPic->getLumaAddr( partAddr ); |
---|
| 1184 | |
---|
| 1185 | Int xFrac = mv->getHor() & 0x3; |
---|
| 1186 | Int yFrac = mv->getVer() & 0x3; |
---|
| 1187 | |
---|
[608] | 1188 | #if H_3D_IC |
---|
| 1189 | if( cu->getSlice()->getIsDepth() ) |
---|
| 1190 | { |
---|
| 1191 | refOffset = mv->getHor() + mv->getVer() * refStride; |
---|
| 1192 | ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1193 | xFrac = 0; |
---|
| 1194 | yFrac = 0; |
---|
| 1195 | } |
---|
[56] | 1196 | #endif |
---|
| 1197 | if ( yFrac == 0 ) |
---|
[2] | 1198 | { |
---|
[655] | 1199 | #if H_3D_IC |
---|
[608] | 1200 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi || bICFlag |
---|
| 1201 | #else |
---|
| 1202 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi |
---|
[443] | 1203 | #endif |
---|
[608] | 1204 | #if H_3D_ARP |
---|
| 1205 | , filterType |
---|
| 1206 | #endif |
---|
| 1207 | ); |
---|
[2] | 1208 | } |
---|
[56] | 1209 | else if ( xFrac == 0 ) |
---|
| 1210 | { |
---|
[655] | 1211 | #if H_3D_IC |
---|
[608] | 1212 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag |
---|
| 1213 | #else |
---|
| 1214 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi |
---|
[443] | 1215 | #endif |
---|
[608] | 1216 | #if H_3D_ARP |
---|
| 1217 | , filterType |
---|
| 1218 | #endif |
---|
| 1219 | ); |
---|
[56] | 1220 | } |
---|
| 1221 | else |
---|
| 1222 | { |
---|
| 1223 | Int tmpStride = m_filteredBlockTmp[0].getStride(); |
---|
| 1224 | Short *tmp = m_filteredBlockTmp[0].getLumaAddr(); |
---|
| 1225 | |
---|
| 1226 | Int filterSize = NTAPS_LUMA; |
---|
| 1227 | Int halfFilterSize = ( filterSize >> 1 ); |
---|
| 1228 | |
---|
[443] | 1229 | m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false |
---|
[608] | 1230 | #if H_3D_ARP |
---|
| 1231 | , filterType |
---|
[443] | 1232 | #endif |
---|
[608] | 1233 | ); |
---|
[655] | 1234 | #if H_3D_IC |
---|
[608] | 1235 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi || bICFlag |
---|
| 1236 | #else |
---|
[443] | 1237 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi |
---|
[608] | 1238 | #endif |
---|
| 1239 | #if H_3D_ARP |
---|
| 1240 | , filterType |
---|
[443] | 1241 | #endif |
---|
[608] | 1242 | ); |
---|
[56] | 1243 | } |
---|
[189] | 1244 | |
---|
[608] | 1245 | #if H_3D_IC |
---|
| 1246 | if( bICFlag ) |
---|
[189] | 1247 | { |
---|
[608] | 1248 | Int a, b, i, j; |
---|
| 1249 | const Int iShift = IC_CONST_SHIFT; |
---|
| 1250 | |
---|
| 1251 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA ); |
---|
[189] | 1252 | |
---|
| 1253 | |
---|
[608] | 1254 | for ( i = 0; i < height; i++ ) |
---|
[189] | 1255 | { |
---|
[608] | 1256 | for ( j = 0; j < width; j++ ) |
---|
[189] | 1257 | { |
---|
[608] | 1258 | dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b ); |
---|
[189] | 1259 | } |
---|
| 1260 | dst += dstStride; |
---|
| 1261 | } |
---|
[655] | 1262 | |
---|
[608] | 1263 | if(bi) |
---|
| 1264 | { |
---|
| 1265 | Pel *dst2 = dstPic->getLumaAddr( partAddr ); |
---|
| 1266 | Int shift = IF_INTERNAL_PREC - g_bitDepthY; |
---|
| 1267 | for (i = 0; i < height; i++) |
---|
| 1268 | { |
---|
| 1269 | for (j = 0; j < width; j++) |
---|
| 1270 | { |
---|
| 1271 | Short val = dst2[j] << shift; |
---|
| 1272 | dst2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
| 1273 | } |
---|
| 1274 | dst2 += dstStride; |
---|
| 1275 | } |
---|
| 1276 | } |
---|
[189] | 1277 | } |
---|
| 1278 | #endif |
---|
[2] | 1279 | } |
---|
| 1280 | |
---|
[56] | 1281 | /** |
---|
| 1282 | * \brief Generate motion-compensated chroma block |
---|
| 1283 | * |
---|
| 1284 | * \param cu Pointer to current CU |
---|
| 1285 | * \param refPic Pointer to reference picture |
---|
| 1286 | * \param partAddr Address of block within CU |
---|
| 1287 | * \param mv Motion vector |
---|
| 1288 | * \param width Width of block |
---|
| 1289 | * \param height Height of block |
---|
| 1290 | * \param dstPic Pointer to destination picture |
---|
| 1291 | * \param bi Flag indicating whether bipred is used |
---|
| 1292 | */ |
---|
[608] | 1293 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
| 1294 | #if H_3D_ARP |
---|
| 1295 | , Bool filterType |
---|
[189] | 1296 | #endif |
---|
[608] | 1297 | #if H_3D_IC |
---|
| 1298 | , Bool bICFlag |
---|
| 1299 | #endif |
---|
[443] | 1300 | ) |
---|
[2] | 1301 | { |
---|
[56] | 1302 | Int refStride = refPic->getCStride(); |
---|
| 1303 | Int dstStride = dstPic->getCStride(); |
---|
| 1304 | |
---|
| 1305 | Int refOffset = (mv->getHor() >> 3) + (mv->getVer() >> 3) * refStride; |
---|
| 1306 | |
---|
| 1307 | Pel* refCb = refPic->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1308 | Pel* refCr = refPic->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1309 | |
---|
| 1310 | Pel* dstCb = dstPic->getCbAddr( partAddr ); |
---|
| 1311 | Pel* dstCr = dstPic->getCrAddr( partAddr ); |
---|
| 1312 | |
---|
| 1313 | Int xFrac = mv->getHor() & 0x7; |
---|
| 1314 | Int yFrac = mv->getVer() & 0x7; |
---|
| 1315 | UInt cxWidth = width >> 1; |
---|
| 1316 | UInt cxHeight = height >> 1; |
---|
| 1317 | |
---|
| 1318 | Int extStride = m_filteredBlockTmp[0].getStride(); |
---|
| 1319 | Short* extY = m_filteredBlockTmp[0].getLumaAddr(); |
---|
| 1320 | |
---|
| 1321 | Int filterSize = NTAPS_CHROMA; |
---|
| 1322 | |
---|
| 1323 | Int halfFilterSize = (filterSize>>1); |
---|
| 1324 | |
---|
| 1325 | if ( yFrac == 0 ) |
---|
| 1326 | { |
---|
[655] | 1327 | #if H_3D_IC |
---|
[608] | 1328 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag |
---|
| 1329 | #else |
---|
[443] | 1330 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
[608] | 1331 | #endif |
---|
| 1332 | #if H_3D_ARP |
---|
| 1333 | , filterType |
---|
| 1334 | #endif |
---|
[443] | 1335 | ); |
---|
[655] | 1336 | #if H_3D_IC |
---|
[608] | 1337 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag |
---|
| 1338 | #else |
---|
[443] | 1339 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
[608] | 1340 | #endif |
---|
| 1341 | #if H_3D_ARP |
---|
| 1342 | , filterType |
---|
| 1343 | #endif |
---|
| 1344 | ); |
---|
[56] | 1345 | } |
---|
| 1346 | else if ( xFrac == 0 ) |
---|
| 1347 | { |
---|
[655] | 1348 | #if H_3D_IC |
---|
[608] | 1349 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag |
---|
| 1350 | #else |
---|
[443] | 1351 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
[608] | 1352 | #endif |
---|
| 1353 | #if H_3D_ARP |
---|
| 1354 | , filterType |
---|
| 1355 | #endif |
---|
| 1356 | ); |
---|
[655] | 1357 | #if H_3D_IC |
---|
[608] | 1358 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag |
---|
| 1359 | #else |
---|
[443] | 1360 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
[608] | 1361 | #endif |
---|
| 1362 | #if H_3D_ARP |
---|
| 1363 | , filterType |
---|
| 1364 | #endif |
---|
| 1365 | ); |
---|
[56] | 1366 | } |
---|
| 1367 | else |
---|
| 1368 | { |
---|
[443] | 1369 | m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
[608] | 1370 | #if H_3D_ARP |
---|
| 1371 | , filterType |
---|
| 1372 | #endif |
---|
| 1373 | ); |
---|
[655] | 1374 | #if H_3D_IC |
---|
[608] | 1375 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag |
---|
| 1376 | #else |
---|
[443] | 1377 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
[608] | 1378 | #endif |
---|
| 1379 | #if H_3D_ARP |
---|
| 1380 | , filterType |
---|
| 1381 | #endif |
---|
| 1382 | ); |
---|
[56] | 1383 | |
---|
[443] | 1384 | m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
[608] | 1385 | #if H_3D_ARP |
---|
| 1386 | , filterType |
---|
| 1387 | #endif |
---|
| 1388 | ); |
---|
[655] | 1389 | #if H_3D_IC |
---|
[608] | 1390 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag |
---|
| 1391 | #else |
---|
[443] | 1392 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
[608] | 1393 | #endif |
---|
| 1394 | #if H_3D_ARP |
---|
| 1395 | , filterType |
---|
| 1396 | #endif |
---|
| 1397 | ); |
---|
[56] | 1398 | } |
---|
[608] | 1399 | |
---|
| 1400 | #if H_3D_IC |
---|
| 1401 | if( bICFlag ) |
---|
[189] | 1402 | { |
---|
[608] | 1403 | Int a, b, i, j; |
---|
| 1404 | const Int iShift = IC_CONST_SHIFT; |
---|
| 1405 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb |
---|
| 1406 | for ( i = 0; i < cxHeight; i++ ) |
---|
[189] | 1407 | { |
---|
[608] | 1408 | for ( j = 0; j < cxWidth; j++ ) |
---|
[189] | 1409 | { |
---|
[608] | 1410 | dstCb[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b ); |
---|
[189] | 1411 | } |
---|
| 1412 | dstCb += dstStride; |
---|
| 1413 | } |
---|
[608] | 1414 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr |
---|
| 1415 | for ( i = 0; i < cxHeight; i++ ) |
---|
[189] | 1416 | { |
---|
[608] | 1417 | for ( j = 0; j < cxWidth; j++ ) |
---|
[189] | 1418 | { |
---|
[608] | 1419 | dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b ); |
---|
[189] | 1420 | } |
---|
| 1421 | dstCr += dstStride; |
---|
| 1422 | } |
---|
[655] | 1423 | |
---|
[608] | 1424 | if(bi) |
---|
[296] | 1425 | { |
---|
[608] | 1426 | Pel* dstCb2 = dstPic->getCbAddr( partAddr ); |
---|
| 1427 | Pel* dstCr2 = dstPic->getCrAddr( partAddr ); |
---|
| 1428 | Int shift = IF_INTERNAL_PREC - g_bitDepthC; |
---|
| 1429 | for (i = 0; i < cxHeight; i++) |
---|
[296] | 1430 | { |
---|
[608] | 1431 | for (j = 0; j < cxWidth; j++) |
---|
[296] | 1432 | { |
---|
[608] | 1433 | Short val = dstCb2[j] << shift; |
---|
| 1434 | dstCb2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
[461] | 1435 | |
---|
[608] | 1436 | val = dstCr2[j] << shift; |
---|
| 1437 | dstCr2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
[296] | 1438 | } |
---|
[608] | 1439 | dstCb2 += dstStride; |
---|
| 1440 | dstCr2 += dstStride; |
---|
[443] | 1441 | } |
---|
| 1442 | } |
---|
[296] | 1443 | } |
---|
[443] | 1444 | #endif |
---|
[296] | 1445 | } |
---|
| 1446 | |
---|
[608] | 1447 | Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) |
---|
[2] | 1448 | { |
---|
[56] | 1449 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1450 | { |
---|
[56] | 1451 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); |
---|
[2] | 1452 | } |
---|
[56] | 1453 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
[2] | 1454 | { |
---|
[56] | 1455 | pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
[2] | 1456 | } |
---|
[56] | 1457 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1458 | { |
---|
[56] | 1459 | pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
| 1460 | } |
---|
| 1461 | } |
---|
| 1462 | |
---|
| 1463 | // AMVP |
---|
[608] | 1464 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred ) |
---|
[56] | 1465 | { |
---|
| 1466 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
[608] | 1467 | if( pcAMVPInfo->iN <= 1 ) |
---|
[56] | 1468 | { |
---|
| 1469 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
| 1470 | |
---|
| 1471 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 1472 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 1473 | return; |
---|
| 1474 | } |
---|
| 1475 | |
---|
| 1476 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
| 1477 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
| 1478 | return; |
---|
| 1479 | } |
---|
| 1480 | |
---|
| 1481 | /** Function for deriving planar intra prediction. |
---|
| 1482 | * \param pSrc pointer to reconstructed sample array |
---|
| 1483 | * \param srcStride the stride of the reconstructed sample array |
---|
| 1484 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 1485 | * \param dstStride the stride of the prediction sample array |
---|
| 1486 | * \param width the width of the block |
---|
| 1487 | * \param height the height of the block |
---|
| 1488 | * |
---|
| 1489 | * This function derives the prediction samples for planar mode (intra coding). |
---|
| 1490 | */ |
---|
| 1491 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
| 1492 | { |
---|
| 1493 | assert(width == height); |
---|
| 1494 | |
---|
| 1495 | Int k, l, bottomLeft, topRight; |
---|
| 1496 | Int horPred; |
---|
[655] | 1497 | Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
[56] | 1498 | UInt blkSize = width; |
---|
| 1499 | UInt offset2D = width; |
---|
| 1500 | UInt shift1D = g_aucConvertToBit[ width ] + 2; |
---|
| 1501 | UInt shift2D = shift1D + 1; |
---|
| 1502 | |
---|
| 1503 | // Get left and above reference column and row |
---|
| 1504 | for(k=0;k<blkSize+1;k++) |
---|
| 1505 | { |
---|
| 1506 | topRow[k] = pSrc[k-srcStride]; |
---|
| 1507 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
| 1508 | } |
---|
| 1509 | |
---|
| 1510 | // Prepare intermediate variables used in interpolation |
---|
| 1511 | bottomLeft = leftColumn[blkSize]; |
---|
| 1512 | topRight = topRow[blkSize]; |
---|
| 1513 | for (k=0;k<blkSize;k++) |
---|
| 1514 | { |
---|
| 1515 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
| 1516 | rightColumn[k] = topRight - leftColumn[k]; |
---|
| 1517 | topRow[k] <<= shift1D; |
---|
| 1518 | leftColumn[k] <<= shift1D; |
---|
| 1519 | } |
---|
| 1520 | |
---|
| 1521 | // Generate prediction signal |
---|
| 1522 | for (k=0;k<blkSize;k++) |
---|
| 1523 | { |
---|
| 1524 | horPred = leftColumn[k] + offset2D; |
---|
| 1525 | for (l=0;l<blkSize;l++) |
---|
[2] | 1526 | { |
---|
[56] | 1527 | horPred += rightColumn[k]; |
---|
| 1528 | topRow[l] += bottomRow[l]; |
---|
| 1529 | rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); |
---|
[2] | 1530 | } |
---|
| 1531 | } |
---|
| 1532 | } |
---|
| 1533 | |
---|
[608] | 1534 | /** Function for filtering intra DC predictor. |
---|
| 1535 | * \param pSrc pointer to reconstructed sample array |
---|
| 1536 | * \param iSrcStride the stride of the reconstructed sample array |
---|
| 1537 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 1538 | * \param iDstStride the stride of the prediction sample array |
---|
| 1539 | * \param iWidth the width of the block |
---|
| 1540 | * \param iHeight the height of the block |
---|
[56] | 1541 | * |
---|
[608] | 1542 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
[56] | 1543 | */ |
---|
[608] | 1544 | Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) |
---|
[56] | 1545 | { |
---|
[608] | 1546 | Pel* pDst = rpDst; |
---|
| 1547 | Int x, y, iDstStride2, iSrcStride2; |
---|
[2] | 1548 | |
---|
[608] | 1549 | // boundary pixels processing |
---|
| 1550 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
[56] | 1551 | |
---|
[608] | 1552 | for ( x = 1; x < iWidth; x++ ) |
---|
[2] | 1553 | { |
---|
[608] | 1554 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
[2] | 1555 | } |
---|
| 1556 | |
---|
[608] | 1557 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
[56] | 1558 | { |
---|
[608] | 1559 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
[56] | 1560 | } |
---|
[2] | 1561 | |
---|
[608] | 1562 | return; |
---|
[2] | 1563 | } |
---|
[608] | 1564 | #if H_3D_IC |
---|
| 1565 | /** Function for deriving the position of first non-zero binary bit of a value |
---|
[56] | 1566 | * \param x input value |
---|
| 1567 | * |
---|
[608] | 1568 | * This function derives the position of first non-zero binary bit of a value |
---|
[56] | 1569 | */ |
---|
| 1570 | Int GetMSB( UInt x ) |
---|
| 1571 | { |
---|
| 1572 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
| 1573 | |
---|
| 1574 | while( x > 1 ) |
---|
| 1575 | { |
---|
| 1576 | bits >>= 1; |
---|
| 1577 | y = x >> bits; |
---|
| 1578 | |
---|
| 1579 | if( y ) |
---|
| 1580 | { |
---|
| 1581 | x = y; |
---|
| 1582 | iMSB += bits; |
---|
| 1583 | } |
---|
| 1584 | } |
---|
| 1585 | |
---|
| 1586 | iMSB+=y; |
---|
| 1587 | |
---|
| 1588 | return iMSB; |
---|
| 1589 | } |
---|
| 1590 | |
---|
| 1591 | |
---|
[608] | 1592 | /** Function for deriving LM illumination compensation. |
---|
[56] | 1593 | */ |
---|
[608] | 1594 | Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType ) |
---|
[56] | 1595 | { |
---|
[608] | 1596 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
| 1597 | Pel *pRec = NULL, *pRef = NULL; |
---|
| 1598 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
| 1599 | Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride(); |
---|
| 1600 | Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride(); |
---|
| 1601 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset, iHor, iVer; |
---|
[56] | 1602 | |
---|
[608] | 1603 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1604 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1605 | iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 ); |
---|
| 1606 | iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 ); |
---|
| 1607 | iRefX = iCUPelX + iHor; |
---|
| 1608 | iRefY = iCUPelY + iVer; |
---|
| 1609 | if( eType != TEXT_LUMA ) |
---|
| 1610 | { |
---|
| 1611 | iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 ); |
---|
| 1612 | iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 ); |
---|
| 1613 | } |
---|
| 1614 | uiWidth = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 ) : ( pcCU->getWidth( 0 ) >> 1 ); |
---|
| 1615 | uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1 ); |
---|
[56] | 1616 | |
---|
| 1617 | Int i, j, iCountShift = 0; |
---|
| 1618 | |
---|
| 1619 | // LLS parameters estimation --> |
---|
| 1620 | |
---|
| 1621 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
[608] | 1622 | Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12); |
---|
[56] | 1623 | |
---|
[608] | 1624 | if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelY > 0 && iRefY > 0 ) |
---|
[56] | 1625 | { |
---|
[608] | 1626 | iRefOffset = iHor + iVer * iRefStride - iRefStride; |
---|
| 1627 | if( eType == TEXT_LUMA ) |
---|
[56] | 1628 | { |
---|
[608] | 1629 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1630 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
[56] | 1631 | } |
---|
[608] | 1632 | else if( eType == TEXT_CHROMA_U ) |
---|
[56] | 1633 | { |
---|
[608] | 1634 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1635 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
[56] | 1636 | } |
---|
[608] | 1637 | else |
---|
| 1638 | { |
---|
| 1639 | assert( eType == TEXT_CHROMA_V ); |
---|
| 1640 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1641 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1642 | } |
---|
[56] | 1643 | |
---|
[608] | 1644 | for( j = 0; j < uiWidth; j+=2 ) |
---|
[189] | 1645 | { |
---|
| 1646 | x += pRef[j]; |
---|
| 1647 | y += pRec[j]; |
---|
[608] | 1648 | xx += (pRef[j] * pRef[j])>>precShift; |
---|
| 1649 | xy += (pRef[j] * pRec[j])>>precShift; |
---|
[189] | 1650 | } |
---|
[608] | 1651 | iCountShift += g_aucConvertToBit[ uiWidth ] + 1; |
---|
[189] | 1652 | } |
---|
| 1653 | |
---|
| 1654 | |
---|
[608] | 1655 | if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelX > 0 && iRefX > 0 ) |
---|
[189] | 1656 | { |
---|
[608] | 1657 | iRefOffset = iHor + iVer * iRefStride - 1; |
---|
| 1658 | if( eType == TEXT_LUMA ) |
---|
| 1659 | { |
---|
| 1660 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1661 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1662 | } |
---|
| 1663 | else if( eType == TEXT_CHROMA_U ) |
---|
| 1664 | { |
---|
| 1665 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1666 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1667 | } |
---|
| 1668 | else |
---|
| 1669 | { |
---|
| 1670 | assert( eType == TEXT_CHROMA_V ); |
---|
| 1671 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1672 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1673 | } |
---|
| 1674 | |
---|
| 1675 | for( i = 0; i < uiHeight; i+=2 ) |
---|
[189] | 1676 | { |
---|
| 1677 | x += pRef[0]; |
---|
| 1678 | y += pRec[0]; |
---|
[655] | 1679 | |
---|
[608] | 1680 | xx += (pRef[0] * pRef[0])>>precShift; |
---|
| 1681 | xy += (pRef[0] * pRec[0])>>precShift; |
---|
| 1682 | |
---|
| 1683 | pRef += iRefStride*2; |
---|
| 1684 | pRec += iRecStride*2; |
---|
[189] | 1685 | } |
---|
[608] | 1686 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 1 ); |
---|
[189] | 1687 | } |
---|
| 1688 | |
---|
[608] | 1689 | xy += xx >> IC_REG_COST_SHIFT; |
---|
| 1690 | xx += xx >> IC_REG_COST_SHIFT; |
---|
| 1691 | Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift); |
---|
| 1692 | Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift); |
---|
| 1693 | const Int iShift = IC_CONST_SHIFT; |
---|
| 1694 | { |
---|
[189] | 1695 | { |
---|
| 1696 | const Int iShiftA2 = 6; |
---|
| 1697 | const Int iAccuracyShift = 15; |
---|
| 1698 | |
---|
| 1699 | Int iScaleShiftA2 = 0; |
---|
| 1700 | Int iScaleShiftA1 = 0; |
---|
| 1701 | Int a1s = a1; |
---|
| 1702 | Int a2s = a2; |
---|
| 1703 | |
---|
[608] | 1704 | a1 = Clip3(0, 2*a2, a1); |
---|
| 1705 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
| 1706 | iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF; |
---|
[189] | 1707 | |
---|
| 1708 | if( iScaleShiftA1 < 0 ) |
---|
| 1709 | { |
---|
| 1710 | iScaleShiftA1 = 0; |
---|
| 1711 | } |
---|
| 1712 | |
---|
| 1713 | if( iScaleShiftA2 < 0 ) |
---|
| 1714 | { |
---|
| 1715 | iScaleShiftA2 = 0; |
---|
| 1716 | } |
---|
| 1717 | |
---|
| 1718 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
| 1719 | |
---|
[608] | 1720 | |
---|
[189] | 1721 | a2s = a2 >> iScaleShiftA2; |
---|
| 1722 | |
---|
| 1723 | a1s = a1 >> iScaleShiftA1; |
---|
| 1724 | |
---|
[608] | 1725 | a = a1s * m_uiaShift[ a2s ]; |
---|
| 1726 | a = a >> iScaleShiftA; |
---|
[189] | 1727 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 1728 | } |
---|
| 1729 | } |
---|
| 1730 | } |
---|
[608] | 1731 | #endif |
---|
[189] | 1732 | |
---|
[608] | 1733 | #if H_3D_VSP |
---|
| 1734 | // not fully support iRatioTxtPerDepth* != 1 |
---|
[724] | 1735 | Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int &vspSize, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY ) |
---|
[189] | 1736 | { |
---|
[608] | 1737 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE; |
---|
| 1738 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE; |
---|
[189] | 1739 | |
---|
[608] | 1740 | Int refDepStride = picRefDepth->getStride(); |
---|
[189] | 1741 | |
---|
[608] | 1742 | Int refDepOffset = ( (mv->getHor()+2) >> 2 ) + ( (mv->getVer()+2) >> 2 ) * refDepStride; |
---|
| 1743 | Pel *refDepth = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
[189] | 1744 | |
---|
[608] | 1745 | if( ratioTxtPerDepthX!=1 || ratioTxtPerDepthY!=1 ) |
---|
[189] | 1746 | { |
---|
[608] | 1747 | Int posX, posY; |
---|
| 1748 | refDepth = picRefDepth->getLumaAddr( ); |
---|
| 1749 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
| 1750 | posX /= ratioTxtPerDepthX; // texture position -> depth postion |
---|
| 1751 | posY /= ratioTxtPerDepthY; |
---|
| 1752 | refDepOffset += posX + posY * refDepStride; |
---|
[189] | 1753 | |
---|
[608] | 1754 | width /= ratioTxtPerDepthX; // texture size -> depth size |
---|
| 1755 | height /= ratioTxtPerDepthY; |
---|
[189] | 1756 | } |
---|
| 1757 | |
---|
[608] | 1758 | refDepth += refDepOffset; |
---|
[189] | 1759 | |
---|
[608] | 1760 | Int depStride = yuvDepth->getStride(); |
---|
| 1761 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
[189] | 1762 | |
---|
[724] | 1763 | if ((height % 8)) |
---|
| 1764 | { |
---|
| 1765 | vspSize = 1; // 8x4 |
---|
[608] | 1766 | } |
---|
[724] | 1767 | else if ((width % 8)) |
---|
| 1768 | { |
---|
| 1769 | vspSize = 0; // 4x8 |
---|
| 1770 | } |
---|
| 1771 | else |
---|
| 1772 | { |
---|
| 1773 | Bool ULvsBR, URvsBL; |
---|
| 1774 | ULvsBR = refDepth[0] < refDepth[refDepStride * (height-1) + width-1]; |
---|
| 1775 | URvsBL = refDepth[width-1] < refDepth[refDepStride * (height-1)]; |
---|
| 1776 | vspSize = ( ULvsBR ^ URvsBL ) ? 0 : 1; |
---|
| 1777 | } |
---|
| 1778 | Int subBlockW, subBlockH; |
---|
| 1779 | Int depStrideTmp = depStride * nTxtPerDepthY; |
---|
| 1780 | if (vspSize) |
---|
| 1781 | { |
---|
| 1782 | subBlockW = 8; |
---|
| 1783 | subBlockH = 4; |
---|
| 1784 | } |
---|
| 1785 | else |
---|
| 1786 | { |
---|
| 1787 | subBlockW = 4; |
---|
| 1788 | subBlockH = 8; |
---|
| 1789 | } |
---|
| 1790 | for( Int y=0; y<height; y+=subBlockH ) |
---|
| 1791 | { |
---|
| 1792 | Pel *refDepthTmp[4]; |
---|
| 1793 | refDepthTmp[0] = refDepth + refDepStride * y; |
---|
| 1794 | refDepthTmp[1] = refDepthTmp[0] + subBlockW - 1; |
---|
| 1795 | refDepthTmp[2] = refDepthTmp[0] + refDepStride * (subBlockH - 1); |
---|
| 1796 | refDepthTmp[3] = refDepthTmp[2] + subBlockW - 1; |
---|
| 1797 | for( Int x=0; x<width; x+=subBlockW ) |
---|
| 1798 | { |
---|
| 1799 | Pel maxDepthVal; |
---|
| 1800 | maxDepthVal = refDepthTmp[0][x]; |
---|
| 1801 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[1][x]); |
---|
| 1802 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[2][x]); |
---|
| 1803 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[3][x]); |
---|
| 1804 | Pel *depthTmp = &depth[x+y*depStride]; |
---|
| 1805 | for( Int sY=0; sY<subBlockH; sY+=nTxtPerDepthY ) |
---|
| 1806 | { |
---|
| 1807 | for( Int sX=0; sX<subBlockW; sX+=nTxtPerDepthX ) |
---|
| 1808 | { |
---|
| 1809 | depthTmp[sX] = maxDepthVal; |
---|
| 1810 | } |
---|
| 1811 | depthTmp += depStrideTmp; |
---|
| 1812 | } |
---|
| 1813 | } |
---|
[773] | 1814 | } |
---|
[608] | 1815 | } |
---|
| 1816 | |
---|
[724] | 1817 | Void TComPrediction::xPredInterLumaBlkFromDM( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi, Int vspSize) |
---|
[608] | 1818 | { |
---|
| 1819 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE; |
---|
| 1820 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE; |
---|
| 1821 | |
---|
[724] | 1822 | nTxtPerDepthX = nTxtPerDepthX << vspSize; |
---|
| 1823 | nTxtPerDepthY = nTxtPerDepthY << (1-vspSize); |
---|
[773] | 1824 | |
---|
[608] | 1825 | Int refStride = picRef->getStride(); |
---|
| 1826 | Int dstStride = yuvDst->getStride(); |
---|
| 1827 | Int depStride = yuvDepth->getStride(); |
---|
| 1828 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
| 1829 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
| 1830 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
| 1831 | |
---|
| 1832 | Pel *ref = picRef->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
| 1833 | Pel *dst = yuvDst->getLumaAddr(partAddr); |
---|
| 1834 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
| 1835 | |
---|
| 1836 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 1837 | #if H_3D_VSP_CONSTRAINED |
---|
| 1838 | //get LUT based horizontal reference range |
---|
| 1839 | Int range = xGetConstrainedSize(width, height); |
---|
| 1840 | |
---|
| 1841 | // The minimum depth value |
---|
| 1842 | Int minRelativePos = MAX_INT; |
---|
| 1843 | Int maxRelativePos = MIN_INT; |
---|
| 1844 | |
---|
| 1845 | Pel* depthTemp, *depthInitial=depth; |
---|
| 1846 | for (Int yTxt = 0; yTxt < height; yTxt++) |
---|
| 1847 | { |
---|
| 1848 | for (Int xTxt = 0; xTxt < width; xTxt++) |
---|
| 1849 | { |
---|
| 1850 | if (depthPosX+xTxt < widthDepth) |
---|
[189] | 1851 | { |
---|
[608] | 1852 | depthTemp = depthInitial + xTxt; |
---|
[189] | 1853 | } |
---|
| 1854 | else |
---|
| 1855 | { |
---|
[608] | 1856 | depthTemp = depthInitial + (widthDepth - depthPosX - 1); |
---|
[189] | 1857 | } |
---|
| 1858 | |
---|
[608] | 1859 | Int disparity = shiftLUT[ *depthTemp ]; // << iShiftPrec; |
---|
| 1860 | Int disparityInt = disparity >> 2; |
---|
[189] | 1861 | |
---|
[608] | 1862 | if( disparity <= 0) |
---|
[189] | 1863 | { |
---|
[608] | 1864 | if (minRelativePos > disparityInt+xTxt) |
---|
| 1865 | { |
---|
| 1866 | minRelativePos = disparityInt+xTxt; |
---|
| 1867 | } |
---|
[189] | 1868 | } |
---|
| 1869 | else |
---|
| 1870 | { |
---|
[608] | 1871 | if (maxRelativePos < disparityInt+xTxt) |
---|
| 1872 | { |
---|
| 1873 | maxRelativePos = disparityInt+xTxt; |
---|
| 1874 | } |
---|
[189] | 1875 | } |
---|
| 1876 | } |
---|
[608] | 1877 | if (depthPosY+yTxt < heightDepth) |
---|
| 1878 | { |
---|
| 1879 | depthInitial = depthInitial + depStride; |
---|
| 1880 | } |
---|
| 1881 | } |
---|
[56] | 1882 | |
---|
[608] | 1883 | Int disparity_tmp = shiftLUT[ *depth ]; // << iShiftPrec; |
---|
| 1884 | if (disparity_tmp <= 0) |
---|
[56] | 1885 | { |
---|
[608] | 1886 | maxRelativePos = minRelativePos + range -1 ; |
---|
[56] | 1887 | } |
---|
[608] | 1888 | else |
---|
[56] | 1889 | { |
---|
[608] | 1890 | minRelativePos = maxRelativePos - range +1 ; |
---|
[56] | 1891 | } |
---|
[608] | 1892 | #endif |
---|
| 1893 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
[56] | 1894 | |
---|
[608] | 1895 | TComMv dv(0, 0); |
---|
[56] | 1896 | |
---|
[608] | 1897 | for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY ) |
---|
| 1898 | { |
---|
| 1899 | for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX ) |
---|
| 1900 | { |
---|
| 1901 | Pel repDepth = depth[ xTxt ]; |
---|
| 1902 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
| 1903 | |
---|
| 1904 | Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec ?? |
---|
| 1905 | Int xFrac = disparity & 0x3; |
---|
| 1906 | |
---|
| 1907 | dv.setHor( disparity ); |
---|
| 1908 | cu->clipMv( dv ); |
---|
| 1909 | |
---|
| 1910 | Int refOffset = xTxt + (dv.getHor() >> 2); |
---|
| 1911 | |
---|
| 1912 | #if H_3D_VSP_CONSTRAINED |
---|
| 1913 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
| 1914 | { |
---|
| 1915 | xFrac = 0; |
---|
| 1916 | } |
---|
| 1917 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
[5] | 1918 | #endif |
---|
[608] | 1919 | |
---|
| 1920 | assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 ); |
---|
| 1921 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
| 1922 | } |
---|
| 1923 | ref += refStrideBlock; |
---|
| 1924 | dst += dstStrideBlock; |
---|
| 1925 | depth += depStrideBlock; |
---|
[443] | 1926 | } |
---|
| 1927 | |
---|
| 1928 | } |
---|
[608] | 1929 | |
---|
[724] | 1930 | Void TComPrediction::xPredInterChromaBlkFromDM ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi, Int vspSize) |
---|
[608] | 1931 | { |
---|
| 1932 | #if (H_3D_VSP_BLOCKSIZE==1) |
---|
| 1933 | Int nTxtPerDepthX = 1; |
---|
| 1934 | Int nTxtPerDepthY = 1; |
---|
[443] | 1935 | #else |
---|
[608] | 1936 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE >> 1; |
---|
| 1937 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE >> 1; |
---|
| 1938 | #endif |
---|
[2] | 1939 | |
---|
[724] | 1940 | nTxtPerDepthX = nTxtPerDepthX << vspSize; |
---|
| 1941 | nTxtPerDepthY = nTxtPerDepthY << (1-vspSize); |
---|
[773] | 1942 | |
---|
[608] | 1943 | Int refStride = picRef->getCStride(); |
---|
| 1944 | Int dstStride = yuvDst->getCStride(); |
---|
| 1945 | Int depStride = yuvDepth->getStride(); |
---|
| 1946 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
| 1947 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
| 1948 | Int depStrideBlock = depStride * (nTxtPerDepthY<<1); |
---|
[2] | 1949 | |
---|
[608] | 1950 | Pel *refCb = picRef->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
| 1951 | Pel *refCr = picRef->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
| 1952 | Pel *dstCb = yuvDst->getCbAddr(partAddr); |
---|
| 1953 | Pel *dstCr = yuvDst->getCrAddr(partAddr); |
---|
| 1954 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
[56] | 1955 | |
---|
[608] | 1956 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 1957 | #if H_3D_VSP_CONSTRAINED |
---|
| 1958 | //get LUT based horizontal reference range |
---|
| 1959 | Int range = xGetConstrainedSize(width, height, false); |
---|
[296] | 1960 | |
---|
[608] | 1961 | // The minimum depth value |
---|
| 1962 | Int minRelativePos = MAX_INT; |
---|
| 1963 | Int maxRelativePos = MIN_INT; |
---|
| 1964 | |
---|
| 1965 | Int depthTmp; |
---|
| 1966 | for (Int yTxt=0; yTxt<height; yTxt++) |
---|
[56] | 1967 | { |
---|
[608] | 1968 | for (Int xTxt=0; xTxt<width; xTxt++) |
---|
[56] | 1969 | { |
---|
[608] | 1970 | depthTmp = m_pDepthBlock[xTxt+yTxt*width]; |
---|
| 1971 | Int disparity = shiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
| 1972 | Int disparityInt = disparity >> 3;//in chroma resolution |
---|
| 1973 | |
---|
| 1974 | if (disparityInt < 0) |
---|
[56] | 1975 | { |
---|
[608] | 1976 | if (minRelativePos > disparityInt+xTxt) |
---|
| 1977 | { |
---|
| 1978 | minRelativePos = disparityInt+xTxt; |
---|
| 1979 | } |
---|
[56] | 1980 | } |
---|
| 1981 | else |
---|
| 1982 | { |
---|
[608] | 1983 | if (maxRelativePos < disparityInt+xTxt) |
---|
| 1984 | { |
---|
| 1985 | maxRelativePos = disparityInt+xTxt; |
---|
| 1986 | } |
---|
[56] | 1987 | } |
---|
| 1988 | } |
---|
| 1989 | } |
---|
| 1990 | |
---|
[608] | 1991 | depthTmp = m_pDepthBlock[0]; |
---|
| 1992 | Int disparity_tmp = shiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
| 1993 | if ( disparity_tmp < 0 ) |
---|
[56] | 1994 | { |
---|
[608] | 1995 | maxRelativePos = minRelativePos + range - 1; |
---|
[56] | 1996 | } |
---|
[608] | 1997 | else |
---|
[56] | 1998 | { |
---|
[608] | 1999 | minRelativePos = maxRelativePos - range + 1; |
---|
[56] | 2000 | } |
---|
[2] | 2001 | |
---|
[608] | 2002 | #endif // H_3D_VSP_CONSTRAINED |
---|
| 2003 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2004 | |
---|
| 2005 | TComMv dv(0, 0); |
---|
| 2006 | // luma size -> chroma size |
---|
| 2007 | height >>= 1; |
---|
| 2008 | width >>= 1; |
---|
| 2009 | |
---|
| 2010 | for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY ) |
---|
[5] | 2011 | { |
---|
[608] | 2012 | for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX ) |
---|
[5] | 2013 | { |
---|
[608] | 2014 | Pel repDepth = depth[ xTxt<<1 ]; |
---|
| 2015 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
| 2016 | |
---|
| 2017 | Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec; |
---|
| 2018 | Int xFrac = disparity & 0x7; |
---|
| 2019 | |
---|
| 2020 | dv.setHor( disparity ); |
---|
| 2021 | cu->clipMv( dv ); |
---|
| 2022 | |
---|
| 2023 | Int refOffset = xTxt + (dv.getHor() >> 3); |
---|
| 2024 | |
---|
| 2025 | #if H_3D_VSP_CONSTRAINED |
---|
| 2026 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
[5] | 2027 | { |
---|
[608] | 2028 | xFrac = 0; |
---|
[5] | 2029 | } |
---|
[608] | 2030 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
| 2031 | #endif |
---|
| 2032 | |
---|
| 2033 | assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 ); |
---|
| 2034 | assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 ); |
---|
| 2035 | |
---|
| 2036 | m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
| 2037 | m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
[5] | 2038 | } |
---|
[608] | 2039 | refCb += refStrideBlock; |
---|
| 2040 | refCr += refStrideBlock; |
---|
| 2041 | dstCb += dstStrideBlock; |
---|
| 2042 | dstCr += dstStrideBlock; |
---|
| 2043 | depth += depStrideBlock; |
---|
[5] | 2044 | } |
---|
| 2045 | } |
---|
[2] | 2046 | |
---|
[5] | 2047 | |
---|
[608] | 2048 | #if H_3D_VSP_CONSTRAINED |
---|
| 2049 | Int TComPrediction::xGetConstrainedSize(Int nPbW, Int nPbH, Bool bLuma) |
---|
[56] | 2050 | { |
---|
[608] | 2051 | Int iSize = 0; |
---|
| 2052 | if (bLuma) |
---|
[2] | 2053 | { |
---|
[608] | 2054 | Int iArea = (nPbW+7) * (nPbH+7); |
---|
| 2055 | Int iAlpha = iArea / nPbH - nPbW - 7; |
---|
| 2056 | iSize = iAlpha + nPbW; |
---|
[2] | 2057 | } |
---|
[608] | 2058 | else // chroma |
---|
| 2059 | { |
---|
| 2060 | Int iArea = (nPbW+2) * (nPbH+2); |
---|
| 2061 | Int iAlpha = iArea / nPbH - nPbW - 4; |
---|
| 2062 | iSize = iAlpha + nPbW; |
---|
| 2063 | } |
---|
| 2064 | return iSize; |
---|
[2] | 2065 | } |
---|
[608] | 2066 | #endif // H_3D_VSP_CONSTRAINED |
---|
[2] | 2067 | |
---|
[608] | 2068 | #endif // H_3D_VSP |
---|
| 2069 | |
---|
| 2070 | #if H_3D_DIM |
---|
| 2071 | Void TComPrediction::xPredBiSegDCs( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ) |
---|
[2] | 2072 | { |
---|
[608] | 2073 | Int refDC1, refDC2; |
---|
| 2074 | const Int iTR = ( patternStride - 1 ) - srcStride; |
---|
| 2075 | const Int iTM = ( ( patternStride - 1 ) >> 1 ) - srcStride; |
---|
| 2076 | const Int iLB = ( patternStride - 1 ) * srcStride - 1; |
---|
| 2077 | const Int iLM = ( ( patternStride - 1 ) >> 1 ) * srcStride - 1; |
---|
[2] | 2078 | |
---|
[608] | 2079 | Bool bL = ( biSegPattern[0] != biSegPattern[(patternStride-1)*patternStride] ); |
---|
| 2080 | Bool bT = ( biSegPattern[0] != biSegPattern[(patternStride-1)] ); |
---|
| 2081 | |
---|
| 2082 | if( bL == bT ) |
---|
[56] | 2083 | { |
---|
[608] | 2084 | refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : 1<<( g_bitDepthY - 1 ); |
---|
| 2085 | refDC2 = ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1; |
---|
[56] | 2086 | } |
---|
| 2087 | else |
---|
| 2088 | { |
---|
[608] | 2089 | refDC1 = bL ? ptrSrc[iLB] : ptrSrc[iTR]; |
---|
| 2090 | refDC2 = bL ? ptrSrc[iTM] : ptrSrc[iLM]; |
---|
[56] | 2091 | } |
---|
| 2092 | |
---|
[608] | 2093 | predDC1 = biSegPattern[0] ? refDC1 : refDC2; |
---|
| 2094 | predDC2 = biSegPattern[0] ? refDC2 : refDC1; |
---|
[2] | 2095 | } |
---|
| 2096 | |
---|
[608] | 2097 | Void TComPrediction::xAssignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 ) |
---|
[56] | 2098 | { |
---|
[608] | 2099 | if( dstStride == patternStride ) |
---|
| 2100 | { |
---|
| 2101 | for( UInt k = 0; k < (patternStride * patternStride); k++ ) |
---|
| 2102 | { |
---|
| 2103 | if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; } |
---|
| 2104 | else { ptrDst[k] = valDC1; } |
---|
| 2105 | } |
---|
[443] | 2106 | } |
---|
[608] | 2107 | else |
---|
| 2108 | { |
---|
| 2109 | Pel* piTemp = ptrDst; |
---|
| 2110 | for( UInt uiY = 0; uiY < patternStride; uiY++ ) |
---|
| 2111 | { |
---|
| 2112 | for( UInt uiX = 0; uiX < patternStride; uiX++ ) |
---|
| 2113 | { |
---|
| 2114 | if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; } |
---|
| 2115 | else { piTemp[uiX] = valDC1; } |
---|
| 2116 | } |
---|
| 2117 | piTemp += dstStride; |
---|
| 2118 | biSegPattern += patternStride; |
---|
| 2119 | } |
---|
[443] | 2120 | } |
---|
[56] | 2121 | } |
---|
| 2122 | |
---|
[608] | 2123 | #if H_3D_DIM_DMM |
---|
[56] | 2124 | |
---|
[608] | 2125 | Void TComPrediction::xPredContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) |
---|
[56] | 2126 | { |
---|
[608] | 2127 | pcContourWedge->clear(); |
---|
[56] | 2128 | |
---|
[608] | 2129 | // get copy of co-located texture luma block |
---|
| 2130 | TComYuv cTempYuv; |
---|
| 2131 | cTempYuv.create( uiWidth, uiHeight ); |
---|
| 2132 | cTempYuv.clear(); |
---|
| 2133 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2134 | xCopyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
| 2135 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
[56] | 2136 | |
---|
[608] | 2137 | // find contour for texture luma block |
---|
| 2138 | UInt iDC = 0; |
---|
| 2139 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
| 2140 | { |
---|
| 2141 | iDC += piRefBlkY[k]; |
---|
| 2142 | } |
---|
| 2143 | |
---|
[655] | 2144 | Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2; // |
---|
| 2145 | iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2; // iDC /= (uiWidth*uiHeight); |
---|
| 2146 | |
---|
[608] | 2147 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
[56] | 2148 | |
---|
[608] | 2149 | Bool* pabContourPattern = pcContourWedge->getPattern(); |
---|
| 2150 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
[443] | 2151 | { |
---|
[608] | 2152 | pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; |
---|
[443] | 2153 | } |
---|
[608] | 2154 | |
---|
| 2155 | cTempYuv.destroy(); |
---|
[56] | 2156 | } |
---|
| 2157 | |
---|
[608] | 2158 | |
---|
| 2159 | Void TComPrediction::xCopyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) |
---|
[56] | 2160 | { |
---|
[608] | 2161 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
| 2162 | assert( pcPicYuvRef != NULL ); |
---|
| 2163 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
| 2164 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
[56] | 2165 | |
---|
[608] | 2166 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
[56] | 2167 | { |
---|
[608] | 2168 | ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); |
---|
| 2169 | piDestBlockY += uiWidth; |
---|
| 2170 | piRefY += iRefStride; |
---|
[56] | 2171 | } |
---|
| 2172 | } |
---|
[655] | 2173 | #endif |
---|
[56] | 2174 | |
---|
[2] | 2175 | |
---|
[608] | 2176 | #if H_3D_DIM_SDC |
---|
| 2177 | Void TComPrediction::analyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride |
---|
| 2178 | ,UInt uiIntraMode |
---|
| 2179 | ,Bool orgDC |
---|
| 2180 | ) |
---|
| 2181 | { |
---|
| 2182 | Int iSumDepth[2]; |
---|
| 2183 | memset(iSumDepth, 0, sizeof(Int)*2); |
---|
| 2184 | Int iSumPix[2]; |
---|
| 2185 | memset(iSumPix, 0, sizeof(Int)*2); |
---|
| 2186 | |
---|
| 2187 | if (orgDC == false) |
---|
[2] | 2188 | { |
---|
[608] | 2189 | if ( getDimType(uiIntraMode) == DMM1_IDX ) |
---|
| 2190 | { |
---|
| 2191 | UChar ucSegmentLT = pMask[0]; |
---|
| 2192 | UChar ucSegmentRT = pMask[uiSize-1]; |
---|
| 2193 | UChar ucSegmentLB = pMask[uiMaskStride * (uiSize-1)]; |
---|
| 2194 | UChar ucSegmentRB = pMask[uiMaskStride * (uiSize-1) + (uiSize-1)]; |
---|
| 2195 | |
---|
| 2196 | rpSegMeans[ucSegmentLT] = pOrig[0]; |
---|
| 2197 | rpSegMeans[ucSegmentRT] = pOrig[uiSize-1]; |
---|
| 2198 | rpSegMeans[ucSegmentLB] = pOrig[uiStride * (uiSize-1) ]; |
---|
| 2199 | rpSegMeans[ucSegmentRB] = pOrig[uiStride * (uiSize-1) + (uiSize-1) ]; |
---|
| 2200 | } |
---|
| 2201 | else if (uiIntraMode == PLANAR_IDX) |
---|
| 2202 | { |
---|
| 2203 | Pel* pLeftTop = pOrig; |
---|
| 2204 | Pel* pRightTop = pOrig + (uiSize-1); |
---|
| 2205 | Pel* pLeftBottom = (pOrig+ (uiStride*(uiSize-1))); |
---|
| 2206 | Pel* pRightBottom = (pOrig+ (uiStride*(uiSize-1)) + (uiSize-1)); |
---|
| 2207 | |
---|
| 2208 | rpSegMeans[0] = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2; |
---|
| 2209 | } |
---|
| 2210 | return; |
---|
[2] | 2211 | } |
---|
[608] | 2212 | |
---|
| 2213 | Int subSamplePix; |
---|
| 2214 | if ( uiSize == 64 || uiSize == 32 ) |
---|
[2] | 2215 | { |
---|
[608] | 2216 | subSamplePix = 2; |
---|
[2] | 2217 | } |
---|
[608] | 2218 | else |
---|
[2] | 2219 | { |
---|
[608] | 2220 | subSamplePix = 1; |
---|
[2] | 2221 | } |
---|
[608] | 2222 | for (Int y=0; y<uiSize; y+=subSamplePix) |
---|
[2] | 2223 | { |
---|
[608] | 2224 | for (Int x=0; x<uiSize; x+=subSamplePix) |
---|
| 2225 | { |
---|
| 2226 | UChar ucSegment = pMask?(UChar)pMask[x]:0; |
---|
| 2227 | assert( ucSegment < uiNumSegments ); |
---|
| 2228 | |
---|
| 2229 | iSumDepth[ucSegment] += pOrig[x]; |
---|
| 2230 | iSumPix[ucSegment] += 1; |
---|
| 2231 | } |
---|
| 2232 | |
---|
| 2233 | pOrig += uiStride*subSamplePix; |
---|
| 2234 | pMask += uiMaskStride*subSamplePix; |
---|
[2] | 2235 | } |
---|
[608] | 2236 | |
---|
| 2237 | // compute mean for each segment |
---|
| 2238 | for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ ) |
---|
[2] | 2239 | { |
---|
[608] | 2240 | if( iSumPix[ucSeg] > 0 ) |
---|
| 2241 | rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg]; |
---|
| 2242 | else |
---|
| 2243 | rpSegMeans[ucSeg] = 0; // this happens for zero-segments |
---|
[2] | 2244 | } |
---|
| 2245 | } |
---|
[608] | 2246 | #endif // H_3D_DIM_SDC |
---|
| 2247 | #endif |
---|
[56] | 2248 | //! \} |
---|