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