[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 | |
---|
[100] | 48 | #if LGE_EDGE_INTRA |
---|
| 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 | |
---|
[100] | 425 | #if LGE_EDGE_INTRA |
---|
| 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 | { |
---|
[152] | 630 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 631 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr)) |
---|
[152] | 632 | #else |
---|
[56] | 633 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
[152] | 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 | } |
---|
[152] | 650 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 651 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr) ) |
---|
[152] | 652 | #else |
---|
[56] | 653 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
[152] | 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 | { |
---|
[152] | 699 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 700 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr)) |
---|
[152] | 701 | #else |
---|
[56] | 702 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
[152] | 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 |
---|
[152] | 724 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 725 | if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr)) |
---|
[152] | 726 | #else |
---|
[56] | 727 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
[152] | 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 | |
---|
| 756 | |
---|
[56] | 757 | |
---|
| 758 | #if DEPTH_MAP_GENERATION |
---|
| 759 | 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 ) |
---|
| 760 | #else |
---|
| 761 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi ) |
---|
[2] | 762 | #endif |
---|
[56] | 763 | { |
---|
| 764 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
| 765 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 766 | pcCU->clipMv(cMv); |
---|
| 767 | |
---|
| 768 | #if DEPTH_MAP_GENERATION |
---|
| 769 | if( bPrdDepthMap ) |
---|
| 770 | { |
---|
| 771 | UInt uiRShift = 0; |
---|
[100] | 772 | #if PDM_REMOVE_DEPENDENCE |
---|
| 773 | if( pcCU->getPic()->getStoredPDMforV2() == 1 ) |
---|
| 774 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMapTemp(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 ); |
---|
| 775 | else |
---|
| 776 | #endif |
---|
| 777 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 ); |
---|
| 778 | |
---|
[56] | 779 | return; |
---|
| 780 | } |
---|
| 781 | #endif |
---|
| 782 | |
---|
| 783 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 784 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
| 785 | { |
---|
| 786 | UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 ); |
---|
| 787 | UInt uiOffset = bi ? IF_INTERNAL_OFFS : 0; |
---|
| 788 | #if DEPTH_MAP_GENERATION |
---|
| 789 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift, uiOffset ); |
---|
| 790 | #else |
---|
| 791 | xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, uiOffset ); |
---|
| 792 | #endif |
---|
| 793 | } |
---|
| 794 | else |
---|
| 795 | { |
---|
| 796 | #endif |
---|
[152] | 797 | #if LGE_ILLUCOMP_B0045 |
---|
| 798 | Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId()); |
---|
| 799 | |
---|
| 800 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, bICFlag); |
---|
| 801 | #else |
---|
[56] | 802 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
[152] | 803 | #endif |
---|
[56] | 804 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 805 | } |
---|
| 806 | #endif |
---|
[152] | 807 | #if LGE_ILLUCOMP_B0045 |
---|
| 808 | Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId()); |
---|
| 809 | |
---|
| 810 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, bICFlag ); |
---|
| 811 | #else |
---|
[56] | 812 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); |
---|
[152] | 813 | #endif |
---|
[2] | 814 | } |
---|
| 815 | |
---|
| 816 | |
---|
[56] | 817 | #if DEPTH_MAP_GENERATION |
---|
| 818 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ) |
---|
| 819 | #else |
---|
| 820 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx ) |
---|
| 821 | #endif |
---|
[2] | 822 | { |
---|
[56] | 823 | TComYuv* pcMbYuv; |
---|
| 824 | Int iRefIdx[2] = {-1, -1}; |
---|
| 825 | |
---|
| 826 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
| 827 | { |
---|
| 828 | RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
| 829 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 830 | |
---|
| 831 | if ( iRefIdx[iRefList] < 0 ) |
---|
| 832 | { |
---|
| 833 | continue; |
---|
| 834 | } |
---|
| 835 | |
---|
| 836 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
| 837 | |
---|
| 838 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
| 839 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
| 840 | { |
---|
| 841 | #if DEPTH_MAP_GENERATION |
---|
| 842 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
| 843 | #else |
---|
| 844 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true ); |
---|
| 845 | #endif |
---|
| 846 | } |
---|
| 847 | else |
---|
| 848 | { |
---|
| 849 | if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() ) |
---|
| 850 | { |
---|
| 851 | #if DEPTH_MAP_GENERATION |
---|
| 852 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); |
---|
| 853 | #else |
---|
| 854 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true ); |
---|
| 855 | #endif |
---|
| 856 | } |
---|
| 857 | else |
---|
| 858 | { |
---|
| 859 | #if DEPTH_MAP_GENERATION |
---|
| 860 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); |
---|
| 861 | #else |
---|
| 862 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, false ); |
---|
| 863 | #endif |
---|
| 864 | } |
---|
| 865 | } |
---|
| 866 | } |
---|
| 867 | |
---|
| 868 | if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() ) |
---|
| 869 | { |
---|
| 870 | xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 871 | } |
---|
| 872 | else |
---|
| 873 | { |
---|
| 874 | #if DEPTH_MAP_GENERATION |
---|
| 875 | if ( bPrdDepthMap ) |
---|
| 876 | { |
---|
| 877 | xWeightedAveragePdm( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, uiSubSampExpX, uiSubSampExpY ); |
---|
| 878 | } |
---|
| 879 | else |
---|
| 880 | { |
---|
| 881 | xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 882 | } |
---|
| 883 | #else |
---|
| 884 | xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 885 | #endif |
---|
| 886 | } |
---|
[2] | 887 | } |
---|
| 888 | |
---|
[56] | 889 | Void |
---|
| 890 | #if DEPTH_MAP_GENERATION |
---|
| 891 | TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset ) |
---|
| 892 | #else |
---|
| 893 | TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset ) |
---|
| 894 | #endif |
---|
[2] | 895 | { |
---|
[56] | 896 | #if DEPTH_MAP_GENERATION |
---|
| 897 | Int iShiftX = 2 + uiSubSampExpX; |
---|
| 898 | Int iShiftY = 2 + uiSubSampExpY; |
---|
| 899 | Int iAddX = ( 1 << iShiftX ) >> 1; |
---|
| 900 | Int iAddY = ( 1 << iShiftY ) >> 1; |
---|
| 901 | Int iHor = ( pcMv->getHor() + iAddX ) >> iShiftX; |
---|
| 902 | Int iVer = ( pcMv->getVer() + iAddY ) >> iShiftY; |
---|
| 903 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 904 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
[2] | 905 | { |
---|
[56] | 906 | iHor = pcMv->getHor(); |
---|
| 907 | iVer = pcMv->getVer(); |
---|
| 908 | } |
---|
| 909 | #endif |
---|
| 910 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
| 911 | Int iDstStride = rpcYuv->getStride(); |
---|
| 912 | Int iRefOffset = iHor + iVer * iRefStride; |
---|
| 913 | #else |
---|
| 914 | Int iFPelMask = ~3; |
---|
| 915 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
| 916 | Int iDstStride = rpcYuv->getStride(); |
---|
| 917 | Int iHor = ( pcMv->getHor() + 2 ) & iFPelMask; |
---|
| 918 | Int iVer = ( pcMv->getVer() + 2 ) & iFPelMask; |
---|
| 919 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 920 | if( pcCU->getSlice()->getSPS()->isDepth() ) |
---|
| 921 | { |
---|
| 922 | iHor = pcMv->getHor() * 4; |
---|
| 923 | iVer = pcMv->getVer() * 4; |
---|
| 924 | } |
---|
| 925 | #endif |
---|
| 926 | Int ixFrac = iHor & 0x3; |
---|
| 927 | Int iyFrac = iVer & 0x3; |
---|
| 928 | Int iRefOffset = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride; |
---|
| 929 | #endif |
---|
| 930 | |
---|
| 931 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; |
---|
| 932 | Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr ); |
---|
| 933 | |
---|
| 934 | for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride ) |
---|
| 935 | { |
---|
| 936 | for( Int x = 0; x < iWidth; x++ ) |
---|
[2] | 937 | { |
---|
[56] | 938 | piDstY[ x ] = ( piRefY[ x ] << uiRShift ) - uiOffset; |
---|
[2] | 939 | } |
---|
| 940 | } |
---|
[56] | 941 | } |
---|
| 942 | |
---|
| 943 | |
---|
| 944 | /** |
---|
| 945 | * \brief Generate motion-compensated luma block |
---|
| 946 | * |
---|
| 947 | * \param cu Pointer to current CU |
---|
| 948 | * \param refPic Pointer to reference picture |
---|
| 949 | * \param partAddr Address of block within CU |
---|
| 950 | * \param mv Motion vector |
---|
| 951 | * \param width Width of block |
---|
| 952 | * \param height Height of block |
---|
| 953 | * \param dstPic Pointer to destination picture |
---|
| 954 | * \param bi Flag indicating whether bipred is used |
---|
| 955 | */ |
---|
[152] | 956 | #if LGE_ILLUCOMP_B0045 |
---|
| 957 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag) |
---|
| 958 | #else |
---|
[56] | 959 | Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi ) |
---|
[152] | 960 | #endif |
---|
[56] | 961 | { |
---|
| 962 | Int refStride = refPic->getStride(); |
---|
| 963 | Int refOffset = ( mv->getHor() >> 2 ) + ( mv->getVer() >> 2 ) * refStride; |
---|
| 964 | Pel *ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 965 | |
---|
| 966 | Int dstStride = dstPic->getStride(); |
---|
| 967 | Pel *dst = dstPic->getLumaAddr( partAddr ); |
---|
| 968 | |
---|
| 969 | Int xFrac = mv->getHor() & 0x3; |
---|
| 970 | Int yFrac = mv->getVer() & 0x3; |
---|
| 971 | |
---|
| 972 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
| 973 | assert( ! cu->getSlice()->getIsDepth() || ( xFrac == 0 && yFrac == 0 ) ); |
---|
| 974 | #endif |
---|
| 975 | |
---|
| 976 | if ( yFrac == 0 ) |
---|
[2] | 977 | { |
---|
[56] | 978 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi ); |
---|
[2] | 979 | } |
---|
[56] | 980 | else if ( xFrac == 0 ) |
---|
| 981 | { |
---|
| 982 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi ); |
---|
| 983 | } |
---|
| 984 | else |
---|
| 985 | { |
---|
| 986 | Int tmpStride = m_filteredBlockTmp[0].getStride(); |
---|
| 987 | Short *tmp = m_filteredBlockTmp[0].getLumaAddr(); |
---|
| 988 | |
---|
| 989 | Int filterSize = NTAPS_LUMA; |
---|
| 990 | Int halfFilterSize = ( filterSize >> 1 ); |
---|
| 991 | |
---|
| 992 | m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false ); |
---|
| 993 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi); |
---|
| 994 | } |
---|
[152] | 995 | |
---|
| 996 | #if LGE_ILLUCOMP_B0045 |
---|
| 997 | if(bICFlag) |
---|
| 998 | { |
---|
| 999 | Int a, b, iShift, i, j; |
---|
| 1000 | |
---|
| 1001 | xGetLLSICPrediction(cu, mv, refPic, a, b, iShift); |
---|
| 1002 | |
---|
| 1003 | for (i = 0; i < height; i++) |
---|
| 1004 | { |
---|
| 1005 | for (j = 0; j < width; j++) |
---|
| 1006 | { |
---|
| 1007 | if(bi) |
---|
| 1008 | { |
---|
| 1009 | Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
| 1010 | dst[j] = ( (a*dst[j]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS; |
---|
| 1011 | } |
---|
| 1012 | else |
---|
| 1013 | dst[j] = Clip( ( (a*dst[j]) >> iShift ) + b ); |
---|
| 1014 | } |
---|
| 1015 | dst += dstStride; |
---|
| 1016 | } |
---|
| 1017 | } |
---|
| 1018 | #endif |
---|
[2] | 1019 | } |
---|
| 1020 | |
---|
[56] | 1021 | /** |
---|
| 1022 | * \brief Generate motion-compensated chroma block |
---|
| 1023 | * |
---|
| 1024 | * \param cu Pointer to current CU |
---|
| 1025 | * \param refPic Pointer to reference picture |
---|
| 1026 | * \param partAddr Address of block within CU |
---|
| 1027 | * \param mv Motion vector |
---|
| 1028 | * \param width Width of block |
---|
| 1029 | * \param height Height of block |
---|
| 1030 | * \param dstPic Pointer to destination picture |
---|
| 1031 | * \param bi Flag indicating whether bipred is used |
---|
| 1032 | */ |
---|
[152] | 1033 | #if LGE_ILLUCOMP_B0045 |
---|
| 1034 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag ) |
---|
| 1035 | #else |
---|
[56] | 1036 | Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi ) |
---|
[152] | 1037 | #endif |
---|
[2] | 1038 | { |
---|
[56] | 1039 | Int refStride = refPic->getCStride(); |
---|
| 1040 | Int dstStride = dstPic->getCStride(); |
---|
| 1041 | |
---|
| 1042 | Int refOffset = (mv->getHor() >> 3) + (mv->getVer() >> 3) * refStride; |
---|
| 1043 | |
---|
| 1044 | Pel* refCb = refPic->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1045 | Pel* refCr = refPic->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1046 | |
---|
| 1047 | Pel* dstCb = dstPic->getCbAddr( partAddr ); |
---|
| 1048 | Pel* dstCr = dstPic->getCrAddr( partAddr ); |
---|
| 1049 | |
---|
| 1050 | Int xFrac = mv->getHor() & 0x7; |
---|
| 1051 | Int yFrac = mv->getVer() & 0x7; |
---|
| 1052 | UInt cxWidth = width >> 1; |
---|
| 1053 | UInt cxHeight = height >> 1; |
---|
| 1054 | |
---|
| 1055 | Int extStride = m_filteredBlockTmp[0].getStride(); |
---|
| 1056 | Short* extY = m_filteredBlockTmp[0].getLumaAddr(); |
---|
| 1057 | |
---|
| 1058 | Int filterSize = NTAPS_CHROMA; |
---|
| 1059 | |
---|
| 1060 | Int halfFilterSize = (filterSize>>1); |
---|
| 1061 | |
---|
| 1062 | if ( yFrac == 0 ) |
---|
| 1063 | { |
---|
| 1064 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi); |
---|
| 1065 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi); |
---|
| 1066 | } |
---|
| 1067 | else if ( xFrac == 0 ) |
---|
| 1068 | { |
---|
| 1069 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi); |
---|
| 1070 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi); |
---|
| 1071 | } |
---|
| 1072 | else |
---|
| 1073 | { |
---|
| 1074 | m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false); |
---|
| 1075 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi); |
---|
| 1076 | |
---|
| 1077 | m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false); |
---|
| 1078 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi); |
---|
| 1079 | } |
---|
[152] | 1080 | #if LGE_ILLUCOMP_B0045 |
---|
| 1081 | if(bICFlag) |
---|
| 1082 | { |
---|
| 1083 | Int a, b, iShift, i, j; |
---|
| 1084 | xGetLLSICPredictionChroma(cu, mv, refPic, a, b, iShift, 0); // Cb |
---|
| 1085 | for (i = 0; i < cxHeight; i++) |
---|
| 1086 | { |
---|
| 1087 | for (j = 0; j < cxWidth; j++) |
---|
| 1088 | { |
---|
| 1089 | if(bi) |
---|
| 1090 | { |
---|
| 1091 | Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
| 1092 | dstCb[j] = ( (a*dstCb[j]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS; |
---|
| 1093 | } |
---|
| 1094 | else |
---|
| 1095 | dstCb[j] = Clip3(0, 255, ((a*dstCb[j])>>iShift)+b); |
---|
| 1096 | } |
---|
| 1097 | dstCb += dstStride; |
---|
| 1098 | } |
---|
| 1099 | |
---|
| 1100 | xGetLLSICPredictionChroma(cu, mv, refPic, a, b, iShift, 1); // Cr |
---|
| 1101 | for (i = 0; i < cxHeight; i++) |
---|
| 1102 | { |
---|
| 1103 | for (j = 0; j < cxWidth; j++) |
---|
| 1104 | { |
---|
| 1105 | if(bi) |
---|
| 1106 | { |
---|
| 1107 | Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
| 1108 | dstCr[j] = ( (a*dstCr[j]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS; |
---|
| 1109 | } |
---|
| 1110 | else |
---|
| 1111 | dstCr[j] = Clip3(0, 255, ((a*dstCr[j])>>iShift)+b); |
---|
| 1112 | } |
---|
| 1113 | dstCr += dstStride; |
---|
| 1114 | } |
---|
| 1115 | } |
---|
| 1116 | #endif |
---|
[2] | 1117 | } |
---|
| 1118 | |
---|
[56] | 1119 | #if DEPTH_MAP_GENERATION |
---|
| 1120 | 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] | 1121 | { |
---|
[56] | 1122 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1123 | { |
---|
[56] | 1124 | rpcYuvDst->addAvgPdm( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
[2] | 1125 | } |
---|
[56] | 1126 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
[2] | 1127 | { |
---|
[56] | 1128 | pcYuvSrc0->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
[2] | 1129 | } |
---|
[56] | 1130 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1131 | { |
---|
[56] | 1132 | pcYuvSrc1->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
[2] | 1133 | } |
---|
[56] | 1134 | else |
---|
[2] | 1135 | { |
---|
[56] | 1136 | assert (0); |
---|
[2] | 1137 | } |
---|
[56] | 1138 | } |
---|
| 1139 | #endif |
---|
| 1140 | |
---|
| 1141 | Void TComPrediction::xWeightedAverage( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) |
---|
| 1142 | { |
---|
| 1143 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1144 | { |
---|
[56] | 1145 | rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); |
---|
[2] | 1146 | } |
---|
[56] | 1147 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
[2] | 1148 | { |
---|
[56] | 1149 | pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
[2] | 1150 | } |
---|
[56] | 1151 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
[2] | 1152 | { |
---|
[56] | 1153 | pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
| 1154 | } |
---|
| 1155 | } |
---|
| 1156 | |
---|
| 1157 | // AMVP |
---|
| 1158 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred ) |
---|
| 1159 | { |
---|
| 1160 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
| 1161 | |
---|
| 1162 | if( pcCU->getAMVPMode(uiPartAddr) == AM_NONE || (pcAMVPInfo->iN <= 1 && pcCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
| 1163 | { |
---|
| 1164 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
| 1165 | |
---|
| 1166 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 1167 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 1168 | return; |
---|
| 1169 | } |
---|
| 1170 | |
---|
| 1171 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
| 1172 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
| 1173 | return; |
---|
| 1174 | } |
---|
| 1175 | |
---|
| 1176 | /** Function for deriving planar intra prediction. |
---|
| 1177 | * \param pSrc pointer to reconstructed sample array |
---|
| 1178 | * \param srcStride the stride of the reconstructed sample array |
---|
| 1179 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 1180 | * \param dstStride the stride of the prediction sample array |
---|
| 1181 | * \param width the width of the block |
---|
| 1182 | * \param height the height of the block |
---|
| 1183 | * |
---|
| 1184 | * This function derives the prediction samples for planar mode (intra coding). |
---|
| 1185 | */ |
---|
| 1186 | Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
| 1187 | { |
---|
| 1188 | assert(width == height); |
---|
| 1189 | |
---|
| 1190 | Int k, l, bottomLeft, topRight; |
---|
| 1191 | Int horPred; |
---|
| 1192 | Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
| 1193 | UInt blkSize = width; |
---|
| 1194 | UInt offset2D = width; |
---|
| 1195 | UInt shift1D = g_aucConvertToBit[ width ] + 2; |
---|
| 1196 | UInt shift2D = shift1D + 1; |
---|
| 1197 | |
---|
| 1198 | // Get left and above reference column and row |
---|
| 1199 | for(k=0;k<blkSize+1;k++) |
---|
| 1200 | { |
---|
| 1201 | topRow[k] = pSrc[k-srcStride]; |
---|
| 1202 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
| 1203 | } |
---|
| 1204 | |
---|
| 1205 | // Prepare intermediate variables used in interpolation |
---|
| 1206 | bottomLeft = leftColumn[blkSize]; |
---|
| 1207 | topRight = topRow[blkSize]; |
---|
| 1208 | for (k=0;k<blkSize;k++) |
---|
| 1209 | { |
---|
| 1210 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
| 1211 | rightColumn[k] = topRight - leftColumn[k]; |
---|
| 1212 | topRow[k] <<= shift1D; |
---|
| 1213 | leftColumn[k] <<= shift1D; |
---|
| 1214 | } |
---|
| 1215 | |
---|
| 1216 | // Generate prediction signal |
---|
| 1217 | for (k=0;k<blkSize;k++) |
---|
| 1218 | { |
---|
| 1219 | horPred = leftColumn[k] + offset2D; |
---|
| 1220 | for (l=0;l<blkSize;l++) |
---|
[2] | 1221 | { |
---|
[56] | 1222 | horPred += rightColumn[k]; |
---|
| 1223 | topRow[l] += bottomRow[l]; |
---|
| 1224 | rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); |
---|
[2] | 1225 | } |
---|
| 1226 | } |
---|
| 1227 | } |
---|
| 1228 | |
---|
[56] | 1229 | /** Function for deriving chroma LM intra prediction. |
---|
| 1230 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
| 1231 | * \param piSrc pointer to reconstructed chroma sample array |
---|
| 1232 | * \param pPred pointer for the prediction sample array |
---|
| 1233 | * \param uiPredStride the stride of the prediction sample array |
---|
| 1234 | * \param uiCWidth the width of the chroma block |
---|
| 1235 | * \param uiCHeight the height of the chroma block |
---|
| 1236 | * \param uiChromaId boolean indication of chroma component |
---|
| 1237 | * |
---|
| 1238 | * This function derives the prediction samples for chroma LM mode (chroma intra coding) |
---|
| 1239 | */ |
---|
| 1240 | Void TComPrediction::predLMIntraChroma( TComPattern* pcPattern, Int* piSrc, Pel* pPred, UInt uiPredStride, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId ) |
---|
| 1241 | { |
---|
| 1242 | UInt uiWidth = 2 * uiCWidth; |
---|
[2] | 1243 | |
---|
[56] | 1244 | xGetLLSPrediction( pcPattern, piSrc+uiWidth+2, uiWidth+1, pPred, uiPredStride, uiCWidth, uiCHeight, 1 ); |
---|
| 1245 | } |
---|
| 1246 | |
---|
| 1247 | /** Function for deriving downsampled luma sample of current chroma block and its above, left causal pixel |
---|
| 1248 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
| 1249 | * \param uiCWidth the width of the chroma block |
---|
| 1250 | * \param uiCHeight the height of the chroma block |
---|
| 1251 | * |
---|
| 1252 | * This function derives downsampled luma sample of current chroma block and its above, left causal pixel |
---|
| 1253 | */ |
---|
| 1254 | Void TComPrediction::getLumaRecPixels( TComPattern* pcPattern, UInt uiCWidth, UInt uiCHeight ) |
---|
[2] | 1255 | { |
---|
[56] | 1256 | UInt uiWidth = 2 * uiCWidth; |
---|
| 1257 | UInt uiHeight = 2 * uiCHeight; |
---|
[2] | 1258 | |
---|
[56] | 1259 | Pel* pRecSrc = pcPattern->getROIY(); |
---|
| 1260 | Pel* pDst0 = m_pLumaRecBuffer + m_iLumaRecStride + 1; |
---|
[2] | 1261 | |
---|
[56] | 1262 | Int iRecSrcStride = pcPattern->getPatternLStride(); |
---|
| 1263 | Int iRecSrcStride2 = iRecSrcStride << 1; |
---|
| 1264 | Int iDstStride = m_iLumaRecStride; |
---|
| 1265 | Int iSrcStride = ( max( uiWidth, uiHeight ) << 1 ) + 1; |
---|
| 1266 | |
---|
| 1267 | Int* ptrSrc = pcPattern->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); |
---|
| 1268 | |
---|
| 1269 | // initial pointers |
---|
| 1270 | Pel* pDst = pDst0 - 1 - iDstStride; |
---|
| 1271 | Int* piSrc = ptrSrc; |
---|
| 1272 | |
---|
| 1273 | // top left corner downsampled from ADI buffer |
---|
| 1274 | // don't need this point |
---|
| 1275 | |
---|
| 1276 | // top row downsampled from ADI buffer |
---|
| 1277 | pDst++; |
---|
| 1278 | piSrc ++; |
---|
| 1279 | for (Int i = 0; i < uiCWidth; i++) |
---|
[2] | 1280 | { |
---|
[56] | 1281 | pDst[i] = ((piSrc[2*i] * 2 ) + piSrc[2*i - 1] + piSrc[2*i + 1] + 2) >> 2; |
---|
[2] | 1282 | } |
---|
| 1283 | |
---|
[56] | 1284 | // left column downsampled from ADI buffer |
---|
| 1285 | pDst = pDst0 - 1; |
---|
| 1286 | piSrc = ptrSrc + iSrcStride; |
---|
| 1287 | for (Int j = 0; j < uiCHeight; j++) |
---|
| 1288 | { |
---|
| 1289 | pDst[0] = ( piSrc[0] + piSrc[iSrcStride] ) >> 1; |
---|
| 1290 | piSrc += iSrcStride << 1; |
---|
| 1291 | pDst += iDstStride; |
---|
| 1292 | } |
---|
[2] | 1293 | |
---|
[56] | 1294 | // inner part from reconstructed picture buffer |
---|
| 1295 | for( Int j = 0; j < uiCHeight; j++ ) |
---|
| 1296 | { |
---|
| 1297 | for (Int i = 0; i < uiCWidth; i++) |
---|
| 1298 | { |
---|
| 1299 | pDst0[i] = (pRecSrc[2*i] + pRecSrc[2*i + iRecSrcStride]) >> 1; |
---|
| 1300 | } |
---|
| 1301 | |
---|
| 1302 | pDst0 += iDstStride; |
---|
| 1303 | pRecSrc += iRecSrcStride2; |
---|
| 1304 | } |
---|
[2] | 1305 | } |
---|
| 1306 | |
---|
[56] | 1307 | /** Function for deriving the positon of first non-zero binary bit of a value |
---|
| 1308 | * \param x input value |
---|
| 1309 | * |
---|
| 1310 | * This function derives the positon of first non-zero binary bit of a value |
---|
| 1311 | */ |
---|
| 1312 | Int GetMSB( UInt x ) |
---|
| 1313 | { |
---|
| 1314 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
| 1315 | |
---|
| 1316 | while( x > 1 ) |
---|
| 1317 | { |
---|
| 1318 | bits >>= 1; |
---|
| 1319 | y = x >> bits; |
---|
| 1320 | |
---|
| 1321 | if( y ) |
---|
| 1322 | { |
---|
| 1323 | x = y; |
---|
| 1324 | iMSB += bits; |
---|
| 1325 | } |
---|
| 1326 | } |
---|
| 1327 | |
---|
| 1328 | iMSB+=y; |
---|
| 1329 | |
---|
| 1330 | return iMSB; |
---|
| 1331 | } |
---|
| 1332 | |
---|
| 1333 | /** Function for counting leading number of zeros/ones |
---|
| 1334 | * \param x input value |
---|
| 1335 | \ This function counts leading number of zeros for positive numbers and |
---|
| 1336 | \ leading number of ones for negative numbers. This can be implemented in |
---|
| 1337 | \ single instructure cycle on many processors. |
---|
| 1338 | */ |
---|
| 1339 | |
---|
| 1340 | Short CountLeadingZerosOnes (Short x) |
---|
| 1341 | { |
---|
| 1342 | Short clz; |
---|
| 1343 | Short i; |
---|
| 1344 | |
---|
| 1345 | if(x == 0) |
---|
| 1346 | { |
---|
| 1347 | clz = 0; |
---|
| 1348 | } |
---|
| 1349 | else |
---|
| 1350 | { |
---|
| 1351 | if (x == -1) |
---|
| 1352 | { |
---|
| 1353 | clz = 15; |
---|
| 1354 | } |
---|
| 1355 | else |
---|
| 1356 | { |
---|
| 1357 | if(x < 0) |
---|
| 1358 | { |
---|
| 1359 | x = ~x; |
---|
| 1360 | } |
---|
| 1361 | clz = 15; |
---|
| 1362 | for(i = 0;i < 15;++i) |
---|
| 1363 | { |
---|
| 1364 | if(x) |
---|
| 1365 | { |
---|
| 1366 | clz --; |
---|
| 1367 | } |
---|
| 1368 | x = x >> 1; |
---|
| 1369 | } |
---|
| 1370 | } |
---|
| 1371 | } |
---|
| 1372 | return clz; |
---|
| 1373 | } |
---|
| 1374 | |
---|
| 1375 | /** Function for deriving LM intra prediction. |
---|
| 1376 | * \param pcPattern pointer to neighbouring pixel access pattern |
---|
| 1377 | * \param pSrc0 pointer to reconstructed chroma sample array |
---|
| 1378 | * \param iSrcStride the stride of reconstructed chroma sample array |
---|
| 1379 | * \param pDst0 reference to pointer for the prediction sample array |
---|
| 1380 | * \param iDstStride the stride of the prediction sample array |
---|
| 1381 | * \param uiWidth the width of the chroma block |
---|
| 1382 | * \param uiHeight the height of the chroma block |
---|
| 1383 | * \param uiExt0 line number of neiggboirng pixels for calculating LM model parameter, default value is 1 |
---|
| 1384 | * |
---|
| 1385 | * This function derives the prediction samples for chroma LM mode (chroma intra coding) |
---|
| 1386 | */ |
---|
| 1387 | Void TComPrediction::xGetLLSPrediction( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 ) |
---|
| 1388 | { |
---|
| 1389 | |
---|
| 1390 | Pel *pDst, *pLuma; |
---|
| 1391 | Int *pSrc; |
---|
| 1392 | |
---|
| 1393 | Int iLumaStride = m_iLumaRecStride; |
---|
| 1394 | Pel* pLuma0 = m_pLumaRecBuffer + uiExt0 * iLumaStride + uiExt0; |
---|
| 1395 | |
---|
| 1396 | Int i, j, iCountShift = 0; |
---|
| 1397 | |
---|
| 1398 | UInt uiExt = uiExt0; |
---|
| 1399 | |
---|
| 1400 | // LLS parameters estimation --> |
---|
| 1401 | |
---|
| 1402 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
| 1403 | |
---|
| 1404 | pSrc = pSrc0 - iSrcStride; |
---|
| 1405 | pLuma = pLuma0 - iLumaStride; |
---|
| 1406 | |
---|
| 1407 | for( j = 0; j < uiWidth; j++ ) |
---|
| 1408 | { |
---|
| 1409 | x += pLuma[j]; |
---|
| 1410 | y += pSrc[j]; |
---|
| 1411 | xx += pLuma[j] * pLuma[j]; |
---|
| 1412 | xy += pLuma[j] * pSrc[j]; |
---|
| 1413 | } |
---|
| 1414 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
| 1415 | |
---|
| 1416 | pSrc = pSrc0 - uiExt; |
---|
| 1417 | pLuma = pLuma0 - uiExt; |
---|
| 1418 | |
---|
| 1419 | for( i = 0; i < uiHeight; i++ ) |
---|
| 1420 | { |
---|
| 1421 | x += pLuma[0]; |
---|
| 1422 | y += pSrc[0]; |
---|
| 1423 | xx += pLuma[0] * pLuma[0]; |
---|
| 1424 | xy += pLuma[0] * pSrc[0]; |
---|
| 1425 | |
---|
| 1426 | pSrc += iSrcStride; |
---|
| 1427 | pLuma += iLumaStride; |
---|
| 1428 | } |
---|
| 1429 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
| 1430 | |
---|
| 1431 | Int iTempShift = ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
| 1432 | |
---|
| 1433 | if(iTempShift > 0) |
---|
| 1434 | { |
---|
| 1435 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1436 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1437 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1438 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1439 | iCountShift -= iTempShift; |
---|
| 1440 | } |
---|
| 1441 | |
---|
| 1442 | Int a, b, iShift = 13; |
---|
| 1443 | |
---|
| 1444 | if( iCountShift == 0 ) |
---|
| 1445 | { |
---|
| 1446 | a = 0; |
---|
| 1447 | b = 1 << (g_uiBitDepth + g_uiBitIncrement - 1); |
---|
| 1448 | iShift = 0; |
---|
| 1449 | } |
---|
| 1450 | else |
---|
| 1451 | { |
---|
| 1452 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
| 1453 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
| 1454 | |
---|
| 1455 | { |
---|
| 1456 | const Int iShiftA2 = 6; |
---|
| 1457 | const Int iShiftA1 = 15; |
---|
| 1458 | const Int iAccuracyShift = 15; |
---|
| 1459 | |
---|
| 1460 | Int iScaleShiftA2 = 0; |
---|
| 1461 | Int iScaleShiftA1 = 0; |
---|
| 1462 | Int a1s = a1; |
---|
| 1463 | Int a2s = a2; |
---|
| 1464 | |
---|
| 1465 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
| 1466 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
| 1467 | |
---|
| 1468 | if( iScaleShiftA1 < 0 ) |
---|
| 1469 | { |
---|
| 1470 | iScaleShiftA1 = 0; |
---|
| 1471 | } |
---|
| 1472 | |
---|
| 1473 | if( iScaleShiftA2 < 0 ) |
---|
| 1474 | { |
---|
| 1475 | iScaleShiftA2 = 0; |
---|
| 1476 | } |
---|
| 1477 | |
---|
| 1478 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
| 1479 | |
---|
| 1480 | a2s = a2 >> iScaleShiftA2; |
---|
| 1481 | |
---|
| 1482 | a1s = a1 >> iScaleShiftA1; |
---|
| 1483 | |
---|
| 1484 | if (a2s >= 1) |
---|
| 1485 | { |
---|
| 1486 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
| 1487 | } |
---|
| 1488 | else |
---|
| 1489 | { |
---|
| 1490 | a = 0; |
---|
| 1491 | } |
---|
| 1492 | |
---|
| 1493 | if( iScaleShiftA < 0 ) |
---|
| 1494 | { |
---|
| 1495 | a = a << -iScaleShiftA; |
---|
| 1496 | } |
---|
| 1497 | else |
---|
| 1498 | { |
---|
| 1499 | a = a >> iScaleShiftA; |
---|
| 1500 | } |
---|
| 1501 | |
---|
| 1502 | a = Clip3(-( 1 << 15 ), ( 1 << 15 ) - 1, a); |
---|
| 1503 | |
---|
| 1504 | Int minA = -(1 << (6)); |
---|
| 1505 | Int maxA = (1 << 6) - 1; |
---|
| 1506 | if( a <= maxA && a >= minA ) |
---|
| 1507 | { |
---|
| 1508 | // do nothing |
---|
| 1509 | } |
---|
| 1510 | else |
---|
| 1511 | { |
---|
| 1512 | Short n = CountLeadingZerosOnes(a); |
---|
| 1513 | a = a >> (9-n); |
---|
| 1514 | iShift -= (9-n); |
---|
| 1515 | } |
---|
| 1516 | |
---|
| 1517 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 1518 | } |
---|
| 1519 | } |
---|
| 1520 | |
---|
| 1521 | // <-- end of LLS parameters estimation |
---|
| 1522 | |
---|
| 1523 | // get prediction --> |
---|
| 1524 | uiExt = uiExt0; |
---|
| 1525 | pLuma = pLuma0; |
---|
| 1526 | pDst = pDst0; |
---|
| 1527 | |
---|
| 1528 | for( i = 0; i < uiHeight; i++ ) |
---|
| 1529 | { |
---|
| 1530 | for( j = 0; j < uiWidth; j++ ) |
---|
| 1531 | { |
---|
| 1532 | pDst[j] = Clip( ( ( a * pLuma[j] ) >> iShift ) + b ); |
---|
| 1533 | } |
---|
| 1534 | |
---|
| 1535 | pDst += iDstStride; |
---|
| 1536 | pLuma += iLumaStride; |
---|
| 1537 | } |
---|
| 1538 | // <-- end of get prediction |
---|
| 1539 | |
---|
| 1540 | } |
---|
| 1541 | |
---|
[152] | 1542 | |
---|
| 1543 | #if LGE_ILLUCOMP_B0045 |
---|
| 1544 | /** Function for deriving LM illumination compensation. |
---|
| 1545 | */ |
---|
| 1546 | Void TComPrediction::xGetLLSICPrediction(TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift) |
---|
| 1547 | { |
---|
| 1548 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
| 1549 | Pel *pRec, *pRef; |
---|
| 1550 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
| 1551 | Int iRecStride = pRecPic->getStride(), iRefStride = pRefPic->getStride(); |
---|
| 1552 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset; |
---|
| 1553 | |
---|
| 1554 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1555 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1556 | iRefX = iCUPelX + (pMv->getHor() >> 2); |
---|
| 1557 | iRefY = iCUPelY + (pMv->getVer() >> 2); |
---|
| 1558 | uiWidth = pcCU->getWidth(0); |
---|
| 1559 | uiHeight = pcCU->getHeight(0); |
---|
| 1560 | |
---|
| 1561 | Int i, j, iCountShift = 0; |
---|
| 1562 | |
---|
| 1563 | // LLS parameters estimation --> |
---|
| 1564 | |
---|
| 1565 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
| 1566 | |
---|
| 1567 | if(pcCU->getPUAbove(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelY > 0 && iRefY > 0) |
---|
| 1568 | { |
---|
| 1569 | iRefOffset = ( pMv->getHor() >> 2 ) + ( pMv->getVer() >> 2 ) * iRefStride - iRefStride; |
---|
| 1570 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1571 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1572 | |
---|
| 1573 | for( j = 0; j < uiWidth; j++ ) |
---|
| 1574 | { |
---|
| 1575 | x += pRef[j]; |
---|
| 1576 | y += pRec[j]; |
---|
| 1577 | xx += pRef[j] * pRef[j]; |
---|
| 1578 | xy += pRef[j] * pRec[j]; |
---|
| 1579 | } |
---|
| 1580 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
| 1581 | } |
---|
| 1582 | |
---|
| 1583 | |
---|
| 1584 | if(pcCU->getPULeft(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelX > 0 && iRefX > 0) |
---|
| 1585 | { |
---|
| 1586 | iRefOffset = ( pMv->getHor() >> 2 ) + ( pMv->getVer() >> 2 ) * iRefStride - 1; |
---|
| 1587 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1588 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1589 | |
---|
| 1590 | for( i = 0; i < uiHeight; i++ ) |
---|
| 1591 | { |
---|
| 1592 | x += pRef[0]; |
---|
| 1593 | y += pRec[0]; |
---|
| 1594 | xx += pRef[0] * pRef[0]; |
---|
| 1595 | xy += pRef[0] * pRec[0]; |
---|
| 1596 | |
---|
| 1597 | pRef += iRefStride; |
---|
| 1598 | pRec += iRecStride; |
---|
| 1599 | } |
---|
| 1600 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
| 1601 | } |
---|
| 1602 | |
---|
| 1603 | Int iTempShift = ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
| 1604 | |
---|
| 1605 | if(iTempShift > 0) |
---|
| 1606 | { |
---|
| 1607 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1608 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1609 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1610 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1611 | iCountShift -= iTempShift; |
---|
| 1612 | } |
---|
| 1613 | |
---|
| 1614 | iShift = 13; |
---|
| 1615 | |
---|
| 1616 | if( iCountShift == 0 ) |
---|
| 1617 | { |
---|
| 1618 | a = 1; |
---|
| 1619 | b = 0; |
---|
| 1620 | iShift = 0; |
---|
| 1621 | } |
---|
| 1622 | else |
---|
| 1623 | { |
---|
| 1624 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
| 1625 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
| 1626 | |
---|
| 1627 | { |
---|
| 1628 | const Int iShiftA2 = 6; |
---|
| 1629 | const Int iShiftA1 = 15; |
---|
| 1630 | const Int iAccuracyShift = 15; |
---|
| 1631 | |
---|
| 1632 | Int iScaleShiftA2 = 0; |
---|
| 1633 | Int iScaleShiftA1 = 0; |
---|
| 1634 | Int a1s = a1; |
---|
| 1635 | Int a2s = a2; |
---|
| 1636 | |
---|
| 1637 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
| 1638 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
| 1639 | |
---|
| 1640 | if( iScaleShiftA1 < 0 ) |
---|
| 1641 | { |
---|
| 1642 | iScaleShiftA1 = 0; |
---|
| 1643 | } |
---|
| 1644 | |
---|
| 1645 | if( iScaleShiftA2 < 0 ) |
---|
| 1646 | { |
---|
| 1647 | iScaleShiftA2 = 0; |
---|
| 1648 | } |
---|
| 1649 | |
---|
| 1650 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
| 1651 | |
---|
| 1652 | a2s = a2 >> iScaleShiftA2; |
---|
| 1653 | |
---|
| 1654 | a1s = a1 >> iScaleShiftA1; |
---|
| 1655 | |
---|
| 1656 | if (a2s >= 1) |
---|
| 1657 | { |
---|
| 1658 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
| 1659 | } |
---|
| 1660 | else |
---|
| 1661 | { |
---|
| 1662 | a = 0; |
---|
| 1663 | } |
---|
| 1664 | |
---|
| 1665 | if( iScaleShiftA < 0 ) |
---|
| 1666 | { |
---|
| 1667 | a = a << -iScaleShiftA; |
---|
| 1668 | } |
---|
| 1669 | else |
---|
| 1670 | { |
---|
| 1671 | a = a >> iScaleShiftA; |
---|
| 1672 | } |
---|
| 1673 | |
---|
| 1674 | a = Clip3(-( 1 << 15 ), ( 1 << 15 ) - 1, a); |
---|
| 1675 | |
---|
| 1676 | Int minA = -(1 << (6)); |
---|
| 1677 | Int maxA = (1 << 6) - 1; |
---|
| 1678 | if( a <= maxA && a >= minA ) |
---|
| 1679 | { |
---|
| 1680 | // do nothing |
---|
| 1681 | } |
---|
| 1682 | else |
---|
| 1683 | { |
---|
| 1684 | Short n = CountLeadingZerosOnes(a); |
---|
| 1685 | a = a >> (9-n); |
---|
| 1686 | iShift -= (9-n); |
---|
| 1687 | } |
---|
| 1688 | |
---|
| 1689 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 1690 | } |
---|
| 1691 | } |
---|
| 1692 | } |
---|
| 1693 | |
---|
| 1694 | Void TComPrediction::xGetLLSICPredictionChroma(TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift, Int iChromaId) |
---|
| 1695 | { |
---|
| 1696 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
| 1697 | Pel *pRec = NULL, *pRef = NULL; |
---|
| 1698 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
| 1699 | Int iRecStride = pRecPic->getCStride(), iRefStride = pRefPic->getCStride(); |
---|
| 1700 | Int iCUPelX, iCUPelY, iRefX, iRefY, iRefOffset; |
---|
| 1701 | |
---|
| 1702 | iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1703 | iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]]; |
---|
| 1704 | iRefX = iCUPelX + (pMv->getHor() >> 3); |
---|
| 1705 | iRefY = iCUPelY + (pMv->getVer() >> 3); |
---|
| 1706 | uiWidth = pcCU->getWidth(0) >> 1; |
---|
| 1707 | uiHeight = pcCU->getHeight(0) >> 1; |
---|
| 1708 | |
---|
| 1709 | Int i, j, iCountShift = 0; |
---|
| 1710 | |
---|
| 1711 | // LLS parameters estimation --> |
---|
| 1712 | |
---|
| 1713 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
| 1714 | |
---|
| 1715 | if(pcCU->getPUAbove(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelY > 0 && iRefY > 0) |
---|
| 1716 | { |
---|
| 1717 | iRefOffset = ( pMv->getHor() >> 3 ) + ( pMv->getVer() >> 3 ) * iRefStride - iRefStride; |
---|
| 1718 | if (iChromaId == 0) // Cb |
---|
| 1719 | { |
---|
| 1720 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1721 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1722 | } |
---|
| 1723 | else if (iChromaId == 1) // Cr |
---|
| 1724 | { |
---|
| 1725 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1726 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 1727 | } |
---|
| 1728 | |
---|
| 1729 | for( j = 0; j < uiWidth; j++ ) |
---|
| 1730 | { |
---|
| 1731 | x += pRef[j]; |
---|
| 1732 | y += pRec[j]; |
---|
| 1733 | xx += pRef[j] * pRef[j]; |
---|
| 1734 | xy += pRef[j] * pRec[j]; |
---|
| 1735 | } |
---|
| 1736 | iCountShift += g_aucConvertToBit[ uiWidth ] + 2; |
---|
| 1737 | } |
---|
| 1738 | |
---|
| 1739 | |
---|
| 1740 | if(pcCU->getPULeft(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelX > 0 && iRefX > 0) |
---|
| 1741 | { |
---|
| 1742 | iRefOffset = ( pMv->getHor() >> 3 ) + ( pMv->getVer() >> 3 ) * iRefStride - 1; |
---|
| 1743 | if (iChromaId == 0) // Cb |
---|
| 1744 | { |
---|
| 1745 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1746 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1747 | } |
---|
| 1748 | else if (iChromaId == 1) // Cr |
---|
| 1749 | { |
---|
| 1750 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 1751 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 1752 | } |
---|
| 1753 | |
---|
| 1754 | for( i = 0; i < uiHeight; i++ ) |
---|
| 1755 | { |
---|
| 1756 | x += pRef[0]; |
---|
| 1757 | y += pRec[0]; |
---|
| 1758 | xx += pRef[0] * pRef[0]; |
---|
| 1759 | xy += pRef[0] * pRec[0]; |
---|
| 1760 | |
---|
| 1761 | pRef += iRefStride; |
---|
| 1762 | pRec += iRecStride; |
---|
| 1763 | } |
---|
| 1764 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); |
---|
| 1765 | } |
---|
| 1766 | |
---|
| 1767 | Int iTempShift = ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 - 15; |
---|
| 1768 | |
---|
| 1769 | if(iTempShift > 0) |
---|
| 1770 | { |
---|
| 1771 | x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1772 | y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1773 | xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1774 | xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; |
---|
| 1775 | iCountShift -= iTempShift; |
---|
| 1776 | } |
---|
| 1777 | |
---|
| 1778 | iShift = 13; |
---|
| 1779 | |
---|
| 1780 | if( iCountShift == 0 ) |
---|
| 1781 | { |
---|
| 1782 | a = 1; |
---|
| 1783 | b = 0; |
---|
| 1784 | iShift = 0; |
---|
| 1785 | } |
---|
| 1786 | else |
---|
| 1787 | { |
---|
| 1788 | Int a1 = ( xy << iCountShift ) - y * x; |
---|
| 1789 | Int a2 = ( xx << iCountShift ) - x * x; |
---|
| 1790 | |
---|
| 1791 | { |
---|
| 1792 | const Int iShiftA2 = 6; |
---|
| 1793 | const Int iShiftA1 = 15; |
---|
| 1794 | const Int iAccuracyShift = 15; |
---|
| 1795 | |
---|
| 1796 | Int iScaleShiftA2 = 0; |
---|
| 1797 | Int iScaleShiftA1 = 0; |
---|
| 1798 | Int a1s = a1; |
---|
| 1799 | Int a2s = a2; |
---|
| 1800 | |
---|
| 1801 | iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1; |
---|
| 1802 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
| 1803 | |
---|
| 1804 | if( iScaleShiftA1 < 0 ) |
---|
| 1805 | { |
---|
| 1806 | iScaleShiftA1 = 0; |
---|
| 1807 | } |
---|
| 1808 | |
---|
| 1809 | if( iScaleShiftA2 < 0 ) |
---|
| 1810 | { |
---|
| 1811 | iScaleShiftA2 = 0; |
---|
| 1812 | } |
---|
| 1813 | |
---|
| 1814 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
| 1815 | |
---|
| 1816 | a2s = a2 >> iScaleShiftA2; |
---|
| 1817 | |
---|
| 1818 | a1s = a1 >> iScaleShiftA1; |
---|
| 1819 | |
---|
| 1820 | if (a2s >= 1) |
---|
| 1821 | { |
---|
| 1822 | a = a1s * m_uiaShift[ a2s - 1]; |
---|
| 1823 | } |
---|
| 1824 | else |
---|
| 1825 | { |
---|
| 1826 | a = 0; |
---|
| 1827 | } |
---|
| 1828 | |
---|
| 1829 | if( iScaleShiftA < 0 ) |
---|
| 1830 | { |
---|
| 1831 | a = a << -iScaleShiftA; |
---|
| 1832 | } |
---|
| 1833 | else |
---|
| 1834 | { |
---|
| 1835 | a = a >> iScaleShiftA; |
---|
| 1836 | } |
---|
| 1837 | |
---|
| 1838 | a = Clip3(-( 1 << 15 ), ( 1 << 15 ) - 1, a); |
---|
| 1839 | |
---|
| 1840 | Int minA = -(1 << (6)); |
---|
| 1841 | Int maxA = (1 << 6) - 1; |
---|
| 1842 | if( a <= maxA && a >= minA ) |
---|
| 1843 | { |
---|
| 1844 | // do nothing |
---|
| 1845 | } |
---|
| 1846 | else |
---|
| 1847 | { |
---|
| 1848 | Short n = CountLeadingZerosOnes(a); |
---|
| 1849 | a = a >> (9-n); |
---|
| 1850 | iShift -= (9-n); |
---|
| 1851 | } |
---|
| 1852 | |
---|
| 1853 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 1854 | } |
---|
| 1855 | } |
---|
| 1856 | } |
---|
| 1857 | #endif |
---|
[56] | 1858 | /** Function for filtering intra DC predictor. |
---|
| 1859 | * \param pSrc pointer to reconstructed sample array |
---|
| 1860 | * \param iSrcStride the stride of the reconstructed sample array |
---|
| 1861 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 1862 | * \param iDstStride the stride of the prediction sample array |
---|
| 1863 | * \param iWidth the width of the block |
---|
| 1864 | * \param iHeight the height of the block |
---|
| 1865 | * |
---|
| 1866 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
| 1867 | */ |
---|
| 1868 | Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) |
---|
| 1869 | { |
---|
| 1870 | Pel* pDst = rpDst; |
---|
| 1871 | Int x, y, iDstStride2, iSrcStride2; |
---|
| 1872 | |
---|
| 1873 | // boundary pixels processing |
---|
| 1874 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
| 1875 | |
---|
| 1876 | for ( x = 1; x < iWidth; x++ ) |
---|
| 1877 | { |
---|
| 1878 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
| 1879 | } |
---|
| 1880 | |
---|
| 1881 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
| 1882 | { |
---|
| 1883 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
| 1884 | } |
---|
| 1885 | |
---|
| 1886 | return; |
---|
| 1887 | } |
---|
| 1888 | |
---|
[5] | 1889 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[2] | 1890 | Void TComPrediction::predIntraLumaDMM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder ) |
---|
| 1891 | { |
---|
[5] | 1892 | #if HHI_DMM_WEDGE_INTRA |
---|
[56] | 1893 | if( uiMode == DMM_WEDGE_FULL_IDX ) { xPredIntraWedgeFull ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU->getWedgeFullTabIdx ( uiAbsPartIdx ) ); } |
---|
| 1894 | 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 ) ); } |
---|
| 1895 | if( uiMode == DMM_WEDGE_PREDDIR_IDX ) { xPredIntraWedgeDir ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU->getWedgePredDirDeltaEnd( uiAbsPartIdx ) ); } |
---|
| 1896 | 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] | 1897 | #endif |
---|
| 1898 | #if HHI_DMM_PRED_TEX |
---|
[56] | 1899 | if( uiMode == DMM_WEDGE_PREDTEX_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); } |
---|
| 1900 | if( uiMode == DMM_WEDGE_PREDTEX_D_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getWedgePredTexDeltaDC1( uiAbsPartIdx ), pcCU->getWedgePredTexDeltaDC2( uiAbsPartIdx ) ); } |
---|
| 1901 | if( uiMode == DMM_CONTOUR_PREDTEX_IDX ) { xPredIntraContourTex( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); } |
---|
| 1902 | 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] | 1903 | #endif |
---|
| 1904 | } |
---|
[2] | 1905 | |
---|
[56] | 1906 | Void TComPrediction::getWedgePredDCs( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft ) |
---|
[2] | 1907 | { |
---|
[56] | 1908 | riPredDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); //pred val, if no neighbors are available |
---|
| 1909 | riPredDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
[2] | 1910 | |
---|
[56] | 1911 | if( !bAbove && !bLeft ) { return; } |
---|
[2] | 1912 | |
---|
[56] | 1913 | UInt uiNumSmpDC1 = 0, uiNumSmpDC2 = 0; |
---|
| 1914 | Int iPredDC1 = 0, iPredDC2 = 0; |
---|
| 1915 | |
---|
| 1916 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
| 1917 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
| 1918 | |
---|
| 1919 | if( bAbove ) |
---|
| 1920 | { |
---|
| 1921 | for( Int k = 0; k < pcWedgelet->getWidth(); k++ ) |
---|
| 1922 | { |
---|
| 1923 | if( true == pabWedgePattern[k] ) |
---|
| 1924 | { |
---|
| 1925 | iPredDC2 += piMask[k-iMaskStride]; |
---|
| 1926 | uiNumSmpDC2++; |
---|
| 1927 | } |
---|
| 1928 | else |
---|
| 1929 | { |
---|
| 1930 | iPredDC1 += piMask[k-iMaskStride]; |
---|
| 1931 | uiNumSmpDC1++; |
---|
| 1932 | } |
---|
| 1933 | } |
---|
| 1934 | } |
---|
| 1935 | if( bLeft ) |
---|
| 1936 | { |
---|
| 1937 | for( Int k = 0; k < pcWedgelet->getHeight(); k++ ) |
---|
| 1938 | { |
---|
| 1939 | if( true == pabWedgePattern[k*uiWedgeStride] ) |
---|
| 1940 | { |
---|
| 1941 | iPredDC2 += piMask[k*iMaskStride-1]; |
---|
| 1942 | uiNumSmpDC2++; |
---|
| 1943 | } |
---|
| 1944 | else |
---|
| 1945 | { |
---|
| 1946 | iPredDC1 += piMask[k*iMaskStride-1]; |
---|
| 1947 | uiNumSmpDC1++; |
---|
| 1948 | } |
---|
| 1949 | } |
---|
| 1950 | } |
---|
| 1951 | |
---|
| 1952 | if( uiNumSmpDC1 > 0 ) |
---|
| 1953 | { |
---|
| 1954 | iPredDC1 /= uiNumSmpDC1; |
---|
| 1955 | riPredDC1 = iPredDC1; |
---|
| 1956 | } |
---|
| 1957 | if( uiNumSmpDC2 > 0 ) |
---|
| 1958 | { |
---|
| 1959 | iPredDC2 /= uiNumSmpDC2; |
---|
| 1960 | riPredDC2 = iPredDC2; |
---|
| 1961 | } |
---|
[2] | 1962 | } |
---|
| 1963 | |
---|
[5] | 1964 | Void TComPrediction::calcWedgeDCs( TComWedgelet* pcWedgelet, Pel* piOrig, UInt uiStride, Int& riDC1, Int& riDC2 ) |
---|
[2] | 1965 | { |
---|
[5] | 1966 | UInt uiDC1 = 0; |
---|
| 1967 | UInt uiDC2 = 0; |
---|
| 1968 | UInt uiNumPixDC1 = 0, uiNumPixDC2 = 0; |
---|
| 1969 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
| 1970 | if( uiStride == pcWedgelet->getStride() ) |
---|
| 1971 | { |
---|
| 1972 | for( UInt k = 0; k < (pcWedgelet->getWidth() * pcWedgelet->getHeight()); k++ ) |
---|
| 1973 | { |
---|
| 1974 | if( true == pabWedgePattern[k] ) |
---|
| 1975 | { |
---|
| 1976 | uiDC2 += piOrig[k]; |
---|
| 1977 | uiNumPixDC2++; |
---|
| 1978 | } |
---|
| 1979 | else |
---|
| 1980 | { |
---|
| 1981 | uiDC1 += piOrig[k]; |
---|
| 1982 | uiNumPixDC1++; |
---|
| 1983 | } |
---|
| 1984 | } |
---|
| 1985 | } |
---|
| 1986 | else |
---|
| 1987 | { |
---|
| 1988 | Pel* piTemp = piOrig; |
---|
| 1989 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
| 1990 | for( UInt uiY = 0; uiY < pcWedgelet->getHeight(); uiY++ ) |
---|
| 1991 | { |
---|
| 1992 | for( UInt uiX = 0; uiX < pcWedgelet->getWidth(); uiX++ ) |
---|
| 1993 | { |
---|
| 1994 | if( true == pabWedgePattern[uiX] ) |
---|
| 1995 | { |
---|
| 1996 | uiDC2 += piTemp[uiX]; |
---|
| 1997 | uiNumPixDC2++; |
---|
| 1998 | } |
---|
| 1999 | else |
---|
| 2000 | { |
---|
| 2001 | uiDC1 += piTemp[uiX]; |
---|
| 2002 | uiNumPixDC1++; |
---|
| 2003 | } |
---|
| 2004 | } |
---|
| 2005 | piTemp += uiStride; |
---|
| 2006 | pabWedgePattern += uiWedgeStride; |
---|
| 2007 | } |
---|
| 2008 | } |
---|
[2] | 2009 | |
---|
[5] | 2010 | if( uiNumPixDC1 > 0 ) { riDC1 = uiDC1 / uiNumPixDC1; } |
---|
| 2011 | else { riDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); } |
---|
[2] | 2012 | |
---|
[5] | 2013 | if( uiNumPixDC2 > 0 ) { riDC2 = uiDC2 / uiNumPixDC2; } |
---|
| 2014 | else { riDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); } |
---|
| 2015 | } |
---|
[2] | 2016 | |
---|
[5] | 2017 | Void TComPrediction::assignWedgeDCs2Pred( TComWedgelet* pcWedgelet, Pel* piPred, UInt uiStride, Int iDC1, Int iDC2 ) |
---|
| 2018 | { |
---|
| 2019 | Bool* pabWedgePattern = pcWedgelet->getPattern(); |
---|
| 2020 | |
---|
| 2021 | if( uiStride == pcWedgelet->getStride() ) |
---|
[2] | 2022 | { |
---|
[5] | 2023 | for( UInt k = 0; k < (pcWedgelet->getWidth() * pcWedgelet->getHeight()); k++ ) |
---|
| 2024 | { |
---|
| 2025 | if( true == pabWedgePattern[k] ) |
---|
| 2026 | { |
---|
| 2027 | piPred[k] = iDC2; |
---|
| 2028 | } |
---|
| 2029 | else |
---|
| 2030 | { |
---|
| 2031 | piPred[k] = iDC1; |
---|
| 2032 | } |
---|
| 2033 | } |
---|
[2] | 2034 | } |
---|
[5] | 2035 | else |
---|
| 2036 | { |
---|
| 2037 | Pel* piTemp = piPred; |
---|
| 2038 | UInt uiWedgeStride = pcWedgelet->getStride(); |
---|
| 2039 | for( UInt uiY = 0; uiY < pcWedgelet->getHeight(); uiY++ ) |
---|
| 2040 | { |
---|
| 2041 | for( UInt uiX = 0; uiX < pcWedgelet->getWidth(); uiX++ ) |
---|
| 2042 | { |
---|
| 2043 | if( true == pabWedgePattern[uiX] ) |
---|
| 2044 | { |
---|
| 2045 | piTemp[uiX] = iDC2; |
---|
| 2046 | } |
---|
| 2047 | else |
---|
[56] | 2048 | { |
---|
[5] | 2049 | piTemp[uiX] = iDC1; |
---|
| 2050 | } |
---|
| 2051 | } |
---|
| 2052 | piTemp += uiStride; |
---|
| 2053 | pabWedgePattern += uiWedgeStride; |
---|
| 2054 | } |
---|
| 2055 | } |
---|
[2] | 2056 | } |
---|
| 2057 | |
---|
[56] | 2058 | Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Int& riDeltaDC ) |
---|
[2] | 2059 | { |
---|
[56] | 2060 | Int iSign = riDeltaDC < 0 ? -1 : 1; |
---|
| 2061 | UInt uiAbs = abs( riDeltaDC ); |
---|
[2] | 2062 | |
---|
[56] | 2063 | Int iQp = pcCU->getQP(0); |
---|
| 2064 | Double dMax = (Double)( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
| 2065 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 + g_iDeltaDCsQuantOffset ) ); |
---|
[2] | 2066 | |
---|
[56] | 2067 | riDeltaDC = iSign * roftoi( uiAbs * dStepSize ); |
---|
| 2068 | return; |
---|
| 2069 | } |
---|
[2] | 2070 | |
---|
[56] | 2071 | Void TComPrediction::xDeltaDCQuantScaleDown( TComDataCU* pcCU, Int& riDeltaDC ) |
---|
| 2072 | { |
---|
| 2073 | Int iSign = riDeltaDC < 0 ? -1 : 1; |
---|
| 2074 | UInt uiAbs = abs( riDeltaDC ); |
---|
[2] | 2075 | |
---|
[56] | 2076 | Int iQp = pcCU->getQP(0); |
---|
| 2077 | Double dMax = (Double)( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
| 2078 | Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 + g_iDeltaDCsQuantOffset ) ); |
---|
| 2079 | |
---|
| 2080 | riDeltaDC = iSign * roftoi( uiAbs / dStepSize ); |
---|
| 2081 | return; |
---|
| 2082 | } |
---|
| 2083 | #endif |
---|
| 2084 | |
---|
| 2085 | #if HHI_DMM_PRED_TEX |
---|
| 2086 | Void TComPrediction::getBestContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) |
---|
| 2087 | { |
---|
| 2088 | pcContourWedge->clear(); |
---|
| 2089 | |
---|
| 2090 | // get copy of co-located texture luma block |
---|
| 2091 | TComYuv cTempYuv; |
---|
| 2092 | cTempYuv.create( uiWidth, uiHeight ); |
---|
| 2093 | cTempYuv.clear(); |
---|
| 2094 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2095 | copyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
| 2096 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2097 | |
---|
| 2098 | // find contour for texture luma block |
---|
| 2099 | UInt iDC = 0; |
---|
| 2100 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
| 2101 | { |
---|
| 2102 | iDC += piRefBlkY[k]; |
---|
[2] | 2103 | } |
---|
[56] | 2104 | iDC /= (uiWidth*uiHeight); |
---|
| 2105 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2106 | |
---|
| 2107 | Bool* pabContourPattern = pcContourWedge->getPattern(); |
---|
| 2108 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
| 2109 | { |
---|
| 2110 | pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; |
---|
| 2111 | } |
---|
| 2112 | |
---|
| 2113 | cTempYuv.destroy(); |
---|
| 2114 | } |
---|
| 2115 | |
---|
| 2116 | UInt TComPrediction::getBestWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight ) |
---|
| 2117 | { |
---|
| 2118 | assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
| 2119 | |
---|
| 2120 | // get copy of co-located texture luma block |
---|
| 2121 | TComYuv cTempYuv; |
---|
| 2122 | cTempYuv.create( uiWidth, uiHeight ); |
---|
| 2123 | cTempYuv.clear(); |
---|
| 2124 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2125 | |
---|
| 2126 | copyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
| 2127 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2128 | |
---|
| 2129 | // local pred buffer |
---|
| 2130 | TComYuv cPredYuv; |
---|
| 2131 | cPredYuv.create( uiWidth, uiHeight ); |
---|
| 2132 | cPredYuv.clear(); |
---|
| 2133 | Pel* piPred = cPredYuv.getLumaAddr(); |
---|
| 2134 | |
---|
| 2135 | UInt uiPredStride = cPredYuv.getStride(); |
---|
| 2136 | |
---|
[158] | 2137 | // wedge search |
---|
[56] | 2138 | TComWedgeDist cWedgeDist; |
---|
| 2139 | UInt uiBestDist = MAX_UINT; |
---|
| 2140 | UInt uiBestTabIdx = 0; |
---|
| 2141 | Int iDC1 = 0; |
---|
| 2142 | Int iDC2 = 0; |
---|
[158] | 2143 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])]; |
---|
[56] | 2144 | |
---|
[158] | 2145 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
| 2146 | TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); |
---|
| 2147 | TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); |
---|
| 2148 | UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 2149 | Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; |
---|
| 2150 | |
---|
| 2151 | std::vector< std::vector<UInt> > pauiWdgLstSz = g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]]; |
---|
| 2152 | if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) |
---|
| 2153 | { |
---|
| 2154 | std::vector<UInt>* pauiWdgLst = &pauiWdgLstSz[uiColTexIntraDir-2]; |
---|
| 2155 | for( UInt uiIdxW = 0; uiIdxW < pauiWdgLst->size(); uiIdxW++ ) |
---|
| 2156 | { |
---|
| 2157 | UInt uiIdx = pauiWdgLst->at(uiIdxW); |
---|
| 2158 | calcWedgeDCs ( &(pacWedgeList->at(uiIdx)), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
| 2159 | assignWedgeDCs2Pred( &(pacWedgeList->at(uiIdx)), piPred, uiPredStride, iDC1, iDC2 ); |
---|
| 2160 | |
---|
| 2161 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
| 2162 | |
---|
| 2163 | if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) |
---|
| 2164 | { |
---|
| 2165 | uiBestDist = uiActDist; |
---|
| 2166 | uiBestTabIdx = uiIdx; |
---|
| 2167 | } |
---|
| 2168 | } |
---|
| 2169 | } |
---|
| 2170 | else |
---|
| 2171 | { |
---|
| 2172 | WedgeNodeList* pacWedgeNodeList = &g_aacWedgeNodeLists[(g_aucConvertToBit[uiWidth])]; |
---|
| 2173 | UInt uiBestNodeDist = MAX_UINT; |
---|
| 2174 | UInt uiBestNodeId = 0; |
---|
| 2175 | for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ ) |
---|
| 2176 | { |
---|
| 2177 | calcWedgeDCs ( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
| 2178 | assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piPred, uiPredStride, iDC1, iDC2 ); |
---|
| 2179 | |
---|
| 2180 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
| 2181 | |
---|
| 2182 | if( uiActDist < uiBestNodeDist || uiBestNodeDist == MAX_UINT ) |
---|
| 2183 | { |
---|
| 2184 | uiBestNodeDist = uiActDist; |
---|
| 2185 | uiBestNodeId = uiNodeId; |
---|
| 2186 | } |
---|
| 2187 | } |
---|
| 2188 | |
---|
| 2189 | // refinement |
---|
| 2190 | uiBestDist = uiBestNodeDist; |
---|
| 2191 | uiBestTabIdx = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx(); |
---|
| 2192 | for( UInt uiRefId = 0; uiRefId < NUM_WEDGE_REFINES; uiRefId++ ) |
---|
| 2193 | { |
---|
| 2194 | if( pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ) != NO_IDX ) |
---|
| 2195 | { |
---|
| 2196 | calcWedgeDCs ( &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
| 2197 | assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))), piPred, uiPredStride, iDC1, iDC2 ); |
---|
| 2198 | |
---|
| 2199 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
| 2200 | |
---|
| 2201 | if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) |
---|
| 2202 | { |
---|
| 2203 | uiBestDist = uiActDist; |
---|
| 2204 | uiBestTabIdx = pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ); |
---|
| 2205 | } |
---|
| 2206 | } |
---|
| 2207 | } |
---|
| 2208 | } |
---|
| 2209 | #else |
---|
[56] | 2210 | for( UInt uiIdx = 0; uiIdx < pacWedgeList->size(); uiIdx++ ) |
---|
[2] | 2211 | { |
---|
[56] | 2212 | calcWedgeDCs ( &(pacWedgeList->at(uiIdx)), piRefBlkY, uiWidth, iDC1, iDC2 ); |
---|
| 2213 | assignWedgeDCs2Pred( &(pacWedgeList->at(uiIdx)), piPred, uiPredStride, iDC1, iDC2 ); |
---|
| 2214 | |
---|
| 2215 | UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); |
---|
| 2216 | |
---|
| 2217 | if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) |
---|
[2] | 2218 | { |
---|
[56] | 2219 | uiBestDist = uiActDist; |
---|
| 2220 | uiBestTabIdx = uiIdx; |
---|
[2] | 2221 | } |
---|
| 2222 | } |
---|
[158] | 2223 | #endif |
---|
[2] | 2224 | |
---|
[56] | 2225 | cPredYuv.destroy(); |
---|
| 2226 | cTempYuv.destroy(); |
---|
| 2227 | return uiBestTabIdx; |
---|
| 2228 | } |
---|
| 2229 | |
---|
| 2230 | Void TComPrediction::copyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) |
---|
| 2231 | { |
---|
| 2232 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
| 2233 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
| 2234 | Pel* piRefY; |
---|
| 2235 | |
---|
| 2236 | piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 2237 | |
---|
| 2238 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
[2] | 2239 | { |
---|
[56] | 2240 | ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); |
---|
| 2241 | // ::memset(piDestBlockY, 128, sizeof(Pel)*uiWidth); |
---|
| 2242 | piDestBlockY += uiWidth; |
---|
| 2243 | piRefY += iRefStride; |
---|
[2] | 2244 | } |
---|
| 2245 | } |
---|
| 2246 | |
---|
[56] | 2247 | 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] | 2248 | { |
---|
[5] | 2249 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
| 2250 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
[2] | 2251 | |
---|
[56] | 2252 | // get wedge pattern |
---|
| 2253 | UInt uiTextureWedgeTabIdx = 0; |
---|
| 2254 | if( bEncoder ) |
---|
| 2255 | { |
---|
| 2256 | // encoder: load stored wedge pattern from CU |
---|
| 2257 | uiTextureWedgeTabIdx = pcCU->getWedgePredTexTabIdx( uiAbsPartIdx ); |
---|
| 2258 | } |
---|
| 2259 | else |
---|
| 2260 | { |
---|
| 2261 | // decoder: get and store wedge pattern in CU |
---|
| 2262 | uiTextureWedgeTabIdx = getBestWedgeFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight ); |
---|
| 2263 | |
---|
| 2264 | UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1); |
---|
| 2265 | pcCU->setWedgePredTexTabIdxSubParts( uiTextureWedgeTabIdx, uiAbsPartIdx, uiDepth ); |
---|
| 2266 | } |
---|
| 2267 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTextureWedgeTabIdx)); |
---|
| 2268 | |
---|
[5] | 2269 | // get wedge pred DCs |
---|
| 2270 | Int iPredDC1 = 0; |
---|
| 2271 | Int iPredDC2 = 0; |
---|
| 2272 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
| 2273 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
| 2274 | piMask += iMaskStride+1; |
---|
| 2275 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
[2] | 2276 | |
---|
[5] | 2277 | if( bDelta ) |
---|
[2] | 2278 | { |
---|
[5] | 2279 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
| 2280 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
[2] | 2281 | } |
---|
| 2282 | |
---|
[5] | 2283 | // assign wedge pred DCs to prediction |
---|
[56] | 2284 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
| 2285 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
[2] | 2286 | } |
---|
| 2287 | |
---|
[56] | 2288 | 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 ) |
---|
| 2289 | { |
---|
| 2290 | // get contour pattern |
---|
| 2291 | TComWedgelet* pcContourWedge = new TComWedgelet( iWidth, iHeight ); |
---|
| 2292 | getBestContourFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight, pcContourWedge ); |
---|
| 2293 | |
---|
| 2294 | // get wedge pred DCs |
---|
| 2295 | Int iPredDC1 = 0; |
---|
| 2296 | Int iPredDC2 = 0; |
---|
| 2297 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
| 2298 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
| 2299 | piMask += iMaskStride+1; |
---|
| 2300 | getWedgePredDCs( pcContourWedge, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
| 2301 | |
---|
| 2302 | if( bDelta ) |
---|
| 2303 | { |
---|
| 2304 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
| 2305 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
| 2306 | } |
---|
| 2307 | |
---|
| 2308 | // assign wedge pred DCs to prediction |
---|
| 2309 | if( bDelta ) { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
| 2310 | else { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
| 2311 | |
---|
| 2312 | pcContourWedge->destroy(); |
---|
| 2313 | delete pcContourWedge; |
---|
| 2314 | } |
---|
| 2315 | #endif |
---|
| 2316 | |
---|
| 2317 | #if HHI_DMM_WEDGE_INTRA |
---|
[2] | 2318 | UInt TComPrediction::getBestContinueWedge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd ) |
---|
| 2319 | { |
---|
| 2320 | UInt uiThisBlockSize = uiWidth; |
---|
| 2321 | assert( uiThisBlockSize >= DMM_WEDGEMODEL_MIN_SIZE && uiThisBlockSize <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
| 2322 | WedgeRefList* pacContDWedgeRefList = &g_aacWedgeRefLists[(g_aucConvertToBit[uiThisBlockSize])]; |
---|
| 2323 | |
---|
| 2324 | UInt uiPredDirWedgeTabIdx = 0; |
---|
| 2325 | TComDataCU* pcTempCU; |
---|
| 2326 | UInt uiTempPartIdx; |
---|
| 2327 | // 1st: try continue above wedgelet |
---|
| 2328 | pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 2329 | if( pcTempCU ) |
---|
| 2330 | { |
---|
| 2331 | UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx ); |
---|
| 2332 | if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir || |
---|
| 2333 | DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir || |
---|
| 2334 | DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir || |
---|
[5] | 2335 | DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir |
---|
| 2336 | #if HHI_DMM_PRED_TEX |
---|
[56] | 2337 | || |
---|
[2] | 2338 | DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir || |
---|
[5] | 2339 | DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir |
---|
| 2340 | #endif |
---|
[56] | 2341 | ) |
---|
[2] | 2342 | { |
---|
| 2343 | UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )]; |
---|
| 2344 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; |
---|
| 2345 | |
---|
| 2346 | // get offset between current and reference block |
---|
| 2347 | UInt uiOffsetX = 0; |
---|
| 2348 | UInt uiOffsetY = 0; |
---|
| 2349 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
| 2350 | |
---|
| 2351 | // get reference wedgelet |
---|
[56] | 2352 | UInt uiRefWedgeTabIdx = 0; |
---|
[2] | 2353 | switch( uhLumaIntraDir ) |
---|
| 2354 | { |
---|
| 2355 | case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
| 2356 | case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
| 2357 | case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
| 2358 | case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
[5] | 2359 | #if HHI_DMM_PRED_TEX |
---|
[2] | 2360 | case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
| 2361 | case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
[5] | 2362 | #endif |
---|
[2] | 2363 | default: { assert( 0 ); return uiPredDirWedgeTabIdx; } |
---|
| 2364 | } |
---|
| 2365 | TComWedgelet* pcRefWedgelet; |
---|
| 2366 | pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx )); |
---|
[56] | 2367 | |
---|
[2] | 2368 | // find reference wedgelet, if direction is suitable for continue wedge |
---|
| 2369 | if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) ) |
---|
| 2370 | { |
---|
| 2371 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
| 2372 | pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd ); |
---|
[56] | 2373 | getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
[2] | 2374 | return uiPredDirWedgeTabIdx; |
---|
| 2375 | } |
---|
| 2376 | } |
---|
| 2377 | } |
---|
| 2378 | |
---|
| 2379 | // 2nd: try continue left wedglelet |
---|
| 2380 | pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 2381 | if( pcTempCU ) |
---|
| 2382 | { |
---|
[5] | 2383 | UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx ); |
---|
| 2384 | if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir || |
---|
| 2385 | DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir || |
---|
[2] | 2386 | DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir || |
---|
[5] | 2387 | DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir |
---|
| 2388 | #if HHI_DMM_PRED_TEX |
---|
[56] | 2389 | || |
---|
[5] | 2390 | DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir || |
---|
| 2391 | DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir |
---|
| 2392 | #endif |
---|
| 2393 | ) |
---|
| 2394 | { |
---|
[2] | 2395 | UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )]; |
---|
| 2396 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; |
---|
| 2397 | |
---|
| 2398 | // get offset between current and reference block |
---|
| 2399 | UInt uiOffsetX = 0; |
---|
| 2400 | UInt uiOffsetY = 0; |
---|
| 2401 | xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); |
---|
| 2402 | |
---|
| 2403 | // get reference wedgelet |
---|
| 2404 | UInt uiRefWedgeTabIdx = 0; |
---|
| 2405 | switch( uhLumaIntraDir ) |
---|
| 2406 | { |
---|
| 2407 | case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
| 2408 | case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx ( uiTempPartIdx ); } break; |
---|
| 2409 | case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
| 2410 | case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break; |
---|
[5] | 2411 | #if HHI_DMM_PRED_TEX |
---|
[2] | 2412 | case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
| 2413 | case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break; |
---|
[5] | 2414 | #endif |
---|
[2] | 2415 | default: { assert( 0 ); return uiPredDirWedgeTabIdx; } |
---|
| 2416 | } |
---|
| 2417 | TComWedgelet* pcRefWedgelet; |
---|
| 2418 | pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx )); |
---|
| 2419 | |
---|
| 2420 | // find reference wedgelet, if direction is suitable for continue wedge |
---|
| 2421 | if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) ) |
---|
| 2422 | { |
---|
| 2423 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
| 2424 | pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd ); |
---|
[56] | 2425 | getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
[2] | 2426 | return uiPredDirWedgeTabIdx; |
---|
| 2427 | } |
---|
| 2428 | } |
---|
| 2429 | } |
---|
| 2430 | |
---|
| 2431 | // 3rd: (default) make wedglet from intra dir and max slope point |
---|
| 2432 | Int iSlopeX = 0; |
---|
| 2433 | Int iSlopeY = 0; |
---|
| 2434 | UInt uiStartPosX = 0; |
---|
| 2435 | UInt uiStartPosY = 0; |
---|
| 2436 | if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) ) |
---|
| 2437 | { |
---|
| 2438 | UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; |
---|
| 2439 | xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd ); |
---|
[56] | 2440 | getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); |
---|
[2] | 2441 | return uiPredDirWedgeTabIdx; |
---|
| 2442 | } |
---|
| 2443 | |
---|
| 2444 | return uiPredDirWedgeTabIdx; |
---|
| 2445 | } |
---|
| 2446 | |
---|
[56] | 2447 | Bool TComPrediction::getWedgePatternIdx( WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ) |
---|
| 2448 | { |
---|
| 2449 | ruiTabIdx = 0; |
---|
| 2450 | |
---|
| 2451 | for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ ) |
---|
| 2452 | { |
---|
| 2453 | TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx)); |
---|
| 2454 | |
---|
| 2455 | if( pcTestWedgeRef->getStartX() == uhXs && |
---|
| 2456 | pcTestWedgeRef->getStartY() == uhYs && |
---|
| 2457 | pcTestWedgeRef->getEndX() == uhXe && |
---|
| 2458 | pcTestWedgeRef->getEndY() == uhYe ) |
---|
| 2459 | { |
---|
| 2460 | ruiTabIdx = pcTestWedgeRef->getRefIdx(); |
---|
| 2461 | return true; |
---|
| 2462 | } |
---|
| 2463 | } |
---|
| 2464 | |
---|
| 2465 | return false; |
---|
| 2466 | } |
---|
| 2467 | |
---|
| 2468 | 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 ) |
---|
| 2469 | { |
---|
| 2470 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
| 2471 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
| 2472 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTabIdx)); |
---|
| 2473 | |
---|
| 2474 | // get wedge pred DCs |
---|
| 2475 | Int iPredDC1 = 0; |
---|
| 2476 | Int iPredDC2 = 0; |
---|
| 2477 | |
---|
| 2478 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
| 2479 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
| 2480 | piMask += iMaskStride+1; |
---|
| 2481 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
| 2482 | |
---|
| 2483 | if( bDelta ) |
---|
| 2484 | { |
---|
| 2485 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
| 2486 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
| 2487 | } |
---|
| 2488 | |
---|
| 2489 | // assign wedge pred DCs to prediction |
---|
| 2490 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
| 2491 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
| 2492 | } |
---|
| 2493 | |
---|
| 2494 | 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 ) |
---|
| 2495 | { |
---|
| 2496 | assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); |
---|
| 2497 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; |
---|
| 2498 | |
---|
| 2499 | // get wedge pattern |
---|
| 2500 | UInt uiDirWedgeTabIdx = 0; |
---|
| 2501 | if( bEncoder ) |
---|
| 2502 | { |
---|
| 2503 | // encoder: load stored wedge pattern from CU |
---|
| 2504 | uiDirWedgeTabIdx = pcCU->getWedgePredDirTabIdx( uiAbsPartIdx ); |
---|
| 2505 | } |
---|
| 2506 | else |
---|
| 2507 | { |
---|
| 2508 | uiDirWedgeTabIdx = getBestContinueWedge( pcCU, uiAbsPartIdx, iWidth, iHeight, iWedgeDeltaEnd ); |
---|
| 2509 | |
---|
| 2510 | UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1); |
---|
| 2511 | pcCU->setWedgePredDirTabIdxSubParts( uiDirWedgeTabIdx, uiAbsPartIdx, uiDepth ); |
---|
| 2512 | } |
---|
| 2513 | TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiDirWedgeTabIdx)); |
---|
| 2514 | |
---|
| 2515 | // get wedge pred DCs |
---|
| 2516 | Int iPredDC1 = 0; |
---|
| 2517 | Int iPredDC2 = 0; |
---|
| 2518 | |
---|
| 2519 | Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
| 2520 | Int iMaskStride = ( iWidth<<1 ) + 1; |
---|
| 2521 | piMask += iMaskStride+1; |
---|
| 2522 | getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); |
---|
| 2523 | |
---|
| 2524 | if( bDelta ) |
---|
| 2525 | { |
---|
| 2526 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); |
---|
| 2527 | xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); |
---|
| 2528 | } |
---|
| 2529 | |
---|
| 2530 | // assign wedge pred DCs to prediction |
---|
| 2531 | if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } |
---|
| 2532 | else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } |
---|
| 2533 | } |
---|
| 2534 | |
---|
[2] | 2535 | Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ) |
---|
| 2536 | { |
---|
| 2537 | ruiOffsetX = 0; |
---|
| 2538 | ruiOffsetY = 0; |
---|
| 2539 | |
---|
[5] | 2540 | // get offset between current and above/left block |
---|
| 2541 | UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
[2] | 2542 | UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 2543 | |
---|
| 2544 | UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart(); |
---|
[5] | 2545 | UInt uiMaxDepthRefCU = 0; |
---|
| 2546 | while( uiNumPartInRefCU > 1 ) |
---|
| 2547 | { |
---|
| 2548 | uiNumPartInRefCU >>= 2; |
---|
| 2549 | uiMaxDepthRefCU++; |
---|
| 2550 | } |
---|
[2] | 2551 | |
---|
| 2552 | UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1); |
---|
[5] | 2553 | UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2; |
---|
[2] | 2554 | UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts; |
---|
| 2555 | |
---|
| 2556 | UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
| 2557 | UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; |
---|
| 2558 | |
---|
| 2559 | if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); } |
---|
| 2560 | if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); } |
---|
| 2561 | } |
---|
| 2562 | |
---|
| 2563 | Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ) |
---|
| 2564 | { |
---|
| 2565 | riSlopeX = 0; |
---|
| 2566 | riSlopeY = 0; |
---|
| 2567 | ruiStartPosX = 0; |
---|
| 2568 | ruiStartPosY = 0; |
---|
| 2569 | |
---|
| 2570 | // 1st step: get wedge start point (max. slope) |
---|
| 2571 | Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt ); |
---|
| 2572 | Int iSourceStride = ( uiBlockSize<<1 ) + 1; |
---|
| 2573 | |
---|
| 2574 | UInt uiSlopeMaxAbove = 0; |
---|
| 2575 | UInt uiPosSlopeMaxAbove = 0; |
---|
| 2576 | for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ ) |
---|
| 2577 | { |
---|
| 2578 | if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove ) |
---|
| 2579 | { |
---|
| 2580 | uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] ); |
---|
| 2581 | uiPosSlopeMaxAbove = uiPosHor; |
---|
| 2582 | } |
---|
| 2583 | } |
---|
| 2584 | |
---|
| 2585 | UInt uiSlopeMaxLeft = 0; |
---|
| 2586 | UInt uiPosSlopeMaxLeft = 0; |
---|
| 2587 | for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ ) |
---|
| 2588 | { |
---|
| 2589 | if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft ) |
---|
| 2590 | { |
---|
| 2591 | uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ); |
---|
| 2592 | uiPosSlopeMaxLeft = uiPosVer; |
---|
| 2593 | } |
---|
| 2594 | } |
---|
| 2595 | |
---|
| 2596 | if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 ) |
---|
| 2597 | { |
---|
| 2598 | return false; |
---|
| 2599 | } |
---|
| 2600 | |
---|
| 2601 | if( uiSlopeMaxAbove > uiSlopeMaxLeft ) |
---|
| 2602 | { |
---|
| 2603 | ruiStartPosX = uiPosSlopeMaxAbove; |
---|
| 2604 | ruiStartPosY = 0; |
---|
| 2605 | } |
---|
| 2606 | else |
---|
| 2607 | { |
---|
| 2608 | ruiStartPosX = 0; |
---|
| 2609 | ruiStartPosY = uiPosSlopeMaxLeft; |
---|
| 2610 | } |
---|
| 2611 | |
---|
| 2612 | // 2nd step: derive wedge direction |
---|
[56] | 2613 | #if LOGI_INTRA_NAME_3MPM |
---|
| 2614 | Int uiPreds[3] = {-1, -1, -1}; |
---|
| 2615 | #else |
---|
[2] | 2616 | Int uiPreds[2] = {-1, -1}; |
---|
[56] | 2617 | #endif |
---|
| 2618 | Int iMode = -1; |
---|
| 2619 | Int iPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds, &iMode ); |
---|
[2] | 2620 | |
---|
| 2621 | UInt uiDirMode = 0; |
---|
[56] | 2622 | #if LOGI_INTRA_NAME_3MPM |
---|
| 2623 | if( iMode >= 0 ) { iPredNum = iMode; } |
---|
| 2624 | if( iPredNum == 1 ) { uiDirMode = uiPreds[0]; } |
---|
| 2625 | if( iPredNum == 2 ) { uiDirMode = uiPreds[1]; } |
---|
[2] | 2626 | |
---|
[56] | 2627 | if( uiDirMode < 2 ) { return false; } // no planar & DC |
---|
[2] | 2628 | |
---|
[56] | 2629 | Bool modeHor = (uiDirMode < 18); |
---|
| 2630 | Bool modeVer = !modeHor; |
---|
| 2631 | Int intraPredAngle = modeVer ? (Int)uiDirMode - VER_IDX : modeHor ? -((Int)uiDirMode - HOR_IDX) : 0; |
---|
| 2632 | #else |
---|
| 2633 | if( iPredNum == 1 ) { uiDirMode = g_aucAngIntraModeOrder[uiPreds[0]]; } |
---|
| 2634 | if( iPredNum == 2 ) { uiDirMode = g_aucAngIntraModeOrder[uiPreds[1]]; } |
---|
| 2635 | |
---|
| 2636 | if( uiDirMode == 0 ) { return false; } // no DC |
---|
| 2637 | |
---|
[2] | 2638 | Bool modeVer = (uiDirMode < 18); |
---|
| 2639 | Bool modeHor = !modeVer; |
---|
| 2640 | Int intraPredAngle = modeVer ? uiDirMode - 9 : modeHor ? uiDirMode - 25 : 0; |
---|
[56] | 2641 | #endif |
---|
[2] | 2642 | Int absAng = abs(intraPredAngle); |
---|
| 2643 | Int signAng = intraPredAngle < 0 ? -1 : 1; |
---|
[56] | 2644 | Int angTable[9] = {0,2,5,9,13,17,21,26,32}; |
---|
[2] | 2645 | absAng = angTable[absAng]; |
---|
| 2646 | intraPredAngle = signAng * absAng; |
---|
| 2647 | |
---|
| 2648 | // 3rd step: set slope for direction |
---|
| 2649 | if( modeHor ) |
---|
[56] | 2650 | { |
---|
[2] | 2651 | if( intraPredAngle > 0 ) |
---|
| 2652 | { |
---|
| 2653 | riSlopeX = -32; |
---|
| 2654 | riSlopeY = intraPredAngle; |
---|
| 2655 | } |
---|
| 2656 | else |
---|
| 2657 | { |
---|
| 2658 | riSlopeX = 32; |
---|
| 2659 | riSlopeY = -intraPredAngle; |
---|
| 2660 | } |
---|
[56] | 2661 | } |
---|
[2] | 2662 | else if( modeVer ) |
---|
| 2663 | { |
---|
| 2664 | if( intraPredAngle > 0 ) |
---|
| 2665 | { |
---|
| 2666 | riSlopeX = intraPredAngle; |
---|
| 2667 | riSlopeY = -32; |
---|
[56] | 2668 | } |
---|
| 2669 | else |
---|
| 2670 | { |
---|
[2] | 2671 | riSlopeX = -intraPredAngle; |
---|
| 2672 | riSlopeY = 32; |
---|
| 2673 | } |
---|
| 2674 | } |
---|
| 2675 | |
---|
[56] | 2676 | return true; |
---|
[2] | 2677 | } |
---|
| 2678 | |
---|
| 2679 | 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 ) |
---|
| 2680 | { |
---|
| 2681 | ruhXs = 0; |
---|
| 2682 | ruhYs = 0; |
---|
| 2683 | ruhXe = 0; |
---|
| 2684 | ruhYe = 0; |
---|
| 2685 | |
---|
| 2686 | // scaling of start pos and block size to wedge resolution |
---|
| 2687 | UInt uiScaledStartPosX = 0; |
---|
| 2688 | UInt uiScaledStartPosY = 0; |
---|
| 2689 | UInt uiScaledBlockSize = 0; |
---|
| 2690 | WedgeResolution eWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiBlockSize]]; |
---|
| 2691 | switch( eWedgeRes ) |
---|
| 2692 | { |
---|
| 2693 | case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; } |
---|
| 2694 | case( FULL_PEL ): { uiScaledStartPosX = uiPMSPosX; uiScaledStartPosY = uiPMSPosY; uiScaledBlockSize = uiBlockSize; break; } |
---|
| 2695 | case( HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; } |
---|
[56] | 2696 | } |
---|
| 2697 | Int iMaxPos = (Int)uiScaledBlockSize - 1; |
---|
[2] | 2698 | |
---|
| 2699 | // case above |
---|
| 2700 | if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 ) |
---|
| 2701 | { |
---|
| 2702 | ruhXs = (UChar)uiScaledStartPosX; |
---|
| 2703 | ruhYs = 0; |
---|
| 2704 | |
---|
| 2705 | if( iDeltaY == 0 ) |
---|
[56] | 2706 | { |
---|
[2] | 2707 | if( iDeltaX < 0 ) |
---|
| 2708 | { |
---|
| 2709 | ruhXe = 0; |
---|
[56] | 2710 | ruhYe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); |
---|
[2] | 2711 | return; |
---|
| 2712 | } |
---|
| 2713 | else |
---|
| 2714 | { |
---|
[56] | 2715 | ruhXe = (UChar)iMaxPos; |
---|
| 2716 | ruhYe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); |
---|
[2] | 2717 | std::swap( ruhXs, ruhXe ); |
---|
| 2718 | std::swap( ruhYs, ruhYe ); |
---|
| 2719 | return; |
---|
| 2720 | } |
---|
| 2721 | } |
---|
| 2722 | |
---|
| 2723 | // regular case |
---|
[56] | 2724 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
[2] | 2725 | |
---|
| 2726 | if( iVirtualEndX < 0 ) |
---|
| 2727 | { |
---|
| 2728 | Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd; |
---|
| 2729 | if( iYe < (Int)uiScaledBlockSize ) |
---|
| 2730 | { |
---|
| 2731 | ruhXe = 0; |
---|
[56] | 2732 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
[2] | 2733 | return; |
---|
| 2734 | } |
---|
| 2735 | else |
---|
| 2736 | { |
---|
[56] | 2737 | ruhXe = (UChar)std::min( (iYe - iMaxPos), iMaxPos ); |
---|
| 2738 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2739 | return; |
---|
| 2740 | } |
---|
| 2741 | } |
---|
[56] | 2742 | else if( iVirtualEndX > iMaxPos ) |
---|
[2] | 2743 | { |
---|
[56] | 2744 | Int iYe = roftoi( (Double)(iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
[2] | 2745 | if( iYe < (Int)uiScaledBlockSize ) |
---|
| 2746 | { |
---|
[56] | 2747 | ruhXe = (UChar)iMaxPos; |
---|
| 2748 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
[2] | 2749 | std::swap( ruhXs, ruhXe ); |
---|
| 2750 | std::swap( ruhYs, ruhYe ); |
---|
| 2751 | return; |
---|
| 2752 | } |
---|
| 2753 | else |
---|
| 2754 | { |
---|
[56] | 2755 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
| 2756 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2757 | return; |
---|
| 2758 | } |
---|
| 2759 | } |
---|
| 2760 | else |
---|
| 2761 | { |
---|
| 2762 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
| 2763 | if( iXe < 0 ) |
---|
| 2764 | { |
---|
| 2765 | ruhXe = 0; |
---|
[56] | 2766 | ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); |
---|
[2] | 2767 | return; |
---|
| 2768 | } |
---|
[56] | 2769 | else if( iXe > iMaxPos ) |
---|
[2] | 2770 | { |
---|
[56] | 2771 | ruhXe = (UChar)iMaxPos; |
---|
| 2772 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
[2] | 2773 | std::swap( ruhXs, ruhXe ); |
---|
| 2774 | std::swap( ruhYs, ruhYe ); |
---|
| 2775 | return; |
---|
| 2776 | } |
---|
| 2777 | else |
---|
| 2778 | { |
---|
| 2779 | ruhXe = (UChar)iXe; |
---|
[56] | 2780 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2781 | return; |
---|
| 2782 | } |
---|
| 2783 | } |
---|
| 2784 | } |
---|
| 2785 | |
---|
| 2786 | // case left |
---|
| 2787 | if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 ) |
---|
| 2788 | { |
---|
| 2789 | ruhXs = 0; |
---|
| 2790 | ruhYs = (UChar)uiScaledStartPosY; |
---|
| 2791 | |
---|
| 2792 | if( iDeltaX == 0 ) |
---|
| 2793 | { |
---|
| 2794 | if( iDeltaY < 0 ) |
---|
| 2795 | { |
---|
[56] | 2796 | ruhXe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos ); |
---|
[2] | 2797 | ruhYe = 0; |
---|
| 2798 | std::swap( ruhXs, ruhXe ); |
---|
| 2799 | std::swap( ruhYs, ruhYe ); |
---|
| 2800 | return; |
---|
| 2801 | } |
---|
| 2802 | else |
---|
| 2803 | { |
---|
[56] | 2804 | ruhXe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); |
---|
| 2805 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2806 | return; |
---|
| 2807 | } |
---|
| 2808 | } |
---|
| 2809 | |
---|
| 2810 | // regular case |
---|
[56] | 2811 | Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iMaxPos * ((Double)iDeltaY / (Double)iDeltaX) ); |
---|
[2] | 2812 | |
---|
| 2813 | if( iVirtualEndY < 0 ) |
---|
| 2814 | { |
---|
| 2815 | Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd; |
---|
| 2816 | if( iXe < (Int)uiScaledBlockSize ) |
---|
| 2817 | { |
---|
[56] | 2818 | ruhXe = (UChar)std::max( iXe, 0 ); |
---|
[2] | 2819 | ruhYe = 0; |
---|
| 2820 | std::swap( ruhXs, ruhXe ); |
---|
| 2821 | std::swap( ruhYs, ruhYe ); |
---|
| 2822 | return; |
---|
| 2823 | } |
---|
| 2824 | else |
---|
| 2825 | { |
---|
[56] | 2826 | ruhXe = (UChar)iMaxPos; |
---|
| 2827 | ruhYe = (UChar)std::min( (iXe - iMaxPos), iMaxPos ); |
---|
[2] | 2828 | std::swap( ruhXs, ruhXe ); |
---|
| 2829 | std::swap( ruhYs, ruhYe ); |
---|
| 2830 | return; |
---|
| 2831 | } |
---|
| 2832 | } |
---|
| 2833 | else if( iVirtualEndY > (uiScaledBlockSize-1) ) |
---|
| 2834 | { |
---|
| 2835 | Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd; |
---|
| 2836 | if( iXe < (Int)uiScaledBlockSize ) |
---|
| 2837 | { |
---|
[56] | 2838 | ruhXe = (UChar)std::max( iXe, 0 ); |
---|
[2] | 2839 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
| 2840 | return; |
---|
| 2841 | } |
---|
| 2842 | else |
---|
| 2843 | { |
---|
[56] | 2844 | ruhXe = (UChar)iMaxPos; |
---|
| 2845 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
[2] | 2846 | std::swap( ruhXs, ruhXe ); |
---|
| 2847 | std::swap( ruhYs, ruhYe ); |
---|
| 2848 | return; |
---|
| 2849 | } |
---|
| 2850 | } |
---|
| 2851 | else |
---|
| 2852 | { |
---|
| 2853 | Int iYe = iVirtualEndY - iDeltaEnd; |
---|
| 2854 | if( iYe < 0 ) |
---|
| 2855 | { |
---|
[56] | 2856 | ruhXe = (UChar)std::max( (iMaxPos + iYe), 0 ); |
---|
[2] | 2857 | ruhYe = 0; |
---|
| 2858 | std::swap( ruhXs, ruhXe ); |
---|
| 2859 | std::swap( ruhYs, ruhYe ); |
---|
| 2860 | return; |
---|
| 2861 | } |
---|
[56] | 2862 | else if( iYe > iMaxPos ) |
---|
[2] | 2863 | { |
---|
[56] | 2864 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
| 2865 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2866 | return; |
---|
| 2867 | } |
---|
| 2868 | else |
---|
| 2869 | { |
---|
[56] | 2870 | ruhXe = (UChar)iMaxPos; |
---|
[2] | 2871 | ruhYe = (UChar)iYe; |
---|
| 2872 | std::swap( ruhXs, ruhXe ); |
---|
| 2873 | std::swap( ruhYs, ruhYe ); |
---|
| 2874 | return; |
---|
| 2875 | } |
---|
| 2876 | } |
---|
| 2877 | } |
---|
| 2878 | |
---|
| 2879 | // case origin |
---|
| 2880 | if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 ) |
---|
| 2881 | { |
---|
| 2882 | if( iDeltaX*iDeltaY < 0 ) |
---|
| 2883 | { |
---|
| 2884 | return; |
---|
| 2885 | } |
---|
| 2886 | |
---|
| 2887 | ruhXs = 0; |
---|
| 2888 | ruhYs = 0; |
---|
| 2889 | |
---|
| 2890 | if( iDeltaY == 0 ) |
---|
| 2891 | { |
---|
[56] | 2892 | ruhXe = (UChar)iMaxPos; |
---|
[2] | 2893 | ruhYe = 0; |
---|
| 2894 | std::swap( ruhXs, ruhXe ); |
---|
| 2895 | std::swap( ruhYs, ruhYe ); |
---|
| 2896 | return; |
---|
[56] | 2897 | } |
---|
[2] | 2898 | |
---|
| 2899 | if( iDeltaX == 0 ) |
---|
| 2900 | { |
---|
| 2901 | ruhXe = 0; |
---|
[56] | 2902 | ruhYe = (UChar)iMaxPos; |
---|
[2] | 2903 | return; |
---|
[56] | 2904 | } |
---|
[2] | 2905 | |
---|
[56] | 2906 | Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); |
---|
[2] | 2907 | |
---|
[56] | 2908 | if( iVirtualEndX > iMaxPos ) |
---|
[2] | 2909 | { |
---|
[56] | 2910 | Int iYe = roftoi( (Double)((Int)iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd; |
---|
[2] | 2911 | if( iYe < (Int)uiScaledBlockSize ) |
---|
| 2912 | { |
---|
| 2913 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
[56] | 2914 | ruhYe = (UChar)std::max( iYe, 0 ); |
---|
[2] | 2915 | std::swap( ruhXs, ruhXe ); |
---|
| 2916 | std::swap( ruhYs, ruhYe ); |
---|
| 2917 | return; |
---|
| 2918 | } |
---|
| 2919 | else |
---|
| 2920 | { |
---|
[56] | 2921 | ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 ); |
---|
[2] | 2922 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
| 2923 | return; |
---|
| 2924 | } |
---|
| 2925 | } |
---|
| 2926 | else |
---|
| 2927 | { |
---|
| 2928 | Int iXe = iVirtualEndX + iDeltaEnd; |
---|
| 2929 | if( iXe < 0 ) |
---|
| 2930 | { |
---|
| 2931 | ruhXe = 0; |
---|
[56] | 2932 | ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); |
---|
[2] | 2933 | return; |
---|
| 2934 | } |
---|
[56] | 2935 | else if( iXe > iMaxPos ) |
---|
[2] | 2936 | { |
---|
| 2937 | ruhXe = (UChar)(uiScaledBlockSize-1); |
---|
[56] | 2938 | ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 ); |
---|
[2] | 2939 | std::swap( ruhXs, ruhXe ); |
---|
| 2940 | std::swap( ruhYs, ruhYe ); |
---|
| 2941 | return; |
---|
| 2942 | } |
---|
| 2943 | else |
---|
| 2944 | { |
---|
| 2945 | ruhXe = (UChar)iXe; |
---|
| 2946 | ruhYe = (UChar)(uiScaledBlockSize-1); |
---|
| 2947 | return; |
---|
| 2948 | } |
---|
| 2949 | } |
---|
| 2950 | } |
---|
| 2951 | } |
---|
[5] | 2952 | #endif |
---|
[2] | 2953 | |
---|
| 2954 | Void |
---|
[56] | 2955 | TComPrediction::predIntraDepthAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight ) |
---|
[2] | 2956 | { |
---|
[56] | 2957 | Pel* pDst = piPred; |
---|
| 2958 | Int* ptrSrc = pcTComPattern->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); |
---|
| 2959 | Int sw = ( iWidth<<1 ) + 1; |
---|
| 2960 | #if !LOGI_INTRA_NAME_3MPM |
---|
| 2961 | uiDirMode = g_aucAngIntraModeOrder[ uiDirMode ]; |
---|
[21] | 2962 | #endif |
---|
[56] | 2963 | xPredIntraAngDepth( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode ); |
---|
[2] | 2964 | } |
---|
| 2965 | |
---|
[56] | 2966 | Int |
---|
| 2967 | TComPrediction::xGetDCDepth( Int* pSrc, Int iDelta, Int iBlkSize ) |
---|
[2] | 2968 | { |
---|
[56] | 2969 | Int iDC = PDM_UNDEFINED_DEPTH; |
---|
| 2970 | Int iSum = 0; |
---|
| 2971 | Int iNum = 0; |
---|
| 2972 | for( Int k = 0; k < iBlkSize; k++, pSrc += iDelta ) |
---|
[2] | 2973 | { |
---|
[56] | 2974 | if( *pSrc != PDM_UNDEFINED_DEPTH ) |
---|
[2] | 2975 | { |
---|
[56] | 2976 | iSum += *pSrc; |
---|
| 2977 | iNum ++; |
---|
[2] | 2978 | } |
---|
| 2979 | } |
---|
[56] | 2980 | if( iNum ) |
---|
[2] | 2981 | { |
---|
[56] | 2982 | iDC = ( iSum + ( iNum >> 1 ) ) / iNum; |
---|
[2] | 2983 | } |
---|
[56] | 2984 | return iDC; |
---|
[2] | 2985 | } |
---|
| 2986 | |
---|
[56] | 2987 | Int |
---|
| 2988 | TComPrediction::xGetDCValDepth( Int iVal1, Int iVal2, Int iVal3, Int iVal4 ) |
---|
[2] | 2989 | { |
---|
[56] | 2990 | if ( iVal1 != PDM_UNDEFINED_DEPTH ) return iVal1; |
---|
| 2991 | else if( iVal2 != PDM_UNDEFINED_DEPTH ) return iVal2; |
---|
| 2992 | else if( iVal3 != PDM_UNDEFINED_DEPTH ) return iVal3; |
---|
| 2993 | return iVal4; |
---|
[2] | 2994 | } |
---|
| 2995 | |
---|
[56] | 2996 | Void |
---|
| 2997 | TComPrediction::xPredIntraAngDepth( Int* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, UInt dirMode ) |
---|
[2] | 2998 | { |
---|
[56] | 2999 | AOF( width == height ); |
---|
| 3000 | Int blkSize = width; |
---|
| 3001 | Int iDCAbove = xGetDCDepth( pSrc - srcStride, 1, blkSize ); |
---|
| 3002 | Int iDCAboveRight = xGetDCDepth( pSrc - srcStride + blkSize, 1, blkSize ); |
---|
| 3003 | Int iDCLeft = xGetDCDepth( pSrc - 1, srcStride, blkSize ); |
---|
| 3004 | Int iDCBelowLeft = xGetDCDepth( pSrc - 1 + blkSize * srcStride, srcStride, blkSize ); |
---|
| 3005 | Int iWgt, iDC1, iDC2; |
---|
| 3006 | if( dirMode < 2 ) // 1..2 |
---|
[2] | 3007 | { |
---|
[56] | 3008 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
| 3009 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
| 3010 | iWgt = 8; |
---|
[2] | 3011 | } |
---|
[56] | 3012 | else if( dirMode < 11 ) // 3..10 |
---|
[2] | 3013 | { |
---|
[56] | 3014 | iDC1 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
| 3015 | iDC2 = xGetDCValDepth( iDCBelowLeft, iDCLeft, iDCAbove, iDCAboveRight ); |
---|
| 3016 | iWgt = 6 + dirMode; |
---|
[2] | 3017 | } |
---|
[56] | 3018 | else if( dirMode < 27 ) // 11..26 |
---|
[2] | 3019 | { |
---|
[56] | 3020 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
| 3021 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
| 3022 | iWgt = dirMode - 10; |
---|
[2] | 3023 | } |
---|
[56] | 3024 | else if( dirMode < 35 ) // 27..34 |
---|
[2] | 3025 | { |
---|
[56] | 3026 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
| 3027 | iDC2 = xGetDCValDepth( iDCAboveRight, iDCAbove, iDCLeft, iDCBelowLeft ); |
---|
| 3028 | iWgt = 42 - dirMode; |
---|
[2] | 3029 | } |
---|
[56] | 3030 | else // (wedgelet -> use simple DC prediction |
---|
[2] | 3031 | { |
---|
[56] | 3032 | iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); |
---|
| 3033 | iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); |
---|
| 3034 | iWgt = 8; |
---|
[2] | 3035 | } |
---|
[56] | 3036 | Int iWgt2 = 16 - iWgt; |
---|
| 3037 | Int iDCVal = ( iWgt * iDC1 + iWgt2 * iDC2 + 8 ) >> 4; |
---|
[2] | 3038 | |
---|
[56] | 3039 | // set depth |
---|
| 3040 | for( Int iY = 0; iY < blkSize; iY++, pDst += dstStride ) |
---|
[21] | 3041 | { |
---|
[56] | 3042 | for( Int iX = 0; iX < blkSize; iX++ ) |
---|
[2] | 3043 | { |
---|
[56] | 3044 | pDst[ iX ] = iDCVal; |
---|
[2] | 3045 | } |
---|
| 3046 | } |
---|
| 3047 | } |
---|
| 3048 | |
---|
[56] | 3049 | //! \} |
---|