[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); |
---|
[724] | 427 | #if !SEC_DMM3_RBC_F0147 |
---|
[608] | 428 | Bool isRbcMode = (dimType == RBC_IDX); |
---|
[724] | 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; |
---|
[724] | 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; |
---|
[724] | 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; |
---|
[724] | 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 ); |
---|
[724] | 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 |
---|
[724] | 501 | #if QC_DIM_DELTADC_UNIFY_F0132 && !SEC_DMM3_RBC_F0147 |
---|
| 502 | if( isDmmMode || isRbcMode) |
---|
| 503 | #else |
---|
[608] | 504 | if( isDmmMode ) |
---|
[724] | 505 | #endif |
---|
[608] | 506 | { |
---|
| 507 | #if H_3D_DIM_DLT |
---|
[758] | 508 | #if DLT_DIFF_CODING_IN_PPS |
---|
| 509 | segDC1 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 ); |
---|
| 510 | segDC2 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 ); |
---|
| 511 | #else |
---|
[608] | 512 | segDC1 = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 ); |
---|
| 513 | segDC2 = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 ); |
---|
[758] | 514 | #endif |
---|
[608] | 515 | #else |
---|
| 516 | segDC1 = ClipY( predDC1 + deltaDC1 ); |
---|
| 517 | segDC2 = ClipY( predDC2 + deltaDC2 ); |
---|
| 518 | #endif |
---|
| 519 | } |
---|
| 520 | #endif |
---|
[724] | 521 | #if H_3D_DIM_RBC && !QC_DIM_DELTADC_UNIFY_F0132 |
---|
[608] | 522 | if( isRbcMode ) |
---|
| 523 | { |
---|
| 524 | xDeltaDCQuantScaleUp( pcCU, deltaDC1 ); |
---|
| 525 | xDeltaDCQuantScaleUp( pcCU, deltaDC2 ); |
---|
| 526 | segDC1 = ClipY( predDC1 + deltaDC1 ); |
---|
| 527 | segDC2 = ClipY( predDC2 + deltaDC2 ); |
---|
| 528 | } |
---|
| 529 | #endif |
---|
[100] | 530 | } |
---|
[608] | 531 | else |
---|
[100] | 532 | { |
---|
[608] | 533 | segDC1 = predDC1; |
---|
| 534 | segDC2 = predDC2; |
---|
[100] | 535 | } |
---|
| 536 | |
---|
[608] | 537 | // set prediction signal |
---|
| 538 | Pel* pDst = piPred; |
---|
| 539 | xAssignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 ); |
---|
[100] | 540 | |
---|
[608] | 541 | #if H_3D_DIM_DMM |
---|
| 542 | if( dimType == DMM4_IDX ) { dmmSegmentation->destroy(); delete dmmSegmentation; } |
---|
| 543 | #endif |
---|
[100] | 544 | } |
---|
[608] | 545 | #endif |
---|
[100] | 546 | |
---|
[608] | 547 | /** Function for checking identical motion. |
---|
| 548 | * \param TComDataCU* pcCU |
---|
| 549 | * \param UInt PartAddr |
---|
| 550 | */ |
---|
| 551 | Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) |
---|
[100] | 552 | { |
---|
[608] | 553 | if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getPPS()->getWPBiPred() ) |
---|
[100] | 554 | { |
---|
[608] | 555 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0) |
---|
[100] | 556 | { |
---|
[608] | 557 | Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); |
---|
| 558 | Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); |
---|
| 559 | if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
[100] | 560 | { |
---|
[608] | 561 | return true; |
---|
[100] | 562 | } |
---|
| 563 | } |
---|
| 564 | } |
---|
[608] | 565 | return false; |
---|
[100] | 566 | } |
---|
| 567 | |
---|
[724] | 568 | #if MTK_SPIVMP_F0110 |
---|
| 569 | Void TComPrediction::xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr ) |
---|
| 570 | { |
---|
| 571 | for (Int i = 0; i < iNumSP; i++) |
---|
| 572 | { |
---|
| 573 | uiMergedSPW[i] = iSPWidth; |
---|
| 574 | uiMergedSPH[i] = iSPHeight; |
---|
| 575 | pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]); |
---|
| 576 | } |
---|
| 577 | // horizontal sub-PU merge |
---|
| 578 | for (Int i=0; i<iNumSP; i++) |
---|
| 579 | { |
---|
| 580 | if (i % iNumSPInOneLine == iNumSPInOneLine - 1 || uiMergedSPW[i]==0 || uiMergedSPH[i]==0) |
---|
| 581 | { |
---|
| 582 | continue; |
---|
| 583 | } |
---|
| 584 | for (Int j=i+1; j<i+iNumSPInOneLine-i%iNumSPInOneLine; j++) |
---|
| 585 | { |
---|
| 586 | if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j])) |
---|
| 587 | { |
---|
| 588 | uiMergedSPW[i] += iSPWidth; |
---|
| 589 | uiMergedSPW[j] = uiMergedSPH[j] = 0; |
---|
| 590 | } |
---|
| 591 | else |
---|
| 592 | { |
---|
| 593 | break; |
---|
| 594 | } |
---|
| 595 | } |
---|
| 596 | } |
---|
| 597 | //vertical sub-PU merge |
---|
| 598 | for (Int i=0; i<iNumSP-iNumSPInOneLine; i++) |
---|
| 599 | { |
---|
| 600 | if (uiMergedSPW[i]==0 || uiMergedSPH[i]==0) |
---|
| 601 | { |
---|
| 602 | continue; |
---|
| 603 | } |
---|
| 604 | for (Int j=i+iNumSPInOneLine; j<iNumSP; j+=iNumSPInOneLine) |
---|
| 605 | { |
---|
| 606 | if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j]) && uiMergedSPW[i]==uiMergedSPW[j]) |
---|
| 607 | { |
---|
| 608 | uiMergedSPH[i] += iSPHeight; |
---|
| 609 | uiMergedSPH[j] = uiMergedSPW[j] = 0; |
---|
| 610 | } |
---|
| 611 | else |
---|
| 612 | { |
---|
| 613 | break; |
---|
| 614 | } |
---|
| 615 | } |
---|
| 616 | } |
---|
| 617 | } |
---|
[608] | 618 | |
---|
[724] | 619 | Bool TComPrediction::xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 ) |
---|
| 620 | { |
---|
| 621 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr1)) |
---|
| 622 | { |
---|
| 623 | return false; |
---|
| 624 | } |
---|
| 625 | if( pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr1)) |
---|
| 626 | { |
---|
| 627 | return false; |
---|
| 628 | } |
---|
| 629 | |
---|
| 630 | if (pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) >= 0) |
---|
| 631 | { |
---|
| 632 | if (pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr1)) |
---|
| 633 | { |
---|
| 634 | return false; |
---|
| 635 | } |
---|
| 636 | } |
---|
| 637 | |
---|
| 638 | if (pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) >= 0) |
---|
| 639 | { |
---|
| 640 | if (pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr1)) |
---|
| 641 | { |
---|
| 642 | return false; |
---|
| 643 | } |
---|
| 644 | } |
---|
| 645 | return true; |
---|
| 646 | } |
---|
| 647 | #endif |
---|
| 648 | |
---|
[56] | 649 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) |
---|
| 650 | { |
---|
| 651 | Int iWidth; |
---|
| 652 | Int iHeight; |
---|
| 653 | UInt uiPartAddr; |
---|
| 654 | |
---|
| 655 | if ( iPartIdx >= 0 ) |
---|
| 656 | { |
---|
| 657 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
[608] | 658 | #if H_3D_VSP |
---|
[622] | 659 | if ( pcCU->getVSPFlag(uiPartAddr) == 0) |
---|
[56] | 660 | { |
---|
| 661 | #endif |
---|
[608] | 662 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
[56] | 663 | { |
---|
[608] | 664 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
| 665 | { |
---|
| 666 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
| 667 | } |
---|
| 668 | else |
---|
| 669 | { |
---|
| 670 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 671 | } |
---|
| 672 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
| 673 | { |
---|
| 674 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 675 | } |
---|
[56] | 676 | } |
---|
| 677 | else |
---|
| 678 | { |
---|
[724] | 679 | #if MTK_SPIVMP_F0110 |
---|
| 680 | if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0) |
---|
[608] | 681 | { |
---|
[724] | 682 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 683 | |
---|
| 684 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 685 | |
---|
| 686 | UInt uiW[256], uiH[256]; |
---|
| 687 | UInt uiSPAddr[256]; |
---|
| 688 | |
---|
| 689 | xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr); |
---|
| 690 | |
---|
| 691 | //MC |
---|
| 692 | for (Int i = 0; i < iNumSP; i++) |
---|
| 693 | { |
---|
| 694 | if (uiW[i]==0 || uiH[i]==0) |
---|
| 695 | { |
---|
| 696 | continue; |
---|
| 697 | } |
---|
| 698 | if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] )) |
---|
| 699 | { |
---|
| 700 | xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred ); |
---|
| 701 | } |
---|
| 702 | else |
---|
| 703 | { |
---|
| 704 | xPredInterBi (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred); |
---|
| 705 | } |
---|
| 706 | } |
---|
[608] | 707 | } |
---|
| 708 | else |
---|
| 709 | { |
---|
[724] | 710 | #endif |
---|
| 711 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
| 712 | { |
---|
| 713 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
| 714 | } |
---|
| 715 | else |
---|
| 716 | { |
---|
| 717 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
| 718 | } |
---|
| 719 | #if MTK_SPIVMP_F0110 |
---|
[608] | 720 | } |
---|
[724] | 721 | #endif |
---|
[56] | 722 | } |
---|
[608] | 723 | #if H_3D_VSP |
---|
[56] | 724 | } |
---|
| 725 | else |
---|
| 726 | { |
---|
[608] | 727 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
[622] | 728 | { |
---|
[608] | 729 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
[622] | 730 | } |
---|
[56] | 731 | else |
---|
[622] | 732 | { |
---|
[608] | 733 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
[622] | 734 | } |
---|
[608] | 735 | } |
---|
[296] | 736 | #endif |
---|
[2] | 737 | return; |
---|
| 738 | } |
---|
[56] | 739 | |
---|
| 740 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ ) |
---|
| 741 | { |
---|
| 742 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
| 743 | |
---|
[608] | 744 | #if H_3D_VSP |
---|
[622] | 745 | if ( pcCU->getVSPFlag(uiPartAddr) == 0 ) |
---|
[56] | 746 | { |
---|
[189] | 747 | #endif |
---|
[608] | 748 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
[56] | 749 | { |
---|
[608] | 750 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
| 751 | { |
---|
| 752 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
| 753 | } |
---|
| 754 | else |
---|
| 755 | { |
---|
| 756 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 757 | } |
---|
| 758 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
| 759 | { |
---|
| 760 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 761 | } |
---|
[56] | 762 | } |
---|
[608] | 763 | else |
---|
[56] | 764 | { |
---|
[724] | 765 | #if MTK_SPIVMP_F0110 |
---|
| 766 | if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) |
---|
| 767 | { |
---|
| 768 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 769 | |
---|
| 770 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 771 | |
---|
| 772 | UInt uiW[256], uiH[256]; |
---|
| 773 | UInt uiSPAddr[256]; |
---|
| 774 | |
---|
| 775 | xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr); |
---|
| 776 | //MC |
---|
| 777 | for (Int i = 0; i < iNumSP; i++) |
---|
| 778 | { |
---|
| 779 | if (uiW[i]==0 || uiH[i]==0) |
---|
| 780 | { |
---|
| 781 | continue; |
---|
| 782 | } |
---|
| 783 | if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] )) |
---|
| 784 | { |
---|
| 785 | xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred ); |
---|
| 786 | } |
---|
| 787 | else |
---|
| 788 | { |
---|
| 789 | xPredInterBi (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred); |
---|
| 790 | } |
---|
| 791 | } |
---|
| 792 | } |
---|
| 793 | else |
---|
| 794 | { |
---|
| 795 | #endif |
---|
[608] | 796 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
| 797 | { |
---|
| 798 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
| 799 | } |
---|
| 800 | else |
---|
| 801 | { |
---|
| 802 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
| 803 | } |
---|
[724] | 804 | #if MTK_SPIVMP_F0110 |
---|
| 805 | } |
---|
| 806 | #endif |
---|
[56] | 807 | } |
---|
[608] | 808 | #if H_3D_VSP |
---|
[56] | 809 | } |
---|
| 810 | else |
---|
| 811 | { |
---|
| 812 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
[622] | 813 | { |
---|
[608] | 814 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
[622] | 815 | } |
---|
[56] | 816 | else |
---|
[622] | 817 | { |
---|
[608] | 818 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
[622] | 819 | } |
---|
[56] | 820 | } |
---|
[608] | 821 | #endif |
---|
[56] | 822 | } |
---|
| 823 | return; |
---|
| 824 | } |
---|
[2] | 825 | |
---|
[608] | 826 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
[296] | 827 | { |
---|
[608] | 828 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
| 829 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 830 | pcCU->clipMv(cMv); |
---|
| 831 | #if H_3D_ARP |
---|
[724] | 832 | #if QC_MTK_INTERVIEW_ARP_F0123_F0108 |
---|
| 833 | if(pcCU->getARPW( uiPartAddr ) > 0 && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC()) |
---|
| 834 | { |
---|
| 835 | xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi ); |
---|
| 836 | } |
---|
| 837 | else |
---|
| 838 | #endif |
---|
[608] | 839 | if( pcCU->getARPW( uiPartAddr ) > 0 |
---|
| 840 | && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N |
---|
| 841 | && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() |
---|
| 842 | ) |
---|
[443] | 843 | { |
---|
[608] | 844 | xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi ); |
---|
[443] | 845 | } |
---|
[608] | 846 | else |
---|
| 847 | { |
---|
[443] | 848 | #endif |
---|
[608] | 849 | #if H_3D_IC |
---|
| 850 | Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ); |
---|
| 851 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
| 852 | #if H_3D_ARP |
---|
| 853 | , false |
---|
[443] | 854 | #endif |
---|
[608] | 855 | , bICFlag ); |
---|
| 856 | bICFlag = bICFlag && (iWidth > 8); |
---|
| 857 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
| 858 | #if H_3D_ARP |
---|
| 859 | , false |
---|
[443] | 860 | #endif |
---|
[608] | 861 | , bICFlag ); |
---|
[443] | 862 | #else |
---|
[608] | 863 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
| 864 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
[443] | 865 | #endif |
---|
[608] | 866 | #if H_3D_ARP |
---|
[443] | 867 | } |
---|
| 868 | #endif |
---|
| 869 | } |
---|
| 870 | |
---|
[608] | 871 | #if H_3D_VSP |
---|
| 872 | Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
[56] | 873 | { |
---|
[608] | 874 | // Get depth reference |
---|
[622] | 875 | Int depthRefViewIdx = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
[655] | 876 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
| 877 | TComPic* pRefPicBaseDepth = 0; |
---|
| 878 | Bool bIsCurrDepthCoded = false; |
---|
| 879 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() ); |
---|
| 880 | if ( pRefPicBaseDepth->getPicYuvRec() != NULL ) |
---|
| 881 | { |
---|
| 882 | bIsCurrDepthCoded = true; |
---|
| 883 | } |
---|
| 884 | else |
---|
| 885 | { |
---|
| 886 | pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
| 887 | } |
---|
| 888 | #else |
---|
[608] | 889 | TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx ); |
---|
[655] | 890 | #endif |
---|
[608] | 891 | assert(pRefPicBaseDepth != NULL); |
---|
| 892 | TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec(); |
---|
| 893 | assert(pcBaseViewDepthPicYuv != NULL); |
---|
[296] | 894 | |
---|
[608] | 895 | // Get texture reference |
---|
| 896 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 897 | assert(iRefIdx >= 0); |
---|
| 898 | TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); |
---|
| 899 | TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec(); |
---|
| 900 | assert(pcBaseViewTxtPicYuv != NULL); |
---|
[56] | 901 | |
---|
[608] | 902 | // Initialize LUT according to the reference viewIdx |
---|
| 903 | Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex(); |
---|
| 904 | Int* pShiftLUT = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx ); |
---|
| 905 | assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() ); |
---|
[100] | 906 | |
---|
[608] | 907 | // Do compensation |
---|
| 908 | TComMv cDv = pcCU->getDvInfo(uiPartAddr).m_acNBDV; |
---|
| 909 | pcCU->clipMv(cDv); |
---|
[296] | 910 | |
---|
[655] | 911 | #if H_3D_FCO_VSP_DONBDV_E0163 |
---|
| 912 | if ( bIsCurrDepthCoded ) |
---|
| 913 | { |
---|
| 914 | cDv.setZero(); |
---|
| 915 | } |
---|
| 916 | #endif |
---|
[608] | 917 | // fetch virtual depth map |
---|
| 918 | pcBaseViewDepthPicYuv->extendPicBorder(); |
---|
[724] | 919 | |
---|
| 920 | #if MTK_F0109_LG_F0120_VSP_BLOCK |
---|
| 921 | Int vspSize=0; |
---|
| 922 | xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp,vspSize ); |
---|
| 923 | // sub-PU based compensation |
---|
| 924 | xPredInterLumaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi, vspSize); |
---|
| 925 | xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi, vspSize); |
---|
| 926 | #else |
---|
[608] | 927 | xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp ); |
---|
| 928 | // sub-PU based compensation |
---|
| 929 | xPredInterLumaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
| 930 | xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi ); |
---|
[724] | 931 | #endif |
---|
[608] | 932 | } |
---|
[296] | 933 | #endif |
---|
[189] | 934 | |
---|
[608] | 935 | #if H_3D_ARP |
---|
| 936 | Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled ) |
---|
| 937 | { |
---|
| 938 | Int iRefIdx = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 939 | TComMv cMv = pNewMvFiled ? pNewMvFiled->getMv() : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 940 | Bool bTobeScaled = false; |
---|
| 941 | TComPic* pcPicYuvBaseCol = NULL; |
---|
| 942 | TComPic* pcPicYuvBaseRef = NULL; |
---|
[2] | 943 | |
---|
[608] | 944 | #if H_3D_NBDV |
---|
[443] | 945 | DisInfo cDistparity; |
---|
| 946 | cDistparity.bDV = pcCU->getDvInfo(uiPartAddr).bDV; |
---|
| 947 | if( cDistparity.bDV ) |
---|
| 948 | { |
---|
[608] | 949 | cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV; |
---|
[443] | 950 | assert(pcCU->getDvInfo(uiPartAddr).bDV == pcCU->getDvInfo(0).bDV); |
---|
[608] | 951 | cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
[443] | 952 | } |
---|
| 953 | #else |
---|
[608] | 954 | assert(0); // ARP can be applied only when a DV is available |
---|
[443] | 955 | #endif |
---|
| 956 | |
---|
[608] | 957 | UChar dW = cDistparity.bDV ? pcCU->getARPW ( uiPartAddr ) : 0; |
---|
| 958 | |
---|
| 959 | if( cDistparity.bDV ) |
---|
[443] | 960 | { |
---|
[724] | 961 | #if SHARP_ARP_REF_CHECK_F0105 |
---|
| 962 | Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList); |
---|
| 963 | if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() ) |
---|
| 964 | #else |
---|
[608] | 965 | if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC()!= pcCU->getSlice()->getPOC() ) |
---|
[724] | 966 | #endif |
---|
[608] | 967 | { |
---|
[443] | 968 | bTobeScaled = true; |
---|
[608] | 969 | } |
---|
| 970 | |
---|
| 971 | pcPicYuvBaseCol = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(), cDistparity.m_aVIdxCan ); |
---|
[724] | 972 | |
---|
| 973 | #if SHARP_ARP_REF_CHECK_F0105 |
---|
| 974 | pcPicYuvBaseRef = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan ); |
---|
| 975 | |
---|
| 976 | if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan)) |
---|
| 977 | #else |
---|
[608] | 978 | pcPicYuvBaseRef = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC(), cDistparity.m_aVIdxCan ); |
---|
| 979 | |
---|
| 980 | if( ( !pcPicYuvBaseCol || pcPicYuvBaseCol->getPOC() != pcCU->getSlice()->getPOC() ) || ( !pcPicYuvBaseRef || pcPicYuvBaseRef->getPOC() != pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ) ) |
---|
[724] | 981 | #endif |
---|
[443] | 982 | { |
---|
| 983 | dW = 0; |
---|
| 984 | bTobeScaled = false; |
---|
| 985 | } |
---|
| 986 | else |
---|
[608] | 987 | { |
---|
[724] | 988 | #if SHARP_ARP_REF_CHECK_F0105 |
---|
| 989 | assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() ); |
---|
| 990 | #else |
---|
[443] | 991 | assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ); |
---|
[724] | 992 | #endif |
---|
[608] | 993 | } |
---|
| 994 | |
---|
[443] | 995 | if(bTobeScaled) |
---|
| 996 | { |
---|
[608] | 997 | Int iCurrPOC = pcCU->getSlice()->getPOC(); |
---|
[443] | 998 | Int iColRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx ); |
---|
| 999 | Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, 0); |
---|
| 1000 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC); |
---|
| 1001 | if ( iScale != 4096 ) |
---|
[608] | 1002 | { |
---|
[443] | 1003 | cMv = cMv.scaleMv( iScale ); |
---|
[608] | 1004 | } |
---|
[443] | 1005 | iRefIdx = 0; |
---|
| 1006 | } |
---|
| 1007 | } |
---|
[608] | 1008 | |
---|
[443] | 1009 | pcCU->clipMv(cMv); |
---|
| 1010 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(); |
---|
[608] | 1011 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true ); |
---|
| 1012 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, true ); |
---|
| 1013 | |
---|
[443] | 1014 | if( dW > 0 ) |
---|
| 1015 | { |
---|
[608] | 1016 | TComYuv * pYuvB0 = &m_acYuvPredBase[0]; |
---|
[443] | 1017 | TComYuv * pYuvB1 = &m_acYuvPredBase[1]; |
---|
[608] | 1018 | |
---|
| 1019 | TComMv cMVwithDisparity = cMv + cDistparity.m_acNBDV; |
---|
| 1020 | pcCU->clipMv(cMVwithDisparity); |
---|
| 1021 | |
---|
| 1022 | assert ( cDistparity.bDV ); |
---|
| 1023 | |
---|
[443] | 1024 | pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec(); |
---|
[608] | 1025 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true ); |
---|
| 1026 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acNBDV, iWidth, iHeight, pYuvB0, bi, true ); |
---|
| 1027 | |
---|
[443] | 1028 | pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec(); |
---|
[608] | 1029 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true ); |
---|
| 1030 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, bi, true ); |
---|
| 1031 | |
---|
| 1032 | pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight ); |
---|
| 1033 | |
---|
| 1034 | if( 2 == dW ) |
---|
| 1035 | { |
---|
| 1036 | pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); |
---|
| 1037 | } |
---|
| 1038 | rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi ); |
---|
[443] | 1039 | } |
---|
| 1040 | } |
---|
[724] | 1041 | #if QC_MTK_INTERVIEW_ARP_F0123_F0108 |
---|
| 1042 | Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled ) |
---|
| 1043 | { |
---|
| 1044 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 1045 | TComMv cDMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 1046 | TComMv cTempDMv = cDMv; |
---|
| 1047 | UChar dW = pcCU->getARPW ( uiPartAddr ); |
---|
| 1048 | |
---|
| 1049 | TComPic* pcPicYuvBaseTRef = NULL; |
---|
| 1050 | TComPic* pcPicYuvCurrTRef = NULL; |
---|
| 1051 | TComPic* pcPicYuvBaseCol = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); |
---|
| 1052 | TComPicYuv* pcYuvBaseCol = pcPicYuvBaseCol->getPicYuvRec(); |
---|
| 1053 | Bool bTMVAvai = false; |
---|
| 1054 | TComMv cBaseTMV; |
---|
| 1055 | if( pNewMvFiled ) |
---|
| 1056 | { |
---|
| 1057 | iRefIdx = pNewMvFiled->getRefIdx(); |
---|
| 1058 | cDMv = pNewMvFiled->getMv(); |
---|
| 1059 | } |
---|
| 1060 | pcCU->clipMv(cTempDMv); |
---|
| 1061 | |
---|
| 1062 | assert(dW > 0); |
---|
| 1063 | #if SHARP_ARP_REF_CHECK_F0105 |
---|
| 1064 | if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex())) |
---|
| 1065 | { |
---|
| 1066 | dW = 0; |
---|
| 1067 | } |
---|
[443] | 1068 | #endif |
---|
[724] | 1069 | Int uiLCUAddr,uiAbsPartAddr; |
---|
| 1070 | Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2 + ((cDMv.getHor() + 2)>>2); |
---|
| 1071 | Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2); |
---|
[443] | 1072 | |
---|
[724] | 1073 | irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX); |
---|
| 1074 | irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); |
---|
| 1075 | pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr); |
---|
| 1076 | TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr ); |
---|
| 1077 | |
---|
| 1078 | if(!pColCU->isIntra(uiAbsPartAddr)) |
---|
| 1079 | { |
---|
| 1080 | TComMvField puMVField; |
---|
| 1081 | for(Int iList = 0; iList < (pColCU->getSlice()->isInterB() ? 2: 1) && !bTMVAvai; iList ++) |
---|
| 1082 | { |
---|
| 1083 | RefPicList eRefPicListCurr = RefPicList(iList); |
---|
| 1084 | Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr); |
---|
| 1085 | if( iRef != -1) |
---|
| 1086 | { |
---|
| 1087 | pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); |
---|
| 1088 | Int iCurrPOC = pColCU->getSlice()->getPOC(); |
---|
| 1089 | Int iCurrRefPOC = pcPicYuvBaseTRef->getPOC(); |
---|
| 1090 | Int iCurrRef = pcCU->getSlice()->getFirstTRefIdx(eRefPicListCurr); |
---|
| 1091 | if( iCurrRef >= 0) |
---|
| 1092 | { |
---|
| 1093 | pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic(eRefPicListCurr,iCurrRef); |
---|
| 1094 | Int iTargetPOC = pcPicYuvCurrTRef->getPOC(); |
---|
| 1095 | { |
---|
| 1096 | pcPicYuvBaseTRef = pcCU->getSlice()->getBaseViewRefPic(iTargetPOC, pcPicYuvBaseCol->getViewIndex() ); |
---|
| 1097 | if(pcPicYuvBaseTRef) |
---|
| 1098 | { |
---|
| 1099 | cBaseTMV = pColCU->getCUMvField(eRefPicListCurr)->getMv(uiAbsPartAddr); |
---|
| 1100 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC); |
---|
| 1101 | if ( iScale != 4096 ) |
---|
| 1102 | cBaseTMV = cBaseTMV.scaleMv( iScale ); |
---|
| 1103 | bTMVAvai = true; |
---|
| 1104 | break; |
---|
| 1105 | } |
---|
| 1106 | } |
---|
| 1107 | } |
---|
| 1108 | } |
---|
| 1109 | } |
---|
| 1110 | } |
---|
| 1111 | if (bTMVAvai == false) |
---|
| 1112 | { |
---|
| 1113 | bTMVAvai = true; |
---|
| 1114 | cBaseTMV.set(0, 0); |
---|
| 1115 | pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicList, pcCU->getSlice()->getFirstTRefIdx(eRefPicList)); |
---|
| 1116 | pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic (eRefPicList, pcCU->getSlice()->getFirstTRefIdx(eRefPicList)); |
---|
| 1117 | } |
---|
| 1118 | |
---|
| 1119 | xPredInterLumaBlk ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi, bTMVAvai); |
---|
| 1120 | xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi, bTMVAvai); |
---|
| 1121 | |
---|
| 1122 | if( dW > 0 && bTMVAvai ) |
---|
| 1123 | { |
---|
| 1124 | TComYuv* pYuvCurrTRef = &m_acYuvPredBase[0]; |
---|
| 1125 | TComYuv* pYuvBaseTRef = &m_acYuvPredBase[1]; |
---|
| 1126 | TComPicYuv* pcYuvCurrTref = pcPicYuvCurrTRef->getPicYuvRec(); |
---|
| 1127 | TComPicYuv* pcYuvBaseTref = pcPicYuvBaseTRef->getPicYuvRec(); |
---|
| 1128 | TComMv cTempMv = cDMv + cBaseTMV; |
---|
| 1129 | |
---|
| 1130 | pcCU->clipMv(cBaseTMV); |
---|
| 1131 | pcCU->clipMv(cTempMv); |
---|
| 1132 | |
---|
| 1133 | xPredInterLumaBlk ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, bi, true); |
---|
| 1134 | xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, bi, true); |
---|
| 1135 | xPredInterLumaBlk ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, bi, true); |
---|
| 1136 | xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, bi, true); |
---|
| 1137 | |
---|
| 1138 | pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight ); |
---|
| 1139 | if(dW == 2) |
---|
| 1140 | { |
---|
| 1141 | pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); |
---|
| 1142 | } |
---|
| 1143 | rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi ); |
---|
| 1144 | } |
---|
| 1145 | } |
---|
| 1146 | #endif |
---|
| 1147 | |
---|
| 1148 | #endif |
---|
| 1149 | |
---|
[608] | 1150 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
[2] | 1151 | { |
---|
[56] | 1152 | TComYuv* pcMbYuv; |
---|
| 1153 | Int iRefIdx[2] = {-1, -1}; |
---|
| 1154 | |
---|
| 1155 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
| 1156 | { |
---|
| 1157 | RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
| 1158 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 1159 | |
---|
| 1160 | if ( iRefIdx[iRefList] < 0 ) |
---|
| 1161 | { |
---|
| 1162 | continue; |
---|
| 1163 | } |
---|
| 1164 | |
---|
| 1165 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
| 1166 | |
---|
| 1167 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
| 1168 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
| 1169 | { |
---|
[608] | 1170 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
[56] | 1171 | } |
---|
| 1172 | else |
---|
| 1173 | { |
---|
[608] | 1174 | if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || |
---|
| 1175 | ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) ) |
---|
[56] | 1176 | { |
---|
[608] | 1177 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
[56] | 1178 | } |
---|
| 1179 | else |
---|
| 1180 | { |
---|
[608] | 1181 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv ); |
---|
[56] | 1182 | } |
---|
| 1183 | } |
---|
| 1184 | } |
---|
[608] | 1185 | |
---|
| 1186 | if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) |
---|
[56] | 1187 | { |
---|
| 1188 | xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
[608] | 1189 | } |
---|
[313] | 1190 | else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) |
---|
| 1191 | { |
---|
[608] | 1192 | xWeightedPredictionUni( pcCU, &m_acYuvPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred ); |
---|
[313] | 1193 | } |
---|
[56] | 1194 | else |
---|
| 1195 | { |
---|
[608] | 1196 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
[56] | 1197 | } |
---|
[2] | 1198 | } |
---|
| 1199 | |
---|
[608] | 1200 | #if H_3D_VSP |
---|
[296] | 1201 | |
---|
[608] | 1202 | Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
| 1203 | { |
---|
| 1204 | TComYuv* pcMbYuv; |
---|
| 1205 | Int iRefIdx[2] = {-1, -1}; |
---|
| 1206 | Bool bi = (pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0); |
---|
[296] | 1207 | |
---|
[608] | 1208 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
[2] | 1209 | { |
---|
[608] | 1210 | RefPicList eRefPicList = RefPicList(iRefList); |
---|
| 1211 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
[56] | 1212 | |
---|
[608] | 1213 | if ( iRefIdx[iRefList] < 0 ) |
---|
[622] | 1214 | { |
---|
[608] | 1215 | continue; |
---|
[622] | 1216 | } |
---|
[608] | 1217 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
[56] | 1218 | |
---|
[608] | 1219 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
| 1220 | xPredInterUniVSP ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, bi ); |
---|
[2] | 1221 | } |
---|
[296] | 1222 | |
---|
[608] | 1223 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 1224 | } |
---|
[296] | 1225 | |
---|
| 1226 | #endif |
---|
[56] | 1227 | |
---|
| 1228 | /** |
---|
| 1229 | * \brief Generate motion-compensated luma block |
---|
| 1230 | * |
---|
| 1231 | * \param cu Pointer to current CU |
---|
| 1232 | * \param refPic Pointer to reference picture |
---|
| 1233 | * \param partAddr Address of block within CU |
---|
| 1234 | * \param mv Motion vector |
---|
| 1235 | * \param width Width of block |
---|
| 1236 | * \param height Height of block |
---|
| 1237 | * \param dstPic Pointer to destination picture |
---|
| 1238 | * \param bi Flag indicating whether bipred is used |
---|
| 1239 | */ |
---|
[608] | 1240 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
| 1241 | #if H_3D_ARP |
---|
| 1242 | , Bool filterType |
---|
[189] | 1243 | #endif |
---|
[608] | 1244 | #if H_3D_IC |
---|
| 1245 | , Bool bICFlag |
---|
| 1246 | #endif |
---|
| 1247 | ) |
---|
[56] | 1248 | { |
---|
| 1249 | Int refStride = refPic->getStride(); |
---|
| 1250 | Int refOffset = ( mv->getHor() >> 2 ) + ( mv->getVer() >> 2 ) * refStride; |
---|
| 1251 | Pel *ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1252 | |
---|
| 1253 | Int dstStride = dstPic->getStride(); |
---|
| 1254 | Pel *dst = dstPic->getLumaAddr( partAddr ); |
---|
| 1255 | |
---|
| 1256 | Int xFrac = mv->getHor() & 0x3; |
---|
| 1257 | Int yFrac = mv->getVer() & 0x3; |
---|
| 1258 | |
---|
[608] | 1259 | #if H_3D_IC |
---|
| 1260 | if( cu->getSlice()->getIsDepth() ) |
---|
| 1261 | { |
---|
| 1262 | refOffset = mv->getHor() + mv->getVer() * refStride; |
---|
| 1263 | ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1264 | xFrac = 0; |
---|
| 1265 | yFrac = 0; |
---|
| 1266 | } |
---|
[56] | 1267 | #endif |
---|
| 1268 | if ( yFrac == 0 ) |
---|
[2] | 1269 | { |
---|
[655] | 1270 | #if H_3D_IC |
---|
[608] | 1271 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi || bICFlag |
---|
| 1272 | #else |
---|
| 1273 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi |
---|
[443] | 1274 | #endif |
---|
[608] | 1275 | #if H_3D_ARP |
---|
| 1276 | , filterType |
---|
| 1277 | #endif |
---|
| 1278 | ); |
---|
[2] | 1279 | } |
---|
[56] | 1280 | else if ( xFrac == 0 ) |
---|
| 1281 | { |
---|
[655] | 1282 | #if H_3D_IC |
---|
[608] | 1283 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag |
---|
| 1284 | #else |
---|
| 1285 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi |
---|
[443] | 1286 | #endif |
---|
[608] | 1287 | #if H_3D_ARP |
---|
| 1288 | , filterType |
---|
| 1289 | #endif |
---|
| 1290 | ); |
---|
[56] | 1291 | } |
---|
| 1292 | else |
---|
| 1293 | { |
---|
| 1294 | Int tmpStride = m_filteredBlockTmp[0].getStride(); |
---|
| 1295 | Short *tmp = m_filteredBlockTmp[0].getLumaAddr(); |
---|
| 1296 | |
---|
| 1297 | Int filterSize = NTAPS_LUMA; |
---|
| 1298 | Int halfFilterSize = ( filterSize >> 1 ); |
---|
| 1299 | |
---|
[443] | 1300 | m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false |
---|
[608] | 1301 | #if H_3D_ARP |
---|
| 1302 | , filterType |
---|
[443] | 1303 | #endif |
---|
[608] | 1304 | ); |
---|
[655] | 1305 | #if H_3D_IC |
---|
[608] | 1306 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi || bICFlag |
---|
| 1307 | #else |
---|
[443] | 1308 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi |
---|
[608] | 1309 | #endif |
---|
| 1310 | #if H_3D_ARP |
---|
| 1311 | , filterType |
---|
[443] | 1312 | #endif |
---|
[608] | 1313 | ); |
---|
[56] | 1314 | } |
---|
[189] | 1315 | |
---|
[608] | 1316 | #if H_3D_IC |
---|
| 1317 | if( bICFlag ) |
---|
[189] | 1318 | { |
---|
[608] | 1319 | Int a, b, i, j; |
---|
| 1320 | const Int iShift = IC_CONST_SHIFT; |
---|
| 1321 | |
---|
| 1322 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA ); |
---|
[189] | 1323 | |
---|
| 1324 | |
---|
[608] | 1325 | for ( i = 0; i < height; i++ ) |
---|
[189] | 1326 | { |
---|
[608] | 1327 | for ( j = 0; j < width; j++ ) |
---|
[189] | 1328 | { |
---|
[608] | 1329 | dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b ); |
---|
[189] | 1330 | } |
---|
| 1331 | dst += dstStride; |
---|
| 1332 | } |
---|
[655] | 1333 | |
---|
[608] | 1334 | if(bi) |
---|
| 1335 | { |
---|
| 1336 | Pel *dst2 = dstPic->getLumaAddr( partAddr ); |
---|
| 1337 | Int shift = IF_INTERNAL_PREC - g_bitDepthY; |
---|
| 1338 | for (i = 0; i < height; i++) |
---|
| 1339 | { |
---|
| 1340 | for (j = 0; j < width; j++) |
---|
| 1341 | { |
---|
| 1342 | Short val = dst2[j] << shift; |
---|
| 1343 | dst2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
| 1344 | } |
---|
| 1345 | dst2 += dstStride; |
---|
| 1346 | } |
---|
| 1347 | } |
---|
[189] | 1348 | } |
---|
| 1349 | #endif |
---|
[2] | 1350 | } |
---|
| 1351 | |
---|
[56] | 1352 | /** |
---|
| 1353 | * \brief Generate motion-compensated chroma block |
---|
| 1354 | * |
---|
| 1355 | * \param cu Pointer to current CU |
---|
| 1356 | * \param refPic Pointer to reference picture |
---|
| 1357 | * \param partAddr Address of block within CU |
---|
| 1358 | * \param mv Motion vector |
---|
| 1359 | * \param width Width of block |
---|
| 1360 | * \param height Height of block |
---|
| 1361 | * \param dstPic Pointer to destination picture |
---|
| 1362 | * \param bi Flag indicating whether bipred is used |
---|
| 1363 | */ |
---|
[608] | 1364 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi |
---|
| 1365 | #if H_3D_ARP |
---|
| 1366 | , Bool filterType |
---|
[189] | 1367 | #endif |
---|
[608] | 1368 | #if H_3D_IC |
---|
| 1369 | , Bool bICFlag |
---|
| 1370 | #endif |
---|
[443] | 1371 | ) |
---|
[2] | 1372 | { |
---|
[56] | 1373 | Int refStride = refPic->getCStride(); |
---|
| 1374 | Int dstStride = dstPic->getCStride(); |
---|
| 1375 | |
---|
| 1376 | Int refOffset = (mv->getHor() >> 3) + (mv->getVer() >> 3) * refStride; |
---|
| 1377 | |
---|
| 1378 | Pel* refCb = refPic->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1379 | Pel* refCr = refPic->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1380 | |
---|
| 1381 | Pel* dstCb = dstPic->getCbAddr( partAddr ); |
---|
| 1382 | Pel* dstCr = dstPic->getCrAddr( partAddr ); |
---|
| 1383 | |
---|
| 1384 | Int xFrac = mv->getHor() & 0x7; |
---|
| 1385 | Int yFrac = mv->getVer() & 0x7; |
---|
| 1386 | UInt cxWidth = width >> 1; |
---|
| 1387 | UInt cxHeight = height >> 1; |
---|
| 1388 | |
---|
| 1389 | Int extStride = m_filteredBlockTmp[0].getStride(); |
---|
| 1390 | Short* extY = m_filteredBlockTmp[0].getLumaAddr(); |
---|
| 1391 | |
---|
| 1392 | Int filterSize = NTAPS_CHROMA; |
---|
| 1393 | |
---|
| 1394 | Int halfFilterSize = (filterSize>>1); |
---|
| 1395 | |
---|
| 1396 | if ( yFrac == 0 ) |
---|
| 1397 | { |
---|
[655] | 1398 | #if H_3D_IC |
---|
[608] | 1399 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag |
---|
| 1400 | #else |
---|
[443] | 1401 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
[608] | 1402 | #endif |
---|
| 1403 | #if H_3D_ARP |
---|
| 1404 | , filterType |
---|
| 1405 | #endif |
---|
[443] | 1406 | ); |
---|
[655] | 1407 | #if H_3D_IC |
---|
[608] | 1408 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag |
---|
| 1409 | #else |
---|
[443] | 1410 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi |
---|
[608] | 1411 | #endif |
---|
| 1412 | #if H_3D_ARP |
---|
| 1413 | , filterType |
---|
| 1414 | #endif |
---|
| 1415 | ); |
---|
[56] | 1416 | } |
---|
| 1417 | else if ( xFrac == 0 ) |
---|
| 1418 | { |
---|
[655] | 1419 | #if H_3D_IC |
---|
[608] | 1420 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag |
---|
| 1421 | #else |
---|
[443] | 1422 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
[608] | 1423 | #endif |
---|
| 1424 | #if H_3D_ARP |
---|
| 1425 | , filterType |
---|
| 1426 | #endif |
---|
| 1427 | ); |
---|
[655] | 1428 | #if H_3D_IC |
---|
[608] | 1429 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag |
---|
| 1430 | #else |
---|
[443] | 1431 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi |
---|
[608] | 1432 | #endif |
---|
| 1433 | #if H_3D_ARP |
---|
| 1434 | , filterType |
---|
| 1435 | #endif |
---|
| 1436 | ); |
---|
[56] | 1437 | } |
---|
| 1438 | else |
---|
| 1439 | { |
---|
[443] | 1440 | m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
[608] | 1441 | #if H_3D_ARP |
---|
| 1442 | , filterType |
---|
| 1443 | #endif |
---|
| 1444 | ); |
---|
[655] | 1445 | #if H_3D_IC |
---|
[608] | 1446 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag |
---|
| 1447 | #else |
---|
[443] | 1448 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
[608] | 1449 | #endif |
---|
| 1450 | #if H_3D_ARP |
---|
| 1451 | , filterType |
---|
| 1452 | #endif |
---|
| 1453 | ); |
---|
[56] | 1454 | |
---|
[443] | 1455 | m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false |
---|
[608] | 1456 | #if H_3D_ARP |
---|
| 1457 | , filterType |
---|
| 1458 | #endif |
---|
| 1459 | ); |
---|
[655] | 1460 | #if H_3D_IC |
---|
[608] | 1461 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag |
---|
| 1462 | #else |
---|
[443] | 1463 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi |
---|
[608] | 1464 | #endif |
---|
| 1465 | #if H_3D_ARP |
---|
| 1466 | , filterType |
---|
| 1467 | #endif |
---|
| 1468 | ); |
---|
[56] | 1469 | } |
---|
[608] | 1470 | |
---|
| 1471 | #if H_3D_IC |
---|
| 1472 | if( bICFlag ) |
---|
[189] | 1473 | { |
---|
[608] | 1474 | Int a, b, i, j; |
---|
| 1475 | const Int iShift = IC_CONST_SHIFT; |
---|
| 1476 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb |
---|
| 1477 | for ( i = 0; i < cxHeight; i++ ) |
---|
[189] | 1478 | { |
---|
[608] | 1479 | for ( j = 0; j < cxWidth; j++ ) |
---|
[189] | 1480 | { |
---|
[608] | 1481 | dstCb[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b ); |
---|
[189] | 1482 | } |
---|
| 1483 | dstCb += dstStride; |
---|
| 1484 | } |
---|
[608] | 1485 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr |
---|
| 1486 | for ( i = 0; i < cxHeight; i++ ) |
---|
[189] | 1487 | { |
---|
[608] | 1488 | for ( j = 0; j < cxWidth; j++ ) |
---|
[189] | 1489 | { |
---|
[608] | 1490 | dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b ); |
---|
[189] | 1491 | } |
---|
| 1492 | dstCr += dstStride; |
---|
| 1493 | } |
---|
[655] | 1494 | |
---|
[608] | 1495 | if(bi) |
---|
[296] | 1496 | { |
---|
[608] | 1497 | Pel* dstCb2 = dstPic->getCbAddr( partAddr ); |
---|
| 1498 | Pel* dstCr2 = dstPic->getCrAddr( partAddr ); |
---|
| 1499 | Int shift = IF_INTERNAL_PREC - g_bitDepthC; |
---|
| 1500 | for (i = 0; i < cxHeight; i++) |
---|
[296] | 1501 | { |
---|
[608] | 1502 | for (j = 0; j < cxWidth; j++) |
---|
[296] | 1503 | { |
---|
[608] | 1504 | Short val = dstCb2[j] << shift; |
---|
| 1505 | dstCb2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
[461] | 1506 | |
---|
[608] | 1507 | val = dstCr2[j] << shift; |
---|
| 1508 | dstCr2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
[296] | 1509 | } |
---|
[608] | 1510 | dstCb2 += dstStride; |
---|
| 1511 | dstCr2 += dstStride; |
---|
[443] | 1512 | } |
---|
| 1513 | } |
---|
[296] | 1514 | } |
---|
[443] | 1515 | #endif |
---|
[296] | 1516 | } |
---|
| 1517 | |
---|
[608] | 1518 | Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) |
---|
[2] | 1519 | { |
---|
[56] | 1520 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1521 | { |
---|
[56] | 1522 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); |
---|
[2] | 1523 | } |
---|
[56] | 1524 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
[2] | 1525 | { |
---|
[56] | 1526 | pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
[2] | 1527 | } |
---|
[56] | 1528 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1529 | { |
---|
[56] | 1530 | pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
| 1531 | } |
---|
| 1532 | } |
---|
| 1533 | |
---|
| 1534 | // AMVP |
---|
[608] | 1535 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred ) |
---|
[56] | 1536 | { |
---|
| 1537 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
[608] | 1538 | if( pcAMVPInfo->iN <= 1 ) |
---|
[56] | 1539 | { |
---|
| 1540 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
| 1541 | |
---|
| 1542 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 1543 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 1544 | return; |
---|
| 1545 | } |
---|
| 1546 | |
---|
| 1547 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
| 1548 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
| 1549 | return; |
---|
| 1550 | } |
---|
| 1551 | |
---|
| 1552 | /** Function for deriving planar intra prediction. |
---|
| 1553 | * \param pSrc pointer to reconstructed sample array |
---|
| 1554 | * \param srcStride the stride of the reconstructed sample array |
---|
| 1555 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 1556 | * \param dstStride the stride of the prediction sample array |
---|
| 1557 | * \param width the width of the block |
---|
| 1558 | * \param height the height of the block |
---|
| 1559 | * |
---|
| 1560 | * This function derives the prediction samples for planar mode (intra coding). |
---|
| 1561 | */ |
---|
| 1562 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
| 1563 | { |
---|
| 1564 | assert(width == height); |
---|
| 1565 | |
---|
| 1566 | Int k, l, bottomLeft, topRight; |
---|
| 1567 | Int horPred; |
---|
[655] | 1568 | Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
[56] | 1569 | UInt blkSize = width; |
---|
| 1570 | UInt offset2D = width; |
---|
| 1571 | UInt shift1D = g_aucConvertToBit[ width ] + 2; |
---|
| 1572 | UInt shift2D = shift1D + 1; |
---|
| 1573 | |
---|
| 1574 | // Get left and above reference column and row |
---|
| 1575 | for(k=0;k<blkSize+1;k++) |
---|
| 1576 | { |
---|
| 1577 | topRow[k] = pSrc[k-srcStride]; |
---|
| 1578 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
| 1579 | } |
---|
| 1580 | |
---|
| 1581 | // Prepare intermediate variables used in interpolation |
---|
| 1582 | bottomLeft = leftColumn[blkSize]; |
---|
| 1583 | topRight = topRow[blkSize]; |
---|
| 1584 | for (k=0;k<blkSize;k++) |
---|
| 1585 | { |
---|
| 1586 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
| 1587 | rightColumn[k] = topRight - leftColumn[k]; |
---|
| 1588 | topRow[k] <<= shift1D; |
---|
| 1589 | leftColumn[k] <<= shift1D; |
---|
| 1590 | } |
---|
| 1591 | |
---|
| 1592 | // Generate prediction signal |
---|
| 1593 | for (k=0;k<blkSize;k++) |
---|
| 1594 | { |
---|
| 1595 | horPred = leftColumn[k] + offset2D; |
---|
| 1596 | for (l=0;l<blkSize;l++) |
---|
[2] | 1597 | { |
---|
[56] | 1598 | horPred += rightColumn[k]; |
---|
| 1599 | topRow[l] += bottomRow[l]; |
---|
| 1600 | rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); |
---|
[2] | 1601 | } |
---|
| 1602 | } |
---|
| 1603 | } |
---|
| 1604 | |
---|
[608] | 1605 | /** Function for filtering intra DC predictor. |
---|
| 1606 | * \param pSrc pointer to reconstructed sample array |
---|
| 1607 | * \param iSrcStride the stride of the reconstructed sample array |
---|
| 1608 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 1609 | * \param iDstStride the stride of the prediction sample array |
---|
| 1610 | * \param iWidth the width of the block |
---|
| 1611 | * \param iHeight the height of the block |
---|
[56] | 1612 | * |
---|
[608] | 1613 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
[56] | 1614 | */ |
---|
[608] | 1615 | Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) |
---|
[56] | 1616 | { |
---|
[608] | 1617 | Pel* pDst = rpDst; |
---|
| 1618 | Int x, y, iDstStride2, iSrcStride2; |
---|
[2] | 1619 | |
---|
[608] | 1620 | // boundary pixels processing |
---|
| 1621 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
[56] | 1622 | |
---|
[608] | 1623 | for ( x = 1; x < iWidth; x++ ) |
---|
[2] | 1624 | { |
---|
[608] | 1625 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
[2] | 1626 | } |
---|
| 1627 | |
---|
[608] | 1628 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
[56] | 1629 | { |
---|
[608] | 1630 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
[56] | 1631 | } |
---|
[2] | 1632 | |
---|
[608] | 1633 | return; |
---|
[2] | 1634 | } |
---|
[608] | 1635 | #if H_3D_IC |
---|
| 1636 | /** Function for deriving the position of first non-zero binary bit of a value |
---|
[56] | 1637 | * \param x input value |
---|
| 1638 | * |
---|
[608] | 1639 | * This function derives the position of first non-zero binary bit of a value |
---|
[56] | 1640 | */ |
---|
| 1641 | Int GetMSB( UInt x ) |
---|
| 1642 | { |
---|
| 1643 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
| 1644 | |
---|
| 1645 | while( x > 1 ) |
---|
| 1646 | { |
---|
| 1647 | bits >>= 1; |
---|
| 1648 | y = x >> bits; |
---|
| 1649 | |
---|
| 1650 | if( y ) |
---|
| 1651 | { |
---|
| 1652 | x = y; |
---|
| 1653 | iMSB += bits; |
---|
| 1654 | } |
---|
| 1655 | } |
---|
| 1656 | |
---|
| 1657 | iMSB+=y; |
---|
| 1658 | |
---|
| 1659 | return iMSB; |
---|
| 1660 | } |
---|
| 1661 | |
---|
| 1662 | |
---|
[608] | 1663 | /** Function for deriving LM illumination compensation. |
---|
[56] | 1664 | */ |
---|
[608] | 1665 | Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType ) |
---|
[56] | 1666 | { |
---|
[608] | 1667 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
| 1668 | Pel *pRec = NULL, *pRef = NULL; |
---|
| 1669 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
| 1670 | Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride(); |
---|
| 1671 | Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride(); |
---|
| 1672 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset, iHor, iVer; |
---|
[56] | 1673 | |
---|
[608] | 1674 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1675 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1676 | iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 ); |
---|
| 1677 | iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 ); |
---|
| 1678 | iRefX = iCUPelX + iHor; |
---|
| 1679 | iRefY = iCUPelY + iVer; |
---|
| 1680 | if( eType != TEXT_LUMA ) |
---|
| 1681 | { |
---|
| 1682 | iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 ); |
---|
| 1683 | iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 ); |
---|
| 1684 | } |
---|
| 1685 | uiWidth = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 ) : ( pcCU->getWidth( 0 ) >> 1 ); |
---|
| 1686 | uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1 ); |
---|
[56] | 1687 | |
---|
| 1688 | Int i, j, iCountShift = 0; |
---|
| 1689 | |
---|
| 1690 | // LLS parameters estimation --> |
---|
| 1691 | |
---|
| 1692 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
[608] | 1693 | Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12); |
---|
[56] | 1694 | |
---|
[608] | 1695 | if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelY > 0 && iRefY > 0 ) |
---|
[56] | 1696 | { |
---|
[608] | 1697 | iRefOffset = iHor + iVer * iRefStride - iRefStride; |
---|
| 1698 | if( eType == TEXT_LUMA ) |
---|
[56] | 1699 | { |
---|
[608] | 1700 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1701 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
[56] | 1702 | } |
---|
[608] | 1703 | else if( eType == TEXT_CHROMA_U ) |
---|
[56] | 1704 | { |
---|
[608] | 1705 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1706 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
[56] | 1707 | } |
---|
[608] | 1708 | else |
---|
| 1709 | { |
---|
| 1710 | assert( eType == TEXT_CHROMA_V ); |
---|
| 1711 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1712 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1713 | } |
---|
[56] | 1714 | |
---|
[608] | 1715 | for( j = 0; j < uiWidth; j+=2 ) |
---|
[189] | 1716 | { |
---|
| 1717 | x += pRef[j]; |
---|
| 1718 | y += pRec[j]; |
---|
[608] | 1719 | xx += (pRef[j] * pRef[j])>>precShift; |
---|
| 1720 | xy += (pRef[j] * pRec[j])>>precShift; |
---|
[189] | 1721 | } |
---|
[608] | 1722 | iCountShift += g_aucConvertToBit[ uiWidth ] + 1; |
---|
[189] | 1723 | } |
---|
| 1724 | |
---|
| 1725 | |
---|
[608] | 1726 | if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelX > 0 && iRefX > 0 ) |
---|
[189] | 1727 | { |
---|
[608] | 1728 | iRefOffset = iHor + iVer * iRefStride - 1; |
---|
| 1729 | if( eType == TEXT_LUMA ) |
---|
| 1730 | { |
---|
| 1731 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1732 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1733 | } |
---|
| 1734 | else if( eType == TEXT_CHROMA_U ) |
---|
| 1735 | { |
---|
| 1736 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1737 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1738 | } |
---|
| 1739 | else |
---|
| 1740 | { |
---|
| 1741 | assert( eType == TEXT_CHROMA_V ); |
---|
| 1742 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1743 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1744 | } |
---|
| 1745 | |
---|
| 1746 | for( i = 0; i < uiHeight; i+=2 ) |
---|
[189] | 1747 | { |
---|
| 1748 | x += pRef[0]; |
---|
| 1749 | y += pRec[0]; |
---|
[655] | 1750 | |
---|
[608] | 1751 | xx += (pRef[0] * pRef[0])>>precShift; |
---|
| 1752 | xy += (pRef[0] * pRec[0])>>precShift; |
---|
| 1753 | |
---|
| 1754 | pRef += iRefStride*2; |
---|
| 1755 | pRec += iRecStride*2; |
---|
[189] | 1756 | } |
---|
[608] | 1757 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 1 ); |
---|
[189] | 1758 | } |
---|
| 1759 | |
---|
[608] | 1760 | xy += xx >> IC_REG_COST_SHIFT; |
---|
| 1761 | xx += xx >> IC_REG_COST_SHIFT; |
---|
| 1762 | Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift); |
---|
| 1763 | Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift); |
---|
| 1764 | const Int iShift = IC_CONST_SHIFT; |
---|
| 1765 | { |
---|
[189] | 1766 | { |
---|
| 1767 | const Int iShiftA2 = 6; |
---|
| 1768 | const Int iAccuracyShift = 15; |
---|
| 1769 | |
---|
| 1770 | Int iScaleShiftA2 = 0; |
---|
| 1771 | Int iScaleShiftA1 = 0; |
---|
| 1772 | Int a1s = a1; |
---|
| 1773 | Int a2s = a2; |
---|
| 1774 | |
---|
[608] | 1775 | a1 = Clip3(0, 2*a2, a1); |
---|
| 1776 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
| 1777 | iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF; |
---|
[189] | 1778 | |
---|
| 1779 | if( iScaleShiftA1 < 0 ) |
---|
| 1780 | { |
---|
| 1781 | iScaleShiftA1 = 0; |
---|
| 1782 | } |
---|
| 1783 | |
---|
| 1784 | if( iScaleShiftA2 < 0 ) |
---|
| 1785 | { |
---|
| 1786 | iScaleShiftA2 = 0; |
---|
| 1787 | } |
---|
| 1788 | |
---|
| 1789 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
| 1790 | |
---|
[608] | 1791 | |
---|
[189] | 1792 | a2s = a2 >> iScaleShiftA2; |
---|
| 1793 | |
---|
| 1794 | a1s = a1 >> iScaleShiftA1; |
---|
| 1795 | |
---|
[608] | 1796 | a = a1s * m_uiaShift[ a2s ]; |
---|
| 1797 | a = a >> iScaleShiftA; |
---|
[189] | 1798 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 1799 | } |
---|
| 1800 | } |
---|
| 1801 | } |
---|
[608] | 1802 | #endif |
---|
[189] | 1803 | |
---|
[608] | 1804 | #if H_3D_VSP |
---|
| 1805 | // not fully support iRatioTxtPerDepth* != 1 |
---|
[724] | 1806 | #if MTK_F0109_LG_F0120_VSP_BLOCK |
---|
| 1807 | Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int &vspSize, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY ) |
---|
| 1808 | #else |
---|
[608] | 1809 | Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY ) |
---|
[724] | 1810 | #endif |
---|
[189] | 1811 | { |
---|
[608] | 1812 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE; |
---|
| 1813 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE; |
---|
[189] | 1814 | |
---|
[608] | 1815 | Int refDepStride = picRefDepth->getStride(); |
---|
[189] | 1816 | |
---|
[608] | 1817 | Int refDepOffset = ( (mv->getHor()+2) >> 2 ) + ( (mv->getVer()+2) >> 2 ) * refDepStride; |
---|
| 1818 | Pel *refDepth = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
[189] | 1819 | |
---|
[608] | 1820 | if( ratioTxtPerDepthX!=1 || ratioTxtPerDepthY!=1 ) |
---|
[189] | 1821 | { |
---|
[608] | 1822 | Int posX, posY; |
---|
| 1823 | refDepth = picRefDepth->getLumaAddr( ); |
---|
| 1824 | cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture |
---|
| 1825 | posX /= ratioTxtPerDepthX; // texture position -> depth postion |
---|
| 1826 | posY /= ratioTxtPerDepthY; |
---|
| 1827 | refDepOffset += posX + posY * refDepStride; |
---|
[189] | 1828 | |
---|
[608] | 1829 | width /= ratioTxtPerDepthX; // texture size -> depth size |
---|
| 1830 | height /= ratioTxtPerDepthY; |
---|
[189] | 1831 | } |
---|
| 1832 | |
---|
[608] | 1833 | refDepth += refDepOffset; |
---|
[189] | 1834 | |
---|
[608] | 1835 | Int depStride = yuvDepth->getStride(); |
---|
| 1836 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
[189] | 1837 | |
---|
[724] | 1838 | #if !SHARP_VSP_BLOCK_IN_AMP_F0102 |
---|
[608] | 1839 | if( width<8 || height<8 ) |
---|
| 1840 | { // no split |
---|
| 1841 | Int rightOffset = width - 1; |
---|
| 1842 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
| 1843 | Pel *refDepthTop = refDepth; |
---|
| 1844 | Pel *refDepthBot = refDepthTop + (height-1)*refDepStride; |
---|
[189] | 1845 | |
---|
[608] | 1846 | Pel maxDepth = refDepthTop[0] > refDepthBot[0] ? refDepthTop[0] : refDepthBot[0]; |
---|
| 1847 | if( maxDepth < refDepthTop[rightOffset] ) { maxDepth = refDepthTop[rightOffset]; } |
---|
| 1848 | if( maxDepth < refDepthBot[rightOffset] ) { maxDepth = refDepthBot[rightOffset]; } |
---|
| 1849 | |
---|
| 1850 | for( Int sY=0; sY<height; sY+=nTxtPerDepthY ) |
---|
| 1851 | { |
---|
| 1852 | for( Int sX=0; sX<width; sX+=nTxtPerDepthX ) |
---|
| 1853 | { |
---|
| 1854 | depth[sX] = maxDepth; |
---|
| 1855 | } |
---|
| 1856 | depth += depStrideBlock; |
---|
| 1857 | } |
---|
[724] | 1858 | #if MTK_F0109_LG_F0120_VSP_BLOCK |
---|
| 1859 | if(width==4) |
---|
| 1860 | vspSize=0; |
---|
| 1861 | else |
---|
| 1862 | vspSize=1; |
---|
| 1863 | #endif |
---|
[189] | 1864 | } |
---|
| 1865 | else |
---|
[608] | 1866 | { // split to 4x8, or 8x4 |
---|
| 1867 | Int blocksize = 8; |
---|
| 1868 | Int subblocksize = 4; |
---|
| 1869 | Int depStrideBlock = depStride * blocksize; |
---|
| 1870 | Pel *depthTmp = NULL; |
---|
| 1871 | Int depStrideTmp = depStride * nTxtPerDepthY; |
---|
| 1872 | Int offset[4] = { 0, subblocksize-1, subblocksize, blocksize-1 }; |
---|
| 1873 | Pel *refDepthTmp[4] = { NULL, NULL, NULL, NULL }; |
---|
| 1874 | Pel repDepth4x8[2] = {0, 0}; |
---|
| 1875 | Pel repDepth8x4[2] = {0, 0}; |
---|
[724] | 1876 | #endif |
---|
[189] | 1877 | |
---|
[724] | 1878 | #if !MTK_F0109_LG_F0120_VSP_BLOCK |
---|
| 1879 | #if SHARP_VSP_BLOCK_IN_AMP_F0102 |
---|
| 1880 | Int blocksize = 8; |
---|
| 1881 | Int subblocksize = 4; |
---|
| 1882 | Int depStrideBlock = depStride * blocksize; |
---|
| 1883 | Pel *depthTmp = NULL; |
---|
| 1884 | Int depStrideTmp = depStride * nTxtPerDepthY; |
---|
| 1885 | Int offset[4] = { 0, subblocksize-1, subblocksize, blocksize-1 }; |
---|
| 1886 | Pel *refDepthTmp[4] = { NULL, NULL, NULL, NULL }; |
---|
| 1887 | #endif |
---|
[608] | 1888 | Int refDepStrideBlock = refDepStride * blocksize; |
---|
| 1889 | Int refDepStrideSubBlock = refDepStride * subblocksize; |
---|
| 1890 | |
---|
| 1891 | refDepthTmp[0] = refDepth; |
---|
| 1892 | refDepthTmp[2] = refDepthTmp[0] + refDepStrideSubBlock; |
---|
| 1893 | refDepthTmp[1] = refDepthTmp[2] - refDepStride; |
---|
| 1894 | refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock; |
---|
| 1895 | |
---|
[724] | 1896 | #if SHARP_VSP_BLOCK_IN_AMP_F0102 |
---|
| 1897 | Int subBlockW, subBlockH; |
---|
| 1898 | Int blockW, blockH; |
---|
| 1899 | subBlockW = subBlockH = 8; |
---|
| 1900 | if (height % 8) |
---|
| 1901 | { |
---|
| 1902 | subBlockW = 8; |
---|
| 1903 | subBlockH = 4; |
---|
| 1904 | blockW = width; // no further split |
---|
| 1905 | blockH = height; // no further split |
---|
| 1906 | } |
---|
| 1907 | else if (width % 8) |
---|
| 1908 | { |
---|
| 1909 | subBlockW = 4; |
---|
| 1910 | subBlockH = 8; |
---|
| 1911 | blockW = width; // no further split |
---|
| 1912 | blockH = height; // no further split |
---|
| 1913 | } |
---|
| 1914 | else |
---|
| 1915 | { |
---|
| 1916 | blockW = blockH = 8; |
---|
| 1917 | } |
---|
| 1918 | for( Int y=0; y<height; y+=blockH ) |
---|
| 1919 | { |
---|
| 1920 | for( Int x=0; x<width; x+=blockW ) |
---|
| 1921 | { |
---|
| 1922 | if (blockW == 8 && blockH == 8) |
---|
| 1923 | { |
---|
| 1924 | Bool ULvsBR = false, URvsBL = false; |
---|
| 1925 | ULvsBR = refDepthTmp[0][x+offset[0]] < refDepthTmp[3][x+offset[3]]; |
---|
| 1926 | URvsBL = refDepthTmp[0][x+offset[3]] < refDepthTmp[3][x+offset[0]]; |
---|
| 1927 | if( ULvsBR ^ URvsBL ) |
---|
| 1928 | { // 4x8 |
---|
| 1929 | subBlockW = 4; |
---|
| 1930 | subBlockH = 8; |
---|
| 1931 | } |
---|
| 1932 | else |
---|
| 1933 | { |
---|
| 1934 | subBlockW = 8; |
---|
| 1935 | subBlockH = 4; |
---|
| 1936 | } |
---|
| 1937 | } |
---|
| 1938 | for( Int yy=0; yy<blockH; yy+=subBlockH ) |
---|
| 1939 | { |
---|
| 1940 | for( Int xx=0; xx<blockW; xx+=subBlockW ) |
---|
| 1941 | { |
---|
| 1942 | Pel maxDepthVal = 0; |
---|
| 1943 | Int xP0, xP1, yP0, yP1; |
---|
| 1944 | xP0 = x+xx; |
---|
| 1945 | xP1 = x+xx+subBlockW-1; |
---|
| 1946 | yP0 = yy; |
---|
| 1947 | yP1 = yy+subBlockH-1; |
---|
| 1948 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP0+yP0*refDepStride]); |
---|
| 1949 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP1+yP0*refDepStride]); |
---|
| 1950 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP0+yP1*refDepStride]); |
---|
| 1951 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP1+yP1*refDepStride]); |
---|
| 1952 | depthTmp = &depth[x+xx+yy*depStride]; |
---|
| 1953 | for( Int sY=0; sY<subBlockH; sY+=nTxtPerDepthY ) |
---|
| 1954 | { |
---|
| 1955 | for( Int sX=0; sX<subBlockW; sX+=nTxtPerDepthX ) |
---|
| 1956 | { |
---|
| 1957 | depthTmp[sX] = maxDepthVal; |
---|
| 1958 | } |
---|
| 1959 | depthTmp += depStrideTmp; |
---|
| 1960 | } |
---|
| 1961 | } |
---|
| 1962 | } |
---|
| 1963 | } |
---|
| 1964 | refDepthTmp[0] += refDepStrideBlock; |
---|
| 1965 | depth += depStrideBlock; |
---|
| 1966 | } |
---|
| 1967 | #else // SHARP_VSP_BLOCK_IN_AMP_F0102 |
---|
[608] | 1968 | for( Int y=0; y<height; y+=blocksize ) |
---|
[189] | 1969 | { |
---|
[608] | 1970 | for( Int x=0; x<width; x+=blocksize ) |
---|
| 1971 | { |
---|
| 1972 | Bool ULvsBR = false, URvsBL = false; |
---|
[189] | 1973 | |
---|
[608] | 1974 | ULvsBR = refDepthTmp[0][x+offset[0]] < refDepthTmp[3][x+offset[3]]; |
---|
| 1975 | URvsBL = refDepthTmp[0][x+offset[3]] < refDepthTmp[3][x+offset[0]]; |
---|
[189] | 1976 | |
---|
[608] | 1977 | if( ULvsBR ^ URvsBL ) |
---|
| 1978 | { // 4x8 |
---|
| 1979 | repDepth4x8[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[1]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[1]]; |
---|
| 1980 | if( repDepth4x8[0] < refDepthTmp[3][x+offset[0]] ) |
---|
| 1981 | { |
---|
| 1982 | repDepth4x8[0] = refDepthTmp[3][x+offset[0]]; |
---|
| 1983 | } |
---|
| 1984 | if( repDepth4x8[0] < refDepthTmp[3][x+offset[1]] ) |
---|
| 1985 | { |
---|
| 1986 | repDepth4x8[0] = refDepthTmp[3][x+offset[1]]; |
---|
| 1987 | } |
---|
| 1988 | repDepth4x8[1] = refDepthTmp[0][x+offset[2]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[2]] : refDepthTmp[0][x+offset[3]]; |
---|
| 1989 | if( repDepth4x8[1] < refDepthTmp[3][x+offset[2]] ) |
---|
| 1990 | { |
---|
| 1991 | repDepth4x8[1] = refDepthTmp[3][x+offset[2]]; |
---|
| 1992 | } |
---|
| 1993 | if( repDepth4x8[1] < refDepthTmp[3][x+offset[3]] ) |
---|
| 1994 | { |
---|
| 1995 | repDepth4x8[1] = refDepthTmp[3][x+offset[3]]; |
---|
| 1996 | } |
---|
[189] | 1997 | |
---|
[608] | 1998 | depthTmp = &depth[x]; |
---|
| 1999 | for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY ) |
---|
| 2000 | { |
---|
| 2001 | for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX ) |
---|
| 2002 | { |
---|
| 2003 | depthTmp[sX] = repDepth4x8[0]; |
---|
| 2004 | } |
---|
| 2005 | depthTmp += depStrideTmp; |
---|
| 2006 | } |
---|
| 2007 | depthTmp = &depth[x+subblocksize]; |
---|
| 2008 | for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY ) |
---|
| 2009 | { |
---|
| 2010 | for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX ) |
---|
| 2011 | { |
---|
| 2012 | depthTmp[sX] = repDepth4x8[1]; |
---|
| 2013 | } |
---|
| 2014 | depthTmp += depStrideTmp; |
---|
| 2015 | } |
---|
| 2016 | } |
---|
| 2017 | else |
---|
| 2018 | { // 8x4 |
---|
| 2019 | repDepth8x4[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[3]]; |
---|
| 2020 | if( repDepth8x4[0] < refDepthTmp[1][x+offset[0]] ) |
---|
| 2021 | { |
---|
| 2022 | repDepth8x4[0] = refDepthTmp[1][x+offset[0]]; |
---|
| 2023 | } |
---|
| 2024 | if( repDepth8x4[0] < refDepthTmp[1][x+offset[3]] ) |
---|
| 2025 | { |
---|
| 2026 | repDepth8x4[0] = refDepthTmp[1][x+offset[3]]; |
---|
| 2027 | } |
---|
| 2028 | repDepth8x4[1] = refDepthTmp[2][x+offset[0]] > refDepthTmp[2][x+offset[3]] ? refDepthTmp[2][x+offset[0]] : refDepthTmp[2][x+offset[3]]; |
---|
| 2029 | if( repDepth8x4[1] < refDepthTmp[3][x+offset[0]] ) |
---|
| 2030 | { |
---|
| 2031 | repDepth8x4[1] = refDepthTmp[3][x+offset[0]]; |
---|
| 2032 | } |
---|
| 2033 | if( repDepth8x4[1] < refDepthTmp[3][x+offset[3]] ) |
---|
| 2034 | { |
---|
| 2035 | repDepth8x4[1] = refDepthTmp[3][x+offset[3]]; |
---|
| 2036 | } |
---|
| 2037 | |
---|
| 2038 | depthTmp = &depth[x]; |
---|
| 2039 | for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY ) |
---|
| 2040 | { |
---|
| 2041 | for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX ) |
---|
| 2042 | { |
---|
| 2043 | depthTmp[sX] = repDepth8x4[0]; |
---|
| 2044 | } |
---|
| 2045 | depthTmp += depStrideTmp; |
---|
| 2046 | } |
---|
| 2047 | for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY ) |
---|
| 2048 | { |
---|
| 2049 | for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX ) |
---|
| 2050 | { |
---|
| 2051 | depthTmp[sX] = repDepth8x4[1]; |
---|
| 2052 | } |
---|
| 2053 | depthTmp += depStrideTmp; |
---|
| 2054 | } |
---|
| 2055 | } |
---|
[189] | 2056 | } |
---|
[608] | 2057 | refDepthTmp[0] += refDepStrideBlock; |
---|
| 2058 | refDepthTmp[1] += refDepStrideBlock; |
---|
| 2059 | refDepthTmp[2] += refDepStrideBlock; |
---|
| 2060 | refDepthTmp[3] += refDepStrideBlock; |
---|
| 2061 | depth += depStrideBlock; |
---|
| 2062 | } |
---|
[724] | 2063 | #endif // SHARP_VSP_BLOCK_IN_AMP_F0102 |
---|
| 2064 | #else |
---|
| 2065 | #if SHARP_VSP_BLOCK_IN_AMP_F0102 |
---|
| 2066 | if ((height % 8)) |
---|
| 2067 | { |
---|
| 2068 | vspSize = 1; // 8x4 |
---|
[608] | 2069 | } |
---|
[724] | 2070 | else if ((width % 8)) |
---|
| 2071 | { |
---|
| 2072 | vspSize = 0; // 4x8 |
---|
| 2073 | } |
---|
| 2074 | else |
---|
| 2075 | { |
---|
| 2076 | Bool ULvsBR, URvsBL; |
---|
| 2077 | ULvsBR = refDepth[0] < refDepth[refDepStride * (height-1) + width-1]; |
---|
| 2078 | URvsBL = refDepth[width-1] < refDepth[refDepStride * (height-1)]; |
---|
| 2079 | vspSize = ( ULvsBR ^ URvsBL ) ? 0 : 1; |
---|
| 2080 | } |
---|
| 2081 | Int subBlockW, subBlockH; |
---|
| 2082 | Int depStrideTmp = depStride * nTxtPerDepthY; |
---|
| 2083 | if (vspSize) |
---|
| 2084 | { |
---|
| 2085 | subBlockW = 8; |
---|
| 2086 | subBlockH = 4; |
---|
| 2087 | } |
---|
| 2088 | else |
---|
| 2089 | { |
---|
| 2090 | subBlockW = 4; |
---|
| 2091 | subBlockH = 8; |
---|
| 2092 | } |
---|
| 2093 | for( Int y=0; y<height; y+=subBlockH ) |
---|
| 2094 | { |
---|
| 2095 | Pel *refDepthTmp[4]; |
---|
| 2096 | refDepthTmp[0] = refDepth + refDepStride * y; |
---|
| 2097 | refDepthTmp[1] = refDepthTmp[0] + subBlockW - 1; |
---|
| 2098 | refDepthTmp[2] = refDepthTmp[0] + refDepStride * (subBlockH - 1); |
---|
| 2099 | refDepthTmp[3] = refDepthTmp[2] + subBlockW - 1; |
---|
| 2100 | for( Int x=0; x<width; x+=subBlockW ) |
---|
| 2101 | { |
---|
| 2102 | Pel maxDepthVal; |
---|
| 2103 | maxDepthVal = refDepthTmp[0][x]; |
---|
| 2104 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[1][x]); |
---|
| 2105 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[2][x]); |
---|
| 2106 | maxDepthVal = std::max( maxDepthVal, refDepthTmp[3][x]); |
---|
| 2107 | Pel *depthTmp = &depth[x+y*depStride]; |
---|
| 2108 | for( Int sY=0; sY<subBlockH; sY+=nTxtPerDepthY ) |
---|
| 2109 | { |
---|
| 2110 | for( Int sX=0; sX<subBlockW; sX+=nTxtPerDepthX ) |
---|
| 2111 | { |
---|
| 2112 | depthTmp[sX] = maxDepthVal; |
---|
| 2113 | } |
---|
| 2114 | depthTmp += depStrideTmp; |
---|
| 2115 | } |
---|
| 2116 | } |
---|
| 2117 | } |
---|
| 2118 | #else // SHARP_VSP_BLOCK_IN_AMP_F0102 |
---|
| 2119 | Int refDepStrideBlock = refDepStride * height; |
---|
| 2120 | Int refDepStrideSubBlock = refDepStride * height/2; |
---|
| 2121 | refDepthTmp[0] = refDepth; |
---|
| 2122 | refDepthTmp[2] = refDepthTmp[0] + refDepStrideSubBlock; |
---|
| 2123 | refDepthTmp[1] = refDepthTmp[2] - refDepStride; |
---|
| 2124 | refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock; |
---|
| 2125 | offset[3] = width-1; |
---|
| 2126 | Bool ULvsBR = false, URvsBL = false; |
---|
| 2127 | ULvsBR = refDepthTmp[0][0+offset[0]] < refDepthTmp[3][0+offset[3]]; |
---|
| 2128 | URvsBL = refDepthTmp[0][0+offset[3]] < refDepthTmp[3][0+offset[0]]; |
---|
| 2129 | refDepStrideBlock = refDepStride * blocksize; |
---|
| 2130 | refDepStrideSubBlock = refDepStride * subblocksize; |
---|
| 2131 | refDepthTmp[0] = refDepth; |
---|
| 2132 | refDepthTmp[2] = refDepthTmp[0] + refDepStrideSubBlock; |
---|
| 2133 | refDepthTmp[1] = refDepthTmp[2] - refDepStride; |
---|
| 2134 | refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock; |
---|
| 2135 | offset[3] = blocksize-1; |
---|
| 2136 | if( ULvsBR ^ URvsBL ) |
---|
| 2137 | { |
---|
| 2138 | vspSize = 0;//4x8 |
---|
| 2139 | for( Int y=0; y<height; y+=blocksize ) |
---|
| 2140 | { |
---|
| 2141 | for( Int x=0; x<width; x+=blocksize ) |
---|
| 2142 | { |
---|
| 2143 | { // 4x8 |
---|
| 2144 | repDepth4x8[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[1]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[1]]; |
---|
| 2145 | if( repDepth4x8[0] < refDepthTmp[3][x+offset[0]] ) |
---|
| 2146 | { |
---|
| 2147 | repDepth4x8[0] = refDepthTmp[3][x+offset[0]]; |
---|
| 2148 | } |
---|
| 2149 | if( repDepth4x8[0] < refDepthTmp[3][x+offset[1]] ) |
---|
| 2150 | { |
---|
| 2151 | repDepth4x8[0] = refDepthTmp[3][x+offset[1]]; |
---|
| 2152 | } |
---|
| 2153 | repDepth4x8[1] = refDepthTmp[0][x+offset[2]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[2]] : refDepthTmp[0][x+offset[3]]; |
---|
| 2154 | if( repDepth4x8[1] < refDepthTmp[3][x+offset[2]] ) |
---|
| 2155 | { |
---|
| 2156 | repDepth4x8[1] = refDepthTmp[3][x+offset[2]]; |
---|
| 2157 | } |
---|
| 2158 | if( repDepth4x8[1] < refDepthTmp[3][x+offset[3]] ) |
---|
| 2159 | { |
---|
| 2160 | repDepth4x8[1] = refDepthTmp[3][x+offset[3]]; |
---|
| 2161 | } |
---|
[189] | 2162 | |
---|
[724] | 2163 | depthTmp = &depth[x]; |
---|
| 2164 | for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY ) |
---|
| 2165 | { |
---|
| 2166 | for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX ) |
---|
| 2167 | { |
---|
| 2168 | depthTmp[sX] = repDepth4x8[0]; |
---|
| 2169 | } |
---|
| 2170 | depthTmp += depStrideTmp; |
---|
| 2171 | } |
---|
| 2172 | depthTmp = &depth[x+subblocksize]; |
---|
| 2173 | for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY ) |
---|
| 2174 | { |
---|
| 2175 | for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX ) |
---|
| 2176 | { |
---|
| 2177 | depthTmp[sX] = repDepth4x8[1]; |
---|
| 2178 | } |
---|
| 2179 | depthTmp += depStrideTmp; |
---|
| 2180 | } |
---|
| 2181 | } |
---|
| 2182 | } |
---|
| 2183 | refDepthTmp[0] += refDepStrideBlock; |
---|
| 2184 | refDepthTmp[1] += refDepStrideBlock; |
---|
| 2185 | refDepthTmp[2] += refDepStrideBlock; |
---|
| 2186 | refDepthTmp[3] += refDepStrideBlock; |
---|
| 2187 | depth += depStrideBlock; |
---|
| 2188 | } |
---|
| 2189 | } |
---|
| 2190 | else |
---|
| 2191 | { // 8x4 |
---|
| 2192 | vspSize = 1; |
---|
| 2193 | for( Int y=0; y<height; y+=blocksize ) |
---|
| 2194 | { |
---|
| 2195 | for( Int x=0; x<width; x+=blocksize ) |
---|
| 2196 | { |
---|
| 2197 | repDepth8x4[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[3]]; |
---|
| 2198 | if( repDepth8x4[0] < refDepthTmp[1][x+offset[0]] ) |
---|
| 2199 | { |
---|
| 2200 | repDepth8x4[0] = refDepthTmp[1][x+offset[0]]; |
---|
| 2201 | } |
---|
| 2202 | if( repDepth8x4[0] < refDepthTmp[1][x+offset[3]] ) |
---|
| 2203 | { |
---|
| 2204 | repDepth8x4[0] = refDepthTmp[1][x+offset[3]]; |
---|
| 2205 | } |
---|
| 2206 | repDepth8x4[1] = refDepthTmp[2][x+offset[0]] > refDepthTmp[2][x+offset[3]] ? refDepthTmp[2][x+offset[0]] : refDepthTmp[2][x+offset[3]]; |
---|
| 2207 | if( repDepth8x4[1] < refDepthTmp[3][x+offset[0]] ) |
---|
| 2208 | { |
---|
| 2209 | repDepth8x4[1] = refDepthTmp[3][x+offset[0]]; |
---|
| 2210 | } |
---|
| 2211 | if( repDepth8x4[1] < refDepthTmp[3][x+offset[3]] ) |
---|
| 2212 | { |
---|
| 2213 | repDepth8x4[1] = refDepthTmp[3][x+offset[3]]; |
---|
| 2214 | } |
---|
[189] | 2215 | |
---|
[724] | 2216 | depthTmp = &depth[x]; |
---|
| 2217 | for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY ) |
---|
| 2218 | { |
---|
| 2219 | for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX ) |
---|
| 2220 | { |
---|
| 2221 | depthTmp[sX] = repDepth8x4[0]; |
---|
| 2222 | } |
---|
| 2223 | depthTmp += depStrideTmp; |
---|
| 2224 | } |
---|
| 2225 | for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY ) |
---|
| 2226 | { |
---|
| 2227 | for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX ) |
---|
| 2228 | { |
---|
| 2229 | depthTmp[sX] = repDepth8x4[1]; |
---|
| 2230 | } |
---|
| 2231 | depthTmp += depStrideTmp; |
---|
[608] | 2232 | } |
---|
[724] | 2233 | } |
---|
| 2234 | refDepthTmp[0] += refDepStrideBlock; |
---|
| 2235 | refDepthTmp[1] += refDepStrideBlock; |
---|
| 2236 | refDepthTmp[2] += refDepStrideBlock; |
---|
| 2237 | refDepthTmp[3] += refDepStrideBlock; |
---|
| 2238 | depth += depStrideBlock; |
---|
| 2239 | } |
---|
| 2240 | } |
---|
| 2241 | #endif |
---|
| 2242 | #endif |
---|
| 2243 | #if !SHARP_VSP_BLOCK_IN_AMP_F0102 |
---|
| 2244 | } |
---|
| 2245 | #endif |
---|
[608] | 2246 | |
---|
[724] | 2247 | |
---|
| 2248 | } |
---|
| 2249 | #if MTK_F0109_LG_F0120_VSP_BLOCK |
---|
| 2250 | 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) |
---|
| 2251 | #else |
---|
[608] | 2252 | 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 ) |
---|
[724] | 2253 | #endif |
---|
[608] | 2254 | { |
---|
| 2255 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE; |
---|
| 2256 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE; |
---|
| 2257 | |
---|
[724] | 2258 | #if MTK_F0109_LG_F0120_VSP_BLOCK |
---|
| 2259 | nTxtPerDepthX = nTxtPerDepthX << vspSize; |
---|
| 2260 | nTxtPerDepthY = nTxtPerDepthY << (1-vspSize); |
---|
| 2261 | #endif |
---|
[608] | 2262 | Int refStride = picRef->getStride(); |
---|
| 2263 | Int dstStride = yuvDst->getStride(); |
---|
| 2264 | Int depStride = yuvDepth->getStride(); |
---|
| 2265 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
| 2266 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
| 2267 | Int depStrideBlock = depStride * nTxtPerDepthY; |
---|
| 2268 | |
---|
| 2269 | Pel *ref = picRef->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
| 2270 | Pel *dst = yuvDst->getLumaAddr(partAddr); |
---|
| 2271 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
| 2272 | |
---|
| 2273 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2274 | #if H_3D_VSP_CONSTRAINED |
---|
| 2275 | //get LUT based horizontal reference range |
---|
| 2276 | Int range = xGetConstrainedSize(width, height); |
---|
| 2277 | |
---|
| 2278 | // The minimum depth value |
---|
| 2279 | Int minRelativePos = MAX_INT; |
---|
| 2280 | Int maxRelativePos = MIN_INT; |
---|
| 2281 | |
---|
| 2282 | Pel* depthTemp, *depthInitial=depth; |
---|
| 2283 | for (Int yTxt = 0; yTxt < height; yTxt++) |
---|
| 2284 | { |
---|
| 2285 | for (Int xTxt = 0; xTxt < width; xTxt++) |
---|
| 2286 | { |
---|
| 2287 | if (depthPosX+xTxt < widthDepth) |
---|
[189] | 2288 | { |
---|
[608] | 2289 | depthTemp = depthInitial + xTxt; |
---|
[189] | 2290 | } |
---|
| 2291 | else |
---|
| 2292 | { |
---|
[608] | 2293 | depthTemp = depthInitial + (widthDepth - depthPosX - 1); |
---|
[189] | 2294 | } |
---|
| 2295 | |
---|
[608] | 2296 | Int disparity = shiftLUT[ *depthTemp ]; // << iShiftPrec; |
---|
| 2297 | Int disparityInt = disparity >> 2; |
---|
[189] | 2298 | |
---|
[608] | 2299 | if( disparity <= 0) |
---|
[189] | 2300 | { |
---|
[608] | 2301 | if (minRelativePos > disparityInt+xTxt) |
---|
| 2302 | { |
---|
| 2303 | minRelativePos = disparityInt+xTxt; |
---|
| 2304 | } |
---|
[189] | 2305 | } |
---|
| 2306 | else |
---|
| 2307 | { |
---|
[608] | 2308 | if (maxRelativePos < disparityInt+xTxt) |
---|
| 2309 | { |
---|
| 2310 | maxRelativePos = disparityInt+xTxt; |
---|
| 2311 | } |
---|
[189] | 2312 | } |
---|
| 2313 | } |
---|
[608] | 2314 | if (depthPosY+yTxt < heightDepth) |
---|
| 2315 | { |
---|
| 2316 | depthInitial = depthInitial + depStride; |
---|
| 2317 | } |
---|
| 2318 | } |
---|
[56] | 2319 | |
---|
[608] | 2320 | Int disparity_tmp = shiftLUT[ *depth ]; // << iShiftPrec; |
---|
| 2321 | if (disparity_tmp <= 0) |
---|
[56] | 2322 | { |
---|
[608] | 2323 | maxRelativePos = minRelativePos + range -1 ; |
---|
[56] | 2324 | } |
---|
[608] | 2325 | else |
---|
[56] | 2326 | { |
---|
[608] | 2327 | minRelativePos = maxRelativePos - range +1 ; |
---|
[56] | 2328 | } |
---|
[608] | 2329 | #endif |
---|
| 2330 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
[56] | 2331 | |
---|
[608] | 2332 | TComMv dv(0, 0); |
---|
[56] | 2333 | |
---|
[608] | 2334 | for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY ) |
---|
| 2335 | { |
---|
| 2336 | for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX ) |
---|
| 2337 | { |
---|
| 2338 | Pel repDepth = depth[ xTxt ]; |
---|
| 2339 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
| 2340 | |
---|
| 2341 | Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec ?? |
---|
| 2342 | Int xFrac = disparity & 0x3; |
---|
| 2343 | |
---|
| 2344 | dv.setHor( disparity ); |
---|
| 2345 | cu->clipMv( dv ); |
---|
| 2346 | |
---|
| 2347 | Int refOffset = xTxt + (dv.getHor() >> 2); |
---|
| 2348 | |
---|
| 2349 | #if H_3D_VSP_CONSTRAINED |
---|
| 2350 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
| 2351 | { |
---|
| 2352 | xFrac = 0; |
---|
| 2353 | } |
---|
| 2354 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
[5] | 2355 | #endif |
---|
[608] | 2356 | |
---|
| 2357 | assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 ); |
---|
| 2358 | m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
| 2359 | } |
---|
| 2360 | ref += refStrideBlock; |
---|
| 2361 | dst += dstStrideBlock; |
---|
| 2362 | depth += depStrideBlock; |
---|
[443] | 2363 | } |
---|
| 2364 | |
---|
| 2365 | } |
---|
[608] | 2366 | |
---|
[724] | 2367 | #if MTK_F0109_LG_F0120_VSP_BLOCK |
---|
| 2368 | 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) |
---|
| 2369 | #else |
---|
[608] | 2370 | 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 ) |
---|
[724] | 2371 | #endif |
---|
[608] | 2372 | { |
---|
| 2373 | #if (H_3D_VSP_BLOCKSIZE==1) |
---|
| 2374 | Int nTxtPerDepthX = 1; |
---|
| 2375 | Int nTxtPerDepthY = 1; |
---|
[443] | 2376 | #else |
---|
[608] | 2377 | Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE >> 1; |
---|
| 2378 | Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE >> 1; |
---|
| 2379 | #endif |
---|
[2] | 2380 | |
---|
[724] | 2381 | #if MTK_F0109_LG_F0120_VSP_BLOCK |
---|
| 2382 | nTxtPerDepthX = nTxtPerDepthX << vspSize; |
---|
| 2383 | nTxtPerDepthY = nTxtPerDepthY << (1-vspSize); |
---|
| 2384 | #endif |
---|
[608] | 2385 | Int refStride = picRef->getCStride(); |
---|
| 2386 | Int dstStride = yuvDst->getCStride(); |
---|
| 2387 | Int depStride = yuvDepth->getStride(); |
---|
| 2388 | Int refStrideBlock = refStride * nTxtPerDepthY; |
---|
| 2389 | Int dstStrideBlock = dstStride * nTxtPerDepthY; |
---|
| 2390 | Int depStrideBlock = depStride * (nTxtPerDepthY<<1); |
---|
[2] | 2391 | |
---|
[608] | 2392 | Pel *refCb = picRef->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
| 2393 | Pel *refCr = picRef->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ); |
---|
| 2394 | Pel *dstCb = yuvDst->getCbAddr(partAddr); |
---|
| 2395 | Pel *dstCr = yuvDst->getCrAddr(partAddr); |
---|
| 2396 | Pel *depth = yuvDepth->getLumaAddr(); |
---|
[56] | 2397 | |
---|
[608] | 2398 | #if H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2399 | #if H_3D_VSP_CONSTRAINED |
---|
| 2400 | //get LUT based horizontal reference range |
---|
| 2401 | Int range = xGetConstrainedSize(width, height, false); |
---|
[296] | 2402 | |
---|
[608] | 2403 | // The minimum depth value |
---|
| 2404 | Int minRelativePos = MAX_INT; |
---|
| 2405 | Int maxRelativePos = MIN_INT; |
---|
| 2406 | |
---|
| 2407 | Int depthTmp; |
---|
| 2408 | for (Int yTxt=0; yTxt<height; yTxt++) |
---|
[56] | 2409 | { |
---|
[608] | 2410 | for (Int xTxt=0; xTxt<width; xTxt++) |
---|
[56] | 2411 | { |
---|
[608] | 2412 | depthTmp = m_pDepthBlock[xTxt+yTxt*width]; |
---|
| 2413 | Int disparity = shiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
| 2414 | Int disparityInt = disparity >> 3;//in chroma resolution |
---|
| 2415 | |
---|
| 2416 | if (disparityInt < 0) |
---|
[56] | 2417 | { |
---|
[608] | 2418 | if (minRelativePos > disparityInt+xTxt) |
---|
| 2419 | { |
---|
| 2420 | minRelativePos = disparityInt+xTxt; |
---|
| 2421 | } |
---|
[56] | 2422 | } |
---|
| 2423 | else |
---|
| 2424 | { |
---|
[608] | 2425 | if (maxRelativePos < disparityInt+xTxt) |
---|
| 2426 | { |
---|
| 2427 | maxRelativePos = disparityInt+xTxt; |
---|
| 2428 | } |
---|
[56] | 2429 | } |
---|
| 2430 | } |
---|
| 2431 | } |
---|
| 2432 | |
---|
[608] | 2433 | depthTmp = m_pDepthBlock[0]; |
---|
| 2434 | Int disparity_tmp = shiftLUT[ depthTmp ]; // << iShiftPrec; |
---|
| 2435 | if ( disparity_tmp < 0 ) |
---|
[56] | 2436 | { |
---|
[608] | 2437 | maxRelativePos = minRelativePos + range - 1; |
---|
[56] | 2438 | } |
---|
[608] | 2439 | else |
---|
[56] | 2440 | { |
---|
[608] | 2441 | minRelativePos = maxRelativePos - range + 1; |
---|
[56] | 2442 | } |
---|
[2] | 2443 | |
---|
[608] | 2444 | #endif // H_3D_VSP_CONSTRAINED |
---|
| 2445 | #endif // H_3D_VSP_BLOCKSIZE == 1 |
---|
| 2446 | |
---|
| 2447 | TComMv dv(0, 0); |
---|
| 2448 | // luma size -> chroma size |
---|
| 2449 | height >>= 1; |
---|
| 2450 | width >>= 1; |
---|
| 2451 | |
---|
| 2452 | for ( Int yTxt = 0; yTxt < height; yTxt += nTxtPerDepthY ) |
---|
[5] | 2453 | { |
---|
[608] | 2454 | for ( Int xTxt = 0; xTxt < width; xTxt += nTxtPerDepthX ) |
---|
[5] | 2455 | { |
---|
[608] | 2456 | Pel repDepth = depth[ xTxt<<1 ]; |
---|
| 2457 | assert( repDepth >= 0 && repDepth <= 255 ); |
---|
| 2458 | |
---|
| 2459 | Int disparity = shiftLUT[ repDepth ]; // remove << iShiftPrec; |
---|
| 2460 | Int xFrac = disparity & 0x7; |
---|
| 2461 | |
---|
| 2462 | dv.setHor( disparity ); |
---|
| 2463 | cu->clipMv( dv ); |
---|
| 2464 | |
---|
| 2465 | Int refOffset = xTxt + (dv.getHor() >> 3); |
---|
| 2466 | |
---|
| 2467 | #if H_3D_VSP_CONSTRAINED |
---|
| 2468 | if(refOffset<minRelativePos || refOffset>maxRelativePos) |
---|
[5] | 2469 | { |
---|
[608] | 2470 | xFrac = 0; |
---|
[5] | 2471 | } |
---|
[608] | 2472 | refOffset = Clip3(minRelativePos, maxRelativePos, refOffset); |
---|
| 2473 | #endif |
---|
| 2474 | |
---|
| 2475 | assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 ); |
---|
| 2476 | assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 ); |
---|
| 2477 | |
---|
| 2478 | m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
| 2479 | m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi ); |
---|
[5] | 2480 | } |
---|
[608] | 2481 | refCb += refStrideBlock; |
---|
| 2482 | refCr += refStrideBlock; |
---|
| 2483 | dstCb += dstStrideBlock; |
---|
| 2484 | dstCr += dstStrideBlock; |
---|
| 2485 | depth += depStrideBlock; |
---|
[5] | 2486 | } |
---|
| 2487 | } |
---|
[2] | 2488 | |
---|
[5] | 2489 | |
---|
[608] | 2490 | #if H_3D_VSP_CONSTRAINED |
---|
| 2491 | Int TComPrediction::xGetConstrainedSize(Int nPbW, Int nPbH, Bool bLuma) |
---|
[56] | 2492 | { |
---|
[608] | 2493 | Int iSize = 0; |
---|
| 2494 | if (bLuma) |
---|
[2] | 2495 | { |
---|
[608] | 2496 | Int iArea = (nPbW+7) * (nPbH+7); |
---|
| 2497 | Int iAlpha = iArea / nPbH - nPbW - 7; |
---|
| 2498 | iSize = iAlpha + nPbW; |
---|
[2] | 2499 | } |
---|
[608] | 2500 | else // chroma |
---|
| 2501 | { |
---|
| 2502 | Int iArea = (nPbW+2) * (nPbH+2); |
---|
| 2503 | Int iAlpha = iArea / nPbH - nPbW - 4; |
---|
| 2504 | iSize = iAlpha + nPbW; |
---|
| 2505 | } |
---|
| 2506 | return iSize; |
---|
[2] | 2507 | } |
---|
[608] | 2508 | #endif // H_3D_VSP_CONSTRAINED |
---|
[2] | 2509 | |
---|
[608] | 2510 | #endif // H_3D_VSP |
---|
| 2511 | |
---|
| 2512 | #if H_3D_DIM |
---|
| 2513 | Void TComPrediction::xPredBiSegDCs( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ) |
---|
[2] | 2514 | { |
---|
[608] | 2515 | Int refDC1, refDC2; |
---|
| 2516 | const Int iTR = ( patternStride - 1 ) - srcStride; |
---|
| 2517 | const Int iTM = ( ( patternStride - 1 ) >> 1 ) - srcStride; |
---|
| 2518 | const Int iLB = ( patternStride - 1 ) * srcStride - 1; |
---|
| 2519 | const Int iLM = ( ( patternStride - 1 ) >> 1 ) * srcStride - 1; |
---|
[2] | 2520 | |
---|
[608] | 2521 | Bool bL = ( biSegPattern[0] != biSegPattern[(patternStride-1)*patternStride] ); |
---|
| 2522 | Bool bT = ( biSegPattern[0] != biSegPattern[(patternStride-1)] ); |
---|
| 2523 | |
---|
| 2524 | if( bL == bT ) |
---|
[56] | 2525 | { |
---|
[608] | 2526 | refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : 1<<( g_bitDepthY - 1 ); |
---|
| 2527 | refDC2 = ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1; |
---|
[56] | 2528 | } |
---|
| 2529 | else |
---|
| 2530 | { |
---|
[608] | 2531 | refDC1 = bL ? ptrSrc[iLB] : ptrSrc[iTR]; |
---|
| 2532 | refDC2 = bL ? ptrSrc[iTM] : ptrSrc[iLM]; |
---|
[56] | 2533 | } |
---|
| 2534 | |
---|
[608] | 2535 | predDC1 = biSegPattern[0] ? refDC1 : refDC2; |
---|
| 2536 | predDC2 = biSegPattern[0] ? refDC2 : refDC1; |
---|
[2] | 2537 | } |
---|
| 2538 | |
---|
[608] | 2539 | Void TComPrediction::xAssignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 ) |
---|
[56] | 2540 | { |
---|
[608] | 2541 | if( dstStride == patternStride ) |
---|
| 2542 | { |
---|
| 2543 | for( UInt k = 0; k < (patternStride * patternStride); k++ ) |
---|
| 2544 | { |
---|
| 2545 | if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; } |
---|
| 2546 | else { ptrDst[k] = valDC1; } |
---|
| 2547 | } |
---|
[443] | 2548 | } |
---|
[608] | 2549 | else |
---|
| 2550 | { |
---|
| 2551 | Pel* piTemp = ptrDst; |
---|
| 2552 | for( UInt uiY = 0; uiY < patternStride; uiY++ ) |
---|
| 2553 | { |
---|
| 2554 | for( UInt uiX = 0; uiX < patternStride; uiX++ ) |
---|
| 2555 | { |
---|
| 2556 | if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; } |
---|
| 2557 | else { piTemp[uiX] = valDC1; } |
---|
| 2558 | } |
---|
| 2559 | piTemp += dstStride; |
---|
| 2560 | biSegPattern += patternStride; |
---|
| 2561 | } |
---|
[443] | 2562 | } |
---|
[56] | 2563 | } |
---|
| 2564 | |
---|
[608] | 2565 | #if H_3D_DIM_DMM |
---|
[724] | 2566 | #if !SEC_DMM3_RBC_F0147 |
---|
[608] | 2567 | UInt TComPrediction::xPredWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx ) |
---|
[56] | 2568 | { |
---|
[608] | 2569 | TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); |
---|
| 2570 | assert( pcPicTex != NULL ); |
---|
| 2571 | TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); |
---|
| 2572 | UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 2573 | Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; |
---|
[56] | 2574 | |
---|
[622] | 2575 | assert( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ); |
---|
| 2576 | return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx); |
---|
[56] | 2577 | } |
---|
[724] | 2578 | #endif |
---|
[56] | 2579 | |
---|
[608] | 2580 | Void TComPrediction::xPredContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) |
---|
[56] | 2581 | { |
---|
[608] | 2582 | pcContourWedge->clear(); |
---|
[56] | 2583 | |
---|
[608] | 2584 | // get copy of co-located texture luma block |
---|
| 2585 | TComYuv cTempYuv; |
---|
| 2586 | cTempYuv.create( uiWidth, uiHeight ); |
---|
| 2587 | cTempYuv.clear(); |
---|
| 2588 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2589 | xCopyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
| 2590 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
[56] | 2591 | |
---|
[608] | 2592 | // find contour for texture luma block |
---|
| 2593 | UInt iDC = 0; |
---|
| 2594 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
| 2595 | { |
---|
| 2596 | iDC += piRefBlkY[k]; |
---|
| 2597 | } |
---|
| 2598 | |
---|
[655] | 2599 | Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2; // |
---|
| 2600 | iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2; // iDC /= (uiWidth*uiHeight); |
---|
| 2601 | |
---|
[608] | 2602 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
[56] | 2603 | |
---|
[608] | 2604 | Bool* pabContourPattern = pcContourWedge->getPattern(); |
---|
| 2605 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
[443] | 2606 | { |
---|
[608] | 2607 | pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; |
---|
[443] | 2608 | } |
---|
[608] | 2609 | |
---|
| 2610 | cTempYuv.destroy(); |
---|
[56] | 2611 | } |
---|
| 2612 | |
---|
[608] | 2613 | |
---|
| 2614 | Void TComPrediction::xCopyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) |
---|
[56] | 2615 | { |
---|
[608] | 2616 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
| 2617 | assert( pcPicYuvRef != NULL ); |
---|
| 2618 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
| 2619 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
[56] | 2620 | |
---|
[608] | 2621 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
[56] | 2622 | { |
---|
[608] | 2623 | ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); |
---|
| 2624 | piDestBlockY += uiWidth; |
---|
| 2625 | piRefY += iRefStride; |
---|
[56] | 2626 | } |
---|
| 2627 | } |
---|
[655] | 2628 | #endif |
---|
[56] | 2629 | |
---|
[608] | 2630 | #if H_3D_DIM_RBC |
---|
| 2631 | Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Pel& rDeltaDC ) |
---|
| 2632 | { |
---|
| 2633 | Int iSign = rDeltaDC < 0 ? -1 : 1; |
---|
| 2634 | UInt uiAbs = abs( rDeltaDC ); |
---|
[2] | 2635 | |
---|
[608] | 2636 | Int iQp = pcCU->getQP(0); |
---|
| 2637 | Double dMax = (Double)( 1<<( g_bitDepthY - 1 ) ); |
---|
| 2638 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 - 2.0 ) ); |
---|
| 2639 | |
---|
| 2640 | rDeltaDC = iSign * roftoi( uiAbs * dStepSize ); |
---|
| 2641 | return; |
---|
[2] | 2642 | } |
---|
| 2643 | |
---|
[608] | 2644 | Void TComPrediction::xDeltaDCQuantScaleDown( TComDataCU* pcCU, Pel& rDeltaDC ) |
---|
[2] | 2645 | { |
---|
[608] | 2646 | Int iSign = rDeltaDC < 0 ? -1 : 1; |
---|
| 2647 | UInt uiAbs = abs( rDeltaDC ); |
---|
| 2648 | |
---|
| 2649 | Int iQp = pcCU->getQP(0); |
---|
| 2650 | Double dMax = (Double)( 1<<( g_bitDepthY - 1 ) ); |
---|
| 2651 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 - 2.0 ) ); |
---|
| 2652 | |
---|
| 2653 | rDeltaDC = iSign * roftoi( uiAbs / dStepSize ); |
---|
| 2654 | return; |
---|
| 2655 | } |
---|
| 2656 | #endif |
---|
| 2657 | #if H_3D_DIM_SDC |
---|
| 2658 | Void TComPrediction::analyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride |
---|
| 2659 | ,UInt uiIntraMode |
---|
| 2660 | ,Bool orgDC |
---|
| 2661 | ) |
---|
| 2662 | { |
---|
| 2663 | Int iSumDepth[2]; |
---|
| 2664 | memset(iSumDepth, 0, sizeof(Int)*2); |
---|
| 2665 | Int iSumPix[2]; |
---|
| 2666 | memset(iSumPix, 0, sizeof(Int)*2); |
---|
| 2667 | |
---|
| 2668 | if (orgDC == false) |
---|
[2] | 2669 | { |
---|
[608] | 2670 | if ( getDimType(uiIntraMode) == DMM1_IDX ) |
---|
| 2671 | { |
---|
| 2672 | UChar ucSegmentLT = pMask[0]; |
---|
| 2673 | UChar ucSegmentRT = pMask[uiSize-1]; |
---|
| 2674 | UChar ucSegmentLB = pMask[uiMaskStride * (uiSize-1)]; |
---|
| 2675 | UChar ucSegmentRB = pMask[uiMaskStride * (uiSize-1) + (uiSize-1)]; |
---|
| 2676 | |
---|
| 2677 | rpSegMeans[ucSegmentLT] = pOrig[0]; |
---|
| 2678 | rpSegMeans[ucSegmentRT] = pOrig[uiSize-1]; |
---|
| 2679 | rpSegMeans[ucSegmentLB] = pOrig[uiStride * (uiSize-1) ]; |
---|
| 2680 | rpSegMeans[ucSegmentRB] = pOrig[uiStride * (uiSize-1) + (uiSize-1) ]; |
---|
| 2681 | } |
---|
| 2682 | else if (uiIntraMode == PLANAR_IDX) |
---|
| 2683 | { |
---|
| 2684 | Pel* pLeftTop = pOrig; |
---|
| 2685 | Pel* pRightTop = pOrig + (uiSize-1); |
---|
| 2686 | Pel* pLeftBottom = (pOrig+ (uiStride*(uiSize-1))); |
---|
| 2687 | Pel* pRightBottom = (pOrig+ (uiStride*(uiSize-1)) + (uiSize-1)); |
---|
| 2688 | |
---|
| 2689 | rpSegMeans[0] = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2; |
---|
| 2690 | } |
---|
| 2691 | return; |
---|
[2] | 2692 | } |
---|
[608] | 2693 | |
---|
| 2694 | Int subSamplePix; |
---|
| 2695 | if ( uiSize == 64 || uiSize == 32 ) |
---|
[2] | 2696 | { |
---|
[608] | 2697 | subSamplePix = 2; |
---|
[2] | 2698 | } |
---|
[608] | 2699 | else |
---|
[2] | 2700 | { |
---|
[608] | 2701 | subSamplePix = 1; |
---|
[2] | 2702 | } |
---|
[608] | 2703 | for (Int y=0; y<uiSize; y+=subSamplePix) |
---|
[2] | 2704 | { |
---|
[608] | 2705 | for (Int x=0; x<uiSize; x+=subSamplePix) |
---|
| 2706 | { |
---|
| 2707 | UChar ucSegment = pMask?(UChar)pMask[x]:0; |
---|
| 2708 | assert( ucSegment < uiNumSegments ); |
---|
| 2709 | |
---|
| 2710 | iSumDepth[ucSegment] += pOrig[x]; |
---|
| 2711 | iSumPix[ucSegment] += 1; |
---|
| 2712 | } |
---|
| 2713 | |
---|
| 2714 | pOrig += uiStride*subSamplePix; |
---|
| 2715 | pMask += uiMaskStride*subSamplePix; |
---|
[2] | 2716 | } |
---|
[608] | 2717 | |
---|
| 2718 | // compute mean for each segment |
---|
| 2719 | for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ ) |
---|
[2] | 2720 | { |
---|
[608] | 2721 | if( iSumPix[ucSeg] > 0 ) |
---|
| 2722 | rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg]; |
---|
| 2723 | else |
---|
| 2724 | rpSegMeans[ucSeg] = 0; // this happens for zero-segments |
---|
[2] | 2725 | } |
---|
| 2726 | } |
---|
[608] | 2727 | #endif // H_3D_DIM_SDC |
---|
| 2728 | #endif |
---|
[56] | 2729 | //! \} |
---|