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