[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 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, 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 | |
---|
[189] | 48 | #if LGE_EDGE_INTRA_A0070 |
---|
[100] | 49 | #define MAX_DISTANCE_EDGEINTRA 255 |
---|
| 50 | #endif |
---|
| 51 | |
---|
[2] | 52 | TComPrediction::TComPrediction() |
---|
| 53 | : m_pLumaRecBuffer(0) |
---|
| 54 | { |
---|
| 55 | m_piYuvExt = NULL; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | TComPrediction::~TComPrediction() |
---|
| 59 | { |
---|
[56] | 60 | |
---|
[2] | 61 | delete[] m_piYuvExt; |
---|
| 62 | |
---|
| 63 | m_acYuvPred[0].destroy(); |
---|
| 64 | m_acYuvPred[1].destroy(); |
---|
| 65 | |
---|
| 66 | m_cYuvPredTemp.destroy(); |
---|
| 67 | |
---|
| 68 | if( m_pLumaRecBuffer ) |
---|
[56] | 69 | { |
---|
| 70 | delete [] m_pLumaRecBuffer; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | Int i, j; |
---|
| 74 | for (i = 0; i < 4; i++) |
---|
| 75 | { |
---|
| 76 | for (j = 0; j < 4; j++) |
---|
| 77 | { |
---|
| 78 | m_filteredBlock[i][j].destroy(); |
---|
| 79 | } |
---|
| 80 | m_filteredBlockTmp[i].destroy(); |
---|
| 81 | } |
---|
[2] | 82 | } |
---|
| 83 | |
---|
| 84 | Void TComPrediction::initTempBuff() |
---|
| 85 | { |
---|
| 86 | if( m_piYuvExt == NULL ) |
---|
| 87 | { |
---|
[56] | 88 | Int extWidth = g_uiMaxCUWidth + 16; |
---|
| 89 | Int extHeight = g_uiMaxCUHeight + 1; |
---|
| 90 | Int i, j; |
---|
| 91 | for (i = 0; i < 4; i++) |
---|
| 92 | { |
---|
| 93 | m_filteredBlockTmp[i].create(extWidth, extHeight + 7); |
---|
| 94 | for (j = 0; j < 4; j++) |
---|
| 95 | { |
---|
| 96 | m_filteredBlock[i][j].create(extWidth, extHeight); |
---|
| 97 | } |
---|
| 98 | } |
---|
[2] | 99 | m_iYuvExtHeight = ((g_uiMaxCUHeight + 2) << 4); |
---|
| 100 | m_iYuvExtStride = ((g_uiMaxCUWidth + 8) << 4); |
---|
| 101 | m_piYuvExt = new Int[ m_iYuvExtStride * m_iYuvExtHeight ]; |
---|
| 102 | |
---|
| 103 | // new structure |
---|
| 104 | m_acYuvPred[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 105 | m_acYuvPred[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 106 | |
---|
| 107 | m_cYuvPredTemp.create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | m_iLumaRecStride = (g_uiMaxCUWidth>>1) + 1; |
---|
| 111 | m_pLumaRecBuffer = new Pel[ m_iLumaRecStride * m_iLumaRecStride ]; |
---|
| 112 | |
---|
[56] | 113 | for( Int i = 1; i < 64; i++ ) |
---|
| 114 | { |
---|
[2] | 115 | m_uiaShift[i-1] = ( (1 << 15) + i/2 ) / i; |
---|
[56] | 116 | } |
---|
[2] | 117 | } |
---|
| 118 | |
---|
| 119 | // ==================================================================================================================== |
---|
| 120 | // Public member functions |
---|
| 121 | // ==================================================================================================================== |
---|
| 122 | |
---|
| 123 | // Function for calculating DC value of the reference samples used in Intra prediction |
---|
| 124 | Pel TComPrediction::predIntraGetPredValDC( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ) |
---|
| 125 | { |
---|
| 126 | Int iInd, iSum = 0; |
---|
| 127 | Pel pDcVal; |
---|
| 128 | |
---|
| 129 | if (bAbove) |
---|
| 130 | { |
---|
| 131 | for (iInd = 0;iInd < iWidth;iInd++) |
---|
[56] | 132 | { |
---|
[2] | 133 | iSum += pSrc[iInd-iSrcStride]; |
---|
[56] | 134 | } |
---|
[2] | 135 | } |
---|
| 136 | if (bLeft) |
---|
| 137 | { |
---|
| 138 | for (iInd = 0;iInd < iHeight;iInd++) |
---|
[56] | 139 | { |
---|
[2] | 140 | iSum += pSrc[iInd*iSrcStride-1]; |
---|
[56] | 141 | } |
---|
[2] | 142 | } |
---|
| 143 | |
---|
| 144 | if (bAbove && bLeft) |
---|
[56] | 145 | { |
---|
[2] | 146 | pDcVal = (iSum + iWidth) / (iWidth + iHeight); |
---|
[56] | 147 | } |
---|
[2] | 148 | else if (bAbove) |
---|
[56] | 149 | { |
---|
[2] | 150 | pDcVal = (iSum + iWidth/2) / iWidth; |
---|
[56] | 151 | } |
---|
[2] | 152 | else if (bLeft) |
---|
[56] | 153 | { |
---|
[2] | 154 | pDcVal = (iSum + iHeight/2) / iHeight; |
---|
[56] | 155 | } |
---|
[2] | 156 | else |
---|
[56] | 157 | { |
---|
[2] | 158 | pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available |
---|
[56] | 159 | } |
---|
| 160 | |
---|
[2] | 161 | return pDcVal; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | // Function for deriving the angular Intra predictions |
---|
| 165 | |
---|
| 166 | /** Function for deriving the simplified angular intra predictions. |
---|
| 167 | * \param pSrc pointer to reconstructed sample array |
---|
| 168 | * \param srcStride the stride of the reconstructed sample array |
---|
| 169 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 170 | * \param dstStride the stride of the prediction sample array |
---|
| 171 | * \param width the width of the block |
---|
| 172 | * \param height the height of the block |
---|
| 173 | * \param dirMode the intra prediction mode index |
---|
| 174 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
| 175 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
| 176 | * |
---|
| 177 | * This function derives the prediction samples for the angular mode based on the prediction direction indicated by |
---|
| 178 | * the prediction mode index. The prediction direction is given by the displacement of the bottom row of the block and |
---|
| 179 | * the reference row above the block in the case of vertical prediction or displacement of the rightmost column |
---|
| 180 | * of the block and reference column left from the block in the case of the horizontal prediction. The displacement |
---|
| 181 | * is signalled at 1/32 pixel accuracy. When projection of the predicted pixel falls inbetween reference samples, |
---|
| 182 | * the predicted value for the pixel is linearly interpolated from the reference samples. All reference samples are taken |
---|
| 183 | * from the extended main reference. |
---|
| 184 | */ |
---|
[56] | 185 | Void TComPrediction::xPredIntraAng( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable, Bool bFilter ) |
---|
[2] | 186 | { |
---|
| 187 | Int k,l; |
---|
| 188 | Int blkSize = width; |
---|
| 189 | Pel* pDst = rpDst; |
---|
| 190 | |
---|
| 191 | // Map the mode index to main prediction direction and angle |
---|
[56] | 192 | #if LOGI_INTRA_NAME_3MPM |
---|
| 193 | assert( dirMode > 0 ); //no planar |
---|
| 194 | Bool modeDC = dirMode < 2; |
---|
| 195 | Bool modeHor = !modeDC && (dirMode < 18); |
---|
| 196 | Bool modeVer = !modeDC && !modeHor; |
---|
| 197 | Int intraPredAngle = modeVer ? (Int)dirMode - VER_IDX : modeHor ? -((Int)dirMode - HOR_IDX) : 0; |
---|
| 198 | #else |
---|
[2] | 199 | Bool modeDC = dirMode == 0; |
---|
| 200 | Bool modeVer = !modeDC && (dirMode < 18); |
---|
| 201 | Bool modeHor = !modeDC && !modeVer; |
---|
| 202 | Int intraPredAngle = modeVer ? dirMode - 9 : modeHor ? dirMode - 25 : 0; |
---|
[56] | 203 | #endif |
---|
[2] | 204 | Int absAng = abs(intraPredAngle); |
---|
| 205 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
| 206 | |
---|
| 207 | // Set bitshifts and scale the angle parameter to block size |
---|
| 208 | Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
| 209 | Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle |
---|
| 210 | Int invAngle = invAngTable[absAng]; |
---|
| 211 | absAng = angTable[absAng]; |
---|
| 212 | intraPredAngle = signAng * absAng; |
---|
| 213 | |
---|
| 214 | // Do the DC prediction |
---|
| 215 | if (modeDC) |
---|
| 216 | { |
---|
| 217 | Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height, blkAboveAvailable, blkLeftAvailable); |
---|
| 218 | |
---|
| 219 | for (k=0;k<blkSize;k++) |
---|
| 220 | { |
---|
| 221 | for (l=0;l<blkSize;l++) |
---|
| 222 | { |
---|
| 223 | pDst[k*dstStride+l] = dcval; |
---|
| 224 | } |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | // Do angular predictions |
---|
| 229 | else |
---|
| 230 | { |
---|
| 231 | Pel* refMain; |
---|
| 232 | Pel* refSide; |
---|
| 233 | Pel refAbove[2*MAX_CU_SIZE+1]; |
---|
| 234 | Pel refLeft[2*MAX_CU_SIZE+1]; |
---|
| 235 | |
---|
| 236 | // Initialise the Main and Left reference array. |
---|
| 237 | if (intraPredAngle < 0) |
---|
| 238 | { |
---|
| 239 | for (k=0;k<blkSize+1;k++) |
---|
| 240 | { |
---|
| 241 | refAbove[k+blkSize-1] = pSrc[k-srcStride-1]; |
---|
| 242 | } |
---|
| 243 | for (k=0;k<blkSize+1;k++) |
---|
| 244 | { |
---|
| 245 | refLeft[k+blkSize-1] = pSrc[(k-1)*srcStride-1]; |
---|
| 246 | } |
---|
| 247 | refMain = (modeVer ? refAbove : refLeft) + (blkSize-1); |
---|
| 248 | refSide = (modeVer ? refLeft : refAbove) + (blkSize-1); |
---|
| 249 | |
---|
| 250 | // Extend the Main reference to the left. |
---|
| 251 | Int invAngleSum = 128; // rounding for (shift by 8) |
---|
| 252 | for (k=-1; k>blkSize*intraPredAngle>>5; k--) |
---|
| 253 | { |
---|
| 254 | invAngleSum += invAngle; |
---|
| 255 | refMain[k] = refSide[invAngleSum>>8]; |
---|
| 256 | } |
---|
| 257 | } |
---|
| 258 | else |
---|
| 259 | { |
---|
| 260 | for (k=0;k<2*blkSize+1;k++) |
---|
| 261 | { |
---|
| 262 | refAbove[k] = pSrc[k-srcStride-1]; |
---|
| 263 | } |
---|
| 264 | for (k=0;k<2*blkSize+1;k++) |
---|
| 265 | { |
---|
| 266 | refLeft[k] = pSrc[(k-1)*srcStride-1]; |
---|
| 267 | } |
---|
| 268 | refMain = modeVer ? refAbove : refLeft; |
---|
[56] | 269 | refSide = modeVer ? refLeft : refAbove; |
---|
[2] | 270 | } |
---|
| 271 | |
---|
| 272 | if (intraPredAngle == 0) |
---|
| 273 | { |
---|
| 274 | for (k=0;k<blkSize;k++) |
---|
| 275 | { |
---|
| 276 | for (l=0;l<blkSize;l++) |
---|
| 277 | { |
---|
| 278 | pDst[k*dstStride+l] = refMain[l+1]; |
---|
| 279 | } |
---|
| 280 | } |
---|
[56] | 281 | |
---|
| 282 | if ( bFilter ) |
---|
| 283 | { |
---|
| 284 | for (k=0;k<blkSize;k++) |
---|
| 285 | { |
---|
| 286 | #if REMOVE_DIV_OPERATION |
---|
| 287 | pDst[k*dstStride] = Clip ( pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) ); |
---|
| 288 | #else |
---|
| 289 | pDst[k*dstStride] = Clip ( pDst[k*dstStride] + ( refSide[k+1] - refSide[0] ) / 2 ); |
---|
| 290 | #endif |
---|
| 291 | } |
---|
| 292 | } |
---|
[2] | 293 | } |
---|
| 294 | else |
---|
| 295 | { |
---|
| 296 | Int deltaPos=0; |
---|
| 297 | Int deltaInt; |
---|
| 298 | Int deltaFract; |
---|
| 299 | Int refMainIndex; |
---|
| 300 | |
---|
| 301 | for (k=0;k<blkSize;k++) |
---|
| 302 | { |
---|
| 303 | deltaPos += intraPredAngle; |
---|
| 304 | deltaInt = deltaPos >> 5; |
---|
| 305 | deltaFract = deltaPos & (32 - 1); |
---|
| 306 | |
---|
| 307 | if (deltaFract) |
---|
| 308 | { |
---|
| 309 | // Do linear filtering |
---|
| 310 | for (l=0;l<blkSize;l++) |
---|
| 311 | { |
---|
| 312 | refMainIndex = l+deltaInt+1; |
---|
| 313 | pDst[k*dstStride+l] = (Pel) ( ((32-deltaFract)*refMain[refMainIndex]+deltaFract*refMain[refMainIndex+1]+16) >> 5 ); |
---|
| 314 | } |
---|
| 315 | } |
---|
| 316 | else |
---|
| 317 | { |
---|
| 318 | // Just copy the integer samples |
---|
| 319 | for (l=0;l<blkSize;l++) |
---|
| 320 | { |
---|
| 321 | pDst[k*dstStride+l] = refMain[l+deltaInt+1]; |
---|
| 322 | } |
---|
| 323 | } |
---|
| 324 | } |
---|
| 325 | } |
---|
| 326 | |
---|
| 327 | // Flip the block if this is the horizontal mode |
---|
| 328 | if (modeHor) |
---|
| 329 | { |
---|
| 330 | Pel tmp; |
---|
| 331 | for (k=0;k<blkSize-1;k++) |
---|
| 332 | { |
---|
| 333 | for (l=k+1;l<blkSize;l++) |
---|
| 334 | { |
---|
| 335 | tmp = pDst[k*dstStride+l]; |
---|
| 336 | pDst[k*dstStride+l] = pDst[l*dstStride+k]; |
---|
| 337 | pDst[l*dstStride+k] = tmp; |
---|
| 338 | } |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | } |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | Void TComPrediction::predIntraLumaAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, TComDataCU* pcCU, Bool bAbove, Bool bLeft ) |
---|
| 345 | { |
---|
| 346 | Pel *pDst = piPred; |
---|
| 347 | Int *ptrSrc; |
---|
| 348 | |
---|
[56] | 349 | assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 |
---|
| 350 | assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 |
---|
[2] | 351 | assert( iWidth == iHeight ); |
---|
| 352 | |
---|
[56] | 353 | ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
| 354 | |
---|
| 355 | // get starting pixel in block |
---|
| 356 | Int sw = 2 * iWidth + 1; |
---|
| 357 | |
---|
| 358 | // Create the prediction |
---|
| 359 | if ( uiDirMode == PLANAR_IDX ) |
---|
| 360 | { |
---|
| 361 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
| 362 | } |
---|
| 363 | else |
---|
| 364 | { |
---|
| 365 | #if LOGI_INTRA_NAME_3MPM |
---|
| 366 | xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, true ); |
---|
[2] | 367 | #else |
---|
[56] | 368 | xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, g_aucAngIntraModeOrder[ uiDirMode ], bAbove, bLeft, true ); |
---|
| 369 | #endif |
---|
[2] | 370 | |
---|
[56] | 371 | if( (uiDirMode == DC_IDX ) && bAbove && bLeft ) |
---|
| 372 | { |
---|
| 373 | xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight); |
---|
| 374 | } |
---|
| 375 | } |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | // Angular chroma |
---|
| 379 | Void TComPrediction::predIntraChromaAng( TComPattern* pcTComPattern, Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, TComDataCU* pcCU, Bool bAbove, Bool bLeft ) |
---|
| 380 | { |
---|
| 381 | Pel *pDst = piPred; |
---|
| 382 | Int *ptrSrc = piSrc; |
---|
| 383 | |
---|
[2] | 384 | // get starting pixel in block |
---|
[56] | 385 | Int sw = 2 * iWidth + 1; |
---|
[2] | 386 | |
---|
| 387 | if ( uiDirMode == PLANAR_IDX ) |
---|
| 388 | { |
---|
| 389 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
[56] | 390 | } |
---|
| 391 | else |
---|
| 392 | { |
---|
| 393 | // Create the prediction |
---|
| 394 | #if LOGI_INTRA_NAME_3MPM |
---|
| 395 | xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); |
---|
[2] | 396 | #else |
---|
[56] | 397 | xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, g_aucAngIntraModeOrder[ uiDirMode ], bAbove, bLeft, false ); |
---|
[2] | 398 | #endif |
---|
[56] | 399 | } |
---|
| 400 | } |
---|
| 401 | |
---|
| 402 | /** Function for checking identical motion. |
---|
| 403 | * \param TComDataCU* pcCU |
---|
| 404 | * \param UInt PartAddr |
---|
| 405 | */ |
---|
| 406 | Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) |
---|
| 407 | { |
---|
| 408 | if( pcCU->getSlice()->isInterB() && pcCU->getSlice()->getPPS()->getWPBiPredIdc() == 0 ) |
---|
| 409 | { |
---|
| 410 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0) |
---|
| 411 | { |
---|
| 412 | Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); |
---|
| 413 | Int RefViewIdL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getViewId(); |
---|
| 414 | Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); |
---|
| 415 | Int RefViewIdL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getViewId(); |
---|
| 416 | if(RefPOCL0 == RefPOCL1 && RefViewIdL0 == RefViewIdL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
| 417 | { |
---|
| 418 | return true; |
---|
| 419 | } |
---|
| 420 | } |
---|
| 421 | } |
---|
| 422 | return false; |
---|
| 423 | } |
---|
| 424 | |
---|
[189] | 425 | #if LGE_EDGE_INTRA_A0070 |
---|
[100] | 426 | Void TComPrediction::predIntraLumaEdge ( TComDataCU* pcCU, TComPattern* pcTComPattern, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Pel* piPred, UInt uiStride, Bool bDelta ) |
---|
| 427 | { |
---|
| 428 | Pel *piDst = piPred; |
---|
| 429 | Int *piSrc; |
---|
| 430 | Int iSrcStride = ( iWidth<<1 ) + 1; |
---|
| 431 | Int iDstStride = uiStride; |
---|
| 432 | |
---|
| 433 | piSrc = pcTComPattern->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); |
---|
| 434 | |
---|
| 435 | xPredIntraEdge ( pcCU, uiAbsPartIdx, iWidth, iHeight, piSrc, iSrcStride, piDst, iDstStride |
---|
| 436 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
| 437 | , bDelta |
---|
| 438 | #endif |
---|
| 439 | ); |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | Pel TComPrediction::xGetNearestNeighbor( Int x, Int y, Int* pSrc, Int srcStride, Int iWidth, Int iHeight, Bool* bpRegion ) |
---|
| 443 | { |
---|
| 444 | Bool bLeft = (x < y) ? true : false; |
---|
| 445 | Bool bFound = false; |
---|
| 446 | Int iFoundX = -1, iFoundY = -1; |
---|
| 447 | Int cResult = 0; |
---|
| 448 | |
---|
| 449 | UChar* piTopDistance = new UChar[iWidth]; |
---|
| 450 | UChar* piLeftDistance = new UChar[iHeight]; |
---|
| 451 | |
---|
| 452 | for( Int i = 0; i < iWidth; i++ ) |
---|
| 453 | { |
---|
| 454 | int Abs = x > i ? x - i : i - x; |
---|
| 455 | piTopDistance[ i ] = y + Abs; |
---|
| 456 | |
---|
| 457 | Abs = y > i ? y - i : i - y; |
---|
| 458 | piLeftDistance[ i ] = x + Abs; |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | for( Int dist = 0; dist < MAX_DISTANCE_EDGEINTRA && !bFound; dist++ ) |
---|
| 462 | { |
---|
| 463 | if( !bLeft ) |
---|
| 464 | { |
---|
| 465 | for( Int i = 0; i < iWidth; i++ ) |
---|
| 466 | { |
---|
| 467 | if( piTopDistance[ i ] == dist ) |
---|
| 468 | { |
---|
| 469 | if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] ) |
---|
| 470 | { |
---|
| 471 | iFoundX = i; |
---|
| 472 | iFoundY = 0; |
---|
| 473 | bFound = true; |
---|
| 474 | } |
---|
| 475 | } |
---|
| 476 | } |
---|
| 477 | for( Int i = 0; i < iHeight; i++ ) |
---|
| 478 | { |
---|
| 479 | if( piLeftDistance[ i ] == dist ) |
---|
| 480 | { |
---|
| 481 | if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] ) |
---|
| 482 | { |
---|
| 483 | iFoundX = 0; |
---|
| 484 | iFoundY = i; |
---|
| 485 | bFound = true; |
---|
| 486 | } |
---|
| 487 | } |
---|
| 488 | } |
---|
| 489 | } |
---|
| 490 | else |
---|
| 491 | { |
---|
| 492 | for( Int i = 0; i < iHeight; i++ ) |
---|
| 493 | { |
---|
| 494 | if( piLeftDistance[ i ] == dist ) |
---|
| 495 | { |
---|
| 496 | if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] ) |
---|
| 497 | { |
---|
| 498 | iFoundX = 0; |
---|
| 499 | iFoundY = i; |
---|
| 500 | bFound = true; |
---|
| 501 | } |
---|
| 502 | } |
---|
| 503 | } |
---|
| 504 | for( Int i = 0; i < iWidth; i++ ) |
---|
| 505 | { |
---|
| 506 | if( piTopDistance[ i ] == dist ) |
---|
| 507 | { |
---|
| 508 | if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] ) |
---|
| 509 | { |
---|
| 510 | iFoundX = i; |
---|
| 511 | iFoundY = 0; |
---|
| 512 | bFound = true; |
---|
| 513 | } |
---|
| 514 | } |
---|
| 515 | } |
---|
| 516 | } |
---|
| 517 | } |
---|
| 518 | |
---|
| 519 | if( iFoundY == 0 ) |
---|
| 520 | { |
---|
| 521 | cResult = pSrc[ iFoundX + 1 ]; |
---|
| 522 | } |
---|
| 523 | else // iFoundX == 0 |
---|
| 524 | { |
---|
| 525 | cResult = pSrc[ (iFoundY + 1) * srcStride ]; |
---|
| 526 | } |
---|
| 527 | |
---|
| 528 | delete[] piTopDistance; piTopDistance = NULL; |
---|
| 529 | delete[] piLeftDistance; piLeftDistance = NULL; |
---|
| 530 | |
---|
| 531 | assert( bFound ); |
---|
| 532 | |
---|
| 533 | return cResult; |
---|
| 534 | } |
---|
| 535 | |
---|
| 536 | Void TComPrediction::xPredIntraEdge( TComDataCU* pcCU, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, Bool bDelta ) |
---|
| 537 | { |
---|
| 538 | Pel* pDst = rpDst; |
---|
| 539 | Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); |
---|
| 540 | |
---|
| 541 | // Do prediction |
---|
| 542 | { |
---|
| 543 | //UInt uiSum0 = 0, uiSum1 = 0; |
---|
| 544 | Int iSum0 = 0, iSum1 = 0; |
---|
| 545 | //UInt uiMean0, uiMean1; |
---|
| 546 | Int iMean0, iMean1; |
---|
| 547 | //UInt uiCount0 = 0, uiCount1 = 0; |
---|
| 548 | Int iCount0 = 0, iCount1 = 0; |
---|
| 549 | for( UInt ui = 0; ui < iWidth; ui++ ) |
---|
| 550 | { |
---|
| 551 | if( pbRegion[ ui ] == false ) |
---|
| 552 | { |
---|
| 553 | iSum0 += (pSrc[ ui + 1 ]); |
---|
| 554 | iCount0++; |
---|
| 555 | } |
---|
| 556 | else |
---|
| 557 | { |
---|
| 558 | iSum1 += (pSrc[ ui + 1 ]); |
---|
| 559 | iCount1++; |
---|
| 560 | } |
---|
| 561 | } |
---|
| 562 | for( UInt ui = 0; ui < iHeight; ui++ ) // (0,0) recount (to avoid division) |
---|
| 563 | { |
---|
| 564 | if( pbRegion[ ui * iWidth ] == false ) |
---|
| 565 | { |
---|
| 566 | iSum0 += (pSrc[ (ui + 1) * srcStride ]); |
---|
| 567 | iCount0++; |
---|
| 568 | } |
---|
| 569 | else |
---|
| 570 | { |
---|
| 571 | iSum1 += (pSrc[ (ui + 1) * srcStride ]); |
---|
| 572 | iCount1++; |
---|
| 573 | } |
---|
| 574 | } |
---|
| 575 | if( iCount0 == 0 ) |
---|
| 576 | assert(false); |
---|
| 577 | if( iCount1 == 0 ) |
---|
| 578 | assert(false); |
---|
| 579 | iMean0 = iSum0 / iCount0; // TODO : integer op. |
---|
| 580 | iMean1 = iSum1 / iCount1; |
---|
| 581 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
| 582 | if( bDelta ) |
---|
| 583 | { |
---|
| 584 | Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx ); |
---|
| 585 | Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx ); |
---|
| 586 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC0 ); |
---|
| 587 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
| 588 | iMean0 = Clip( iMean0 + iDeltaDC0 ); |
---|
| 589 | iMean1 = Clip( iMean1 + iDeltaDC1 ); |
---|
| 590 | } |
---|
| 591 | #endif |
---|
| 592 | for( UInt ui = 0; ui < iHeight; ui++ ) |
---|
| 593 | { |
---|
| 594 | for( UInt uii = 0; uii < iWidth; uii++ ) |
---|
| 595 | { |
---|
| 596 | if( pbRegion[ uii + ui * iWidth ] == false ) |
---|
| 597 | pDst[ uii + ui * dstStride ] = iMean0; |
---|
| 598 | else |
---|
| 599 | pDst[ uii + ui * dstStride ] = iMean1; |
---|
| 600 | } |
---|
| 601 | } |
---|
| 602 | } |
---|
| 603 | } |
---|
| 604 | #endif |
---|
| 605 | |
---|
[56] | 606 | #if DEPTH_MAP_GENERATION |
---|
| 607 | Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
| 608 | #else |
---|
| 609 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) |
---|
| 610 | #endif |
---|
| 611 | { |
---|
| 612 | Int iWidth; |
---|
| 613 | Int iHeight; |
---|
| 614 | UInt uiPartAddr; |
---|
| 615 | |
---|
| 616 | if ( iPartIdx >= 0 ) |
---|
| 617 | { |
---|
| 618 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
| 619 | |
---|
| 620 | #if DEPTH_MAP_GENERATION |
---|
| 621 | if( bPrdDepthMap ) |
---|
| 622 | { |
---|
| 623 | iWidth >>= uiSubSampExpX; |
---|
| 624 | iHeight >>= uiSubSampExpY; |
---|
| 625 | } |
---|
| 626 | #endif |
---|
| 627 | |
---|
| 628 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
| 629 | { |
---|
[189] | 630 | #if LGE_ILLUCOMP_B0045 |
---|
| 631 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr)) |
---|
| 632 | #else |
---|
[56] | 633 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
[189] | 634 | #endif |
---|
[56] | 635 | { |
---|
| 636 | #if DEPTH_MAP_GENERATION |
---|
| 637 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
| 638 | #else |
---|
| 639 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, true ); |
---|
| 640 | #endif |
---|
| 641 | } |
---|
| 642 | else |
---|
| 643 | { |
---|
| 644 | #if DEPTH_MAP_GENERATION |
---|
| 645 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
| 646 | #else |
---|
| 647 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false ); |
---|
| 648 | #endif |
---|
| 649 | } |
---|
[189] | 650 | #if LGE_ILLUCOMP_B0045 |
---|
| 651 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr) ) |
---|
| 652 | #else |
---|
[56] | 653 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
[189] | 654 | #endif |
---|
[56] | 655 | { |
---|
| 656 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); |
---|
| 657 | } |
---|
| 658 | } |
---|
| 659 | else |
---|
| 660 | { |
---|
| 661 | #if DEPTH_MAP_GENERATION |
---|
| 662 | if( xCheckIdenticalMotion( pcCU, uiPartAddr ) && !bPrdDepthMap ) |
---|
| 663 | #else |
---|
| 664 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
| 665 | #endif |
---|
| 666 | { |
---|
| 667 | #if DEPTH_MAP_GENERATION |
---|
| 668 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
| 669 | #else |
---|
| 670 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, false ); |
---|
| 671 | #endif |
---|
| 672 | } |
---|
| 673 | else |
---|
| 674 | { |
---|
| 675 | #if DEPTH_MAP_GENERATION |
---|
| 676 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
| 677 | #else |
---|
| 678 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx ); |
---|
| 679 | #endif |
---|
| 680 | } |
---|
| 681 | } |
---|
[2] | 682 | return; |
---|
| 683 | } |
---|
[56] | 684 | |
---|
| 685 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ ) |
---|
| 686 | { |
---|
| 687 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
| 688 | |
---|
| 689 | #if DEPTH_MAP_GENERATION |
---|
| 690 | if( bPrdDepthMap ) |
---|
| 691 | { |
---|
| 692 | iWidth >>= uiSubSampExpX; |
---|
| 693 | iHeight >>= uiSubSampExpY; |
---|
| 694 | } |
---|
[2] | 695 | #endif |
---|
| 696 | |
---|
[56] | 697 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
| 698 | { |
---|
[189] | 699 | #if LGE_ILLUCOMP_B0045 |
---|
| 700 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr)) |
---|
| 701 | #else |
---|
[56] | 702 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
[189] | 703 | #endif |
---|
[56] | 704 | { |
---|
| 705 | #if DEPTH_MAP_GENERATION |
---|
| 706 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
| 707 | #else |
---|
| 708 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, true ); |
---|
| 709 | #endif |
---|
| 710 | } |
---|
| 711 | else |
---|
| 712 | { |
---|
| 713 | #if DEPTH_MAP_GENERATION |
---|
| 714 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
| 715 | #else |
---|
| 716 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false ); |
---|
| 717 | #endif |
---|
| 718 | } |
---|
| 719 | #if DEPTH_MAP_GENERATION |
---|
| 720 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
| 721 | #else |
---|
| 722 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false ); |
---|
| 723 | #endif |
---|
[189] | 724 | #if LGE_ILLUCOMP_B0045 |
---|
| 725 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr)) |
---|
| 726 | #else |
---|
[56] | 727 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
[189] | 728 | #endif |
---|
[56] | 729 | { |
---|
| 730 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); |
---|
| 731 | } |
---|
| 732 | } |
---|
| 733 | else |
---|
| 734 | { |
---|
| 735 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
| 736 | { |
---|
| 737 | #if DEPTH_MAP_GENERATION |
---|
| 738 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
| 739 | #else |
---|
| 740 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, false ); |
---|
| 741 | #endif |
---|
| 742 | } |
---|
| 743 | else |
---|
| 744 | { |
---|
| 745 | #if DEPTH_MAP_GENERATION |
---|
| 746 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); |
---|
| 747 | #else |
---|
| 748 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx ); |
---|
| 749 | #endif |
---|
| 750 | } |
---|
| 751 | } |
---|
| 752 | } |
---|
| 753 | return; |
---|
| 754 | } |
---|
[2] | 755 | |
---|
[244] | 756 | #if MTK_MDIVRP_C0138 |
---|
| 757 | Void TComPrediction::residualPrediction(TComDataCU* pcCU, TComYuv* pcYuvPred, TComYuv* pcYuvResPred) |
---|
| 758 | { |
---|
| 759 | Int iWidth; |
---|
| 760 | Int iHeight; |
---|
| 761 | UInt uiPartAddr; |
---|
[2] | 762 | |
---|
[244] | 763 | pcCU->getPartIndexAndSize( 0, uiPartAddr, iWidth, iHeight ); |
---|
[56] | 764 | |
---|
[244] | 765 | Bool bResAvail = false; |
---|
| 766 | |
---|
| 767 | bResAvail = pcCU->getResidualSamples( 0, |
---|
| 768 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 769 | true, |
---|
| 770 | #endif |
---|
| 771 | pcYuvResPred ); |
---|
| 772 | |
---|
| 773 | assert (bResAvail); |
---|
| 774 | |
---|
| 775 | pcYuvPred->add(pcYuvResPred, iWidth, iHeight); |
---|
| 776 | } |
---|
| 777 | #endif |
---|
| 778 | |
---|
[56] | 779 | #if DEPTH_MAP_GENERATION |
---|
| 780 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi ) |
---|
| 781 | #else |
---|
| 782 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi ) |
---|
[2] | 783 | #endif |
---|
[56] | 784 | { |
---|
| 785 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
| 786 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 787 | pcCU->clipMv(cMv); |
---|
| 788 | |
---|
| 789 | #if DEPTH_MAP_GENERATION |
---|
| 790 | if( bPrdDepthMap ) |
---|
| 791 | { |
---|
| 792 | UInt uiRShift = 0; |
---|
[100] | 793 | #if PDM_REMOVE_DEPENDENCE |
---|
| 794 | if( pcCU->getPic()->getStoredPDMforV2() == 1 ) |
---|
| 795 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMapTemp(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 ); |
---|
| 796 | else |
---|
| 797 | #endif |
---|
| 798 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 ); |
---|
| 799 | |
---|
[56] | 800 | return; |
---|
| 801 | } |
---|
| 802 | #endif |
---|
| 803 | |
---|
| 804 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 805 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
| 806 | { |
---|
| 807 | UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 ); |
---|
| 808 | UInt uiOffset = bi ? IF_INTERNAL_OFFS : 0; |
---|
| 809 | #if DEPTH_MAP_GENERATION |
---|
| 810 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift, uiOffset ); |
---|
| 811 | #else |
---|
| 812 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, uiOffset ); |
---|
| 813 | #endif |
---|
| 814 | } |
---|
| 815 | else |
---|
| 816 | { |
---|
| 817 | #endif |
---|
[189] | 818 | #if LGE_ILLUCOMP_B0045 |
---|
| 819 | Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId()); |
---|
| 820 | |
---|
| 821 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, bICFlag); |
---|
| 822 | #else |
---|
[56] | 823 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
[189] | 824 | #endif |
---|
[56] | 825 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 826 | } |
---|
| 827 | #endif |
---|
[189] | 828 | #if LGE_ILLUCOMP_B0045 |
---|
| 829 | Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId()); |
---|
| 830 | |
---|
| 831 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, bICFlag ); |
---|
| 832 | #else |
---|
[56] | 833 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
[189] | 834 | #endif |
---|
[2] | 835 | } |
---|
| 836 | |
---|
| 837 | |
---|
[56] | 838 | #if DEPTH_MAP_GENERATION |
---|
| 839 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ) |
---|
| 840 | #else |
---|
| 841 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx ) |
---|
| 842 | #endif |
---|
[2] | 843 | { |
---|
[56] | 844 | TComYuv* pcMbYuv; |
---|
| 845 | Int iRefIdx[2] = {-1, -1}; |
---|
| 846 | |
---|
| 847 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
| 848 | { |
---|
| 849 | RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
| 850 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 851 | |
---|
| 852 | if ( iRefIdx[iRefList] < 0 ) |
---|
| 853 | { |
---|
| 854 | continue; |
---|
| 855 | } |
---|
| 856 | |
---|
| 857 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
| 858 | |
---|
| 859 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
| 860 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
| 861 | { |
---|
| 862 | #if DEPTH_MAP_GENERATION |
---|
| 863 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
| 864 | #else |
---|
| 865 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true ); |
---|
| 866 | #endif |
---|
| 867 | } |
---|
| 868 | else |
---|
| 869 | { |
---|
| 870 | if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() ) |
---|
| 871 | { |
---|
| 872 | #if DEPTH_MAP_GENERATION |
---|
| 873 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
| 874 | #else |
---|
| 875 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true ); |
---|
| 876 | #endif |
---|
| 877 | } |
---|
| 878 | else |
---|
| 879 | { |
---|
| 880 | #if DEPTH_MAP_GENERATION |
---|
| 881 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
| 882 | #else |
---|
| 883 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, false ); |
---|
| 884 | #endif |
---|
| 885 | } |
---|
| 886 | } |
---|
| 887 | } |
---|
| 888 | |
---|
| 889 | if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() ) |
---|
| 890 | { |
---|
| 891 | xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 892 | } |
---|
| 893 | else |
---|
| 894 | { |
---|
| 895 | #if DEPTH_MAP_GENERATION |
---|
| 896 | if ( bPrdDepthMap ) |
---|
| 897 | { |
---|
| 898 | xWeightedAveragePdm( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, uiSubSampExpX, uiSubSampExpY ); |
---|
| 899 | } |
---|
| 900 | else |
---|
| 901 | { |
---|
| 902 | xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 903 | } |
---|
| 904 | #else |
---|
| 905 | xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 906 | #endif |
---|
| 907 | } |
---|
[2] | 908 | } |
---|
| 909 | |
---|
[56] | 910 | Void |
---|
| 911 | #if DEPTH_MAP_GENERATION |
---|
| 912 | TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset ) |
---|
| 913 | #else |
---|
| 914 | TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset ) |
---|
| 915 | #endif |
---|
[2] | 916 | { |
---|
[56] | 917 | #if DEPTH_MAP_GENERATION |
---|
| 918 | Int iShiftX = 2 + uiSubSampExpX; |
---|
| 919 | Int iShiftY = 2 + uiSubSampExpY; |
---|
| 920 | Int iAddX = ( 1 << iShiftX ) >> 1; |
---|
| 921 | Int iAddY = ( 1 << iShiftY ) >> 1; |
---|
| 922 | Int iHor = ( pcMv->getHor() + iAddX ) >> iShiftX; |
---|
| 923 | Int iVer = ( pcMv->getVer() + iAddY ) >> iShiftY; |
---|
| 924 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 925 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
[2] | 926 | { |
---|
[56] | 927 | iHor = pcMv->getHor(); |
---|
| 928 | iVer = pcMv->getVer(); |
---|
| 929 | } |
---|
| 930 | #endif |
---|
| 931 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
| 932 | Int iDstStride = rpcYuv->getStride(); |
---|
| 933 | Int iRefOffset = iHor + iVer * iRefStride; |
---|
| 934 | #else |
---|
| 935 | Int iFPelMask = ~3; |
---|
| 936 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
| 937 | Int iDstStride = rpcYuv->getStride(); |
---|
| 938 | Int iHor = ( pcMv->getHor() + 2 ) & iFPelMask; |
---|
| 939 | Int iVer = ( pcMv->getVer() + 2 ) & iFPelMask; |
---|
| 940 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 941 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
| 942 | { |
---|
| 943 | iHor = pcMv->getHor() * 4; |
---|
| 944 | iVer = pcMv->getVer() * 4; |
---|
| 945 | } |
---|
| 946 | #endif |
---|
[210] | 947 | #if !QC_MVHEVC_B0046 |
---|
[56] | 948 | Int ixFrac = iHor & 0x3; |
---|
| 949 | Int iyFrac = iVer & 0x3; |
---|
[210] | 950 | #endif |
---|
[56] | 951 | Int iRefOffset = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride; |
---|
| 952 | #endif |
---|
| 953 | |
---|
| 954 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
| 955 | Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr ); |
---|
| 956 | |
---|
| 957 | for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride ) |
---|
| 958 | { |
---|
| 959 | for( Int x = 0; x < iWidth; x++ ) |
---|
[2] | 960 | { |
---|
[56] | 961 | piDstY[ x ] = ( piRefY[ x ] << uiRShift ) - uiOffset; |
---|
[2] | 962 | } |
---|
| 963 | } |
---|
[56] | 964 | } |
---|
| 965 | |
---|
| 966 | |
---|
| 967 | /** |
---|
| 968 | * \brief Generate motion-compensated luma block |
---|
| 969 | * |
---|
| 970 | * \param cu Pointer to current CU |
---|
| 971 | * \param refPic Pointer to reference picture |
---|
| 972 | * \param partAddr Address of block within CU |
---|
| 973 | * \param mv Motion vector |
---|
| 974 | * \param width Width of block |
---|
| 975 | * \param height Height of block |
---|
| 976 | * \param dstPic Pointer to destination picture |
---|
| 977 | * \param bi Flag indicating whether bipred is used |
---|
| 978 | */ |
---|
[189] | 979 | #if LGE_ILLUCOMP_B0045 |
---|
| 980 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag) |
---|
| 981 | #else |
---|
[56] | 982 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi ) |
---|
[189] | 983 | #endif |
---|
[56] | 984 | { |
---|
| 985 | Int refStride = refPic->getStride(); |
---|
| 986 | Int refOffset = ( mv->getHor() >> 2 ) + ( mv->getVer() >> 2 ) * refStride; |
---|
| 987 | Pel *ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 988 | |
---|
| 989 | Int dstStride = dstPic->getStride(); |
---|
| 990 | Pel *dst = dstPic->getLumaAddr( partAddr ); |
---|
| 991 | |
---|
| 992 | Int xFrac = mv->getHor() & 0x3; |
---|
| 993 | Int yFrac = mv->getVer() & 0x3; |
---|
| 994 | |
---|
| 995 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 996 | assert( ! cu->getSlice()->getIsDepth() || ( xFrac == 0 && yFrac == 0 ) ); |
---|
| 997 | #endif |
---|
| 998 | |
---|
| 999 | if ( yFrac == 0 ) |
---|
[2] | 1000 | { |
---|
[56] | 1001 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi ); |
---|
[2] | 1002 | } |
---|
[56] | 1003 | else if ( xFrac == 0 ) |
---|
| 1004 | { |
---|
| 1005 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi ); |
---|
| 1006 | } |
---|
| 1007 | else |
---|
| 1008 | { |
---|
| 1009 | Int tmpStride = m_filteredBlockTmp[0].getStride(); |
---|
| 1010 | Short *tmp = m_filteredBlockTmp[0].getLumaAddr(); |
---|
| 1011 | |
---|
| 1012 | Int filterSize = NTAPS_LUMA; |
---|
| 1013 | Int halfFilterSize = ( filterSize >> 1 ); |
---|
| 1014 | |
---|
| 1015 | m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false ); |
---|
| 1016 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi); |
---|
| 1017 | } |
---|
[189] | 1018 | |
---|
| 1019 | #if LGE_ILLUCOMP_B0045 |
---|
| 1020 | if(bICFlag) |
---|
| 1021 | { |
---|
| 1022 | Int a, b, iShift, i, j; |
---|
| 1023 | |
---|
| 1024 | xGetLLSICPrediction(cu, mv, refPic, a, b, iShift); |
---|
| 1025 | |
---|
| 1026 | for (i = 0; i < height; i++) |
---|
| 1027 | { |
---|
| 1028 | for (j = 0; j < width; j++) |
---|
| 1029 | { |
---|
| 1030 | if(bi) |
---|
| 1031 | { |
---|
| 1032 | Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
| 1033 | dst[j] = ( (a*dst[j]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS; |
---|
| 1034 | } |
---|
| 1035 | else |
---|
| 1036 | dst[j] = Clip( ( (a*dst[j]) >> iShift ) + b ); |
---|
| 1037 | } |
---|
| 1038 | dst += dstStride; |
---|
| 1039 | } |
---|
| 1040 | } |
---|
| 1041 | #endif |
---|
[2] | 1042 | } |
---|
| 1043 | |
---|
[56] | 1044 | /** |
---|
| 1045 | * \brief Generate motion-compensated chroma block |
---|
| 1046 | * |
---|
| 1047 | * \param cu Pointer to current CU |
---|
| 1048 | * \param refPic Pointer to reference picture |
---|
| 1049 | * \param partAddr Address of block within CU |
---|
| 1050 | * \param mv Motion vector |
---|
| 1051 | * \param width Width of block |
---|
| 1052 | * \param height Height of block |
---|
| 1053 | * \param dstPic Pointer to destination picture |
---|
| 1054 | * \param bi Flag indicating whether bipred is used |
---|
| 1055 | */ |
---|
[189] | 1056 | #if LGE_ILLUCOMP_B0045 |
---|
| 1057 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag ) |
---|
| 1058 | #else |
---|
[56] | 1059 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi ) |
---|
[189] | 1060 | #endif |
---|
[2] | 1061 | { |
---|
[56] | 1062 | Int refStride = refPic->getCStride(); |
---|
| 1063 | Int dstStride = dstPic->getCStride(); |
---|
| 1064 | |
---|
| 1065 | Int refOffset = (mv->getHor() >> 3) + (mv->getVer() >> 3) * refStride; |
---|
| 1066 | |
---|
| 1067 | Pel* refCb = refPic->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1068 | Pel* refCr = refPic->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1069 | |
---|
| 1070 | Pel* dstCb = dstPic->getCbAddr( partAddr ); |
---|
| 1071 | Pel* dstCr = dstPic->getCrAddr( partAddr ); |
---|
| 1072 | |
---|
| 1073 | Int xFrac = mv->getHor() & 0x7; |
---|
| 1074 | Int yFrac = mv->getVer() & 0x7; |
---|
| 1075 | UInt cxWidth = width >> 1; |
---|
| 1076 | UInt cxHeight = height >> 1; |
---|
| 1077 | |
---|
| 1078 | Int extStride = m_filteredBlockTmp[0].getStride(); |
---|
| 1079 | Short* extY = m_filteredBlockTmp[0].getLumaAddr(); |
---|
| 1080 | |
---|
| 1081 | Int filterSize = NTAPS_CHROMA; |
---|
| 1082 | |
---|
| 1083 | Int halfFilterSize = (filterSize>>1); |
---|
| 1084 | |
---|
| 1085 | if ( yFrac == 0 ) |
---|
| 1086 | { |
---|
| 1087 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi); |
---|
| 1088 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi); |
---|
| 1089 | } |
---|
| 1090 | else if ( xFrac == 0 ) |
---|
| 1091 | { |
---|
| 1092 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi); |
---|
| 1093 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi); |
---|
| 1094 | } |
---|
| 1095 | else |
---|
| 1096 | { |
---|
| 1097 | m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false); |
---|
| 1098 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi); |
---|
| 1099 | |
---|
| 1100 | m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false); |
---|
| 1101 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi); |
---|
| 1102 | } |
---|
[189] | 1103 | #if LGE_ILLUCOMP_B0045 |
---|
| 1104 | if(bICFlag) |
---|
| 1105 | { |
---|
| 1106 | Int a, b, iShift, i, j; |
---|
| 1107 | xGetLLSICPredictionChroma(cu, mv, refPic, a, b, iShift, 0); // Cb |
---|
| 1108 | for (i = 0; i < cxHeight; i++) |
---|
| 1109 | { |
---|
| 1110 | for (j = 0; j < cxWidth; j++) |
---|
| 1111 | { |
---|
| 1112 | if(bi) |
---|
| 1113 | { |
---|
| 1114 | Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
| 1115 | dstCb[j] = ( (a*dstCb[j]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS; |
---|
| 1116 | } |
---|
| 1117 | else |
---|
| 1118 | dstCb[j] = Clip3(0, 255, ((a*dstCb[j])>>iShift)+b); |
---|
| 1119 | } |
---|
| 1120 | dstCb += dstStride; |
---|
| 1121 | } |
---|
| 1122 | |
---|
| 1123 | xGetLLSICPredictionChroma(cu, mv, refPic, a, b, iShift, 1); // Cr |
---|
| 1124 | for (i = 0; i < cxHeight; i++) |
---|
| 1125 | { |
---|
| 1126 | for (j = 0; j < cxWidth; j++) |
---|
| 1127 | { |
---|
| 1128 | if(bi) |
---|
| 1129 | { |
---|
| 1130 | Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
| 1131 | dstCr[j] = ( (a*dstCr[j]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS; |
---|
| 1132 | } |
---|
| 1133 | else |
---|
| 1134 | dstCr[j] = Clip3(0, 255, ((a*dstCr[j])>>iShift)+b); |
---|
| 1135 | } |
---|
| 1136 | dstCr += dstStride; |
---|
| 1137 | } |
---|
| 1138 | } |
---|
| 1139 | #endif |
---|
[2] | 1140 | } |
---|
| 1141 | |
---|
[56] | 1142 | #if DEPTH_MAP_GENERATION |
---|
| 1143 | Void TComPrediction::xWeightedAveragePdm( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
[2] | 1144 | { |
---|
[56] | 1145 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1146 | { |
---|
[56] | 1147 | rpcYuvDst->addAvgPdm( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
[2] | 1148 | } |
---|
[56] | 1149 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
[2] | 1150 | { |
---|
[56] | 1151 | pcYuvSrc0->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
[2] | 1152 | } |
---|
[56] | 1153 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1154 | { |
---|
[56] | 1155 | pcYuvSrc1->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
[2] | 1156 | } |
---|
[56] | 1157 | else |
---|
[2] | 1158 | { |
---|
[56] | 1159 | assert (0); |
---|
[2] | 1160 | } |
---|
[56] | 1161 | } |
---|
| 1162 | #endif |
---|
| 1163 | |
---|
| 1164 | Void TComPrediction::xWeightedAverage( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) |
---|
| 1165 | { |
---|
| 1166 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1167 | { |
---|
[56] | 1168 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); |
---|
[2] | 1169 | } |
---|
[56] | 1170 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
[2] | 1171 | { |
---|
[56] | 1172 | pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
[2] | 1173 | } |
---|
[56] | 1174 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1175 | { |
---|
[56] | 1176 | pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
| 1177 | } |
---|
| 1178 | } |
---|
| 1179 | |
---|
| 1180 | // AMVP |
---|
| 1181 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred ) |
---|
| 1182 | { |
---|
| 1183 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
| 1184 | |
---|
| 1185 | if( pcCU->getAMVPMode(uiPartAddr) == AM_NONE || (pcAMVPInfo->iN <= 1 && pcCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
| 1186 | { |
---|
| 1187 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
| 1188 | |
---|
| 1189 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 1190 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 1191 | return; |
---|
| 1192 | } |
---|
| 1193 | |
---|
| 1194 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
| 1195 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
| 1196 | return; |
---|
| 1197 | } |
---|
| 1198 | |
---|
| 1199 | /** Function for deriving planar intra prediction. |
---|
| 1200 | * \param pSrc pointer to reconstructed sample array |
---|
| 1201 | * \param srcStride the stride of the reconstructed sample array |
---|
| 1202 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 1203 | * \param dstStride the stride of the prediction sample array |
---|
| 1204 | * \param width the width of the block |
---|
| 1205 | * \param height the height of the block |
---|
| 1206 | * |
---|
| 1207 | * This function derives the prediction samples for planar mode (intra coding). |
---|
| 1208 | */ |
---|
| 1209 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
| 1210 | { |
---|
| 1211 | assert(width == height); |
---|
| 1212 | |
---|
| 1213 | Int k, l, bottomLeft, topRight; |
---|
| 1214 | Int horPred; |
---|
| 1215 | Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
| 1216 | UInt blkSize = width; |
---|
| 1217 | UInt offset2D = width; |
---|
| 1218 | UInt shift1D = g_aucConvertToBit[ width ] + 2; |
---|
| 1219 | UInt shift2D = shift1D + 1; |
---|
| 1220 | |
---|
| 1221 | // Get left and above reference column and row |
---|
| 1222 | for(k=0;k<blkSize+1;k++) |
---|
| 1223 | { |
---|
| 1224 | topRow[k] = pSrc[k-srcStride]; |
---|
| 1225 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
| 1226 | } |
---|
| 1227 | |
---|
| 1228 | // Prepare intermediate variables used in interpolation |
---|
| 1229 | bottomLeft = leftColumn[blkSize]; |
---|
| 1230 | topRight = topRow[blkSize]; |
---|
| 1231 | for (k=0;k<blkSize;k++) |
---|
| 1232 | { |
---|
| 1233 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
| 1234 | rightColumn[k] = topRight - leftColumn[k]; |
---|
| 1235 | topRow[k] <<= shift1D; |
---|
| 1236 | leftColumn[k] <<= shift1D; |
---|
| 1237 | } |
---|
| 1238 | |
---|
| 1239 | // Generate prediction signal |
---|
| 1240 | for (k=0;k<blkSize;k++) |
---|
| 1241 | { |
---|
| 1242 | horPred = leftColumn[k] + offset2D; |
---|
| 1243 | for (l=0;l<blkSize;l++) |
---|
[2] | 1244 | { |
---|
[56] | 1245 | horPred += rightColumn[k]; |
---|
| 1246 | topRow[l] += bottomRow[l]; |
---|
| 1247 | rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); |
---|
[2] | 1248 | } |
---|
| 1249 | } |
---|
| 1250 | } |
---|
| 1251 | |
---|
[56] | 1252 | /** Function for deriving chroma LM intra prediction. |
---|
| 1253 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
| 1254 | * \param piSrc pointer to reconstructed chroma sample array |
---|
| 1255 | * \param pPred pointer for the prediction sample array |
---|
| 1256 | * \param uiPredStride the stride of the prediction sample array |
---|
| 1257 | * \param uiCWidth the width of the chroma block |
---|
| 1258 | * \param uiCHeight the height of the chroma block |
---|
| 1259 | * \param uiChromaId boolean indication of chroma component |
---|
| 1260 | * |
---|
| 1261 | * This function derives the prediction samples for chroma LM mode (chroma intra coding) |
---|
| 1262 | */ |
---|
| 1263 | Void TComPrediction::predLMIntraChroma( TComPattern* pcPattern, Int* piSrc, Pel* pPred, UInt uiPredStride, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId ) |
---|
| 1264 | { |
---|
| 1265 | UInt uiWidth = 2 * uiCWidth; |
---|
[2] | 1266 | |
---|
[56] | 1267 | xGetLLSPrediction( pcPattern, piSrc+uiWidth+2, uiWidth+1, pPred, uiPredStride, uiCWidth, uiCHeight, 1 ); |
---|
| 1268 | } |
---|
| 1269 | |
---|
| 1270 | /** Function for deriving downsampled luma sample of current chroma block and its above, left causal pixel |
---|
| 1271 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
| 1272 | * \param uiCWidth the width of the chroma block |
---|
| 1273 | * \param uiCHeight the height of the chroma block |
---|
| 1274 | * |
---|
| 1275 | * This function derives downsampled luma sample of current chroma block and its above, left causal pixel |
---|
| 1276 | */ |
---|
| 1277 | Void TComPrediction::getLumaRecPixels( TComPattern* pcPattern, UInt uiCWidth, UInt uiCHeight ) |
---|
[2] | 1278 | { |
---|
[56] | 1279 | UInt uiWidth = 2 * uiCWidth; |
---|
| 1280 | UInt uiHeight = 2 * uiCHeight; |
---|
[2] | 1281 | |
---|
[56] | 1282 | Pel* pRecSrc = pcPattern->getROIY(); |
---|
| 1283 | Pel* pDst0 = m_pLumaRecBuffer + m_iLumaRecStride + 1; |
---|
[2] | 1284 | |
---|
[56] | 1285 | Int iRecSrcStride = pcPattern->getPatternLStride(); |
---|
| 1286 | Int iRecSrcStride2 = iRecSrcStride << 1; |
---|
| 1287 | Int iDstStride = m_iLumaRecStride; |
---|
| 1288 | Int iSrcStride = ( max( uiWidth, uiHeight ) << 1 ) + 1; |
---|
| 1289 | |
---|
| 1290 | Int* ptrSrc = pcPattern->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); |
---|
| 1291 | |
---|
| 1292 | // initial pointers |
---|
| 1293 | Pel* pDst = pDst0 - 1 - iDstStride; |
---|
| 1294 | Int* piSrc = ptrSrc; |
---|
| 1295 | |
---|
| 1296 | // top left corner downsampled from ADI buffer |
---|
| 1297 | // don't need this point |
---|
| 1298 | |
---|
| 1299 | // top row downsampled from ADI buffer |
---|
| 1300 | pDst++; |
---|
| 1301 | piSrc ++; |
---|
| 1302 | for (Int i = 0; i < uiCWidth; i++) |
---|
[2] | 1303 | { |
---|
[56] | 1304 | pDst[i] = ((piSrc[2*i] * 2 ) + piSrc[2*i - 1] + piSrc[2*i + 1] + 2) >> 2; |
---|
[2] | 1305 | } |
---|
| 1306 | |
---|
[56] | 1307 | // left column downsampled from ADI buffer |
---|
| 1308 | pDst = pDst0 - 1; |
---|
| 1309 | piSrc = ptrSrc + iSrcStride; |
---|
| 1310 | for (Int j = 0; j < uiCHeight; j++) |
---|
| 1311 | { |
---|
| 1312 | pDst[0] = ( piSrc[0] + piSrc[iSrcStride] ) >> 1; |
---|
| 1313 | piSrc += iSrcStride << 1; |
---|
| 1314 | pDst += iDstStride; |
---|
| 1315 | } |
---|
[2] | 1316 | |
---|
[56] | 1317 | // inner part from reconstructed picture buffer |
---|
| 1318 | for( Int j = 0; j < uiCHeight; j++ ) |
---|
| 1319 | { |
---|
| 1320 | for (Int i = 0; i < uiCWidth; i++) |
---|
| 1321 | { |
---|
| 1322 | pDst0[i] = (pRecSrc[2*i] + pRecSrc[2*i + iRecSrcStride]) >> 1; |
---|
| 1323 | } |
---|
| 1324 | |
---|
| 1325 | pDst0 += iDstStride; |
---|
| 1326 | pRecSrc += iRecSrcStride2; |
---|
| 1327 | } |
---|
[2] | 1328 | } |
---|
| 1329 | |
---|
[56] | 1330 | /** Function for deriving the positon of first non-zero binary bit of a value |
---|
| 1331 | * \param x input value |
---|
| 1332 | * |
---|
| 1333 | * This function derives the positon of first non-zero binary bit of a value |
---|
| 1334 | */ |
---|
| 1335 | Int GetMSB( UInt x ) |
---|
| 1336 | { |
---|
| 1337 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
| 1338 | |
---|
| 1339 | while( x > 1 ) |
---|
| 1340 | { |
---|
| 1341 | bits >>= 1; |
---|
| 1342 | y = x >> bits; |
---|
| 1343 | |
---|
| 1344 | if( y ) |
---|
| 1345 | { |
---|
| 1346 | x = y; |
---|
| 1347 | iMSB += bits; |
---|
| 1348 | } |
---|
| 1349 | } |
---|
| 1350 | |
---|
| 1351 | iMSB+=y; |
---|
| 1352 | |
---|
| 1353 | return iMSB; |
---|
| 1354 | } |
---|
| 1355 | |
---|
| 1356 | /** Function for counting leading number of zeros/ones |
---|
| 1357 | * \param x input value |
---|
| 1358 | \ This function counts leading number of zeros for positive numbers and |
---|
| 1359 | \ leading number of ones for negative numbers. This can be implemented in |
---|
| 1360 | \ single instructure cycle on many processors. |
---|
| 1361 | */ |
---|
| 1362 | |
---|
| 1363 | Short CountLeadingZerosOnes (Short x) |
---|
| 1364 | { |
---|
| 1365 | Short clz; |
---|
| 1366 | Short i; |
---|
| 1367 | |
---|
| 1368 | if(x == 0) |
---|
| 1369 | { |
---|
| 1370 | clz = 0; |
---|
| 1371 | } |
---|
| 1372 | else |
---|
| 1373 | { |
---|
| 1374 | if (x == -1) |
---|
| 1375 | { |
---|
| 1376 | clz = 15; |
---|
| 1377 | } |
---|
| 1378 | else |
---|
| 1379 | { |
---|
| 1380 | if(x < 0) |
---|
| 1381 | { |
---|
| 1382 | x = ~x; |
---|
| 1383 | } |
---|
| 1384 | clz = 15; |
---|
| 1385 | for(i = 0;i < 15;++i) |
---|
| 1386 | { |
---|
| 1387 | if(x) |
---|
| 1388 | { |
---|
| 1389 | clz --; |
---|
| 1390 | } |
---|
| 1391 | x = x >> 1; |
---|
| 1392 | } |
---|
| 1393 | } |
---|
| 1394 | } |
---|
| 1395 | return clz; |
---|
| 1396 | } |
---|
| 1397 | |
---|
| 1398 | /** Function for deriving LM intra prediction. |
---|
| 1399 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
| 1400 | * \param pSrc0 pointer to reconstructed chroma sample array |
---|
| 1401 | * \param iSrcStride the stride of reconstructed chroma sample array |
---|
| 1402 | * \param pDst0 reference to pointer for the prediction sample array |
---|
| 1403 | * \param iDstStride the stride of the prediction sample array |
---|
| 1404 | * \param uiWidth the width of the chroma block |
---|
| 1405 | * \param uiHeight the height of the chroma block |
---|
| 1406 | * \param uiExt0 line number of neiggboirng pixels for calculating LM model parameter, default value is 1 |
---|
| 1407 | * |
---|
| 1408 | * This function derives the prediction samples for chroma LM mode (chroma intra coding) |
---|
| 1409 | */ |
---|
| 1410 | Void TComPrediction::xGetLLSPrediction( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 ) |
---|
| 1411 | { |
---|
| 1412 | |
---|
| 1413 | Pel *pDst, *pLuma; |
---|
| 1414 | Int *pSrc; |
---|
| 1415 | |
---|
| 1416 | Int iLumaStride = m_iLumaRecStride; |
---|
| 1417 | Pel* pLuma0 = m_pLumaRecBuffer + uiExt0 * iLumaStride + uiExt0; |
---|
| 1418 | |
---|
| 1419 | Int i, j, iCountShift = 0; |
---|
| 1420 | |
---|
| 1421 | UInt uiExt = uiExt0; |
---|
| 1422 | |
---|
| 1423 | // LLS parameters estimation --> |
---|
| 1424 | |
---|
| 1425 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
| 1426 | |
---|
| 1427 | pSrc = pSrc0 - iSrcStride; |
---|
| 1428 | pLuma = pLuma0 - iLumaStride; |
---|
| 1429 | |
---|
| 1430 | for( j = 0; j < uiWidth; j++ ) |
---|
| 1431 | { |
---|
| 1432 | x += pLuma[j]; |
---|
| 1433 | y += pSrc[j]; |
---|
| 1434 | xx += pLuma[j] * pLuma[j]; |
---|
| 1435 | xy += pLuma[j] * pSrc[j]; |
---|
| 1436 | } |
---|
| 1437 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
| 1438 | |
---|
| 1439 | pSrc = pSrc0 - uiExt; |
---|
| 1440 | pLuma = pLuma0 - uiExt; |
---|
| 1441 | |
---|
| 1442 | for( i = 0; i < uiHeight; i++ ) |
---|
| 1443 | { |
---|
| 1444 | x += pLuma[0]; |
---|
| 1445 | y += pSrc[0]; |
---|
| 1446 | xx += pLuma[0] * pLuma[0]; |
---|
| 1447 | xy += pLuma[0] * pSrc[0]; |
---|
| 1448 | |
---|
| 1449 | pSrc += iSrcStride; |
---|
| 1450 | pLuma += iLumaStride; |
---|
| 1451 | } |
---|
| 1452 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
| 1453 | |
---|
| 1454 | Int iTempShift = ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
| 1455 | |
---|
| 1456 | if(iTempShift > 0) |
---|
| 1457 | { |
---|
| 1458 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1459 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1460 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1461 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1462 | iCountShift -= iTempShift; |
---|
| 1463 | } |
---|
| 1464 | |
---|
| 1465 | Int a, b, iShift = 13; |
---|
| 1466 | |
---|
| 1467 | if( iCountShift == 0 ) |
---|
| 1468 | { |
---|
| 1469 | a = 0; |
---|
| 1470 | b = 1 << (g_uiBitDepth + g_uiBitIncrement - 1); |
---|
| 1471 | iShift = 0; |
---|
| 1472 | } |
---|
| 1473 | else |
---|
| 1474 | { |
---|
| 1475 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
| 1476 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
| 1477 | |
---|
| 1478 | { |
---|
| 1479 | const Int iShiftA2 = 6; |
---|
| 1480 | const Int iShiftA1 = 15; |
---|
| 1481 | const Int iAccuracyShift = 15; |
---|
| 1482 | |
---|
| 1483 | Int iScaleShiftA2 = 0; |
---|
| 1484 | Int iScaleShiftA1 = 0; |
---|
| 1485 | Int a1s = a1; |
---|
| 1486 | Int a2s = a2; |
---|
| 1487 | |
---|
| 1488 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
| 1489 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
| 1490 | |
---|
| 1491 | if( iScaleShiftA1 < 0 ) |
---|
| 1492 | { |
---|
| 1493 | iScaleShiftA1 = 0; |
---|
| 1494 | } |
---|
| 1495 | |
---|
| 1496 | if( iScaleShiftA2 < 0 ) |
---|
| 1497 | { |
---|
| 1498 | iScaleShiftA2 = 0; |
---|
| 1499 | } |
---|
| 1500 | |
---|
| 1501 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
| 1502 | |
---|
| 1503 | a2s = a2 >> iScaleShiftA2; |
---|
| 1504 | |
---|
| 1505 | a1s = a1 >> iScaleShiftA1; |
---|
| 1506 | |
---|
| 1507 | if (a2s >= 1) |
---|
| 1508 | { |
---|
| 1509 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
| 1510 | } |
---|
| 1511 | else |
---|
| 1512 | { |
---|
| 1513 | a = 0; |
---|
| 1514 | } |
---|
| 1515 | |
---|
| 1516 | if( iScaleShiftA < 0 ) |
---|
| 1517 | { |
---|
| 1518 | a = a << -iScaleShiftA; |
---|
| 1519 | } |
---|
| 1520 | else |
---|
| 1521 | { |
---|
| 1522 | a = a >> iScaleShiftA; |
---|
| 1523 | } |
---|
| 1524 | |
---|
| 1525 | a = Clip3(-( 1 << 15 ), ( 1 << 15 ) - 1, a); |
---|
| 1526 | |
---|
| 1527 | Int minA = -(1 << (6)); |
---|
| 1528 | Int maxA = (1 << 6) - 1; |
---|
| 1529 | if( a <= maxA && a >= minA ) |
---|
| 1530 | { |
---|
| 1531 | // do nothing |
---|
| 1532 | } |
---|
| 1533 | else |
---|
| 1534 | { |
---|
| 1535 | Short n = CountLeadingZerosOnes(a); |
---|
| 1536 | a = a >> (9-n); |
---|
| 1537 | iShift -= (9-n); |
---|
| 1538 | } |
---|
| 1539 | |
---|
| 1540 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 1541 | } |
---|
| 1542 | } |
---|
| 1543 | |
---|
| 1544 | // <-- end of LLS parameters estimation |
---|
| 1545 | |
---|
| 1546 | // get prediction --> |
---|
| 1547 | uiExt = uiExt0; |
---|
| 1548 | pLuma = pLuma0; |
---|
| 1549 | pDst = pDst0; |
---|
| 1550 | |
---|
| 1551 | for( i = 0; i < uiHeight; i++ ) |
---|
| 1552 | { |
---|
| 1553 | for( j = 0; j < uiWidth; j++ ) |
---|
| 1554 | { |
---|
| 1555 | pDst[j] = Clip( ( ( a * pLuma[j] ) >> iShift ) + b ); |
---|
| 1556 | } |
---|
| 1557 | |
---|
| 1558 | pDst += iDstStride; |
---|
| 1559 | pLuma += iLumaStride; |
---|
| 1560 | } |
---|
| 1561 | // <-- end of get prediction |
---|
| 1562 | |
---|
| 1563 | } |
---|
| 1564 | |
---|
[189] | 1565 | |
---|
| 1566 | #if LGE_ILLUCOMP_B0045 |
---|
| 1567 | /** Function for deriving LM illumination compensation. |
---|
| 1568 | */ |
---|
| 1569 | Void TComPrediction::xGetLLSICPrediction(TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift) |
---|
| 1570 | { |
---|
| 1571 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
| 1572 | Pel *pRec, *pRef; |
---|
| 1573 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
| 1574 | Int iRecStride = pRecPic->getStride(), iRefStride = pRefPic->getStride(); |
---|
| 1575 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset; |
---|
| 1576 | |
---|
| 1577 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1578 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1579 | iRefX = iCUPelX + (pMv->getHor() >> 2); |
---|
| 1580 | iRefY = iCUPelY + (pMv->getVer() >> 2); |
---|
| 1581 | uiWidth = pcCU->getWidth(0); |
---|
| 1582 | uiHeight = pcCU->getHeight(0); |
---|
| 1583 | |
---|
| 1584 | Int i, j, iCountShift = 0; |
---|
| 1585 | |
---|
| 1586 | // LLS parameters estimation --> |
---|
| 1587 | |
---|
| 1588 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
| 1589 | |
---|
| 1590 | if(pcCU->getPUAbove(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelY > 0 && iRefY > 0) |
---|
| 1591 | { |
---|
| 1592 | iRefOffset = ( pMv->getHor() >> 2 ) + ( pMv->getVer() >> 2 ) * iRefStride - iRefStride; |
---|
| 1593 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1594 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1595 | |
---|
| 1596 | for( j = 0; j < uiWidth; j++ ) |
---|
| 1597 | { |
---|
| 1598 | x += pRef[j]; |
---|
| 1599 | y += pRec[j]; |
---|
| 1600 | xx += pRef[j] * pRef[j]; |
---|
| 1601 | xy += pRef[j] * pRec[j]; |
---|
| 1602 | } |
---|
| 1603 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
| 1604 | } |
---|
| 1605 | |
---|
| 1606 | |
---|
| 1607 | if(pcCU->getPULeft(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelX > 0 && iRefX > 0) |
---|
| 1608 | { |
---|
| 1609 | iRefOffset = ( pMv->getHor() >> 2 ) + ( pMv->getVer() >> 2 ) * iRefStride - 1; |
---|
| 1610 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1611 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1612 | |
---|
| 1613 | for( i = 0; i < uiHeight; i++ ) |
---|
| 1614 | { |
---|
| 1615 | x += pRef[0]; |
---|
| 1616 | y += pRec[0]; |
---|
| 1617 | xx += pRef[0] * pRef[0]; |
---|
| 1618 | xy += pRef[0] * pRec[0]; |
---|
| 1619 | |
---|
| 1620 | pRef += iRefStride; |
---|
| 1621 | pRec += iRecStride; |
---|
| 1622 | } |
---|
| 1623 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
| 1624 | } |
---|
| 1625 | |
---|
| 1626 | Int iTempShift = ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
| 1627 | |
---|
| 1628 | if(iTempShift > 0) |
---|
| 1629 | { |
---|
| 1630 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1631 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1632 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1633 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1634 | iCountShift -= iTempShift; |
---|
| 1635 | } |
---|
| 1636 | |
---|
| 1637 | iShift = 13; |
---|
| 1638 | |
---|
| 1639 | if( iCountShift == 0 ) |
---|
| 1640 | { |
---|
| 1641 | a = 1; |
---|
| 1642 | b = 0; |
---|
| 1643 | iShift = 0; |
---|
| 1644 | } |
---|
| 1645 | else |
---|
| 1646 | { |
---|
| 1647 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
| 1648 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
| 1649 | |
---|
| 1650 | { |
---|
| 1651 | const Int iShiftA2 = 6; |
---|
| 1652 | const Int iShiftA1 = 15; |
---|
| 1653 | const Int iAccuracyShift = 15; |
---|
| 1654 | |
---|
| 1655 | Int iScaleShiftA2 = 0; |
---|
| 1656 | Int iScaleShiftA1 = 0; |
---|
| 1657 | Int a1s = a1; |
---|
| 1658 | Int a2s = a2; |
---|
| 1659 | |
---|
| 1660 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
| 1661 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
| 1662 | |
---|
| 1663 | if( iScaleShiftA1 < 0 ) |
---|
| 1664 | { |
---|
| 1665 | iScaleShiftA1 = 0; |
---|
| 1666 | } |
---|
| 1667 | |
---|
| 1668 | if( iScaleShiftA2 < 0 ) |
---|
| 1669 | { |
---|
| 1670 | iScaleShiftA2 = 0; |
---|
| 1671 | } |
---|
| 1672 | |
---|
| 1673 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
| 1674 | |
---|
| 1675 | a2s = a2 >> iScaleShiftA2; |
---|
| 1676 | |
---|
| 1677 | a1s = a1 >> iScaleShiftA1; |
---|
| 1678 | |
---|
| 1679 | if (a2s >= 1) |
---|
| 1680 | { |
---|
| 1681 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
| 1682 | } |
---|
| 1683 | else |
---|
| 1684 | { |
---|
| 1685 | a = 0; |
---|
| 1686 | } |
---|
| 1687 | |
---|
| 1688 | if( iScaleShiftA < 0 ) |
---|
| 1689 | { |
---|
| 1690 | a = a << -iScaleShiftA; |
---|
| 1691 | } |
---|
| 1692 | else |
---|
| 1693 | { |
---|
| 1694 | a = a >> iScaleShiftA; |
---|
| 1695 | } |
---|
| 1696 | |
---|
| 1697 | a = Clip3(-( 1 << 15 ), ( 1 << 15 ) - 1, a); |
---|
| 1698 | |
---|
| 1699 | Int minA = -(1 << (6)); |
---|
| 1700 | Int maxA = (1 << 6) - 1; |
---|
| 1701 | if( a <= maxA && a >= minA ) |
---|
| 1702 | { |
---|
| 1703 | // do nothing |
---|
| 1704 | } |
---|
| 1705 | else |
---|
| 1706 | { |
---|
| 1707 | Short n = CountLeadingZerosOnes(a); |
---|
| 1708 | a = a >> (9-n); |
---|
| 1709 | iShift -= (9-n); |
---|
| 1710 | } |
---|
| 1711 | |
---|
| 1712 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 1713 | } |
---|
| 1714 | } |
---|
| 1715 | } |
---|
| 1716 | |
---|
| 1717 | Void TComPrediction::xGetLLSICPredictionChroma(TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift, Int iChromaId) |
---|
| 1718 | { |
---|
| 1719 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
| 1720 | Pel *pRec = NULL, *pRef = NULL; |
---|
| 1721 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
| 1722 | Int iRecStride = pRecPic->getCStride(), iRefStride = pRefPic->getCStride(); |
---|
| 1723 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset; |
---|
| 1724 | |
---|
| 1725 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1726 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1727 | iRefX = iCUPelX + (pMv->getHor() >> 3); |
---|
| 1728 | iRefY = iCUPelY + (pMv->getVer() >> 3); |
---|
| 1729 | uiWidth = pcCU->getWidth(0) >> 1; |
---|
| 1730 | uiHeight = pcCU->getHeight(0) >> 1; |
---|
| 1731 | |
---|
| 1732 | Int i, j, iCountShift = 0; |
---|
| 1733 | |
---|
| 1734 | // LLS parameters estimation --> |
---|
| 1735 | |
---|
| 1736 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
| 1737 | |
---|
| 1738 | if(pcCU->getPUAbove(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelY > 0 && iRefY > 0) |
---|
| 1739 | { |
---|
| 1740 | iRefOffset = ( pMv->getHor() >> 3 ) + ( pMv->getVer() >> 3 ) * iRefStride - iRefStride; |
---|
| 1741 | if (iChromaId == 0) // Cb |
---|
| 1742 | { |
---|
| 1743 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1744 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1745 | } |
---|
| 1746 | else if (iChromaId == 1) // Cr |
---|
| 1747 | { |
---|
| 1748 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1749 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1750 | } |
---|
| 1751 | |
---|
| 1752 | for( j = 0; j < uiWidth; j++ ) |
---|
| 1753 | { |
---|
| 1754 | x += pRef[j]; |
---|
| 1755 | y += pRec[j]; |
---|
| 1756 | xx += pRef[j] * pRef[j]; |
---|
| 1757 | xy += pRef[j] * pRec[j]; |
---|
| 1758 | } |
---|
| 1759 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
| 1760 | } |
---|
| 1761 | |
---|
| 1762 | |
---|
| 1763 | if(pcCU->getPULeft(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelX > 0 && iRefX > 0) |
---|
| 1764 | { |
---|
| 1765 | iRefOffset = ( pMv->getHor() >> 3 ) + ( pMv->getVer() >> 3 ) * iRefStride - 1; |
---|
| 1766 | if (iChromaId == 0) // Cb |
---|
| 1767 | { |
---|
| 1768 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1769 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1770 | } |
---|
| 1771 | else if (iChromaId == 1) // Cr |
---|
| 1772 | { |
---|
| 1773 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1774 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1775 | } |
---|
| 1776 | |
---|
| 1777 | for( i = 0; i < uiHeight; i++ ) |
---|
| 1778 | { |
---|
| 1779 | x += pRef[0]; |
---|
| 1780 | y += pRec[0]; |
---|
| 1781 | xx += pRef[0] * pRef[0]; |
---|
| 1782 | xy += pRef[0] * pRec[0]; |
---|
| 1783 | |
---|
| 1784 | pRef += iRefStride; |
---|
| 1785 | pRec += iRecStride; |
---|
| 1786 | } |
---|
| 1787 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
| 1788 | } |
---|
| 1789 | |
---|
| 1790 | Int iTempShift = ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
| 1791 | |
---|
| 1792 | if(iTempShift > 0) |
---|
| 1793 | { |
---|
| 1794 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1795 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1796 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1797 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1798 | iCountShift -= iTempShift; |
---|
| 1799 | } |
---|
| 1800 | |
---|
| 1801 | iShift = 13; |
---|
| 1802 | |
---|
| 1803 | if( iCountShift == 0 ) |
---|
| 1804 | { |
---|
| 1805 | a = 1; |
---|
| 1806 | b = 0; |
---|
| 1807 | iShift = 0; |
---|
| 1808 | } |
---|
| 1809 | else |
---|
| 1810 | { |
---|
| 1811 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
| 1812 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
| 1813 | |
---|
| 1814 | { |
---|
| 1815 | const Int iShiftA2 = 6; |
---|
| 1816 | const Int iShiftA1 = 15; |
---|
| 1817 | const Int iAccuracyShift = 15; |
---|
| 1818 | |
---|
| 1819 | Int iScaleShiftA2 = 0; |
---|
| 1820 | Int iScaleShiftA1 = 0; |
---|
| 1821 | Int a1s = a1; |
---|
| 1822 | Int a2s = a2; |
---|
| 1823 | |
---|
| 1824 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
| 1825 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
| 1826 | |
---|
| 1827 | if( iScaleShiftA1 < 0 ) |
---|
| 1828 | { |
---|
| 1829 | iScaleShiftA1 = 0; |
---|
| 1830 | } |
---|
| 1831 | |
---|
| 1832 | if( iScaleShiftA2 < 0 ) |
---|
| 1833 | { |
---|
| 1834 | iScaleShiftA2 = 0; |
---|
| 1835 | } |
---|
| 1836 | |
---|
| 1837 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
| 1838 | |
---|
| 1839 | a2s = a2 >> iScaleShiftA2; |
---|
| 1840 | |
---|
| 1841 | a1s = a1 >> iScaleShiftA1; |
---|
| 1842 | |
---|
| 1843 | if (a2s >= 1) |
---|
| 1844 | { |
---|
| 1845 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
| 1846 | } |
---|
| 1847 | else |
---|
| 1848 | { |
---|
| 1849 | a = 0; |
---|
| 1850 | } |
---|
| 1851 | |
---|
| 1852 | if( iScaleShiftA < 0 ) |
---|
| 1853 | { |
---|
| 1854 | a = a << -iScaleShiftA; |
---|
| 1855 | } |
---|
| 1856 | else |
---|
| 1857 | { |
---|
| 1858 | a = a >> iScaleShiftA; |
---|
| 1859 | } |
---|
| 1860 | |
---|
| 1861 | a = Clip3(-( 1 << 15 ), ( 1 << 15 ) - 1, a); |
---|
| 1862 | |
---|
| 1863 | Int minA = -(1 << (6)); |
---|
| 1864 | Int maxA = (1 << 6) - 1; |
---|
| 1865 | if( a <= maxA && a >= minA ) |
---|
| 1866 | { |
---|
| 1867 | // do nothing |
---|
| 1868 | } |
---|
| 1869 | else |
---|
| 1870 | { |
---|
| 1871 | Short n = CountLeadingZerosOnes(a); |
---|
| 1872 | a = a >> (9-n); |
---|
| 1873 | iShift -= (9-n); |
---|
| 1874 | } |
---|
| 1875 | |
---|
| 1876 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 1877 | } |
---|
| 1878 | } |
---|
| 1879 | } |
---|
| 1880 | #endif |
---|
[56] | 1881 | /** Function for filtering intra DC predictor. |
---|
| 1882 | * \param pSrc pointer to reconstructed sample array |
---|
| 1883 | * \param iSrcStride the stride of the reconstructed sample array |
---|
| 1884 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 1885 | * \param iDstStride the stride of the prediction sample array |
---|
| 1886 | * \param iWidth the width of the block |
---|
| 1887 | * \param iHeight the height of the block |
---|
| 1888 | * |
---|
| 1889 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
| 1890 | */ |
---|
| 1891 | Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) |
---|
| 1892 | { |
---|
| 1893 | Pel* pDst = rpDst; |
---|
| 1894 | Int x, y, iDstStride2, iSrcStride2; |
---|
| 1895 | |
---|
| 1896 | // boundary pixels processing |
---|
| 1897 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
| 1898 | |
---|
| 1899 | for ( x = 1; x < iWidth; x++ ) |
---|
| 1900 | { |
---|
| 1901 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
| 1902 | } |
---|
| 1903 | |
---|
| 1904 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
| 1905 | { |
---|
| 1906 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
| 1907 | } |
---|
| 1908 | |
---|
| 1909 | return; |
---|
| 1910 | } |
---|
| 1911 | |
---|
[5] | 1912 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[2] | 1913 | Void TComPrediction::predIntraLumaDMM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder ) |
---|
| 1914 | { |
---|
[5] | 1915 | #if HHI_DMM_WEDGE_INTRA |
---|
[56] | 1916 | if( uiMode == DMM_WEDGE_FULL_IDX ) { xPredIntraWedgeFull ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU->getWedgeFullTabIdx ( uiAbsPartIdx ) ); } |
---|
| 1917 | if( uiMode == DMM_WEDGE_FULL_D_IDX ) { xPredIntraWedgeFull ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getWedgeFullTabIdx( uiAbsPartIdx ), pcCU->getWedgeFullDeltaDC1( uiAbsPartIdx ), pcCU->getWedgeFullDeltaDC2( uiAbsPartIdx ) ); } |
---|
| 1918 | if( uiMode == DMM_WEDGE_PREDDIR_IDX ) { xPredIntraWedgeDir ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU->getWedgePredDirDeltaEnd( uiAbsPartIdx ) ); } |
---|
| 1919 | if( uiMode == DMM_WEDGE_PREDDIR_D_IDX ) { xPredIntraWedgeDir ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getWedgePredDirDeltaEnd( uiAbsPartIdx ), pcCU->getWedgePredDirDeltaDC1( uiAbsPartIdx ), pcCU->getWedgePredDirDeltaDC2( uiAbsPartIdx ) ); } |
---|
[5] | 1920 | #endif |
---|
| 1921 | #if HHI_DMM_PRED_TEX |
---|
[56] | 1922 | if( uiMode == DMM_WEDGE_PREDTEX_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); } |
---|
| 1923 | if( uiMode == DMM_WEDGE_PREDTEX_D_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getWedgePredTexDeltaDC1( uiAbsPartIdx ), pcCU->getWedgePredTexDeltaDC2( uiAbsPartIdx ) ); } |
---|
| 1924 | if( uiMode == DMM_CONTOUR_PREDTEX_IDX ) { xPredIntraContourTex( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); } |
---|
| 1925 | if( uiMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xPredIntraContourTex( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getContourPredTexDeltaDC1( uiAbsPartIdx ), pcCU->getContourPredTexDeltaDC2( uiAbsPartIdx ) ); } |
---|
[5] | 1926 | #endif |
---|
| 1927 | } |
---|
[2] | 1928 | |
---|
[56] | 1929 | Void TComPrediction::getWedgePredDCs( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft ) |
---|
[2] | 1930 | { |
---|
[56] | 1931 | riPredDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); //pred val, if no neighbors are available |
---|
| 1932 | riPredDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
[2] | 1933 | |
---|
[56] | 1934 | if( !bAbove && !bLeft ) { return; } |
---|
[2] | 1935 | |
---|
[56] | 1936 | UInt uiNumSmpDC1 = 0, uiNumSmpDC2 = 0; |
---|
| 1937 | Int iPredDC1 = 0, iPredDC2 = 0; |
---|
| 1938 | |
---|
| 1939 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
| 1940 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
| 1941 | |
---|
| 1942 | if( bAbove ) |
---|
| 1943 | { |
---|
| 1944 | for( Int k = 0; k < pcWedgelet->getWidth(); k++ ) |
---|
| 1945 | { |
---|
| 1946 | if( true == pabWedgePattern[k] ) |
---|
| 1947 | { |
---|
| 1948 | iPredDC2 += piMask[k-iMaskStride]; |
---|
| 1949 | uiNumSmpDC2++; |
---|
| 1950 | } |
---|
| 1951 | else |
---|
| 1952 | { |
---|
| 1953 | iPredDC1 += piMask[k-iMaskStride]; |
---|
| 1954 | uiNumSmpDC1++; |
---|
| 1955 | } |
---|
| 1956 | } |
---|
| 1957 | } |
---|
| 1958 | if( bLeft ) |
---|
| 1959 | { |
---|
| 1960 | for( Int k = 0; k < pcWedgelet->getHeight(); k++ ) |
---|
| 1961 | { |
---|
| 1962 | if( true == pabWedgePattern[k*uiWedgeStride] ) |
---|
| 1963 | { |
---|
| 1964 | iPredDC2 += piMask[k*iMaskStride-1]; |
---|
| 1965 | uiNumSmpDC2++; |
---|
| 1966 | } |
---|
| 1967 | else |
---|
| 1968 | { |
---|
| 1969 | iPredDC1 += piMask[k*iMaskStride-1]; |
---|
| 1970 | uiNumSmpDC1++; |
---|
| 1971 | } |
---|
| 1972 | } |
---|
| 1973 | } |
---|
| 1974 | |
---|
| 1975 | if( uiNumSmpDC1 > 0 ) |
---|
| 1976 | { |
---|
| 1977 | iPredDC1 /= uiNumSmpDC1; |
---|
| 1978 | riPredDC1 = iPredDC1; |
---|
| 1979 | } |
---|
| 1980 | if( uiNumSmpDC2 > 0 ) |
---|
| 1981 | { |
---|
| 1982 | iPredDC2 /= uiNumSmpDC2; |
---|
| 1983 | riPredDC2 = iPredDC2; |
---|
| 1984 | } |
---|
[2] | 1985 | } |
---|
| 1986 | |
---|
[5] | 1987 | Void TComPrediction::calcWedgeDCs( TComWedgelet* pcWedgelet, Pel* piOrig, UInt uiStride, Int& riDC1, Int& riDC2 ) |
---|
[2] | 1988 | { |
---|
[5] | 1989 | UInt uiDC1 = 0; |
---|
| 1990 | UInt uiDC2 = 0; |
---|
| 1991 | UInt uiNumPixDC1 = 0, uiNumPixDC2 = 0; |
---|
| 1992 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
| 1993 | if( uiStride == pcWedgelet->getStride() ) |
---|
| 1994 | { |
---|
| 1995 | for( UInt k = 0; k < (pcWedgelet->getWidth() * pcWedgelet->getHeight()); k++ ) |
---|
| 1996 | { |
---|
| 1997 | if( true == pabWedgePattern[k] ) |
---|
| 1998 | { |
---|
| 1999 | uiDC2 += piOrig[k]; |
---|
| 2000 | uiNumPixDC2++; |
---|
| 2001 | } |
---|
| 2002 | else |
---|
| 2003 | { |
---|
| 2004 | uiDC1 += piOrig[k]; |
---|
| 2005 | uiNumPixDC1++; |
---|
| 2006 | } |
---|
| 2007 | } |
---|
| 2008 | } |
---|
| 2009 | else |
---|
| 2010 | { |
---|
| 2011 | Pel* piTemp = piOrig; |
---|
| 2012 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
| 2013 | for( UInt uiY = 0; uiY < pcWedgelet->getHeight(); uiY++ ) |
---|
| 2014 | { |
---|
| 2015 | for( UInt uiX = 0; uiX < pcWedgelet->getWidth(); uiX++ ) |
---|
| 2016 | { |
---|
| 2017 | if( true == pabWedgePattern[uiX] ) |
---|
| 2018 | { |
---|
| 2019 | uiDC2 += piTemp[uiX]; |
---|
| 2020 | uiNumPixDC2++; |
---|
| 2021 | } |
---|
| 2022 | else |
---|
| 2023 | { |
---|
| 2024 | uiDC1 += piTemp[uiX]; |
---|
| 2025 | uiNumPixDC1++; |
---|
| 2026 | } |
---|
| 2027 | } |
---|
| 2028 | piTemp += uiStride; |
---|
| 2029 | pabWedgePattern += uiWedgeStride; |
---|
| 2030 | } |
---|
| 2031 | } |
---|
[2] | 2032 | |
---|
[5] | 2033 | if( uiNumPixDC1 > 0 ) { riDC1 = uiDC1 / uiNumPixDC1; } |
---|
| 2034 | else { riDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); } |
---|
[2] | 2035 | |
---|
[5] | 2036 | if( uiNumPixDC2 > 0 ) { riDC2 = uiDC2 / uiNumPixDC2; } |
---|
| 2037 | else { riDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); } |
---|
| 2038 | } |
---|
[2] | 2039 | |
---|
[5] | 2040 | Void TComPrediction::assignWedgeDCs2Pred( TComWedgelet* pcWedgelet, Pel* piPred, UInt uiStride, Int iDC1, Int iDC2 ) |
---|
| 2041 | { |
---|
| 2042 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
| 2043 | |
---|
| 2044 | if( uiStride == pcWedgelet->getStride() ) |
---|
[2] | 2045 | { |
---|
[5] | 2046 | for( UInt k = 0; k < (pcWedgelet->getWidth() * pcWedgelet->getHeight()); k++ ) |
---|
| 2047 | { |
---|
| 2048 | if( true == pabWedgePattern[k] ) |
---|
| 2049 | { |
---|
| 2050 | piPred[k] = iDC2; |
---|
| 2051 | } |
---|
| 2052 | else |
---|
| 2053 | { |
---|
| 2054 | piPred[k] = iDC1; |
---|
| 2055 | } |
---|
| 2056 | } |
---|
[2] | 2057 | } |
---|
[5] | 2058 | else |
---|
| 2059 | { |
---|
| 2060 | Pel* piTemp = piPred; |
---|
| 2061 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
| 2062 | for( UInt uiY = 0; uiY < pcWedgelet->getHeight(); uiY++ ) |
---|
| 2063 | { |
---|
| 2064 | for( UInt uiX = 0; uiX < pcWedgelet->getWidth(); uiX++ ) |
---|
| 2065 | { |
---|
| 2066 | if( true == pabWedgePattern[uiX] ) |
---|
| 2067 | { |
---|
| 2068 | piTemp[uiX] = iDC2; |
---|
| 2069 | } |
---|
| 2070 | else |
---|
[56] | 2071 | { |
---|
[5] | 2072 | piTemp[uiX] = iDC1; |
---|
| 2073 | } |
---|
| 2074 | } |
---|
| 2075 | piTemp += uiStride; |
---|
| 2076 | pabWedgePattern += uiWedgeStride; |
---|
| 2077 | } |
---|
| 2078 | } |
---|
[2] | 2079 | } |
---|
| 2080 | |
---|
[56] | 2081 | Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Int& riDeltaDC ) |
---|
[2] | 2082 | { |
---|
[56] | 2083 | Int iSign = riDeltaDC < 0 ? -1 : 1; |
---|
| 2084 | UInt uiAbs = abs( riDeltaDC ); |
---|
[2] | 2085 | |
---|
[56] | 2086 | Int iQp = pcCU->getQP(0); |
---|
| 2087 | Double dMax = (Double)( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
| 2088 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 + g_iDeltaDCsQuantOffset ) ); |
---|
[2] | 2089 | |
---|
[56] | 2090 | riDeltaDC = iSign * roftoi( uiAbs * dStepSize ); |
---|
| 2091 | return; |
---|
| 2092 | } |
---|
[2] | 2093 | |
---|
[56] | 2094 | Void TComPrediction::xDeltaDCQuantScaleDown( TComDataCU* pcCU, Int& riDeltaDC ) |
---|
| 2095 | { |
---|
| 2096 | Int iSign = riDeltaDC < 0 ? -1 : 1; |
---|
| 2097 | UInt uiAbs = abs( riDeltaDC ); |
---|
[2] | 2098 | |
---|
[56] | 2099 | Int iQp = pcCU->getQP(0); |
---|
| 2100 | Double dMax = (Double)( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
| 2101 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 + g_iDeltaDCsQuantOffset ) ); |
---|
| 2102 | |
---|
| 2103 | riDeltaDC = iSign * roftoi( uiAbs / dStepSize ); |
---|
| 2104 | return; |
---|
| 2105 | } |
---|
| 2106 | #endif |
---|
| 2107 | |
---|
| 2108 | #if HHI_DMM_PRED_TEX |
---|
| 2109 | Void TComPrediction::getBestContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) |
---|
| 2110 | { |
---|
| 2111 | pcContourWedge->clear(); |
---|
| 2112 | |
---|
| 2113 | // get copy of co-located texture luma block |
---|
| 2114 | TComYuv cTempYuv; |
---|
| 2115 | cTempYuv.create( uiWidth, uiHeight ); |
---|
| 2116 | cTempYuv.clear(); |
---|
| 2117 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2118 | copyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
| 2119 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2120 | |
---|
| 2121 | // find contour for texture luma block |
---|
| 2122 | UInt iDC = 0; |
---|
| 2123 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
| 2124 | { |
---|
| 2125 | iDC += piRefBlkY[k]; |
---|
[2] | 2126 | } |
---|
[56] | 2127 | iDC /= (uiWidth*uiHeight); |
---|
| 2128 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2129 | |
---|
| 2130 | Bool* pabContourPattern = pcContourWedge->getPattern(); |
---|
| 2131 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
| 2132 | { |
---|
| 2133 | pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; |
---|
| 2134 | } |
---|
| 2135 | |
---|
| 2136 | cTempYuv.destroy(); |
---|
| 2137 | } |
---|
| 2138 | |
---|
| 2139 | UInt TComPrediction::getBestWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight ) |
---|
| 2140 | { |
---|
| 2141 | assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
| 2142 | |
---|
| 2143 | // get copy of co-located texture luma block |
---|
| 2144 | TComYuv cTempYuv; |
---|
| 2145 | cTempYuv.create( uiWidth, uiHeight ); |
---|
| 2146 | cTempYuv.clear(); |
---|
| 2147 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2148 | |
---|
| 2149 | copyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
| 2150 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2151 | |
---|
| 2152 | // local pred buffer |
---|
| 2153 | TComYuv cPredYuv; |
---|
| 2154 | cPredYuv.create( uiWidth, uiHeight ); |
---|
| 2155 | cPredYuv.clear(); |
---|
| 2156 | Pel* piPred = cPredYuv.getLumaAddr(); |
---|
| 2157 | |
---|
| 2158 | UInt uiPredStride = cPredYuv.getStride(); |
---|
| 2159 | |
---|
[189] | 2160 | // wedge search |
---|
[56] | 2161 | TComWedgeDist cWedgeDist; |
---|
| 2162 | UInt uiBestDist = MAX_UINT; |
---|
| 2163 | UInt uiBestTabIdx = 0; |
---|
| 2164 | Int iDC1 = 0; |
---|
| 2165 | Int iDC2 = 0; |
---|
[189] | 2166 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])]; |
---|
[56] | 2167 | |
---|
[189] | 2168 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
| 2169 | TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); |
---|
| 2170 | TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); |
---|
| 2171 | UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 2172 | Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; |
---|
| 2173 | |
---|
| 2174 | std::vector< std::vector<UInt> > pauiWdgLstSz = g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]]; |
---|
| 2175 | if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) |
---|
| 2176 | { |
---|
| 2177 | std::vector<UInt>* pauiWdgLst = &pauiWdgLstSz[uiColTexIntraDir-2]; |
---|
| 2178 | for( UInt uiIdxW = 0; uiIdxW < pauiWdgLst->size(); uiIdxW++ ) |
---|
| 2179 | { |
---|
| 2180 | UInt uiIdx = pauiWdgLst->at(uiIdxW); |
---|
| 2181 | calcWedgeDCs ( &(pacWedgeList->at(uiIdx)), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
| 2182 | assignWedgeDCs2Pred( &(pacWedgeList->at(uiIdx)), piPred, uiPredStride, iDC1, iDC2 ); |
---|
| 2183 | |
---|
| 2184 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
| 2185 | |
---|
| 2186 | if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) |
---|
| 2187 | { |
---|
| 2188 | uiBestDist = uiActDist; |
---|
| 2189 | uiBestTabIdx = uiIdx; |
---|
| 2190 | } |
---|
| 2191 | } |
---|
| 2192 | } |
---|
| 2193 | else |
---|
| 2194 | { |
---|
| 2195 | WedgeNodeList* pacWedgeNodeList = &g_aacWedgeNodeLists[(g_aucConvertToBit[uiWidth])]; |
---|
| 2196 | UInt uiBestNodeDist = MAX_UINT; |
---|
| 2197 | UInt uiBestNodeId = 0; |
---|
| 2198 | for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ ) |
---|
| 2199 | { |
---|
| 2200 | calcWedgeDCs ( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
| 2201 | assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piPred, uiPredStride, iDC1, iDC2 ); |
---|
| 2202 | |
---|
| 2203 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
| 2204 | |
---|
| 2205 | if( uiActDist < uiBestNodeDist || uiBestNodeDist == MAX_UINT ) |
---|
| 2206 | { |
---|
| 2207 | uiBestNodeDist = uiActDist; |
---|
| 2208 | uiBestNodeId = uiNodeId; |
---|
| 2209 | } |
---|
| 2210 | } |
---|
| 2211 | |
---|
| 2212 | // refinement |
---|
| 2213 | uiBestDist = uiBestNodeDist; |
---|
| 2214 | uiBestTabIdx = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx(); |
---|
| 2215 | for( UInt uiRefId = 0; uiRefId < NUM_WEDGE_REFINES; uiRefId++ ) |
---|
| 2216 | { |
---|
| 2217 | if( pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ) != NO_IDX ) |
---|
| 2218 | { |
---|
| 2219 | calcWedgeDCs ( &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
| 2220 | assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))), piPred, uiPredStride, iDC1, iDC2 ); |
---|
| 2221 | |
---|
| 2222 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
| 2223 | |
---|
| 2224 | if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) |
---|
| 2225 | { |
---|
| 2226 | uiBestDist = uiActDist; |
---|
| 2227 | uiBestTabIdx = pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ); |
---|
| 2228 | } |
---|
| 2229 | } |
---|
| 2230 | } |
---|
| 2231 | } |
---|
| 2232 | #else |
---|
[56] | 2233 | for( UInt uiIdx = 0; uiIdx < pacWedgeList->size(); uiIdx++ ) |
---|
[2] | 2234 | { |
---|
[56] | 2235 | calcWedgeDCs ( &(pacWedgeList->at(uiIdx)), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
| 2236 | assignWedgeDCs2Pred( &(pacWedgeList->at(uiIdx)), piPred, uiPredStride, iDC1, iDC2 ); |
---|
| 2237 | |
---|
| 2238 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
| 2239 | |
---|
| 2240 | if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) |
---|
[2] | 2241 | { |
---|
[56] | 2242 | uiBestDist = uiActDist; |
---|
| 2243 | uiBestTabIdx = uiIdx; |
---|
[2] | 2244 | } |
---|
| 2245 | } |
---|
[189] | 2246 | #endif |
---|
[2] | 2247 | |
---|
[56] | 2248 | cPredYuv.destroy(); |
---|
| 2249 | cTempYuv.destroy(); |
---|
| 2250 | return uiBestTabIdx; |
---|
| 2251 | } |
---|
| 2252 | |
---|
| 2253 | Void TComPrediction::copyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) |
---|
| 2254 | { |
---|
| 2255 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
| 2256 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
| 2257 | Pel* piRefY; |
---|
| 2258 | |
---|
| 2259 | piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 2260 | |
---|
| 2261 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
[2] | 2262 | { |
---|
[56] | 2263 | ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); |
---|
| 2264 | // ::memset(piDestBlockY, 128, sizeof(Pel)*uiWidth); |
---|
| 2265 | piDestBlockY += uiWidth; |
---|
| 2266 | piRefY += iRefStride; |
---|
[2] | 2267 | } |
---|
| 2268 | } |
---|
| 2269 | |
---|
[56] | 2270 | Void TComPrediction::xPredIntraWedgeTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 ) |
---|
[2] | 2271 | { |
---|
[5] | 2272 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
| 2273 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
[2] | 2274 | |
---|
[56] | 2275 | // get wedge pattern |
---|
| 2276 | UInt uiTextureWedgeTabIdx = 0; |
---|
| 2277 | if( bEncoder ) |
---|
| 2278 | { |
---|
| 2279 | // encoder: load stored wedge pattern from CU |
---|
| 2280 | uiTextureWedgeTabIdx = pcCU->getWedgePredTexTabIdx( uiAbsPartIdx ); |
---|
| 2281 | } |
---|
| 2282 | else |
---|
| 2283 | { |
---|
| 2284 | // decoder: get and store wedge pattern in CU |
---|
| 2285 | uiTextureWedgeTabIdx = getBestWedgeFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight ); |
---|
| 2286 | |
---|
| 2287 | UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1); |
---|
| 2288 | pcCU->setWedgePredTexTabIdxSubParts( uiTextureWedgeTabIdx, uiAbsPartIdx, uiDepth ); |
---|
| 2289 | } |
---|
| 2290 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTextureWedgeTabIdx)); |
---|
| 2291 | |
---|
[5] | 2292 | // get wedge pred DCs |
---|
| 2293 | Int iPredDC1 = 0; |
---|
| 2294 | Int iPredDC2 = 0; |
---|
| 2295 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
| 2296 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
| 2297 | piMask += iMaskStride+1; |
---|
| 2298 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
[2] | 2299 | |
---|
[5] | 2300 | if( bDelta ) |
---|
[2] | 2301 | { |
---|
[5] | 2302 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
| 2303 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
[2] | 2304 | } |
---|
| 2305 | |
---|
[5] | 2306 | // assign wedge pred DCs to prediction |
---|
[56] | 2307 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
| 2308 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
[2] | 2309 | } |
---|
| 2310 | |
---|
[56] | 2311 | Void TComPrediction::xPredIntraContourTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 ) |
---|
| 2312 | { |
---|
| 2313 | // get contour pattern |
---|
| 2314 | TComWedgelet* pcContourWedge = new TComWedgelet( iWidth, iHeight ); |
---|
| 2315 | getBestContourFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight, pcContourWedge ); |
---|
| 2316 | |
---|
| 2317 | // get wedge pred DCs |
---|
| 2318 | Int iPredDC1 = 0; |
---|
| 2319 | Int iPredDC2 = 0; |
---|
| 2320 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
| 2321 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
| 2322 | piMask += iMaskStride+1; |
---|
| 2323 | getWedgePredDCs( pcContourWedge, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
| 2324 | |
---|
| 2325 | if( bDelta ) |
---|
| 2326 | { |
---|
| 2327 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
| 2328 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
| 2329 | } |
---|
| 2330 | |
---|
| 2331 | // assign wedge pred DCs to prediction |
---|
| 2332 | if( bDelta ) { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
| 2333 | else { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
| 2334 | |
---|
| 2335 | pcContourWedge->destroy(); |
---|
| 2336 | delete pcContourWedge; |
---|
| 2337 | } |
---|
| 2338 | #endif |
---|
| 2339 | |
---|
| 2340 | #if HHI_DMM_WEDGE_INTRA |
---|
[2] | 2341 | UInt TComPrediction::getBestContinueWedge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd ) |
---|
| 2342 | { |
---|
| 2343 | UInt uiThisBlockSize = uiWidth; |
---|
| 2344 | assert( uiThisBlockSize >= DMM_WEDGEMODEL_MIN_SIZE && uiThisBlockSize <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
| 2345 | WedgeRefList* pacContDWedgeRefList = &g_aacWedgeRefLists[(g_aucConvertToBit[uiThisBlockSize])]; |
---|
| 2346 | |
---|
| 2347 | UInt uiPredDirWedgeTabIdx = 0; |
---|
| 2348 | TComDataCU* pcTempCU; |
---|
| 2349 | UInt uiTempPartIdx; |
---|
| 2350 | // 1st: try continue above wedgelet |
---|
| 2351 | pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 2352 | if( pcTempCU ) |
---|
| 2353 | { |
---|
| 2354 | UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx ); |
---|
| 2355 | if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir || |
---|
| 2356 | DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir || |
---|
| 2357 | DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir || |
---|
[5] | 2358 | DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir |
---|
| 2359 | #if HHI_DMM_PRED_TEX |
---|
[56] | 2360 | || |
---|
[2] | 2361 | DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir || |
---|
[5] | 2362 | DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir |
---|
| 2363 | #endif |
---|
[56] | 2364 | ) |
---|
[2] | 2365 | { |
---|
| 2366 | UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )]; |
---|
| 2367 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; |
---|
| 2368 | |
---|
| 2369 | // get offset between current and reference block |
---|
| 2370 | UInt uiOffsetX = 0; |
---|
| 2371 | UInt uiOffsetY = 0; |
---|
| 2372 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
| 2373 | |
---|
| 2374 | // get reference wedgelet |
---|
[56] | 2375 | UInt uiRefWedgeTabIdx = 0; |
---|
[2] | 2376 | switch( uhLumaIntraDir ) |
---|
| 2377 | { |
---|
| 2378 | case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
| 2379 | case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
| 2380 | case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
| 2381 | case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
[5] | 2382 | #if HHI_DMM_PRED_TEX |
---|
[2] | 2383 | case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
| 2384 | case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
[5] | 2385 | #endif |
---|
[2] | 2386 | default: { assert( 0 ); return uiPredDirWedgeTabIdx; } |
---|
| 2387 | } |
---|
| 2388 | TComWedgelet* pcRefWedgelet; |
---|
| 2389 | pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx )); |
---|
[56] | 2390 | |
---|
[2] | 2391 | // find reference wedgelet, if direction is suitable for continue wedge |
---|
| 2392 | if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) ) |
---|
| 2393 | { |
---|
| 2394 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
| 2395 | pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd ); |
---|
[56] | 2396 | getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
[2] | 2397 | return uiPredDirWedgeTabIdx; |
---|
| 2398 | } |
---|
| 2399 | } |
---|
| 2400 | } |
---|
| 2401 | |
---|
| 2402 | // 2nd: try continue left wedglelet |
---|
| 2403 | pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 2404 | if( pcTempCU ) |
---|
| 2405 | { |
---|
[5] | 2406 | UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx ); |
---|
| 2407 | if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir || |
---|
| 2408 | DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir || |
---|
[2] | 2409 | DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir || |
---|
[5] | 2410 | DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir |
---|
| 2411 | #if HHI_DMM_PRED_TEX |
---|
[56] | 2412 | || |
---|
[5] | 2413 | DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir || |
---|
| 2414 | DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir |
---|
| 2415 | #endif |
---|
| 2416 | ) |
---|
| 2417 | { |
---|
[2] | 2418 | UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )]; |
---|
| 2419 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; |
---|
| 2420 | |
---|
| 2421 | // get offset between current and reference block |
---|
| 2422 | UInt uiOffsetX = 0; |
---|
| 2423 | UInt uiOffsetY = 0; |
---|
| 2424 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
| 2425 | |
---|
| 2426 | // get reference wedgelet |
---|
| 2427 | UInt uiRefWedgeTabIdx = 0; |
---|
| 2428 | switch( uhLumaIntraDir ) |
---|
| 2429 | { |
---|
| 2430 | case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
| 2431 | case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
| 2432 | case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
| 2433 | case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
[5] | 2434 | #if HHI_DMM_PRED_TEX |
---|
[2] | 2435 | case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
| 2436 | case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
[5] | 2437 | #endif |
---|
[2] | 2438 | default: { assert( 0 ); return uiPredDirWedgeTabIdx; } |
---|
| 2439 | } |
---|
| 2440 | TComWedgelet* pcRefWedgelet; |
---|
| 2441 | pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx )); |
---|
| 2442 | |
---|
| 2443 | // find reference wedgelet, if direction is suitable for continue wedge |
---|
| 2444 | if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) ) |
---|
| 2445 | { |
---|
| 2446 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
| 2447 | pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd ); |
---|
[56] | 2448 | getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
[2] | 2449 | return uiPredDirWedgeTabIdx; |
---|
| 2450 | } |
---|
| 2451 | } |
---|
| 2452 | } |
---|
| 2453 | |
---|
| 2454 | // 3rd: (default) make wedglet from intra dir and max slope point |
---|
| 2455 | Int iSlopeX = 0; |
---|
| 2456 | Int iSlopeY = 0; |
---|
| 2457 | UInt uiStartPosX = 0; |
---|
| 2458 | UInt uiStartPosY = 0; |
---|
| 2459 | if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) ) |
---|
| 2460 | { |
---|
| 2461 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
| 2462 | xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd ); |
---|
[56] | 2463 | getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
[2] | 2464 | return uiPredDirWedgeTabIdx; |
---|
| 2465 | } |
---|
| 2466 | |
---|
| 2467 | return uiPredDirWedgeTabIdx; |
---|
| 2468 | } |
---|
| 2469 | |
---|
[56] | 2470 | Bool TComPrediction::getWedgePatternIdx( WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ) |
---|
| 2471 | { |
---|
| 2472 | ruiTabIdx = 0; |
---|
| 2473 | |
---|
| 2474 | for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ ) |
---|
| 2475 | { |
---|
| 2476 | TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx)); |
---|
| 2477 | |
---|
| 2478 | if( pcTestWedgeRef->getStartX() == uhXs && |
---|
| 2479 | pcTestWedgeRef->getStartY() == uhYs && |
---|
| 2480 | pcTestWedgeRef->getEndX() == uhXe && |
---|
| 2481 | pcTestWedgeRef->getEndY() == uhYe ) |
---|
| 2482 | { |
---|
| 2483 | ruiTabIdx = pcTestWedgeRef->getRefIdx(); |
---|
| 2484 | return true; |
---|
| 2485 | } |
---|
| 2486 | } |
---|
| 2487 | |
---|
| 2488 | return false; |
---|
| 2489 | } |
---|
| 2490 | |
---|
| 2491 | Void TComPrediction::xPredIntraWedgeFull( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, UInt uiTabIdx, Int iDeltaDC1, Int iDeltaDC2 ) |
---|
| 2492 | { |
---|
| 2493 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
| 2494 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
| 2495 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTabIdx)); |
---|
| 2496 | |
---|
| 2497 | // get wedge pred DCs |
---|
| 2498 | Int iPredDC1 = 0; |
---|
| 2499 | Int iPredDC2 = 0; |
---|
| 2500 | |
---|
| 2501 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
| 2502 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
| 2503 | piMask += iMaskStride+1; |
---|
| 2504 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
| 2505 | |
---|
| 2506 | if( bDelta ) |
---|
| 2507 | { |
---|
| 2508 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
| 2509 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
| 2510 | } |
---|
| 2511 | |
---|
| 2512 | // assign wedge pred DCs to prediction |
---|
| 2513 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
| 2514 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
| 2515 | } |
---|
| 2516 | |
---|
| 2517 | Void TComPrediction::xPredIntraWedgeDir( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iWedgeDeltaEnd, Int iDeltaDC1, Int iDeltaDC2 ) |
---|
| 2518 | { |
---|
| 2519 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
| 2520 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
| 2521 | |
---|
| 2522 | // get wedge pattern |
---|
| 2523 | UInt uiDirWedgeTabIdx = 0; |
---|
| 2524 | if( bEncoder ) |
---|
| 2525 | { |
---|
| 2526 | // encoder: load stored wedge pattern from CU |
---|
| 2527 | uiDirWedgeTabIdx = pcCU->getWedgePredDirTabIdx( uiAbsPartIdx ); |
---|
| 2528 | } |
---|
| 2529 | else |
---|
| 2530 | { |
---|
| 2531 | uiDirWedgeTabIdx = getBestContinueWedge( pcCU, uiAbsPartIdx, iWidth, iHeight, iWedgeDeltaEnd ); |
---|
| 2532 | |
---|
| 2533 | UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1); |
---|
| 2534 | pcCU->setWedgePredDirTabIdxSubParts( uiDirWedgeTabIdx, uiAbsPartIdx, uiDepth ); |
---|
| 2535 | } |
---|
| 2536 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiDirWedgeTabIdx)); |
---|
| 2537 | |
---|
| 2538 | // get wedge pred DCs |
---|
| 2539 | Int iPredDC1 = 0; |
---|
| 2540 | Int iPredDC2 = 0; |
---|
| 2541 | |
---|
| 2542 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
| 2543 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
| 2544 | piMask += iMaskStride+1; |
---|
| 2545 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
| 2546 | |
---|
| 2547 | if( bDelta ) |
---|
| 2548 | { |
---|
| 2549 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
| 2550 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
| 2551 | } |
---|
| 2552 | |
---|
| 2553 | // assign wedge pred DCs to prediction |
---|
| 2554 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
| 2555 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
| 2556 | } |
---|
| 2557 | |
---|
[2] | 2558 | Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ) |
---|
| 2559 | { |
---|
| 2560 | ruiOffsetX = 0; |
---|
| 2561 | ruiOffsetY = 0; |
---|
| 2562 | |
---|
[5] | 2563 | // get offset between current and above/left block |
---|
| 2564 | UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
[2] | 2565 | UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 2566 | |
---|
| 2567 | UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart(); |
---|
[5] | 2568 | UInt uiMaxDepthRefCU = 0; |
---|
| 2569 | while( uiNumPartInRefCU > 1 ) |
---|
| 2570 | { |
---|
| 2571 | uiNumPartInRefCU >>= 2; |
---|
| 2572 | uiMaxDepthRefCU++; |
---|
| 2573 | } |
---|
[2] | 2574 | |
---|
| 2575 | UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1); |
---|
[5] | 2576 | UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2; |
---|
[2] | 2577 | UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts; |
---|
| 2578 | |
---|
| 2579 | UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
| 2580 | UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
| 2581 | |
---|
| 2582 | if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); } |
---|
| 2583 | if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); } |
---|
| 2584 | } |
---|
| 2585 | |
---|
| 2586 | Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ) |
---|
| 2587 | { |
---|
| 2588 | riSlopeX = 0; |
---|
| 2589 | riSlopeY = 0; |
---|
| 2590 | ruiStartPosX = 0; |
---|
| 2591 | ruiStartPosY = 0; |
---|
| 2592 | |
---|
| 2593 | // 1st step: get wedge start point (max. slope) |
---|
| 2594 | Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt ); |
---|
| 2595 | Int iSourceStride = ( uiBlockSize<<1 ) + 1; |
---|
| 2596 | |
---|
| 2597 | UInt uiSlopeMaxAbove = 0; |
---|
| 2598 | UInt uiPosSlopeMaxAbove = 0; |
---|
| 2599 | for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ ) |
---|
| 2600 | { |
---|
| 2601 | if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove ) |
---|
| 2602 | { |
---|
| 2603 | uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] ); |
---|
| 2604 | uiPosSlopeMaxAbove = uiPosHor; |
---|
| 2605 | } |
---|
| 2606 | } |
---|
| 2607 | |
---|
| 2608 | UInt uiSlopeMaxLeft = 0; |
---|
| 2609 | UInt uiPosSlopeMaxLeft = 0; |
---|
| 2610 | for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ ) |
---|
| 2611 | { |
---|
| 2612 | if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft ) |
---|
| 2613 | { |
---|
| 2614 | uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ); |
---|
| 2615 | uiPosSlopeMaxLeft = uiPosVer; |
---|
| 2616 | } |
---|
| 2617 | } |
---|
| 2618 | |
---|
| 2619 | if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 ) |
---|
| 2620 | { |
---|
| 2621 | return false; |
---|
| 2622 | } |
---|
| 2623 | |
---|
| 2624 | if( uiSlopeMaxAbove > uiSlopeMaxLeft ) |
---|
| 2625 | { |
---|
| 2626 | ruiStartPosX = uiPosSlopeMaxAbove; |
---|
| 2627 | ruiStartPosY = 0; |
---|
| 2628 | } |
---|
| 2629 | else |
---|
| 2630 | { |
---|
| 2631 | ruiStartPosX = 0; |
---|
| 2632 | ruiStartPosY = uiPosSlopeMaxLeft; |
---|
| 2633 | } |
---|
| 2634 | |
---|
| 2635 | // 2nd step: derive wedge direction |
---|
[56] | 2636 | #if LOGI_INTRA_NAME_3MPM |
---|
| 2637 | Int uiPreds[3] = {-1, -1, -1}; |
---|
| 2638 | #else |
---|
[2] | 2639 | Int uiPreds[2] = {-1, -1}; |
---|
[56] | 2640 | #endif |
---|
| 2641 | Int iMode = -1; |
---|
| 2642 | Int iPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds, &iMode ); |
---|
[2] | 2643 | |
---|
| 2644 | UInt uiDirMode = 0; |
---|
[56] | 2645 | #if LOGI_INTRA_NAME_3MPM |
---|
| 2646 | if( iMode >= 0 ) { iPredNum = iMode; } |
---|
| 2647 | if( iPredNum == 1 ) { uiDirMode = uiPreds[0]; } |
---|
| 2648 | if( iPredNum == 2 ) { uiDirMode = uiPreds[1]; } |
---|
[2] | 2649 | |
---|
[56] | 2650 | if( uiDirMode < 2 ) { return false; } // no planar & DC |
---|
[2] | 2651 | |
---|
[56] | 2652 | Bool modeHor = (uiDirMode < 18); |
---|
| 2653 | Bool modeVer = !modeHor; |
---|
| 2654 | Int intraPredAngle = modeVer ? (Int)uiDirMode - VER_IDX : modeHor ? -((Int)uiDirMode - HOR_IDX) : 0; |
---|
| 2655 | #else |
---|
| 2656 | if( iPredNum == 1 ) { uiDirMode = g_aucAngIntraModeOrder[uiPreds[0]]; } |
---|
| 2657 | if( iPredNum == 2 ) { uiDirMode = g_aucAngIntraModeOrder[uiPreds[1]]; } |
---|
| 2658 | |
---|
| 2659 | if( uiDirMode == 0 ) { return false; } // no DC |
---|
| 2660 | |
---|
[2] | 2661 | Bool modeVer = (uiDirMode < 18); |
---|
| 2662 | Bool modeHor = !modeVer; |
---|
| 2663 | Int intraPredAngle = modeVer ? uiDirMode - 9 : modeHor ? uiDirMode - 25 : 0; |
---|
[56] | 2664 | #endif |
---|
[2] | 2665 | Int absAng = abs(intraPredAngle); |
---|
| 2666 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
[56] | 2667 | Int angTable[9] = {0,2,5,9,13,17,21,26,32}; |
---|
[2] | 2668 | absAng = angTable[absAng]; |
---|
| 2669 | intraPredAngle = signAng * absAng; |
---|
| 2670 | |
---|
| 2671 | // 3rd step: set slope for direction |
---|
| 2672 | if( modeHor ) |
---|
[56] | 2673 | { |
---|
[2] | 2674 | if( intraPredAngle > 0 ) |
---|
| 2675 | { |
---|
| 2676 | riSlopeX = -32; |
---|
| 2677 | riSlopeY = intraPredAngle; |
---|
| 2678 | } |
---|
| 2679 | else |
---|
| 2680 | { |
---|
| 2681 | riSlopeX = 32; |
---|
| 2682 | riSlopeY = -intraPredAngle; |
---|
| 2683 | } |
---|
[56] | 2684 | } |
---|
[2] | 2685 | else if( modeVer ) |
---|
| 2686 | { |
---|
| 2687 | if( intraPredAngle > 0 ) |
---|
| 2688 | { |
---|
| 2689 | riSlopeX = intraPredAngle; |
---|
| 2690 | riSlopeY = -32; |
---|
[56] | 2691 | } |
---|
| 2692 | else |
---|
| 2693 | { |
---|
[2] | 2694 | riSlopeX = -intraPredAngle; |
---|
| 2695 | riSlopeY = 32; |
---|
| 2696 | } |
---|
| 2697 | } |
---|
| 2698 | |
---|
[56] | 2699 | return true; |
---|
[2] | 2700 | } |
---|
| 2701 | |
---|
| 2702 | Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd ) |
---|
| 2703 | { |
---|
| 2704 | ruhXs = 0; |
---|
| 2705 | ruhYs = 0; |
---|
| 2706 | ruhXe = 0; |
---|
| 2707 | ruhYe = 0; |
---|
| 2708 | |
---|
| 2709 | // scaling of start pos and block size to wedge resolution |
---|
| 2710 | UInt uiScaledStartPosX = 0; |
---|
| 2711 | UInt uiScaledStartPosY = 0; |
---|
| 2712 | UInt uiScaledBlockSize = 0; |
---|
| 2713 | WedgeResolution eWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiBlockSize]]; |
---|
| 2714 | switch( eWedgeRes ) |
---|
| 2715 | { |
---|
| 2716 | case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; } |
---|
| 2717 | case( FULL_PEL ): { uiScaledStartPosX = uiPMSPosX; uiScaledStartPosY = uiPMSPosY; uiScaledBlockSize = uiBlockSize; break; } |
---|
| 2718 | case( HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; } |
---|
[56] | 2719 | } |
---|
| 2720 | Int iMaxPos = (Int)uiScaledBlockSize - 1; |
---|
[2] | 2721 | |
---|
| 2722 | // case above |
---|
| 2723 | if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 ) |
---|
| 2724 | { |
---|
| 2725 | ruhXs = (UChar)uiScaledStartPosX; |
---|
| 2726 | ruhYs = 0; |
---|
| 2727 | |
---|
| 2728 | if( iDeltaY == 0 ) |
---|
[56] | 2729 | { |
---|
[2] | 2730 | if( iDeltaX < 0 ) |
---|
| 2731 | { |
---|
| 2732 | ruhXe = 0; |
---|
[56] | 2733 | ruhYe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); |
---|
[2] | 2734 | return; |
---|
| 2735 | } |
---|
| 2736 | else |
---|
| 2737 | { |
---|
[56] | 2738 | ruhXe = (UChar)iMaxPos; |
---|
| 2739 | ruhYe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); |
---|
[2] | 2740 | std::swap( ruhXs, ruhXe ); |
---|
| 2741 | std::swap( ruhYs, ruhYe ); |
---|
| 2742 | return; |
---|
| 2743 | } |
---|
| 2744 | } |
---|
| 2745 | |
---|
| 2746 | // regular case |
---|
[56] | 2747 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
[2] | 2748 | |
---|
| 2749 | if( iVirtualEndX < 0 ) |
---|
| 2750 | { |
---|
| 2751 | Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd; |
---|
| 2752 | if( iYe < (Int)uiScaledBlockSize ) |
---|
| 2753 | { |
---|
| 2754 | ruhXe = 0; |
---|
[56] | 2755 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
[2] | 2756 | return; |
---|
| 2757 | } |
---|
| 2758 | else |
---|
| 2759 | { |
---|
[56] | 2760 | ruhXe = (UChar)std::min( (iYe - iMaxPos), iMaxPos ); |
---|
| 2761 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2762 | return; |
---|
| 2763 | } |
---|
| 2764 | } |
---|
[56] | 2765 | else if( iVirtualEndX > iMaxPos ) |
---|
[2] | 2766 | { |
---|
[56] | 2767 | Int iYe = roftoi( (Double)(iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
[2] | 2768 | if( iYe < (Int)uiScaledBlockSize ) |
---|
| 2769 | { |
---|
[56] | 2770 | ruhXe = (UChar)iMaxPos; |
---|
| 2771 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
[2] | 2772 | std::swap( ruhXs, ruhXe ); |
---|
| 2773 | std::swap( ruhYs, ruhYe ); |
---|
| 2774 | return; |
---|
| 2775 | } |
---|
| 2776 | else |
---|
| 2777 | { |
---|
[56] | 2778 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
| 2779 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2780 | return; |
---|
| 2781 | } |
---|
| 2782 | } |
---|
| 2783 | else |
---|
| 2784 | { |
---|
| 2785 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
| 2786 | if( iXe < 0 ) |
---|
| 2787 | { |
---|
| 2788 | ruhXe = 0; |
---|
[56] | 2789 | ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); |
---|
[2] | 2790 | return; |
---|
| 2791 | } |
---|
[56] | 2792 | else if( iXe > iMaxPos ) |
---|
[2] | 2793 | { |
---|
[56] | 2794 | ruhXe = (UChar)iMaxPos; |
---|
| 2795 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
[2] | 2796 | std::swap( ruhXs, ruhXe ); |
---|
| 2797 | std::swap( ruhYs, ruhYe ); |
---|
| 2798 | return; |
---|
| 2799 | } |
---|
| 2800 | else |
---|
| 2801 | { |
---|
| 2802 | ruhXe = (UChar)iXe; |
---|
[56] | 2803 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2804 | return; |
---|
| 2805 | } |
---|
| 2806 | } |
---|
| 2807 | } |
---|
| 2808 | |
---|
| 2809 | // case left |
---|
| 2810 | if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 ) |
---|
| 2811 | { |
---|
| 2812 | ruhXs = 0; |
---|
| 2813 | ruhYs = (UChar)uiScaledStartPosY; |
---|
| 2814 | |
---|
| 2815 | if( iDeltaX == 0 ) |
---|
| 2816 | { |
---|
| 2817 | if( iDeltaY < 0 ) |
---|
| 2818 | { |
---|
[56] | 2819 | ruhXe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); |
---|
[2] | 2820 | ruhYe = 0; |
---|
| 2821 | std::swap( ruhXs, ruhXe ); |
---|
| 2822 | std::swap( ruhYs, ruhYe ); |
---|
| 2823 | return; |
---|
| 2824 | } |
---|
| 2825 | else |
---|
| 2826 | { |
---|
[56] | 2827 | ruhXe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); |
---|
| 2828 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2829 | return; |
---|
| 2830 | } |
---|
| 2831 | } |
---|
| 2832 | |
---|
| 2833 | // regular case |
---|
[56] | 2834 | Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iMaxPos * ((Double)iDeltaY / (Double)iDeltaX) ); |
---|
[2] | 2835 | |
---|
| 2836 | if( iVirtualEndY < 0 ) |
---|
| 2837 | { |
---|
| 2838 | Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd; |
---|
| 2839 | if( iXe < (Int)uiScaledBlockSize ) |
---|
| 2840 | { |
---|
[56] | 2841 | ruhXe = (UChar)std::max( iXe, 0 ); |
---|
[2] | 2842 | ruhYe = 0; |
---|
| 2843 | std::swap( ruhXs, ruhXe ); |
---|
| 2844 | std::swap( ruhYs, ruhYe ); |
---|
| 2845 | return; |
---|
| 2846 | } |
---|
| 2847 | else |
---|
| 2848 | { |
---|
[56] | 2849 | ruhXe = (UChar)iMaxPos; |
---|
| 2850 | ruhYe = (UChar)std::min( (iXe - iMaxPos), iMaxPos ); |
---|
[2] | 2851 | std::swap( ruhXs, ruhXe ); |
---|
| 2852 | std::swap( ruhYs, ruhYe ); |
---|
| 2853 | return; |
---|
| 2854 | } |
---|
| 2855 | } |
---|
| 2856 | else if( iVirtualEndY > (uiScaledBlockSize-1) ) |
---|
| 2857 | { |
---|
| 2858 | Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd; |
---|
| 2859 | if( iXe < (Int)uiScaledBlockSize ) |
---|
| 2860 | { |
---|
[56] | 2861 | ruhXe = (UChar)std::max( iXe, 0 ); |
---|
[2] | 2862 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
| 2863 | return; |
---|
| 2864 | } |
---|
| 2865 | else |
---|
| 2866 | { |
---|
[56] | 2867 | ruhXe = (UChar)iMaxPos; |
---|
| 2868 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
[2] | 2869 | std::swap( ruhXs, ruhXe ); |
---|
| 2870 | std::swap( ruhYs, ruhYe ); |
---|
| 2871 | return; |
---|
| 2872 | } |
---|
| 2873 | } |
---|
| 2874 | else |
---|
| 2875 | { |
---|
| 2876 | Int iYe = iVirtualEndY - iDeltaEnd; |
---|
| 2877 | if( iYe < 0 ) |
---|
| 2878 | { |
---|
[56] | 2879 | ruhXe = (UChar)std::max( (iMaxPos + iYe), 0 ); |
---|
[2] | 2880 | ruhYe = 0; |
---|
| 2881 | std::swap( ruhXs, ruhXe ); |
---|
| 2882 | std::swap( ruhYs, ruhYe ); |
---|
| 2883 | return; |
---|
| 2884 | } |
---|
[56] | 2885 | else if( iYe > iMaxPos ) |
---|
[2] | 2886 | { |
---|
[56] | 2887 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
| 2888 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2889 | return; |
---|
| 2890 | } |
---|
| 2891 | else |
---|
| 2892 | { |
---|
[56] | 2893 | ruhXe = (UChar)iMaxPos; |
---|
[2] | 2894 | ruhYe = (UChar)iYe; |
---|
| 2895 | std::swap( ruhXs, ruhXe ); |
---|
| 2896 | std::swap( ruhYs, ruhYe ); |
---|
| 2897 | return; |
---|
| 2898 | } |
---|
| 2899 | } |
---|
| 2900 | } |
---|
| 2901 | |
---|
| 2902 | // case origin |
---|
| 2903 | if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 ) |
---|
| 2904 | { |
---|
| 2905 | if( iDeltaX*iDeltaY < 0 ) |
---|
| 2906 | { |
---|
| 2907 | return; |
---|
| 2908 | } |
---|
| 2909 | |
---|
| 2910 | ruhXs = 0; |
---|
| 2911 | ruhYs = 0; |
---|
| 2912 | |
---|
| 2913 | if( iDeltaY == 0 ) |
---|
| 2914 | { |
---|
[56] | 2915 | ruhXe = (UChar)iMaxPos; |
---|
[2] | 2916 | ruhYe = 0; |
---|
| 2917 | std::swap( ruhXs, ruhXe ); |
---|
| 2918 | std::swap( ruhYs, ruhYe ); |
---|
| 2919 | return; |
---|
[56] | 2920 | } |
---|
[2] | 2921 | |
---|
| 2922 | if( iDeltaX == 0 ) |
---|
| 2923 | { |
---|
| 2924 | ruhXe = 0; |
---|
[56] | 2925 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2926 | return; |
---|
[56] | 2927 | } |
---|
[2] | 2928 | |
---|
[56] | 2929 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
[2] | 2930 | |
---|
[56] | 2931 | if( iVirtualEndX > iMaxPos ) |
---|
[2] | 2932 | { |
---|
[56] | 2933 | Int iYe = roftoi( (Double)((Int)iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
[2] | 2934 | if( iYe < (Int)uiScaledBlockSize ) |
---|
| 2935 | { |
---|
| 2936 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
[56] | 2937 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
[2] | 2938 | std::swap( ruhXs, ruhXe ); |
---|
| 2939 | std::swap( ruhYs, ruhYe ); |
---|
| 2940 | return; |
---|
| 2941 | } |
---|
| 2942 | else |
---|
| 2943 | { |
---|
[56] | 2944 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
[2] | 2945 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
| 2946 | return; |
---|
| 2947 | } |
---|
| 2948 | } |
---|
| 2949 | else |
---|
| 2950 | { |
---|
| 2951 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
| 2952 | if( iXe < 0 ) |
---|
| 2953 | { |
---|
| 2954 | ruhXe = 0; |
---|
[56] | 2955 | ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); |
---|
[2] | 2956 | return; |
---|
| 2957 | } |
---|
[56] | 2958 | else if( iXe > iMaxPos ) |
---|
[2] | 2959 | { |
---|
| 2960 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
[56] | 2961 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
[2] | 2962 | std::swap( ruhXs, ruhXe ); |
---|
| 2963 | std::swap( ruhYs, ruhYe ); |
---|
| 2964 | return; |
---|
| 2965 | } |
---|
| 2966 | else |
---|
| 2967 | { |
---|
| 2968 | ruhXe = (UChar)iXe; |
---|
| 2969 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
| 2970 | return; |
---|
| 2971 | } |
---|
| 2972 | } |
---|
| 2973 | } |
---|
| 2974 | } |
---|
[5] | 2975 | #endif |
---|
[2] | 2976 | |
---|
| 2977 | Void |
---|
[56] | 2978 | TComPrediction::predIntraDepthAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight ) |
---|
[2] | 2979 | { |
---|
[56] | 2980 | Pel* pDst = piPred; |
---|
| 2981 | Int* ptrSrc = pcTComPattern->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
| 2982 | Int sw = ( iWidth<<1 ) + 1; |
---|
| 2983 | #if !LOGI_INTRA_NAME_3MPM |
---|
| 2984 | uiDirMode = g_aucAngIntraModeOrder[ uiDirMode ]; |
---|
[21] | 2985 | #endif |
---|
[56] | 2986 | xPredIntraAngDepth( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode ); |
---|
[2] | 2987 | } |
---|
| 2988 | |
---|
[56] | 2989 | Int |
---|
| 2990 | TComPrediction::xGetDCDepth( Int* pSrc, Int iDelta, Int iBlkSize ) |
---|
[2] | 2991 | { |
---|
[56] | 2992 | Int iDC = PDM_UNDEFINED_DEPTH; |
---|
| 2993 | Int iSum = 0; |
---|
| 2994 | Int iNum = 0; |
---|
| 2995 | for( Int k = 0; k < iBlkSize; k++, pSrc += iDelta ) |
---|
[2] | 2996 | { |
---|
[56] | 2997 | if( *pSrc != PDM_UNDEFINED_DEPTH ) |
---|
[2] | 2998 | { |
---|
[56] | 2999 | iSum += *pSrc; |
---|
| 3000 | iNum ++; |
---|
[2] | 3001 | } |
---|
| 3002 | } |
---|
[56] | 3003 | if( iNum ) |
---|
[2] | 3004 | { |
---|
[56] | 3005 | iDC = ( iSum + ( iNum >> 1 ) ) / iNum; |
---|
[2] | 3006 | } |
---|
[56] | 3007 | return iDC; |
---|
[2] | 3008 | } |
---|
| 3009 | |
---|
[56] | 3010 | Int |
---|
| 3011 | TComPrediction::xGetDCValDepth( Int iVal1, Int iVal2, Int iVal3, Int iVal4 ) |
---|
[2] | 3012 | { |
---|
[56] | 3013 | if ( iVal1 != PDM_UNDEFINED_DEPTH ) return iVal1; |
---|
| 3014 | else if( iVal2 != PDM_UNDEFINED_DEPTH ) return iVal2; |
---|
| 3015 | else if( iVal3 != PDM_UNDEFINED_DEPTH ) return iVal3; |
---|
| 3016 | return iVal4; |
---|
[2] | 3017 | } |
---|
| 3018 | |
---|
[56] | 3019 | Void |
---|
| 3020 | TComPrediction::xPredIntraAngDepth( Int* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, UInt dirMode ) |
---|
[2] | 3021 | { |
---|
[56] | 3022 | AOF( width == height ); |
---|
| 3023 | Int blkSize = width; |
---|
| 3024 | Int iDCAbove = xGetDCDepth( pSrc - srcStride, 1, blkSize ); |
---|
| 3025 | Int iDCAboveRight = xGetDCDepth( pSrc - srcStride + blkSize, 1, blkSize ); |
---|
| 3026 | Int iDCLeft = xGetDCDepth( pSrc - 1, srcStride, blkSize ); |
---|
| 3027 | Int iDCBelowLeft = xGetDCDepth( pSrc - 1 + blkSize * srcStride, srcStride, blkSize ); |
---|
| 3028 | Int iWgt, iDC1, iDC2; |
---|
| 3029 | if( dirMode < 2 ) // 1..2 |
---|
[2] | 3030 | { |
---|
[56] | 3031 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
| 3032 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
| 3033 | iWgt = 8; |
---|
[2] | 3034 | } |
---|
[56] | 3035 | else if( dirMode < 11 ) // 3..10 |
---|
[2] | 3036 | { |
---|
[56] | 3037 | iDC1 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
| 3038 | iDC2 = xGetDCValDepth( iDCBelowLeft, iDCLeft, iDCAbove, iDCAboveRight ); |
---|
| 3039 | iWgt = 6 + dirMode; |
---|
[2] | 3040 | } |
---|
[56] | 3041 | else if( dirMode < 27 ) // 11..26 |
---|
[2] | 3042 | { |
---|
[56] | 3043 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
| 3044 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
| 3045 | iWgt = dirMode - 10; |
---|
[2] | 3046 | } |
---|
[56] | 3047 | else if( dirMode < 35 ) // 27..34 |
---|
[2] | 3048 | { |
---|
[56] | 3049 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
| 3050 | iDC2 = xGetDCValDepth( iDCAboveRight, iDCAbove, iDCLeft, iDCBelowLeft ); |
---|
| 3051 | iWgt = 42 - dirMode; |
---|
[2] | 3052 | } |
---|
[56] | 3053 | else // (wedgelet -> use simple DC prediction |
---|
[2] | 3054 | { |
---|
[56] | 3055 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
| 3056 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
| 3057 | iWgt = 8; |
---|
[2] | 3058 | } |
---|
[56] | 3059 | Int iWgt2 = 16 - iWgt; |
---|
| 3060 | Int iDCVal = ( iWgt * iDC1 + iWgt2 * iDC2 + 8 ) >> 4; |
---|
[2] | 3061 | |
---|
[56] | 3062 | // set depth |
---|
| 3063 | for( Int iY = 0; iY < blkSize; iY++, pDst += dstStride ) |
---|
[21] | 3064 | { |
---|
[56] | 3065 | for( Int iX = 0; iX < blkSize; iX++ ) |
---|
[2] | 3066 | { |
---|
[56] | 3067 | pDst[ iX ] = iDCVal; |
---|
[2] | 3068 | } |
---|
| 3069 | } |
---|
| 3070 | } |
---|
| 3071 | |
---|
[56] | 3072 | //! \} |
---|