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