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