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