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