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