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