[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 |
---|
[1200] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1200] | 6 | * Copyright (c) 2010-2015, 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" |
---|
[1200] | 40 | #include "TComPic.h" |
---|
| 41 | #include "TComTU.h" |
---|
[2] | 42 | |
---|
[56] | 43 | //! \ingroup TLibCommon |
---|
| 44 | //! \{ |
---|
| 45 | |
---|
[2] | 46 | // ==================================================================================================================== |
---|
[1200] | 47 | // Tables |
---|
| 48 | // ==================================================================================================================== |
---|
| 49 | |
---|
| 50 | const UChar TComPrediction::m_aucIntraFilter[MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS] = |
---|
| 51 | { |
---|
| 52 | { // Luma |
---|
| 53 | 10, //4x4 |
---|
| 54 | 7, //8x8 |
---|
| 55 | 1, //16x16 |
---|
| 56 | 0, //32x32 |
---|
| 57 | 10, //64x64 |
---|
| 58 | }, |
---|
| 59 | { // Chroma |
---|
| 60 | 10, //4xn |
---|
| 61 | 7, //8xn |
---|
| 62 | 1, //16xn |
---|
| 63 | 0, //32xn |
---|
| 64 | 10, //64xn |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | }; |
---|
| 68 | |
---|
| 69 | // ==================================================================================================================== |
---|
[2] | 70 | // Constructor / destructor / initialize |
---|
| 71 | // ==================================================================================================================== |
---|
| 72 | |
---|
| 73 | TComPrediction::TComPrediction() |
---|
| 74 | : m_pLumaRecBuffer(0) |
---|
[608] | 75 | , m_iLumaRecStride(0) |
---|
[2] | 76 | { |
---|
[1200] | 77 | for(UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
| 78 | { |
---|
| 79 | for(UInt buf=0; buf<2; buf++) |
---|
| 80 | { |
---|
| 81 | m_piYuvExt[ch][buf] = NULL; |
---|
| 82 | } |
---|
| 83 | } |
---|
[608] | 84 | #if H_3D_VSP |
---|
| 85 | m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int)); |
---|
| 86 | if (m_pDepthBlock == NULL) |
---|
[1196] | 87 | { |
---|
[296] | 88 | printf("ERROR: UKTGHU, No memory allocated.\n"); |
---|
[1196] | 89 | } |
---|
[296] | 90 | #endif |
---|
[1200] | 91 | |
---|
[2] | 92 | } |
---|
| 93 | |
---|
| 94 | TComPrediction::~TComPrediction() |
---|
| 95 | { |
---|
[608] | 96 | #if H_3D_VSP |
---|
| 97 | if (m_pDepthBlock != NULL) |
---|
[1196] | 98 | { |
---|
| 99 | free(m_pDepthBlock); |
---|
| 100 | } |
---|
[608] | 101 | m_cYuvDepthOnVsp.destroy(); |
---|
[296] | 102 | #endif |
---|
[608] | 103 | |
---|
[1200] | 104 | destroy(); |
---|
| 105 | } |
---|
[2] | 106 | |
---|
[1200] | 107 | Void TComPrediction::destroy() |
---|
| 108 | { |
---|
| 109 | for(UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
| 110 | { |
---|
| 111 | for(UInt buf=0; buf<NUM_PRED_BUF; buf++) |
---|
| 112 | { |
---|
| 113 | delete [] m_piYuvExt[ch][buf]; |
---|
| 114 | m_piYuvExt[ch][buf] = NULL; |
---|
| 115 | } |
---|
| 116 | } |
---|
[2] | 117 | |
---|
[1200] | 118 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 119 | { |
---|
| 120 | m_acYuvPred[i].destroy(); |
---|
| 121 | } |
---|
| 122 | |
---|
[2] | 123 | m_cYuvPredTemp.destroy(); |
---|
[608] | 124 | |
---|
| 125 | #if H_3D_ARP |
---|
[443] | 126 | m_acYuvPredBase[0].destroy(); |
---|
| 127 | m_acYuvPredBase[1].destroy(); |
---|
| 128 | #endif |
---|
[2] | 129 | if( m_pLumaRecBuffer ) |
---|
[56] | 130 | { |
---|
| 131 | delete [] m_pLumaRecBuffer; |
---|
[1200] | 132 | m_pLumaRecBuffer = 0; |
---|
[56] | 133 | } |
---|
[1200] | 134 | m_iLumaRecStride = 0; |
---|
| 135 | |
---|
| 136 | for (UInt i = 0; i < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; i++) |
---|
[56] | 137 | { |
---|
[1200] | 138 | for (UInt j = 0; j < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; j++) |
---|
[56] | 139 | { |
---|
| 140 | m_filteredBlock[i][j].destroy(); |
---|
| 141 | } |
---|
| 142 | m_filteredBlockTmp[i].destroy(); |
---|
| 143 | } |
---|
[2] | 144 | } |
---|
| 145 | |
---|
[1200] | 146 | Void TComPrediction::initTempBuff(ChromaFormat chromaFormatIDC) |
---|
[2] | 147 | { |
---|
[1200] | 148 | // if it has been initialised before, but the chroma format has changed, release the memory and start again. |
---|
| 149 | if( m_piYuvExt[COMPONENT_Y][PRED_BUF_UNFILTERED] != NULL && m_cYuvPredTemp.getChromaFormat()!=chromaFormatIDC) |
---|
[2] | 150 | { |
---|
[1200] | 151 | destroy(); |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | if( m_piYuvExt[COMPONENT_Y][PRED_BUF_UNFILTERED] == NULL ) // check if first is null (in which case, nothing initialised yet) |
---|
| 155 | { |
---|
| 156 | Int extWidth = MAX_CU_SIZE + 16; |
---|
[608] | 157 | Int extHeight = MAX_CU_SIZE + 1; |
---|
[1200] | 158 | |
---|
| 159 | for (UInt i = 0; i < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; i++) |
---|
[56] | 160 | { |
---|
[1200] | 161 | m_filteredBlockTmp[i].create(extWidth, extHeight + 7, chromaFormatIDC); |
---|
| 162 | for (UInt j = 0; j < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; j++) |
---|
[56] | 163 | { |
---|
[1200] | 164 | m_filteredBlock[i][j].create(extWidth, extHeight, chromaFormatIDC); |
---|
[56] | 165 | } |
---|
| 166 | } |
---|
[2] | 167 | |
---|
[1200] | 168 | m_iYuvExtSize = (MAX_CU_SIZE*2+1) * (MAX_CU_SIZE*2+1); |
---|
| 169 | for(UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
| 170 | { |
---|
| 171 | for(UInt buf=0; buf<NUM_PRED_BUF; buf++) |
---|
| 172 | { |
---|
| 173 | m_piYuvExt[ch][buf] = new Pel[ m_iYuvExtSize ]; |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | |
---|
[2] | 177 | // new structure |
---|
[1200] | 178 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 179 | { |
---|
| 180 | m_acYuvPred[i] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC ); |
---|
| 181 | } |
---|
[2] | 182 | |
---|
[1200] | 183 | m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC ); |
---|
[608] | 184 | #if H_3D_ARP |
---|
[443] | 185 | m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 186 | m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 187 | #endif |
---|
[655] | 188 | #if H_3D_VSP |
---|
[608] | 189 | m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 190 | #endif |
---|
[1200] | 191 | |
---|
[2] | 192 | } |
---|
| 193 | |
---|
[1200] | 194 | |
---|
[608] | 195 | if (m_iLumaRecStride != (MAX_CU_SIZE>>1) + 1) |
---|
| 196 | { |
---|
| 197 | m_iLumaRecStride = (MAX_CU_SIZE>>1) + 1; |
---|
| 198 | if (!m_pLumaRecBuffer) |
---|
| 199 | { |
---|
| 200 | m_pLumaRecBuffer = new Pel[ m_iLumaRecStride * m_iLumaRecStride ]; |
---|
| 201 | } |
---|
| 202 | } |
---|
| 203 | #if H_3D_IC |
---|
| 204 | m_uiaShift[0] = 0; |
---|
[56] | 205 | for( Int i = 1; i < 64; i++ ) |
---|
| 206 | { |
---|
[608] | 207 | m_uiaShift[i] = ( (1 << 15) + i/2 ) / i; |
---|
| 208 | } |
---|
| 209 | #endif |
---|
[2] | 210 | } |
---|
| 211 | |
---|
| 212 | // ==================================================================================================================== |
---|
| 213 | // Public member functions |
---|
| 214 | // ==================================================================================================================== |
---|
| 215 | |
---|
| 216 | // Function for calculating DC value of the reference samples used in Intra prediction |
---|
[1200] | 217 | //NOTE: Bit-Limit - 25-bit source |
---|
| 218 | Pel TComPrediction::predIntraGetPredValDC( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ) |
---|
[2] | 219 | { |
---|
[608] | 220 | assert(iWidth > 0 && iHeight > 0); |
---|
[2] | 221 | Int iInd, iSum = 0; |
---|
| 222 | Pel pDcVal; |
---|
| 223 | |
---|
| 224 | if (bAbove) |
---|
| 225 | { |
---|
| 226 | for (iInd = 0;iInd < iWidth;iInd++) |
---|
[56] | 227 | { |
---|
[2] | 228 | iSum += pSrc[iInd-iSrcStride]; |
---|
[56] | 229 | } |
---|
[2] | 230 | } |
---|
| 231 | if (bLeft) |
---|
| 232 | { |
---|
| 233 | for (iInd = 0;iInd < iHeight;iInd++) |
---|
[56] | 234 | { |
---|
[2] | 235 | iSum += pSrc[iInd*iSrcStride-1]; |
---|
[56] | 236 | } |
---|
[2] | 237 | } |
---|
| 238 | |
---|
| 239 | if (bAbove && bLeft) |
---|
[56] | 240 | { |
---|
[2] | 241 | pDcVal = (iSum + iWidth) / (iWidth + iHeight); |
---|
[56] | 242 | } |
---|
[2] | 243 | else if (bAbove) |
---|
[56] | 244 | { |
---|
[2] | 245 | pDcVal = (iSum + iWidth/2) / iWidth; |
---|
[56] | 246 | } |
---|
[2] | 247 | else if (bLeft) |
---|
[56] | 248 | { |
---|
[2] | 249 | pDcVal = (iSum + iHeight/2) / iHeight; |
---|
[56] | 250 | } |
---|
[2] | 251 | else |
---|
[56] | 252 | { |
---|
[2] | 253 | pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available |
---|
[56] | 254 | } |
---|
[1200] | 255 | |
---|
[2] | 256 | return pDcVal; |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | // Function for deriving the angular Intra predictions |
---|
| 260 | |
---|
| 261 | /** Function for deriving the simplified angular intra predictions. |
---|
[1200] | 262 | * \param bitDepth bit depth |
---|
| 263 | * \param pSrc pointer to reconstructed sample array |
---|
| 264 | * \param srcStride the stride of the reconstructed sample array |
---|
| 265 | * \param pTrueDst reference to pointer for the prediction sample array |
---|
| 266 | * \param dstStrideTrue the stride of the prediction sample array |
---|
| 267 | * \param uiWidth the width of the block |
---|
| 268 | * \param uiHeight the height of the block |
---|
| 269 | * \param channelType type of pel array (luma/chroma) |
---|
| 270 | * \param format chroma format |
---|
| 271 | * \param dirMode the intra prediction mode index |
---|
| 272 | * \param blkAboveAvailable boolean indication if the block above is available |
---|
| 273 | * \param blkLeftAvailable boolean indication if the block to the left is available |
---|
| 274 | * \param bEnableEdgeFilters indication whether to enable edge filters |
---|
[2] | 275 | * |
---|
| 276 | * This function derives the prediction samples for the angular mode based on the prediction direction indicated by |
---|
| 277 | * the prediction mode index. The prediction direction is given by the displacement of the bottom row of the block and |
---|
| 278 | * the reference row above the block in the case of vertical prediction or displacement of the rightmost column |
---|
| 279 | * of the block and reference column left from the block in the case of the horizontal prediction. The displacement |
---|
| 280 | * is signalled at 1/32 pixel accuracy. When projection of the predicted pixel falls inbetween reference samples, |
---|
| 281 | * the predicted value for the pixel is linearly interpolated from the reference samples. All reference samples are taken |
---|
| 282 | * from the extended main reference. |
---|
| 283 | */ |
---|
[1200] | 284 | //NOTE: Bit-Limit - 25-bit source |
---|
| 285 | Void TComPrediction::xPredIntraAng( Int bitDepth, |
---|
| 286 | const Pel* pSrc, Int srcStride, |
---|
| 287 | Pel* pTrueDst, Int dstStrideTrue, |
---|
| 288 | UInt uiWidth, UInt uiHeight, ChannelType channelType, |
---|
| 289 | UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable |
---|
| 290 | , const Bool bEnableEdgeFilters |
---|
| 291 | ) |
---|
[2] | 292 | { |
---|
[1200] | 293 | Int width=Int(uiWidth); |
---|
| 294 | Int height=Int(uiHeight); |
---|
[2] | 295 | |
---|
| 296 | // Map the mode index to main prediction direction and angle |
---|
[1200] | 297 | assert( dirMode != PLANAR_IDX ); //no planar |
---|
| 298 | const Bool modeDC = dirMode==DC_IDX; |
---|
[2] | 299 | |
---|
| 300 | // Do the DC prediction |
---|
| 301 | if (modeDC) |
---|
| 302 | { |
---|
[1200] | 303 | const Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height, blkAboveAvailable, blkLeftAvailable); |
---|
[2] | 304 | |
---|
[1200] | 305 | for (Int y=height;y>0;y--, pTrueDst+=dstStrideTrue) |
---|
[2] | 306 | { |
---|
[1200] | 307 | for (Int x=0; x<width;) // width is always a multiple of 4. |
---|
[2] | 308 | { |
---|
[1200] | 309 | pTrueDst[x++] = dcval; |
---|
[2] | 310 | } |
---|
| 311 | } |
---|
| 312 | } |
---|
[1200] | 313 | else // Do angular predictions |
---|
| 314 | { |
---|
| 315 | const Bool bIsModeVer = (dirMode >= 18); |
---|
| 316 | const Int intraPredAngleMode = (bIsModeVer) ? (Int)dirMode - VER_IDX : -((Int)dirMode - HOR_IDX); |
---|
| 317 | const Int absAngMode = abs(intraPredAngleMode); |
---|
| 318 | const Int signAng = intraPredAngleMode < 0 ? -1 : 1; |
---|
| 319 | const Bool edgeFilter = bEnableEdgeFilters && isLuma(channelType) && (width <= MAXIMUM_INTRA_FILTERED_WIDTH) && (height <= MAXIMUM_INTRA_FILTERED_HEIGHT); |
---|
[2] | 320 | |
---|
[1200] | 321 | // Set bitshifts and scale the angle parameter to block size |
---|
| 322 | static const Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; |
---|
| 323 | static const Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle |
---|
| 324 | Int invAngle = invAngTable[absAngMode]; |
---|
| 325 | Int absAng = angTable[absAngMode]; |
---|
| 326 | Int intraPredAngle = signAng * absAng; |
---|
| 327 | |
---|
[2] | 328 | Pel* refMain; |
---|
| 329 | Pel* refSide; |
---|
[1200] | 330 | |
---|
[2] | 331 | Pel refAbove[2*MAX_CU_SIZE+1]; |
---|
| 332 | Pel refLeft[2*MAX_CU_SIZE+1]; |
---|
| 333 | |
---|
| 334 | // Initialise the Main and Left reference array. |
---|
| 335 | if (intraPredAngle < 0) |
---|
| 336 | { |
---|
[1200] | 337 | const Int refMainOffsetPreScale = (bIsModeVer ? height : width ) - 1; |
---|
| 338 | const Int refMainOffset = height - 1; |
---|
| 339 | for (Int x=0;x<width+1;x++) |
---|
[2] | 340 | { |
---|
[1200] | 341 | refAbove[x+refMainOffset] = pSrc[x-srcStride-1]; |
---|
[2] | 342 | } |
---|
[1200] | 343 | for (Int y=0;y<height+1;y++) |
---|
[2] | 344 | { |
---|
[1200] | 345 | refLeft[y+refMainOffset] = pSrc[(y-1)*srcStride-1]; |
---|
[2] | 346 | } |
---|
[1200] | 347 | refMain = (bIsModeVer ? refAbove : refLeft) + refMainOffset; |
---|
| 348 | refSide = (bIsModeVer ? refLeft : refAbove) + refMainOffset; |
---|
[2] | 349 | |
---|
| 350 | // Extend the Main reference to the left. |
---|
| 351 | Int invAngleSum = 128; // rounding for (shift by 8) |
---|
[1200] | 352 | for (Int k=-1; k>(refMainOffsetPreScale+1)*intraPredAngle>>5; k--) |
---|
[2] | 353 | { |
---|
| 354 | invAngleSum += invAngle; |
---|
| 355 | refMain[k] = refSide[invAngleSum>>8]; |
---|
| 356 | } |
---|
| 357 | } |
---|
| 358 | else |
---|
| 359 | { |
---|
[1200] | 360 | for (Int x=0;x<2*width+1;x++) |
---|
[2] | 361 | { |
---|
[1200] | 362 | refAbove[x] = pSrc[x-srcStride-1]; |
---|
[2] | 363 | } |
---|
[1200] | 364 | for (Int y=0;y<2*height+1;y++) |
---|
[2] | 365 | { |
---|
[1200] | 366 | refLeft[y] = pSrc[(y-1)*srcStride-1]; |
---|
[2] | 367 | } |
---|
[1200] | 368 | refMain = bIsModeVer ? refAbove : refLeft ; |
---|
| 369 | refSide = bIsModeVer ? refLeft : refAbove; |
---|
[2] | 370 | } |
---|
| 371 | |
---|
[1200] | 372 | // swap width/height if we are doing a horizontal mode: |
---|
| 373 | Pel tempArray[MAX_CU_SIZE*MAX_CU_SIZE]; |
---|
| 374 | const Int dstStride = bIsModeVer ? dstStrideTrue : MAX_CU_SIZE; |
---|
| 375 | Pel *pDst = bIsModeVer ? pTrueDst : tempArray; |
---|
| 376 | if (!bIsModeVer) |
---|
[2] | 377 | { |
---|
[1200] | 378 | std::swap(width, height); |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | if (intraPredAngle == 0) // pure vertical or pure horizontal |
---|
| 382 | { |
---|
| 383 | for (Int y=0;y<height;y++) |
---|
[2] | 384 | { |
---|
[1200] | 385 | for (Int x=0;x<width;x++) |
---|
[2] | 386 | { |
---|
[1200] | 387 | pDst[y*dstStride+x] = refMain[x+1]; |
---|
[2] | 388 | } |
---|
| 389 | } |
---|
[56] | 390 | |
---|
[1200] | 391 | if (edgeFilter) |
---|
[56] | 392 | { |
---|
[1200] | 393 | for (Int y=0;y<height;y++) |
---|
[56] | 394 | { |
---|
[1200] | 395 | pDst[y*dstStride] = Clip3 (0, ((1 << bitDepth) - 1), pDst[y*dstStride] + (( refSide[y+1] - refSide[0] ) >> 1) ); |
---|
[56] | 396 | } |
---|
| 397 | } |
---|
[2] | 398 | } |
---|
| 399 | else |
---|
| 400 | { |
---|
[1200] | 401 | Pel *pDsty=pDst; |
---|
[2] | 402 | |
---|
[1200] | 403 | for (Int y=0, deltaPos=intraPredAngle; y<height; y++, deltaPos+=intraPredAngle, pDsty+=dstStride) |
---|
[2] | 404 | { |
---|
[1200] | 405 | const Int deltaInt = deltaPos >> 5; |
---|
| 406 | const Int deltaFract = deltaPos & (32 - 1); |
---|
[2] | 407 | |
---|
| 408 | if (deltaFract) |
---|
| 409 | { |
---|
| 410 | // Do linear filtering |
---|
[1200] | 411 | const Pel *pRM=refMain+deltaInt+1; |
---|
| 412 | Int lastRefMainPel=*pRM++; |
---|
| 413 | for (Int x=0;x<width;pRM++,x++) |
---|
[2] | 414 | { |
---|
[1200] | 415 | Int thisRefMainPel=*pRM; |
---|
| 416 | pDsty[x+0] = (Pel) ( ((32-deltaFract)*lastRefMainPel + deltaFract*thisRefMainPel +16) >> 5 ); |
---|
| 417 | lastRefMainPel=thisRefMainPel; |
---|
[2] | 418 | } |
---|
| 419 | } |
---|
| 420 | else |
---|
| 421 | { |
---|
| 422 | // Just copy the integer samples |
---|
[1200] | 423 | for (Int x=0;x<width; x++) |
---|
[2] | 424 | { |
---|
[1200] | 425 | pDsty[x] = refMain[x+deltaInt+1]; |
---|
[2] | 426 | } |
---|
| 427 | } |
---|
| 428 | } |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | // Flip the block if this is the horizontal mode |
---|
[1200] | 432 | if (!bIsModeVer) |
---|
[2] | 433 | { |
---|
[1200] | 434 | for (Int y=0; y<height; y++) |
---|
[2] | 435 | { |
---|
[1200] | 436 | for (Int x=0; x<width; x++) |
---|
[2] | 437 | { |
---|
[1200] | 438 | pTrueDst[x*dstStrideTrue] = pDst[x]; |
---|
[2] | 439 | } |
---|
[1200] | 440 | pTrueDst++; |
---|
| 441 | pDst+=dstStride; |
---|
[2] | 442 | } |
---|
| 443 | } |
---|
| 444 | } |
---|
| 445 | } |
---|
| 446 | |
---|
[1200] | 447 | Void TComPrediction::predIntraAng( const ComponentID compID, UInt uiDirMode, Pel* piOrg /* Will be null for decoding */, UInt uiOrgStride, Pel* piPred, UInt uiStride, TComTU &rTu, Bool bAbove, Bool bLeft, const Bool bUseFilteredPredSamples, const Bool bUseLosslessDPCM ) |
---|
[2] | 448 | { |
---|
[1200] | 449 | const ChannelType channelType = toChannelType(compID); |
---|
| 450 | const TComRectangle &rect = rTu.getRect(isLuma(compID) ? COMPONENT_Y : COMPONENT_Cb); |
---|
| 451 | const Int iWidth = rect.width; |
---|
| 452 | const Int iHeight = rect.height; |
---|
[2] | 453 | |
---|
[56] | 454 | assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 |
---|
| 455 | assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 |
---|
[1200] | 456 | //assert( iWidth == iHeight ); |
---|
[2] | 457 | |
---|
[1200] | 458 | Pel *pDst = piPred; |
---|
[56] | 459 | |
---|
| 460 | // get starting pixel in block |
---|
[1200] | 461 | const Int sw = (2 * iWidth + 1); |
---|
[56] | 462 | |
---|
[1200] | 463 | if ( bUseLosslessDPCM ) |
---|
[56] | 464 | { |
---|
[1200] | 465 | const Pel *ptrSrc = getPredictorPtr( compID, false ); |
---|
| 466 | // Sample Adaptive intra-Prediction (SAP) |
---|
| 467 | if (uiDirMode==HOR_IDX) |
---|
| 468 | { |
---|
| 469 | // left column filled with reference samples |
---|
| 470 | // remaining columns filled with piOrg data (if available). |
---|
| 471 | for(Int y=0; y<iHeight; y++) |
---|
| 472 | { |
---|
| 473 | piPred[y*uiStride+0] = ptrSrc[(y+1)*sw]; |
---|
| 474 | } |
---|
| 475 | if (piOrg!=0) |
---|
| 476 | { |
---|
| 477 | piPred+=1; // miss off first column |
---|
| 478 | for(Int y=0; y<iHeight; y++, piPred+=uiStride, piOrg+=uiOrgStride) |
---|
| 479 | { |
---|
| 480 | memcpy(piPred, piOrg, (iWidth-1)*sizeof(Pel)); |
---|
| 481 | } |
---|
| 482 | } |
---|
| 483 | } |
---|
| 484 | else // VER_IDX |
---|
| 485 | { |
---|
| 486 | // top row filled with reference samples |
---|
| 487 | // remaining rows filled with piOrd data (if available) |
---|
| 488 | for(Int x=0; x<iWidth; x++) |
---|
| 489 | { |
---|
| 490 | piPred[x] = ptrSrc[x+1]; |
---|
| 491 | } |
---|
| 492 | if (piOrg!=0) |
---|
| 493 | { |
---|
| 494 | piPred+=uiStride; // miss off the first row |
---|
| 495 | for(Int y=1; y<iHeight; y++, piPred+=uiStride, piOrg+=uiOrgStride) |
---|
| 496 | { |
---|
| 497 | memcpy(piPred, piOrg, iWidth*sizeof(Pel)); |
---|
| 498 | } |
---|
| 499 | } |
---|
| 500 | } |
---|
[56] | 501 | } |
---|
| 502 | else |
---|
| 503 | { |
---|
[1200] | 504 | const Pel *ptrSrc = getPredictorPtr( compID, bUseFilteredPredSamples ); |
---|
| 505 | |
---|
| 506 | if ( uiDirMode == PLANAR_IDX ) |
---|
[56] | 507 | { |
---|
[1200] | 508 | xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); |
---|
[56] | 509 | } |
---|
[608] | 510 | else |
---|
| 511 | { |
---|
[1200] | 512 | // Create the prediction |
---|
| 513 | TComDataCU *const pcCU = rTu.getCU(); |
---|
| 514 | const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
| 515 | const Bool enableEdgeFilters = !(pcCU->isRDPCMEnabled(uiAbsPartIdx) && pcCU->getCUTransquantBypass(uiAbsPartIdx)); |
---|
| 516 | #if O0043_BEST_EFFORT_DECODING |
---|
| 517 | const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getStreamBitDepth(channelType); |
---|
| 518 | #else |
---|
| 519 | const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getBitDepth(channelType); |
---|
| 520 | #endif |
---|
| 521 | xPredIntraAng( channelsBitDepthForPrediction, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType, uiDirMode, bAbove, bLeft, enableEdgeFilters ); |
---|
[608] | 522 | |
---|
[1200] | 523 | if(( uiDirMode == DC_IDX ) && bAbove && bLeft ) |
---|
[608] | 524 | { |
---|
[1200] | 525 | xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType ); |
---|
[608] | 526 | } |
---|
| 527 | } |
---|
[56] | 528 | } |
---|
| 529 | |
---|
| 530 | } |
---|
| 531 | |
---|
[608] | 532 | #if H_3D_DIM |
---|
[884] | 533 | Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc, TComWedgelet* dmm4Segmentation ) |
---|
[56] | 534 | { |
---|
[608] | 535 | assert( iWidth == iHeight ); |
---|
| 536 | assert( iWidth >= DIM_MIN_SIZE && iWidth <= DIM_MAX_SIZE ); |
---|
| 537 | assert( isDimMode( uiIntraMode ) ); |
---|
[56] | 538 | |
---|
[608] | 539 | UInt dimType = getDimType ( uiIntraMode ); |
---|
| 540 | Bool isDmmMode = (dimType < DMM_NUM_TYPE); |
---|
[100] | 541 | |
---|
[608] | 542 | Bool* biSegPattern = NULL; |
---|
| 543 | UInt patternStride = 0; |
---|
[100] | 544 | |
---|
[608] | 545 | // get partiton |
---|
| 546 | #if H_3D_DIM_DMM |
---|
| 547 | TComWedgelet* dmmSegmentation = NULL; |
---|
| 548 | if( isDmmMode ) |
---|
[100] | 549 | { |
---|
[608] | 550 | switch( dimType ) |
---|
[100] | 551 | { |
---|
[608] | 552 | case( DMM1_IDX ): |
---|
[100] | 553 | { |
---|
[1039] | 554 | dmmSegmentation = pcCU->isDMM1UpscaleMode((UInt)iWidth) ? |
---|
| 555 | &(g_dmmWedgeLists[ g_aucConvertToBit[pcCU->getDMM1BasePatternWidth((UInt)iWidth)] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]) : |
---|
| 556 | &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]); |
---|
[608] | 557 | } break; |
---|
| 558 | case( DMM4_IDX ): |
---|
[100] | 559 | { |
---|
[833] | 560 | if( dmm4Segmentation == NULL ) |
---|
| 561 | { |
---|
| 562 | dmmSegmentation = new TComWedgelet( iWidth, iHeight ); |
---|
| 563 | xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation ); |
---|
| 564 | } |
---|
| 565 | else |
---|
| 566 | { |
---|
| 567 | xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmm4Segmentation ); |
---|
| 568 | dmmSegmentation = dmm4Segmentation; |
---|
| 569 | } |
---|
[608] | 570 | } break; |
---|
| 571 | default: assert(0); |
---|
[100] | 572 | } |
---|
[608] | 573 | assert( dmmSegmentation ); |
---|
[1039] | 574 | if( dimType == DMM1_IDX && pcCU->isDMM1UpscaleMode((UInt)iWidth) ) |
---|
| 575 | { |
---|
| 576 | biSegPattern = dmmSegmentation->getScaledPattern((UInt)iWidth); |
---|
| 577 | patternStride = iWidth; |
---|
| 578 | } |
---|
| 579 | else |
---|
| 580 | { |
---|
| 581 | biSegPattern = dmmSegmentation->getPattern(); |
---|
| 582 | patternStride = dmmSegmentation->getStride (); |
---|
| 583 | } |
---|
[100] | 584 | } |
---|
[608] | 585 | #endif |
---|
[100] | 586 | |
---|
[608] | 587 | // get predicted partition values |
---|
| 588 | assert( biSegPattern ); |
---|
| 589 | Int* piMask = NULL; |
---|
[724] | 590 | piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering |
---|
[608] | 591 | assert( piMask ); |
---|
| 592 | Int maskStride = 2*iWidth + 1; |
---|
| 593 | Int* ptrSrc = piMask+maskStride+1; |
---|
| 594 | Pel predDC1 = 0; Pel predDC2 = 0; |
---|
| 595 | xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 ); |
---|
| 596 | |
---|
| 597 | // set segment values with deltaDC offsets |
---|
| 598 | Pel segDC1 = 0; |
---|
| 599 | Pel segDC2 = 0; |
---|
[1039] | 600 | if( !pcCU->getSDCFlag( uiAbsPartIdx ) ) |
---|
[100] | 601 | { |
---|
[608] | 602 | Pel deltaDC1 = pcCU->getDimDeltaDC( dimType, 0, uiAbsPartIdx ); |
---|
| 603 | Pel deltaDC2 = pcCU->getDimDeltaDC( dimType, 1, uiAbsPartIdx ); |
---|
| 604 | #if H_3D_DIM_DMM |
---|
| 605 | if( isDmmMode ) |
---|
| 606 | { |
---|
| 607 | #if H_3D_DIM_DLT |
---|
[758] | 608 | segDC1 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 ); |
---|
| 609 | segDC2 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 ); |
---|
| 610 | #else |
---|
[608] | 611 | segDC1 = ClipY( predDC1 + deltaDC1 ); |
---|
| 612 | segDC2 = ClipY( predDC2 + deltaDC2 ); |
---|
| 613 | #endif |
---|
| 614 | } |
---|
| 615 | #endif |
---|
[100] | 616 | } |
---|
[608] | 617 | else |
---|
[100] | 618 | { |
---|
[608] | 619 | segDC1 = predDC1; |
---|
| 620 | segDC2 = predDC2; |
---|
[100] | 621 | } |
---|
| 622 | |
---|
[608] | 623 | // set prediction signal |
---|
| 624 | Pel* pDst = piPred; |
---|
| 625 | xAssignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 ); |
---|
[950] | 626 | pcCU->setDmmPredictor(segDC1, 0); |
---|
| 627 | pcCU->setDmmPredictor(segDC2, 1); |
---|
[100] | 628 | |
---|
[608] | 629 | #if H_3D_DIM_DMM |
---|
[1196] | 630 | if( dimType == DMM4_IDX && dmm4Segmentation == NULL ) |
---|
| 631 | { |
---|
| 632 | dmmSegmentation->destroy(); |
---|
| 633 | delete dmmSegmentation; |
---|
| 634 | } |
---|
[608] | 635 | #endif |
---|
[100] | 636 | } |
---|
[608] | 637 | #endif |
---|
[100] | 638 | |
---|
[1200] | 639 | /** Check for identical motion in both motion vector direction of a bi-directional predicted CU |
---|
| 640 | * \returns true, if motion vectors and reference pictures match |
---|
[608] | 641 | */ |
---|
| 642 | Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) |
---|
[100] | 643 | { |
---|
[608] | 644 | if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getPPS()->getWPBiPred() ) |
---|
[100] | 645 | { |
---|
[608] | 646 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr) >= 0) |
---|
[100] | 647 | { |
---|
[608] | 648 | Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); |
---|
| 649 | Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); |
---|
[976] | 650 | #if H_3D_ARP |
---|
[950] | 651 | if(!pcCU->getARPW(PartAddr) && RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
| 652 | #else |
---|
[608] | 653 | if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) |
---|
[950] | 654 | #endif |
---|
[100] | 655 | { |
---|
[608] | 656 | return true; |
---|
[100] | 657 | } |
---|
| 658 | } |
---|
| 659 | } |
---|
[608] | 660 | return false; |
---|
[100] | 661 | } |
---|
| 662 | |
---|
[773] | 663 | #if H_3D_SPIVMP |
---|
[724] | 664 | Void TComPrediction::xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr ) |
---|
| 665 | { |
---|
| 666 | for (Int i = 0; i < iNumSP; i++) |
---|
| 667 | { |
---|
| 668 | uiMergedSPW[i] = iSPWidth; |
---|
| 669 | uiMergedSPH[i] = iSPHeight; |
---|
| 670 | pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]); |
---|
| 671 | } |
---|
[1039] | 672 | if( pcCU->getARPW( uiPartAddr ) != 0 ) |
---|
| 673 | { |
---|
| 674 | return; |
---|
| 675 | } |
---|
[1084] | 676 | |
---|
[724] | 677 | // horizontal sub-PU merge |
---|
| 678 | for (Int i=0; i<iNumSP; i++) |
---|
| 679 | { |
---|
| 680 | if (i % iNumSPInOneLine == iNumSPInOneLine - 1 || uiMergedSPW[i]==0 || uiMergedSPH[i]==0) |
---|
| 681 | { |
---|
| 682 | continue; |
---|
| 683 | } |
---|
| 684 | for (Int j=i+1; j<i+iNumSPInOneLine-i%iNumSPInOneLine; j++) |
---|
| 685 | { |
---|
| 686 | if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j])) |
---|
| 687 | { |
---|
| 688 | uiMergedSPW[i] += iSPWidth; |
---|
| 689 | uiMergedSPW[j] = uiMergedSPH[j] = 0; |
---|
| 690 | } |
---|
| 691 | else |
---|
| 692 | { |
---|
| 693 | break; |
---|
| 694 | } |
---|
| 695 | } |
---|
| 696 | } |
---|
| 697 | //vertical sub-PU merge |
---|
| 698 | for (Int i=0; i<iNumSP-iNumSPInOneLine; i++) |
---|
| 699 | { |
---|
| 700 | if (uiMergedSPW[i]==0 || uiMergedSPH[i]==0) |
---|
| 701 | { |
---|
| 702 | continue; |
---|
| 703 | } |
---|
| 704 | for (Int j=i+iNumSPInOneLine; j<iNumSP; j+=iNumSPInOneLine) |
---|
| 705 | { |
---|
| 706 | if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j]) && uiMergedSPW[i]==uiMergedSPW[j]) |
---|
| 707 | { |
---|
| 708 | uiMergedSPH[i] += iSPHeight; |
---|
| 709 | uiMergedSPH[j] = uiMergedSPW[j] = 0; |
---|
| 710 | } |
---|
| 711 | else |
---|
| 712 | { |
---|
| 713 | break; |
---|
| 714 | } |
---|
| 715 | } |
---|
| 716 | } |
---|
| 717 | } |
---|
[608] | 718 | |
---|
[724] | 719 | Bool TComPrediction::xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 ) |
---|
| 720 | { |
---|
| 721 | if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr1)) |
---|
| 722 | { |
---|
| 723 | return false; |
---|
| 724 | } |
---|
| 725 | if( pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr1)) |
---|
| 726 | { |
---|
| 727 | return false; |
---|
| 728 | } |
---|
| 729 | |
---|
| 730 | if (pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) >= 0) |
---|
| 731 | { |
---|
| 732 | if (pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr1)) |
---|
| 733 | { |
---|
| 734 | return false; |
---|
| 735 | } |
---|
| 736 | } |
---|
| 737 | |
---|
| 738 | if (pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) >= 0) |
---|
| 739 | { |
---|
| 740 | if (pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr1)) |
---|
| 741 | { |
---|
| 742 | return false; |
---|
| 743 | } |
---|
| 744 | } |
---|
| 745 | return true; |
---|
| 746 | } |
---|
| 747 | #endif |
---|
| 748 | |
---|
[833] | 749 | #if H_3D_DBBP |
---|
[1179] | 750 | PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU) |
---|
[833] | 751 | { |
---|
| 752 | // find virtual partitioning for this CU based on depth block |
---|
| 753 | // segmentation of texture block --> mask IDs |
---|
| 754 | Pel* pDepthBlockStart = pDepthPels; |
---|
[1196] | 755 | |
---|
[833] | 756 | // first compute average of depth block for thresholding |
---|
| 757 | Int iSumDepth = 0; |
---|
| 758 | Int iSubSample = 4; |
---|
[1179] | 759 | Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(); |
---|
| 760 | Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(); |
---|
| 761 | TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag( ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV; |
---|
| 762 | if( pcCU->getSlice()->getDepthRefinementFlag( ) ) |
---|
| 763 | { |
---|
| 764 | cDv.setVer(0); |
---|
| 765 | } |
---|
| 766 | Int iBlkX = ( pcCU->getAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2); |
---|
| 767 | Int iBlkY = ( pcCU->getAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2); |
---|
[1196] | 768 | |
---|
[1179] | 769 | UInt t=0; |
---|
| 770 | |
---|
[833] | 771 | for (Int y=0; y<uiSize; y+=iSubSample) |
---|
[1196] | 772 | { |
---|
[1179] | 773 | for (Int x=0; x<uiSize; x+=iSubSample) |
---|
[1196] | 774 | { |
---|
| 775 | if (iBlkX+x>iPictureWidth) |
---|
| 776 | { |
---|
| 777 | Int depthPel = pDepthPels[t]; |
---|
| 778 | iSumDepth += depthPel; |
---|
| 779 | } |
---|
| 780 | else |
---|
| 781 | { |
---|
| 782 | Int depthPel = pDepthPels[x]; |
---|
| 783 | t=x; |
---|
| 784 | iSumDepth += depthPel; |
---|
| 785 | } |
---|
| 786 | } |
---|
| 787 | |
---|
[1179] | 788 | // next row |
---|
| 789 | if (!(iBlkY+y+4>iPictureHeight)) |
---|
[833] | 790 | { |
---|
[1196] | 791 | pDepthPels += uiDepthStride*iSubSample; |
---|
[833] | 792 | } |
---|
| 793 | } |
---|
[1196] | 794 | |
---|
[833] | 795 | Int iSizeInBits = g_aucConvertToBit[uiSize] - g_aucConvertToBit[iSubSample]; // respect sub-sampling factor |
---|
| 796 | Int iMean = iSumDepth >> iSizeInBits*2; // iMean /= (uiSize*uiSize); |
---|
[1196] | 797 | |
---|
[833] | 798 | // start again for segmentation |
---|
| 799 | pDepthPels = pDepthBlockStart; |
---|
[1196] | 800 | |
---|
[833] | 801 | // start mapping process |
---|
[950] | 802 | Int matchedPartSum[2][2] = {{0,0},{0,0}}; // counter for each part size and boolean option |
---|
| 803 | PartSize virtualPartSizes[2] = { SIZE_Nx2N, SIZE_2NxN}; |
---|
[1196] | 804 | |
---|
[833] | 805 | UInt uiHalfSize = uiSize>>1; |
---|
| 806 | for (Int y=0; y<uiSize; y+=iSubSample) |
---|
| 807 | { |
---|
| 808 | for (Int x=0; x<uiSize; x+=iSubSample) |
---|
| 809 | { |
---|
[1179] | 810 | Int depthPel = 0; |
---|
[1196] | 811 | if (iBlkX+x>iPictureWidth) |
---|
| 812 | { |
---|
| 813 | depthPel = pDepthPels[t]; |
---|
| 814 | } |
---|
| 815 | else |
---|
| 816 | { |
---|
| 817 | depthPel = pDepthPels[x]; |
---|
| 818 | t=x; |
---|
| 819 | } |
---|
| 820 | |
---|
[833] | 821 | // decide which segment this pixel belongs to |
---|
| 822 | Int ucSegment = (Int)(depthPel>iMean); |
---|
[1196] | 823 | |
---|
[833] | 824 | // Matched Filter to find optimal (conventional) partitioning |
---|
[1196] | 825 | |
---|
[833] | 826 | // SIZE_Nx2N |
---|
| 827 | if(x<uiHalfSize) // left |
---|
| 828 | { |
---|
| 829 | matchedPartSum[0][ucSegment]++; |
---|
| 830 | } |
---|
| 831 | else // right |
---|
| 832 | { |
---|
| 833 | matchedPartSum[0][1-ucSegment]++; |
---|
| 834 | } |
---|
[1196] | 835 | |
---|
[833] | 836 | // SIZE_2NxN |
---|
| 837 | if(y<uiHalfSize) // top |
---|
| 838 | { |
---|
| 839 | matchedPartSum[1][ucSegment]++; |
---|
| 840 | } |
---|
| 841 | else // bottom |
---|
| 842 | { |
---|
| 843 | matchedPartSum[1][1-ucSegment]++; |
---|
| 844 | } |
---|
| 845 | } |
---|
[1196] | 846 | |
---|
[833] | 847 | // next row |
---|
[1179] | 848 | if (!(iBlkY+y+4>iPictureHeight)) |
---|
[1196] | 849 | { |
---|
| 850 | pDepthPels += uiDepthStride*iSubSample; |
---|
| 851 | } |
---|
[833] | 852 | } |
---|
[1196] | 853 | |
---|
[833] | 854 | PartSize matchedPartSize = SIZE_NONE; |
---|
[1196] | 855 | |
---|
[833] | 856 | Int iMaxMatchSum = 0; |
---|
[950] | 857 | for(Int p=0; p<2; p++) // loop over partition |
---|
[833] | 858 | { |
---|
| 859 | for( Int b=0; b<=1; b++ ) // loop over boolean options |
---|
| 860 | { |
---|
| 861 | if(matchedPartSum[p][b] > iMaxMatchSum) |
---|
| 862 | { |
---|
| 863 | iMaxMatchSum = matchedPartSum[p][b]; |
---|
| 864 | matchedPartSize = virtualPartSizes[p]; |
---|
| 865 | } |
---|
| 866 | } |
---|
| 867 | } |
---|
[1196] | 868 | |
---|
[833] | 869 | AOF( matchedPartSize != SIZE_NONE ); |
---|
[1196] | 870 | |
---|
[833] | 871 | return matchedPartSize; |
---|
| 872 | } |
---|
| 873 | |
---|
[1179] | 874 | Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU) |
---|
[833] | 875 | { |
---|
| 876 | // segmentation of texture block --> mask IDs |
---|
| 877 | Pel* pDepthBlockStart = pDepthPels; |
---|
[1179] | 878 | |
---|
[833] | 879 | // first compute average of depth block for thresholding |
---|
| 880 | Int iSumDepth = 0; |
---|
| 881 | Int uiMinDepth = MAX_INT; |
---|
| 882 | Int uiMaxDepth = 0; |
---|
[1179] | 883 | uiMinDepth = pDepthPels[ 0 ]; |
---|
| 884 | uiMaxDepth = pDepthPels[ 0 ]; |
---|
[1039] | 885 | iSumDepth = pDepthPels[ 0 ]; |
---|
[1196] | 886 | |
---|
[1179] | 887 | Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(); |
---|
| 888 | Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(); |
---|
| 889 | TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag( ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV; |
---|
| 890 | if( pcCU->getSlice()->getDepthRefinementFlag( ) ) |
---|
| 891 | { |
---|
| 892 | cDv.setVer(0); |
---|
| 893 | } |
---|
| 894 | Int iBlkX = ( pcCU->getAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2); |
---|
| 895 | Int iBlkY = ( pcCU->getAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2); |
---|
| 896 | if (iBlkX>(Int)(iPictureWidth - uiWidth)) |
---|
| 897 | { |
---|
| 898 | iSumDepth += pDepthPels[ iPictureWidth - iBlkX - 1 ]; |
---|
| 899 | uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ iPictureWidth - iBlkX - 1 ]); |
---|
| 900 | uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ iPictureWidth - iBlkX - 1 ]); |
---|
| 901 | } |
---|
| 902 | else |
---|
| 903 | { |
---|
| 904 | iSumDepth += pDepthPels[ uiWidth - 1 ]; |
---|
| 905 | uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiWidth - 1 ]); |
---|
| 906 | uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiWidth - 1 ]); |
---|
| 907 | } |
---|
| 908 | if (iBlkY>(Int)(iPictureHeight - uiHeight)) |
---|
| 909 | { |
---|
| 910 | iSumDepth += pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) ]; |
---|
| 911 | uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) ]); |
---|
| 912 | uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) ]); |
---|
| 913 | } |
---|
| 914 | else |
---|
| 915 | { |
---|
| 916 | iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) ]; |
---|
| 917 | uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) ]); |
---|
| 918 | uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) ]); |
---|
| 919 | } |
---|
| 920 | if (iBlkY>(Int)(iPictureHeight - uiHeight) && iBlkX>(Int)(iPictureWidth - uiWidth)) |
---|
| 921 | { |
---|
| 922 | iSumDepth += pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + iPictureWidth - iBlkX - 1 ]; |
---|
| 923 | uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + iPictureWidth - iBlkX - 1 ]); |
---|
| 924 | uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + iPictureWidth - iBlkX - 1 ]); |
---|
| 925 | } |
---|
| 926 | else if (iBlkY>(Int)(iPictureHeight - uiHeight)) |
---|
| 927 | { |
---|
| 928 | iSumDepth += pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + uiWidth - 1 ]; |
---|
| 929 | uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + uiWidth - 1 ]); |
---|
| 930 | uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (iPictureHeight - iBlkY - 1) + uiWidth - 1 ]); |
---|
| 931 | } |
---|
| 932 | else if (iBlkX>(Int)(iPictureWidth - uiWidth)) |
---|
| 933 | { |
---|
| 934 | iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) + iPictureWidth - iBlkX - 1 ]; |
---|
| 935 | uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + iPictureWidth - iBlkX - 1 ]); |
---|
| 936 | uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + iPictureWidth - iBlkX - 1 ]); |
---|
| 937 | } |
---|
| 938 | else |
---|
| 939 | { |
---|
| 940 | iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]; |
---|
| 941 | uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]); |
---|
| 942 | uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]); |
---|
| 943 | } |
---|
[1039] | 944 | |
---|
[833] | 945 | // don't generate mask for blocks with small depth range (encoder decision) |
---|
| 946 | if( uiMaxDepth - uiMinDepth < 10 ) |
---|
| 947 | { |
---|
| 948 | return false; |
---|
| 949 | } |
---|
[1179] | 950 | |
---|
[833] | 951 | AOF(uiWidth==uiHeight); |
---|
[1039] | 952 | Int iMean = iSumDepth >> 2; |
---|
[1179] | 953 | |
---|
[833] | 954 | // start again for segmentation |
---|
| 955 | pDepthPels = pDepthBlockStart; |
---|
[1179] | 956 | |
---|
[833] | 957 | Bool bInvertMask = pDepthPels[0]>iMean; // top-left segment needs to be mapped to partIdx 0 |
---|
[1179] | 958 | |
---|
[833] | 959 | // generate mask |
---|
[1196] | 960 | UInt t=0; |
---|
[833] | 961 | UInt uiSumPix[2] = {0,0}; |
---|
| 962 | for (Int y=0; y<uiHeight; y++) |
---|
| 963 | { |
---|
| 964 | for (Int x=0; x<uiHeight; x++) |
---|
| 965 | { |
---|
[1179] | 966 | Int depthPel = 0; |
---|
| 967 | if (iBlkX+x>iPictureWidth) |
---|
| 968 | { |
---|
| 969 | depthPel = pDepthPels[t]; |
---|
| 970 | } |
---|
| 971 | else |
---|
| 972 | { |
---|
| 973 | depthPel = pDepthPels[x]; |
---|
| 974 | t=x; |
---|
| 975 | } |
---|
| 976 | |
---|
[833] | 977 | // decide which segment this pixel belongs to |
---|
| 978 | Int ucSegment = (Int)(depthPel>iMean); |
---|
[1179] | 979 | |
---|
[833] | 980 | if( bInvertMask ) |
---|
| 981 | { |
---|
| 982 | ucSegment = 1-ucSegment; |
---|
| 983 | } |
---|
[1179] | 984 | |
---|
[833] | 985 | // count pixels for each segment |
---|
| 986 | uiSumPix[ucSegment]++; |
---|
[1179] | 987 | |
---|
[833] | 988 | // set mask value |
---|
| 989 | pMask[x] = (Bool)ucSegment; |
---|
| 990 | } |
---|
[1179] | 991 | |
---|
[833] | 992 | // next row |
---|
[1179] | 993 | if (!(iBlkY+y+1>iPictureHeight)) |
---|
| 994 | pDepthPels += uiDepthStride; |
---|
[833] | 995 | pMask += MAX_CU_SIZE; |
---|
| 996 | } |
---|
[1179] | 997 | |
---|
[833] | 998 | // don't generate valid mask for tiny segments (encoder decision) |
---|
| 999 | // each segment needs to cover at least 1/8th of block |
---|
| 1000 | UInt uiMinPixPerSegment = (uiWidth*uiHeight) >> 3; |
---|
| 1001 | if( !( uiSumPix[0] > uiMinPixPerSegment && uiSumPix[1] > uiMinPixPerSegment ) ) |
---|
| 1002 | { |
---|
| 1003 | return false; |
---|
| 1004 | } |
---|
[1179] | 1005 | |
---|
[833] | 1006 | // all good |
---|
| 1007 | return true; |
---|
| 1008 | } |
---|
| 1009 | |
---|
[1039] | 1010 | Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize ) |
---|
[833] | 1011 | { |
---|
| 1012 | Pel* piSrc[2] = {pInYuv[0]->getLumaAddr(uiPartAddr), pInYuv[1]->getLumaAddr(uiPartAddr)}; |
---|
| 1013 | UInt uiSrcStride = pInYuv[0]->getStride(); |
---|
| 1014 | Pel* piDst = pOutYuv->getLumaAddr(uiPartAddr); |
---|
| 1015 | UInt uiDstStride = pOutYuv->getStride(); |
---|
| 1016 | |
---|
| 1017 | UInt uiMaskStride= MAX_CU_SIZE; |
---|
[950] | 1018 | Pel* tmpTar = 0; |
---|
| 1019 | tmpTar = (Pel *)xMalloc(Pel, uiWidth*uiHeight); |
---|
[833] | 1020 | |
---|
| 1021 | // backup pointer |
---|
| 1022 | Bool* pMaskStart = pMask; |
---|
| 1023 | |
---|
| 1024 | // combine luma first |
---|
| 1025 | for (Int y=0; y<uiHeight; y++) |
---|
| 1026 | { |
---|
| 1027 | for (Int x=0; x<uiWidth; x++) |
---|
| 1028 | { |
---|
| 1029 | UChar ucSegment = (UChar)pMask[x]; |
---|
| 1030 | AOF( ucSegment < 2 ); |
---|
| 1031 | |
---|
| 1032 | // filtering |
---|
[950] | 1033 | tmpTar[y*uiWidth+x] = piSrc[ucSegment][x]; |
---|
[833] | 1034 | } |
---|
| 1035 | |
---|
| 1036 | piSrc[0] += uiSrcStride; |
---|
| 1037 | piSrc[1] += uiSrcStride; |
---|
| 1038 | pMask += uiMaskStride; |
---|
| 1039 | } |
---|
| 1040 | |
---|
[1039] | 1041 | if (partSize == SIZE_Nx2N) |
---|
| 1042 | { |
---|
| 1043 | for (Int y=0; y<uiHeight; y++) |
---|
| 1044 | { |
---|
| 1045 | for (Int x=0; x<uiWidth; x++) |
---|
| 1046 | { |
---|
| 1047 | Bool l = (x==0)?pMaskStart[y*uiMaskStride+x]:pMaskStart[y*uiMaskStride+x-1]; |
---|
| 1048 | Bool r = (x==uiWidth-1)?pMaskStart[y*uiMaskStride+x]:pMaskStart[y*uiMaskStride+x+1]; |
---|
| 1049 | |
---|
| 1050 | Pel left, right; |
---|
| 1051 | left = (x==0) ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x-1]; |
---|
| 1052 | right = (x==uiWidth-1) ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x+1]; |
---|
| 1053 | |
---|
| 1054 | piDst[x] = (l!=r) ? ClipY( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 )) : tmpTar[y*uiWidth+x]; |
---|
| 1055 | } |
---|
| 1056 | piDst += uiDstStride; |
---|
| 1057 | } |
---|
| 1058 | } |
---|
| 1059 | else // SIZE_2NxN |
---|
| 1060 | { |
---|
| 1061 | for (Int y=0; y<uiHeight; y++) |
---|
| 1062 | { |
---|
| 1063 | for (Int x=0; x<uiWidth; x++) |
---|
| 1064 | { |
---|
| 1065 | Bool t = (y==0)?pMaskStart[y*uiMaskStride+x]:pMaskStart[(y-1)*uiMaskStride+x]; |
---|
| 1066 | Bool b = (y==uiHeight-1)?pMaskStart[y*uiMaskStride+x]:pMaskStart[(y+1)*uiMaskStride+x]; |
---|
| 1067 | |
---|
| 1068 | Pel top, bottom; |
---|
| 1069 | top = (y==0) ? tmpTar[y*uiWidth+x] : tmpTar[(y-1)*uiWidth+x]; |
---|
| 1070 | bottom = (y==uiHeight-1) ? tmpTar[y*uiWidth+x] : tmpTar[(y+1)*uiWidth+x]; |
---|
| 1071 | |
---|
| 1072 | piDst[x] = (t!=b) ? ClipY( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 )) : tmpTar[y*uiWidth+x]; |
---|
| 1073 | } |
---|
| 1074 | piDst += uiDstStride; |
---|
| 1075 | } |
---|
| 1076 | } |
---|
[950] | 1077 | |
---|
[1196] | 1078 | if ( tmpTar ) |
---|
| 1079 | { |
---|
| 1080 | xFree(tmpTar); |
---|
| 1081 | tmpTar = NULL; |
---|
| 1082 | } |
---|
[950] | 1083 | |
---|
[833] | 1084 | // now combine chroma |
---|
| 1085 | Pel* piSrcU[2] = { pInYuv[0]->getCbAddr(uiPartAddr), pInYuv[1]->getCbAddr(uiPartAddr) }; |
---|
| 1086 | Pel* piSrcV[2] = { pInYuv[0]->getCrAddr(uiPartAddr), pInYuv[1]->getCrAddr(uiPartAddr) }; |
---|
| 1087 | UInt uiSrcStrideC = pInYuv[0]->getCStride(); |
---|
| 1088 | Pel* piDstU = pOutYuv->getCbAddr(uiPartAddr); |
---|
| 1089 | Pel* piDstV = pOutYuv->getCrAddr(uiPartAddr); |
---|
| 1090 | UInt uiDstStrideC = pOutYuv->getCStride(); |
---|
| 1091 | UInt uiWidthC = uiWidth >> 1; |
---|
| 1092 | UInt uiHeightC = uiHeight >> 1; |
---|
[950] | 1093 | Pel filSrcU = 0, filSrcV = 0; |
---|
| 1094 | Pel* tmpTarU = 0, *tmpTarV = 0; |
---|
| 1095 | tmpTarU = (Pel *)xMalloc(Pel, uiWidthC*uiHeightC); |
---|
| 1096 | tmpTarV = (Pel *)xMalloc(Pel, uiWidthC*uiHeightC); |
---|
[833] | 1097 | pMask = pMaskStart; |
---|
| 1098 | |
---|
| 1099 | for (Int y=0; y<uiHeightC; y++) |
---|
| 1100 | { |
---|
| 1101 | for (Int x=0; x<uiWidthC; x++) |
---|
| 1102 | { |
---|
| 1103 | UChar ucSegment = (UChar)pMask[x*2]; |
---|
| 1104 | AOF( ucSegment < 2 ); |
---|
| 1105 | |
---|
| 1106 | // filtering |
---|
[950] | 1107 | tmpTarU[y*uiWidthC+x] = piSrcU[ucSegment][x]; |
---|
| 1108 | tmpTarV[y*uiWidthC+x] = piSrcV[ucSegment][x]; |
---|
[833] | 1109 | } |
---|
| 1110 | |
---|
| 1111 | piSrcU[0] += uiSrcStrideC; |
---|
| 1112 | piSrcU[1] += uiSrcStrideC; |
---|
| 1113 | piSrcV[0] += uiSrcStrideC; |
---|
| 1114 | piSrcV[1] += uiSrcStrideC; |
---|
| 1115 | pMask += 2*uiMaskStride; |
---|
| 1116 | } |
---|
[950] | 1117 | |
---|
[1039] | 1118 | if (partSize == SIZE_Nx2N) |
---|
| 1119 | { |
---|
| 1120 | for (Int y=0; y<uiHeightC; y++) |
---|
| 1121 | { |
---|
| 1122 | for (Int x=0; x<uiWidthC; x++) |
---|
| 1123 | { |
---|
| 1124 | Bool l = (x==0)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[y*2*uiMaskStride+(x-1)*2]; |
---|
| 1125 | Bool r = (x==uiWidthC-1)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[y*2*uiMaskStride+(x+1)*2]; |
---|
| 1126 | |
---|
| 1127 | Pel leftU, rightU; |
---|
| 1128 | leftU = (x==0) ? tmpTarU[y*uiWidthC+x] : tmpTarU[y*uiWidthC+x-1]; |
---|
| 1129 | rightU = (x==uiWidthC-1) ? tmpTarU[y*uiWidthC+x] : tmpTarU[y*uiWidthC+x+1]; |
---|
| 1130 | Pel leftV, rightV; |
---|
| 1131 | leftV = (x==0) ? tmpTarV[y*uiWidthC+x] : tmpTarV[y*uiWidthC+x-1]; |
---|
| 1132 | rightV = (x==uiWidthC-1) ? tmpTarV[y*uiWidthC+x] : tmpTarV[y*uiWidthC+x+1]; |
---|
| 1133 | |
---|
| 1134 | if (l!=r) |
---|
| 1135 | { |
---|
| 1136 | filSrcU = ClipC( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 )); |
---|
| 1137 | filSrcV = ClipC( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 )); |
---|
| 1138 | } |
---|
| 1139 | else |
---|
| 1140 | { |
---|
| 1141 | filSrcU = tmpTarU[y*uiWidthC+x]; |
---|
| 1142 | filSrcV = tmpTarV[y*uiWidthC+x]; |
---|
| 1143 | } |
---|
| 1144 | piDstU[x] = filSrcU; |
---|
| 1145 | piDstV[x] = filSrcV; |
---|
| 1146 | } |
---|
| 1147 | piDstU += uiDstStrideC; |
---|
| 1148 | piDstV += uiDstStrideC; |
---|
| 1149 | } |
---|
| 1150 | } |
---|
| 1151 | else |
---|
| 1152 | { |
---|
| 1153 | for (Int y=0; y<uiHeightC; y++) |
---|
| 1154 | { |
---|
| 1155 | for (Int x=0; x<uiWidthC; x++) |
---|
| 1156 | { |
---|
| 1157 | Bool t = (y==0)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[(y-1)*2*uiMaskStride+x*2]; |
---|
| 1158 | Bool b = (y==uiHeightC-1)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[(y+1)*2*uiMaskStride+x*2]; |
---|
| 1159 | |
---|
| 1160 | Pel topU, bottomU; |
---|
| 1161 | topU = (y==0) ? tmpTarU[y*uiWidthC+x] : tmpTarU[(y-1)*uiWidthC+x]; |
---|
| 1162 | bottomU = (y==uiHeightC-1) ? tmpTarU[y*uiWidthC+x] : tmpTarU[(y+1)*uiWidthC+x]; |
---|
| 1163 | Pel topV, bottomV; |
---|
| 1164 | topV = (y==0) ? tmpTarV[y*uiWidthC+x] : tmpTarV[(y-1)*uiWidthC+x]; |
---|
| 1165 | bottomV = (y==uiHeightC-1) ? tmpTarV[y*uiWidthC+x] : tmpTarV[(y+1)*uiWidthC+x]; |
---|
| 1166 | |
---|
| 1167 | if (t!=b) |
---|
| 1168 | { |
---|
| 1169 | filSrcU = ClipC( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 )); |
---|
| 1170 | filSrcV = ClipC( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 )); |
---|
| 1171 | } |
---|
| 1172 | else |
---|
| 1173 | { |
---|
| 1174 | filSrcU = tmpTarU[y*uiWidthC+x]; |
---|
| 1175 | filSrcV = tmpTarV[y*uiWidthC+x]; |
---|
| 1176 | } |
---|
| 1177 | piDstU[x] = filSrcU; |
---|
| 1178 | piDstV[x] = filSrcV; |
---|
| 1179 | } |
---|
| 1180 | piDstU += uiDstStrideC; |
---|
| 1181 | piDstV += uiDstStrideC; |
---|
| 1182 | } |
---|
| 1183 | } |
---|
[950] | 1184 | |
---|
[1196] | 1185 | if( tmpTarU ) |
---|
| 1186 | { |
---|
| 1187 | xFree(tmpTarU); |
---|
| 1188 | tmpTarU = NULL; |
---|
| 1189 | } |
---|
| 1190 | if ( tmpTarV ) |
---|
| 1191 | { |
---|
| 1192 | xFree(tmpTarV); |
---|
| 1193 | tmpTarV = NULL; |
---|
| 1194 | } |
---|
[833] | 1195 | } |
---|
| 1196 | #endif |
---|
| 1197 | |
---|
[56] | 1198 | Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) |
---|
| 1199 | { |
---|
| 1200 | Int iWidth; |
---|
| 1201 | Int iHeight; |
---|
| 1202 | UInt uiPartAddr; |
---|
| 1203 | |
---|
| 1204 | if ( iPartIdx >= 0 ) |
---|
| 1205 | { |
---|
| 1206 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
[608] | 1207 | #if H_3D_VSP |
---|
[622] | 1208 | if ( pcCU->getVSPFlag(uiPartAddr) == 0) |
---|
[56] | 1209 | { |
---|
| 1210 | #endif |
---|
[1200] | 1211 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
| 1212 | { |
---|
| 1213 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
[56] | 1214 | { |
---|
[1200] | 1215 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
[56] | 1216 | } |
---|
| 1217 | else |
---|
| 1218 | { |
---|
[1200] | 1219 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 1220 | } |
---|
| 1221 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
| 1222 | { |
---|
| 1223 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 1224 | } |
---|
| 1225 | } |
---|
| 1226 | else |
---|
| 1227 | { |
---|
[773] | 1228 | #if H_3D_SPIVMP |
---|
[724] | 1229 | if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0) |
---|
[608] | 1230 | { |
---|
[724] | 1231 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 1232 | |
---|
| 1233 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 1234 | |
---|
| 1235 | UInt uiW[256], uiH[256]; |
---|
| 1236 | UInt uiSPAddr[256]; |
---|
| 1237 | |
---|
| 1238 | xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr); |
---|
| 1239 | |
---|
| 1240 | //MC |
---|
| 1241 | for (Int i = 0; i < iNumSP; i++) |
---|
| 1242 | { |
---|
| 1243 | if (uiW[i]==0 || uiH[i]==0) |
---|
| 1244 | { |
---|
| 1245 | continue; |
---|
| 1246 | } |
---|
| 1247 | if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] )) |
---|
| 1248 | { |
---|
| 1249 | xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred ); |
---|
| 1250 | } |
---|
| 1251 | else |
---|
| 1252 | { |
---|
| 1253 | xPredInterBi (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred); |
---|
| 1254 | } |
---|
| 1255 | } |
---|
[608] | 1256 | } |
---|
| 1257 | else |
---|
| 1258 | { |
---|
[724] | 1259 | #endif |
---|
[1200] | 1260 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
| 1261 | { |
---|
| 1262 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
| 1263 | } |
---|
| 1264 | else |
---|
| 1265 | { |
---|
| 1266 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
| 1267 | } |
---|
[773] | 1268 | #if H_3D_SPIVMP |
---|
[608] | 1269 | } |
---|
[724] | 1270 | #endif |
---|
[1200] | 1271 | } |
---|
[608] | 1272 | #if H_3D_VSP |
---|
[56] | 1273 | } |
---|
| 1274 | else |
---|
| 1275 | { |
---|
[608] | 1276 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
[622] | 1277 | { |
---|
[608] | 1278 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
[622] | 1279 | } |
---|
[56] | 1280 | else |
---|
[622] | 1281 | { |
---|
[608] | 1282 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
[622] | 1283 | } |
---|
[608] | 1284 | } |
---|
[296] | 1285 | #endif |
---|
[2] | 1286 | return; |
---|
| 1287 | } |
---|
[56] | 1288 | |
---|
[964] | 1289 | for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ ) |
---|
[56] | 1290 | { |
---|
| 1291 | pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
| 1292 | |
---|
[608] | 1293 | #if H_3D_VSP |
---|
[622] | 1294 | if ( pcCU->getVSPFlag(uiPartAddr) == 0 ) |
---|
[56] | 1295 | { |
---|
[189] | 1296 | #endif |
---|
[1200] | 1297 | if ( eRefPicList != REF_PIC_LIST_X ) |
---|
| 1298 | { |
---|
| 1299 | if( pcCU->getSlice()->getPPS()->getUseWP()) |
---|
[56] | 1300 | { |
---|
[1200] | 1301 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); |
---|
[56] | 1302 | } |
---|
[608] | 1303 | else |
---|
[56] | 1304 | { |
---|
[1200] | 1305 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 1306 | } |
---|
| 1307 | if ( pcCU->getSlice()->getPPS()->getUseWP() ) |
---|
| 1308 | { |
---|
| 1309 | xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); |
---|
| 1310 | } |
---|
| 1311 | } |
---|
| 1312 | else |
---|
| 1313 | { |
---|
[773] | 1314 | #if H_3D_SPIVMP |
---|
[724] | 1315 | if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) |
---|
| 1316 | { |
---|
| 1317 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 1318 | |
---|
| 1319 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 1320 | |
---|
| 1321 | UInt uiW[256], uiH[256]; |
---|
| 1322 | UInt uiSPAddr[256]; |
---|
| 1323 | |
---|
| 1324 | xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr); |
---|
| 1325 | //MC |
---|
| 1326 | for (Int i = 0; i < iNumSP; i++) |
---|
| 1327 | { |
---|
| 1328 | if (uiW[i]==0 || uiH[i]==0) |
---|
| 1329 | { |
---|
| 1330 | continue; |
---|
| 1331 | } |
---|
| 1332 | if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] )) |
---|
| 1333 | { |
---|
| 1334 | xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred ); |
---|
| 1335 | } |
---|
| 1336 | else |
---|
| 1337 | { |
---|
| 1338 | xPredInterBi (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred); |
---|
| 1339 | } |
---|
| 1340 | } |
---|
| 1341 | } |
---|
| 1342 | else |
---|
| 1343 | { |
---|
| 1344 | #endif |
---|
[1200] | 1345 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
| 1346 | { |
---|
| 1347 | xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
| 1348 | } |
---|
| 1349 | else |
---|
| 1350 | { |
---|
| 1351 | xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
| 1352 | } |
---|
[773] | 1353 | #if H_3D_SPIVMP |
---|
[724] | 1354 | } |
---|
| 1355 | #endif |
---|
[1200] | 1356 | } |
---|
[608] | 1357 | #if H_3D_VSP |
---|
[56] | 1358 | } |
---|
| 1359 | else |
---|
| 1360 | { |
---|
| 1361 | if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) |
---|
[622] | 1362 | { |
---|
[608] | 1363 | xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
[622] | 1364 | } |
---|
[56] | 1365 | else |
---|
[622] | 1366 | { |
---|
[608] | 1367 | xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
[622] | 1368 | } |
---|
[56] | 1369 | } |
---|
[608] | 1370 | #endif |
---|
[56] | 1371 | } |
---|
| 1372 | return; |
---|
| 1373 | } |
---|
[2] | 1374 | |
---|
[1200] | 1375 | Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* pcYuvPred, Bool bi ) |
---|
[296] | 1376 | { |
---|
[608] | 1377 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); |
---|
| 1378 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 1379 | pcCU->clipMv(cMv); |
---|
[1200] | 1380 | #if NH_MV |
---|
[1196] | 1381 | pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx ); |
---|
[1179] | 1382 | #endif |
---|
[608] | 1383 | #if H_3D_ARP |
---|
[724] | 1384 | if(pcCU->getARPW( uiPartAddr ) > 0 && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC()) |
---|
| 1385 | { |
---|
[773] | 1386 | xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi ); |
---|
[724] | 1387 | } |
---|
| 1388 | else |
---|
[443] | 1389 | { |
---|
[773] | 1390 | if( pcCU->getARPW( uiPartAddr ) > 0 |
---|
| 1391 | && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N |
---|
| 1392 | && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() |
---|
| 1393 | ) |
---|
| 1394 | { |
---|
| 1395 | xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi ); |
---|
| 1396 | } |
---|
| 1397 | else |
---|
| 1398 | { |
---|
[443] | 1399 | #endif |
---|
[608] | 1400 | #if H_3D_IC |
---|
[773] | 1401 | Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ); |
---|
| 1402 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
[608] | 1403 | #if H_3D_ARP |
---|
[773] | 1404 | , false |
---|
[443] | 1405 | #endif |
---|
[773] | 1406 | , bICFlag ); |
---|
| 1407 | bICFlag = bICFlag && (iWidth > 8); |
---|
| 1408 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi |
---|
[608] | 1409 | #if H_3D_ARP |
---|
[773] | 1410 | , false |
---|
[443] | 1411 | #endif |
---|
[773] | 1412 | , bICFlag ); |
---|
[443] | 1413 | #else |
---|
[1200] | 1414 | |
---|
| 1415 | for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++) |
---|
| 1416 | { |
---|
| 1417 | const ComponentID compID=ComponentID(comp); |
---|
| 1418 | xPredInterBlk (compID, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) ); |
---|
| 1419 | } |
---|
[443] | 1420 | #endif |
---|
[608] | 1421 | #if H_3D_ARP |
---|
[773] | 1422 | } |
---|
[443] | 1423 | } |
---|
| 1424 | #endif |
---|
| 1425 | } |
---|
| 1426 | |
---|
[608] | 1427 | #if H_3D_VSP |
---|
| 1428 | Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) |
---|
[56] | 1429 | { |
---|
[833] | 1430 | Int vspSize = pcCU->getVSPFlag( uiPartAddr ) >> 1; |
---|
| 1431 | |
---|
| 1432 | Int widthSubPU, heightSubPU; |
---|
| 1433 | if (vspSize) |
---|
| 1434 | { |
---|
| 1435 | widthSubPU = 8; |
---|
| 1436 | heightSubPU = 4; |
---|
| 1437 | } |
---|
| 1438 | else |
---|
| 1439 | { |
---|
| 1440 | widthSubPU = 4; |
---|
| 1441 | heightSubPU = 8; |
---|
| 1442 | } |
---|
| 1443 | xPredInterUniSubPU( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi, widthSubPU, heightSubPU ); |
---|
[608] | 1444 | } |
---|
[833] | 1445 | |
---|
| 1446 | Void TComPrediction::xPredInterUniSubPU( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU, Int heightSubPU ) |
---|
| 1447 | { |
---|
| 1448 | UInt numPartsInLine = pcCU->getPic()->getNumPartInWidth(); |
---|
| 1449 | UInt horiNumPartsInSubPU = widthSubPU >> 2; |
---|
| 1450 | UInt vertNumPartsInSubPU = (heightSubPU >> 2) * numPartsInLine; |
---|
| 1451 | |
---|
| 1452 | UInt partAddrRasterLine = g_auiZscanToRaster[ uiPartAddr ]; |
---|
| 1453 | |
---|
| 1454 | for( Int posY=0; posY<iHeight; posY+=heightSubPU, partAddrRasterLine+=vertNumPartsInSubPU ) |
---|
| 1455 | { |
---|
| 1456 | UInt partAddrRasterSubPU = partAddrRasterLine; |
---|
| 1457 | for( Int posX=0; posX<iWidth; posX+=widthSubPU, partAddrRasterSubPU+=horiNumPartsInSubPU ) |
---|
| 1458 | { |
---|
| 1459 | UInt partAddrSubPU = g_auiRasterToZscan[ partAddrRasterSubPU ]; |
---|
| 1460 | Int refIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( partAddrSubPU ); assert (refIdx >= 0); |
---|
| 1461 | TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( partAddrSubPU ); |
---|
| 1462 | pcCU->clipMv(cMv); |
---|
| 1463 | |
---|
| 1464 | xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi ); |
---|
| 1465 | xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi ); |
---|
| 1466 | |
---|
| 1467 | } |
---|
| 1468 | } |
---|
| 1469 | } |
---|
| 1470 | |
---|
[296] | 1471 | #endif |
---|
[189] | 1472 | |
---|
[608] | 1473 | #if H_3D_ARP |
---|
| 1474 | Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled ) |
---|
| 1475 | { |
---|
| 1476 | Int iRefIdx = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 1477 | TComMv cMv = pNewMvFiled ? pNewMvFiled->getMv() : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 1478 | Bool bTobeScaled = false; |
---|
| 1479 | TComPic* pcPicYuvBaseCol = NULL; |
---|
| 1480 | TComPic* pcPicYuvBaseRef = NULL; |
---|
[2] | 1481 | |
---|
[608] | 1482 | #if H_3D_NBDV |
---|
[443] | 1483 | DisInfo cDistparity; |
---|
[1179] | 1484 | cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV; |
---|
| 1485 | cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; |
---|
| 1486 | #else |
---|
[608] | 1487 | assert(0); // ARP can be applied only when a DV is available |
---|
[443] | 1488 | #endif |
---|
[1179] | 1489 | UChar dW = pcCU->getARPW ( uiPartAddr ); |
---|
[608] | 1490 | |
---|
[443] | 1491 | { |
---|
[724] | 1492 | Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList); |
---|
| 1493 | if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() ) |
---|
[608] | 1494 | { |
---|
[443] | 1495 | bTobeScaled = true; |
---|
[608] | 1496 | } |
---|
| 1497 | |
---|
| 1498 | pcPicYuvBaseCol = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(), cDistparity.m_aVIdxCan ); |
---|
[724] | 1499 | |
---|
| 1500 | pcPicYuvBaseRef = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan ); |
---|
| 1501 | |
---|
| 1502 | if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan)) |
---|
[443] | 1503 | { |
---|
| 1504 | dW = 0; |
---|
| 1505 | bTobeScaled = false; |
---|
| 1506 | } |
---|
| 1507 | else |
---|
[608] | 1508 | { |
---|
[724] | 1509 | assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() ); |
---|
[608] | 1510 | } |
---|
| 1511 | |
---|
[443] | 1512 | if(bTobeScaled) |
---|
| 1513 | { |
---|
[608] | 1514 | Int iCurrPOC = pcCU->getSlice()->getPOC(); |
---|
[443] | 1515 | Int iColRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx ); |
---|
| 1516 | Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, 0); |
---|
| 1517 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC); |
---|
| 1518 | if ( iScale != 4096 ) |
---|
[608] | 1519 | { |
---|
[443] | 1520 | cMv = cMv.scaleMv( iScale ); |
---|
[608] | 1521 | } |
---|
[443] | 1522 | iRefIdx = 0; |
---|
| 1523 | } |
---|
| 1524 | } |
---|
[608] | 1525 | |
---|
[443] | 1526 | pcCU->clipMv(cMv); |
---|
| 1527 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(); |
---|
[1039] | 1528 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true ); |
---|
| 1529 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true ); |
---|
[1084] | 1530 | |
---|
[443] | 1531 | if( dW > 0 ) |
---|
| 1532 | { |
---|
[608] | 1533 | TComYuv * pYuvB0 = &m_acYuvPredBase[0]; |
---|
[443] | 1534 | TComYuv * pYuvB1 = &m_acYuvPredBase[1]; |
---|
[608] | 1535 | |
---|
| 1536 | TComMv cMVwithDisparity = cMv + cDistparity.m_acNBDV; |
---|
| 1537 | pcCU->clipMv(cMVwithDisparity); |
---|
[1039] | 1538 | if (iWidth <= 8) |
---|
| 1539 | { |
---|
| 1540 | pYuvB0->clear(); pYuvB1->clear(); |
---|
| 1541 | } |
---|
[950] | 1542 | TComMv cNBDV = cDistparity.m_acNBDV; |
---|
| 1543 | pcCU->clipMv( cNBDV ); |
---|
| 1544 | |
---|
[443] | 1545 | pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec(); |
---|
[1039] | 1546 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true ); |
---|
| 1547 | if (iWidth > 8) |
---|
[1084] | 1548 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true ); |
---|
[608] | 1549 | |
---|
[443] | 1550 | pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec(); |
---|
[1039] | 1551 | xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true ); |
---|
[1084] | 1552 | |
---|
[1039] | 1553 | if (iWidth > 8) |
---|
[1084] | 1554 | xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true ); |
---|
| 1555 | |
---|
[608] | 1556 | pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight ); |
---|
| 1557 | |
---|
| 1558 | if( 2 == dW ) |
---|
| 1559 | { |
---|
| 1560 | pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); |
---|
| 1561 | } |
---|
| 1562 | rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi ); |
---|
[443] | 1563 | } |
---|
| 1564 | } |
---|
[1039] | 1565 | |
---|
| 1566 | Bool TComPrediction::xCheckBiInterviewARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eBaseRefPicList, TComPic*& pcPicYuvCurrTRef, TComMv& cBaseTMV, Int& iCurrTRefPoc ) |
---|
| 1567 | { |
---|
| 1568 | Int iRefIdx = pcCU->getCUMvField( eBaseRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 1569 | TComMv cDMv = pcCU->getCUMvField( eBaseRefPicList )->getMv( uiPartAddr ); |
---|
| 1570 | TComPic* pcPicYuvBaseCol = pcCU->getSlice()->getRefPic( eBaseRefPicList, iRefIdx ); |
---|
| 1571 | TComPicYuv* pcYuvBaseCol = pcPicYuvBaseCol->getPicYuvRec(); |
---|
| 1572 | Int uiLCUAddr,uiAbsPartAddr; |
---|
| 1573 | Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2 + ((cDMv.getHor() + 2)>>2); |
---|
| 1574 | Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2); |
---|
| 1575 | |
---|
| 1576 | irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX); |
---|
| 1577 | irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); |
---|
| 1578 | pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr); |
---|
| 1579 | TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr ); |
---|
| 1580 | |
---|
| 1581 | TComPic* pcPicYuvBaseTRef = NULL; |
---|
| 1582 | pcPicYuvCurrTRef = NULL; |
---|
| 1583 | |
---|
| 1584 | //If there is available motion in base reference list, use it |
---|
| 1585 | if(!pColCU->isIntra(uiAbsPartAddr)) |
---|
| 1586 | { |
---|
| 1587 | for(Int iList = 0; iList < (pColCU->getSlice()->isInterB() ? 2: 1); iList ++) |
---|
| 1588 | { |
---|
| 1589 | RefPicList eRefPicListCurr = RefPicList(iList); |
---|
| 1590 | Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr); |
---|
| 1591 | if( iRef != -1) |
---|
| 1592 | { |
---|
| 1593 | pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); |
---|
| 1594 | Int iCurrPOC = pColCU->getSlice()->getPOC(); |
---|
| 1595 | Int iCurrRefPOC = pcPicYuvBaseTRef->getPOC(); |
---|
| 1596 | Int iCurrRef = pcCU->getSlice()->getFirstTRefIdx(eRefPicListCurr); |
---|
[1084] | 1597 | |
---|
[1039] | 1598 | if( iCurrRef >= 0 && iCurrPOC != iCurrRefPOC) |
---|
| 1599 | { |
---|
| 1600 | pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic(eRefPicListCurr,iCurrRef); |
---|
| 1601 | Int iTargetPOC = pcPicYuvCurrTRef->getPOC(); |
---|
| 1602 | pcPicYuvBaseTRef = pcCU->getSlice()->getBaseViewRefPic(iTargetPOC, pcPicYuvBaseCol->getViewIndex() ); |
---|
| 1603 | if(pcPicYuvBaseTRef) |
---|
| 1604 | { |
---|
| 1605 | cBaseTMV = pColCU->getCUMvField(eRefPicListCurr)->getMv(uiAbsPartAddr); |
---|
| 1606 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC); |
---|
| 1607 | if ( iScale != 4096 ) |
---|
| 1608 | { |
---|
| 1609 | cBaseTMV = cBaseTMV.scaleMv( iScale ); |
---|
| 1610 | } |
---|
| 1611 | iCurrTRefPoc = iTargetPOC; |
---|
| 1612 | return true; |
---|
| 1613 | } |
---|
| 1614 | } |
---|
| 1615 | } |
---|
| 1616 | } |
---|
| 1617 | } |
---|
| 1618 | |
---|
| 1619 | //If there is no available motion in base reference list, use ( 0, 0 ) |
---|
| 1620 | if( pcCU->getSlice()->getFirstTRefIdx( eBaseRefPicList ) >= 0 ) |
---|
| 1621 | { |
---|
| 1622 | cBaseTMV.set( 0, 0 ); |
---|
| 1623 | pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic( eBaseRefPicList, pcCU->getSlice()->getFirstTRefIdx( eBaseRefPicList ) ); |
---|
| 1624 | iCurrTRefPoc = pcPicYuvCurrTRef->getPOC(); |
---|
| 1625 | return true; |
---|
| 1626 | } |
---|
| 1627 | |
---|
| 1628 | return false; |
---|
| 1629 | } |
---|
| 1630 | |
---|
[724] | 1631 | Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled ) |
---|
| 1632 | { |
---|
| 1633 | Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
| 1634 | TComMv cDMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); |
---|
| 1635 | TComMv cTempDMv = cDMv; |
---|
| 1636 | UChar dW = pcCU->getARPW ( uiPartAddr ); |
---|
| 1637 | |
---|
| 1638 | TComPic* pcPicYuvBaseTRef = NULL; |
---|
| 1639 | TComPic* pcPicYuvCurrTRef = NULL; |
---|
| 1640 | TComPic* pcPicYuvBaseCol = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx ); |
---|
| 1641 | TComPicYuv* pcYuvBaseCol = pcPicYuvBaseCol->getPicYuvRec(); |
---|
| 1642 | Bool bTMVAvai = false; |
---|
| 1643 | TComMv cBaseTMV; |
---|
| 1644 | if( pNewMvFiled ) |
---|
| 1645 | { |
---|
| 1646 | iRefIdx = pNewMvFiled->getRefIdx(); |
---|
| 1647 | cDMv = pNewMvFiled->getMv(); |
---|
| 1648 | } |
---|
| 1649 | pcCU->clipMv(cTempDMv); |
---|
| 1650 | |
---|
| 1651 | assert(dW > 0); |
---|
| 1652 | if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex())) |
---|
| 1653 | { |
---|
| 1654 | dW = 0; |
---|
| 1655 | } |
---|
| 1656 | Int uiLCUAddr,uiAbsPartAddr; |
---|
| 1657 | Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2 + ((cDMv.getHor() + 2)>>2); |
---|
| 1658 | Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2); |
---|
[443] | 1659 | |
---|
[724] | 1660 | irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX); |
---|
| 1661 | irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); |
---|
| 1662 | pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr); |
---|
| 1663 | TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr ); |
---|
[1039] | 1664 | if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getIsDepth() ) |
---|
| 1665 | { |
---|
| 1666 | RefPicList eOtherRefList = ( eRefPicList == REF_PIC_LIST_0 ) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
| 1667 | Int iOtherRefIdx = pcCU->getCUMvField( eOtherRefList )->getRefIdx( uiPartAddr ); |
---|
| 1668 | //The other prediction direction is temporal ARP |
---|
| 1669 | if( iOtherRefIdx >= 0 && pcCU->getSlice()->getViewIndex() == pcCU->getSlice()->getRefPic( eOtherRefList, iOtherRefIdx )->getViewIndex() ) |
---|
| 1670 | { |
---|
| 1671 | bTMVAvai = true; |
---|
| 1672 | pcPicYuvBaseTRef = pcCU->getSlice()->getRefPic( eOtherRefList, iOtherRefIdx ); |
---|
| 1673 | Int iCurrPOC = pcCU->getSlice()->getPOC(); |
---|
| 1674 | Int iCurrRefPOC = pcPicYuvBaseTRef->getPOC(); |
---|
| 1675 | Int iCurrRef = pcCU->getSlice()->getFirstTRefIdx( eOtherRefList ); |
---|
| 1676 | |
---|
| 1677 | if( iCurrRef >= 0 ) |
---|
| 1678 | { |
---|
| 1679 | pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic( eOtherRefList,iCurrRef ); |
---|
| 1680 | Int iTargetPOC = pcPicYuvCurrTRef->getPOC(); |
---|
| 1681 | pcPicYuvBaseTRef = pcCU->getSlice()->getBaseViewRefPic( iTargetPOC, pcPicYuvBaseCol->getViewIndex() ); |
---|
| 1682 | if( pcPicYuvBaseTRef ) |
---|
| 1683 | { |
---|
| 1684 | cBaseTMV = pcCU->getCUMvField( eOtherRefList )->getMv( uiPartAddr ); |
---|
| 1685 | Int iScale = pcCU-> xGetDistScaleFactor( iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC ); |
---|
| 1686 | if ( iScale != 4096 ) |
---|
| 1687 | { |
---|
| 1688 | cBaseTMV = cBaseTMV.scaleMv( iScale ); |
---|
| 1689 | } |
---|
| 1690 | } |
---|
| 1691 | else |
---|
| 1692 | { |
---|
| 1693 | dW = 0; |
---|
| 1694 | } |
---|
| 1695 | } |
---|
| 1696 | else |
---|
| 1697 | { |
---|
| 1698 | dW = 0; |
---|
| 1699 | } |
---|
| 1700 | } |
---|
[724] | 1701 | |
---|
[1039] | 1702 | //Both prediction directions are inter-view ARP |
---|
| 1703 | if ( iOtherRefIdx >= 0 && !bTMVAvai ) |
---|
| 1704 | { |
---|
| 1705 | RefPicList eBaseList = REF_PIC_LIST_0; |
---|
| 1706 | Int iCurrTRefPoc; |
---|
| 1707 | bTMVAvai = ( eBaseList != eRefPicList ) && ( pcCU->getSlice()->getViewIndex() != pcCU->getSlice()->getRefPic( eOtherRefList, iOtherRefIdx )->getViewIndex() ); |
---|
| 1708 | |
---|
| 1709 | if ( bTMVAvai ) |
---|
| 1710 | { |
---|
| 1711 | if( xCheckBiInterviewARP( pcCU, uiPartAddr, iWidth, iHeight, eBaseList, pcPicYuvCurrTRef, cBaseTMV, iCurrTRefPoc ) ) |
---|
| 1712 | { |
---|
| 1713 | pcPicYuvBaseTRef = pcCU->getSlice()->getBaseViewRefPic( iCurrTRefPoc, pcPicYuvBaseCol->getViewIndex() ); |
---|
| 1714 | if ( pcPicYuvBaseTRef == NULL ) |
---|
| 1715 | { |
---|
| 1716 | dW = 0; |
---|
| 1717 | } |
---|
| 1718 | } |
---|
| 1719 | else |
---|
| 1720 | { |
---|
| 1721 | dW = 0; |
---|
| 1722 | } |
---|
| 1723 | } |
---|
| 1724 | } |
---|
| 1725 | } |
---|
| 1726 | |
---|
| 1727 | if( !pColCU->isIntra( uiAbsPartAddr ) && !bTMVAvai ) |
---|
[724] | 1728 | { |
---|
| 1729 | TComMvField puMVField; |
---|
| 1730 | for(Int iList = 0; iList < (pColCU->getSlice()->isInterB() ? 2: 1) && !bTMVAvai; iList ++) |
---|
| 1731 | { |
---|
| 1732 | RefPicList eRefPicListCurr = RefPicList(iList); |
---|
| 1733 | Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr); |
---|
| 1734 | if( iRef != -1) |
---|
| 1735 | { |
---|
| 1736 | pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); |
---|
| 1737 | Int iCurrPOC = pColCU->getSlice()->getPOC(); |
---|
| 1738 | Int iCurrRefPOC = pcPicYuvBaseTRef->getPOC(); |
---|
| 1739 | Int iCurrRef = pcCU->getSlice()->getFirstTRefIdx(eRefPicListCurr); |
---|
[1039] | 1740 | if (iCurrRef >= 0 && iCurrRefPOC != iCurrPOC) |
---|
[724] | 1741 | { |
---|
| 1742 | pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic(eRefPicListCurr,iCurrRef); |
---|
| 1743 | Int iTargetPOC = pcPicYuvCurrTRef->getPOC(); |
---|
| 1744 | { |
---|
| 1745 | pcPicYuvBaseTRef = pcCU->getSlice()->getBaseViewRefPic(iTargetPOC, pcPicYuvBaseCol->getViewIndex() ); |
---|
| 1746 | if(pcPicYuvBaseTRef) |
---|
| 1747 | { |
---|
| 1748 | cBaseTMV = pColCU->getCUMvField(eRefPicListCurr)->getMv(uiAbsPartAddr); |
---|
| 1749 | Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC); |
---|
| 1750 | if ( iScale != 4096 ) |
---|
| 1751 | cBaseTMV = cBaseTMV.scaleMv( iScale ); |
---|
| 1752 | bTMVAvai = true; |
---|
| 1753 | break; |
---|
| 1754 | } |
---|
| 1755 | } |
---|
| 1756 | } |
---|
| 1757 | } |
---|
| 1758 | } |
---|
| 1759 | } |
---|
| 1760 | if (bTMVAvai == false) |
---|
| 1761 | { |
---|
| 1762 | bTMVAvai = true; |
---|
| 1763 | cBaseTMV.set(0, 0); |
---|
| 1764 | pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicList, pcCU->getSlice()->getFirstTRefIdx(eRefPicList)); |
---|
| 1765 | pcPicYuvCurrTRef = pcCU->getSlice()->getRefPic (eRefPicList, pcCU->getSlice()->getFirstTRefIdx(eRefPicList)); |
---|
| 1766 | } |
---|
[1084] | 1767 | |
---|
[1039] | 1768 | xPredInterLumaBlk ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ), bTMVAvai); |
---|
| 1769 | xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ), bTMVAvai); |
---|
[1084] | 1770 | |
---|
[724] | 1771 | if( dW > 0 && bTMVAvai ) |
---|
| 1772 | { |
---|
| 1773 | TComYuv* pYuvCurrTRef = &m_acYuvPredBase[0]; |
---|
| 1774 | TComYuv* pYuvBaseTRef = &m_acYuvPredBase[1]; |
---|
| 1775 | TComPicYuv* pcYuvCurrTref = pcPicYuvCurrTRef->getPicYuvRec(); |
---|
| 1776 | TComPicYuv* pcYuvBaseTref = pcPicYuvBaseTRef->getPicYuvRec(); |
---|
| 1777 | TComMv cTempMv = cDMv + cBaseTMV; |
---|
| 1778 | |
---|
| 1779 | pcCU->clipMv(cBaseTMV); |
---|
| 1780 | pcCU->clipMv(cTempMv); |
---|
[1084] | 1781 | |
---|
[1039] | 1782 | if (iWidth <= 8) |
---|
| 1783 | { |
---|
| 1784 | pYuvCurrTRef->clear(); pYuvBaseTRef->clear(); |
---|
| 1785 | } |
---|
| 1786 | xPredInterLumaBlk ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true, true); |
---|
[1084] | 1787 | |
---|
[1039] | 1788 | if (iWidth > 8) |
---|
[1084] | 1789 | xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true, true); |
---|
| 1790 | |
---|
[1039] | 1791 | xPredInterLumaBlk ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, true, true); |
---|
[1084] | 1792 | |
---|
[1039] | 1793 | if (iWidth > 8) |
---|
[1084] | 1794 | xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, true, true); |
---|
[724] | 1795 | |
---|
| 1796 | pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight ); |
---|
| 1797 | if(dW == 2) |
---|
| 1798 | { |
---|
| 1799 | pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); |
---|
| 1800 | } |
---|
| 1801 | rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi ); |
---|
| 1802 | } |
---|
| 1803 | } |
---|
| 1804 | #endif |
---|
| 1805 | |
---|
[1200] | 1806 | Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvPred ) |
---|
[2] | 1807 | { |
---|
[56] | 1808 | TComYuv* pcMbYuv; |
---|
[1200] | 1809 | Int iRefIdx[NUM_REF_PIC_LIST_01] = {-1, -1}; |
---|
[56] | 1810 | |
---|
[1200] | 1811 | for ( UInt refList = 0; refList < NUM_REF_PIC_LIST_01; refList++ ) |
---|
[56] | 1812 | { |
---|
[1200] | 1813 | RefPicList eRefPicList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); |
---|
| 1814 | iRefIdx[refList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
[56] | 1815 | |
---|
[1200] | 1816 | if ( iRefIdx[refList] < 0 ) |
---|
[56] | 1817 | { |
---|
| 1818 | continue; |
---|
| 1819 | } |
---|
| 1820 | |
---|
[1200] | 1821 | assert( iRefIdx[refList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
[56] | 1822 | |
---|
[1200] | 1823 | pcMbYuv = &m_acYuvPred[refList]; |
---|
[56] | 1824 | if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) |
---|
| 1825 | { |
---|
[608] | 1826 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
[56] | 1827 | } |
---|
| 1828 | else |
---|
| 1829 | { |
---|
[1200] | 1830 | if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || |
---|
| 1831 | ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) ) |
---|
[56] | 1832 | { |
---|
[608] | 1833 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); |
---|
[56] | 1834 | } |
---|
| 1835 | else |
---|
| 1836 | { |
---|
[608] | 1837 | xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv ); |
---|
[56] | 1838 | } |
---|
| 1839 | } |
---|
| 1840 | } |
---|
[608] | 1841 | |
---|
[1200] | 1842 | if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) |
---|
[56] | 1843 | { |
---|
[1200] | 1844 | xWeightedPredictionBi( pcCU, &m_acYuvPred[REF_PIC_LIST_0], &m_acYuvPred[REF_PIC_LIST_1], iRefIdx[REF_PIC_LIST_0], iRefIdx[REF_PIC_LIST_1], uiPartAddr, iWidth, iHeight, pcYuvPred ); |
---|
| 1845 | } |
---|
[313] | 1846 | else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) |
---|
| 1847 | { |
---|
[1200] | 1848 | xWeightedPredictionUni( pcCU, &m_acYuvPred[REF_PIC_LIST_0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); |
---|
[313] | 1849 | } |
---|
[56] | 1850 | else |
---|
| 1851 | { |
---|
[1200] | 1852 | xWeightedAverage( &m_acYuvPred[REF_PIC_LIST_0], &m_acYuvPred[REF_PIC_LIST_1], iRefIdx[REF_PIC_LIST_0], iRefIdx[REF_PIC_LIST_1], uiPartAddr, iWidth, iHeight, pcYuvPred, pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
[56] | 1853 | } |
---|
[2] | 1854 | } |
---|
| 1855 | |
---|
[608] | 1856 | #if H_3D_VSP |
---|
[296] | 1857 | |
---|
[608] | 1858 | Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) |
---|
| 1859 | { |
---|
| 1860 | TComYuv* pcMbYuv; |
---|
| 1861 | Int iRefIdx[2] = {-1, -1}; |
---|
| 1862 | Bool bi = (pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0); |
---|
[296] | 1863 | |
---|
[608] | 1864 | for ( Int iRefList = 0; iRefList < 2; iRefList++ ) |
---|
[2] | 1865 | { |
---|
[608] | 1866 | RefPicList eRefPicList = RefPicList(iRefList); |
---|
| 1867 | iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); |
---|
[56] | 1868 | |
---|
[608] | 1869 | if ( iRefIdx[iRefList] < 0 ) |
---|
[622] | 1870 | { |
---|
[608] | 1871 | continue; |
---|
[622] | 1872 | } |
---|
[608] | 1873 | assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); |
---|
[56] | 1874 | |
---|
[608] | 1875 | pcMbYuv = &m_acYuvPred[iRefList]; |
---|
| 1876 | xPredInterUniVSP ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, bi ); |
---|
[2] | 1877 | } |
---|
[296] | 1878 | |
---|
[608] | 1879 | xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); |
---|
| 1880 | } |
---|
[296] | 1881 | |
---|
| 1882 | #endif |
---|
[56] | 1883 | |
---|
| 1884 | /** |
---|
[1200] | 1885 | * \brief Generate motion-compensated block |
---|
[56] | 1886 | * |
---|
[1200] | 1887 | * \param compID Colour component ID |
---|
| 1888 | * \param cu Pointer to current CU |
---|
| 1889 | * \param refPic Pointer to reference picture |
---|
| 1890 | * \param partAddr Address of block within CU |
---|
| 1891 | * \param mv Motion vector |
---|
| 1892 | * \param width Width of block |
---|
| 1893 | * \param height Height of block |
---|
| 1894 | * \param dstPic Pointer to destination picture |
---|
| 1895 | * \param bi Flag indicating whether bipred is used |
---|
| 1896 | * \param bitDepth Bit depth |
---|
[56] | 1897 | */ |
---|
[1200] | 1898 | |
---|
| 1899 | |
---|
| 1900 | Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth |
---|
[608] | 1901 | #if H_3D_ARP |
---|
| 1902 | , Bool filterType |
---|
[189] | 1903 | #endif |
---|
[608] | 1904 | #if H_3D_IC |
---|
| 1905 | , Bool bICFlag |
---|
| 1906 | #endif |
---|
[1200] | 1907 | ) |
---|
[56] | 1908 | { |
---|
[1200] | 1909 | Int refStride = refPic->getStride(compID); |
---|
| 1910 | Int dstStride = dstPic->getStride(compID); |
---|
| 1911 | Int shiftHor=(2+refPic->getComponentScaleX(compID)); |
---|
| 1912 | Int shiftVer=(2+refPic->getComponentScaleY(compID)); |
---|
[56] | 1913 | |
---|
[1200] | 1914 | Int refOffset = (mv->getHor() >> shiftHor) + (mv->getVer() >> shiftVer) * refStride; |
---|
| 1915 | |
---|
| 1916 | Pel* ref = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset; |
---|
| 1917 | |
---|
| 1918 | Pel* dst = dstPic->getAddr( compID, partAddr ); |
---|
| 1919 | |
---|
| 1920 | Int xFrac = mv->getHor() & ((1<<shiftHor)-1); |
---|
| 1921 | Int yFrac = mv->getVer() & ((1<<shiftVer)-1); |
---|
| 1922 | |
---|
[608] | 1923 | #if H_3D_IC |
---|
| 1924 | if( cu->getSlice()->getIsDepth() ) |
---|
| 1925 | { |
---|
| 1926 | refOffset = mv->getHor() + mv->getVer() * refStride; |
---|
| 1927 | ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; |
---|
| 1928 | xFrac = 0; |
---|
| 1929 | yFrac = 0; |
---|
| 1930 | } |
---|
[56] | 1931 | #endif |
---|
[1200] | 1932 | |
---|
| 1933 | UInt cxWidth = width >> refPic->getComponentScaleX(compID); |
---|
| 1934 | UInt cxHeight = height >> refPic->getComponentScaleY(compID); |
---|
| 1935 | |
---|
| 1936 | const ChromaFormat chFmt = cu->getPic()->getChromaFormat(); |
---|
| 1937 | |
---|
[56] | 1938 | if ( yFrac == 0 ) |
---|
[2] | 1939 | { |
---|
[655] | 1940 | #if H_3D_IC |
---|
[608] | 1941 | m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi || bICFlag |
---|
| 1942 | #else |
---|
[1200] | 1943 | m_if.filterHor(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth |
---|
[443] | 1944 | #endif |
---|
[1200] | 1945 | #if H_3D_ARP |
---|
[608] | 1946 | , filterType |
---|
[1200] | 1947 | #endif |
---|
| 1948 | ); |
---|
[2] | 1949 | } |
---|
[56] | 1950 | else if ( xFrac == 0 ) |
---|
| 1951 | { |
---|
[655] | 1952 | #if H_3D_IC |
---|
[608] | 1953 | m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag |
---|
| 1954 | #else |
---|
[1200] | 1955 | m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth |
---|
[443] | 1956 | #endif |
---|
[608] | 1957 | #if H_3D_ARP |
---|
| 1958 | , filterType |
---|
| 1959 | #endif |
---|
[1200] | 1960 | ); |
---|
[56] | 1961 | } |
---|
| 1962 | else |
---|
| 1963 | { |
---|
[1200] | 1964 | Int tmpStride = m_filteredBlockTmp[0].getStride(compID); |
---|
| 1965 | Pel* tmp = m_filteredBlockTmp[0].getAddr(compID); |
---|
[56] | 1966 | |
---|
[1200] | 1967 | const Int vFilterSize = isLuma(compID) ? NTAPS_LUMA : NTAPS_CHROMA; |
---|
[56] | 1968 | |
---|
[1200] | 1969 | m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false, chFmt, bitDepth |
---|
[608] | 1970 | #if H_3D_ARP |
---|
| 1971 | , filterType |
---|
[443] | 1972 | #endif |
---|
[1200] | 1973 | ); |
---|
[655] | 1974 | #if H_3D_IC |
---|
[608] | 1975 | m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi || bICFlag |
---|
| 1976 | #else |
---|
[1200] | 1977 | m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight, yFrac, false, !bi, chFmt, bitDepth |
---|
[608] | 1978 | #endif |
---|
| 1979 | #if H_3D_ARP |
---|
| 1980 | , filterType |
---|
[443] | 1981 | #endif |
---|
[1200] | 1982 | ); |
---|
[56] | 1983 | } |
---|
[189] | 1984 | |
---|
[608] | 1985 | #if H_3D_IC |
---|
| 1986 | if( bICFlag ) |
---|
[189] | 1987 | { |
---|
[608] | 1988 | Int a, b, i, j; |
---|
| 1989 | const Int iShift = IC_CONST_SHIFT; |
---|
| 1990 | |
---|
| 1991 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA ); |
---|
[189] | 1992 | |
---|
| 1993 | |
---|
[608] | 1994 | for ( i = 0; i < height; i++ ) |
---|
[189] | 1995 | { |
---|
[608] | 1996 | for ( j = 0; j < width; j++ ) |
---|
[189] | 1997 | { |
---|
[608] | 1998 | dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b ); |
---|
[189] | 1999 | } |
---|
| 2000 | dst += dstStride; |
---|
| 2001 | } |
---|
[655] | 2002 | |
---|
[608] | 2003 | if(bi) |
---|
| 2004 | { |
---|
| 2005 | Pel *dst2 = dstPic->getLumaAddr( partAddr ); |
---|
| 2006 | Int shift = IF_INTERNAL_PREC - g_bitDepthY; |
---|
| 2007 | for (i = 0; i < height; i++) |
---|
| 2008 | { |
---|
| 2009 | for (j = 0; j < width; j++) |
---|
| 2010 | { |
---|
| 2011 | Short val = dst2[j] << shift; |
---|
| 2012 | dst2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
| 2013 | } |
---|
| 2014 | dst2 += dstStride; |
---|
| 2015 | } |
---|
| 2016 | } |
---|
[189] | 2017 | } |
---|
| 2018 | #endif |
---|
[1200] | 2019 | |
---|
[2] | 2020 | } |
---|
| 2021 | |
---|
[1200] | 2022 | |
---|
[608] | 2023 | #if H_3D_ARP |
---|
| 2024 | , Bool filterType |
---|
[189] | 2025 | #endif |
---|
[608] | 2026 | #if H_3D_IC |
---|
| 2027 | , Bool bICFlag |
---|
| 2028 | #endif |
---|
[655] | 2029 | #if H_3D_IC |
---|
[608] | 2030 | m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag |
---|
| 2031 | #else |
---|
| 2032 | #endif |
---|
| 2033 | #if H_3D_ARP |
---|
| 2034 | , filterType |
---|
| 2035 | #endif |
---|
[655] | 2036 | #if H_3D_IC |
---|
[608] | 2037 | m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag |
---|
| 2038 | #else |
---|
| 2039 | #endif |
---|
| 2040 | #if H_3D_ARP |
---|
| 2041 | , filterType |
---|
| 2042 | #endif |
---|
[655] | 2043 | #if H_3D_IC |
---|
[608] | 2044 | m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag |
---|
| 2045 | #else |
---|
| 2046 | #endif |
---|
| 2047 | #if H_3D_ARP |
---|
| 2048 | , filterType |
---|
| 2049 | #endif |
---|
[655] | 2050 | #if H_3D_IC |
---|
[608] | 2051 | m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag |
---|
| 2052 | #else |
---|
| 2053 | #endif |
---|
| 2054 | #if H_3D_ARP |
---|
| 2055 | , filterType |
---|
| 2056 | #endif |
---|
| 2057 | #if H_3D_ARP |
---|
| 2058 | , filterType |
---|
| 2059 | #endif |
---|
[655] | 2060 | #if H_3D_IC |
---|
[608] | 2061 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag |
---|
| 2062 | #else |
---|
| 2063 | #endif |
---|
| 2064 | #if H_3D_ARP |
---|
| 2065 | , filterType |
---|
| 2066 | #endif |
---|
| 2067 | #if H_3D_ARP |
---|
| 2068 | , filterType |
---|
| 2069 | #endif |
---|
[655] | 2070 | #if H_3D_IC |
---|
[608] | 2071 | m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag |
---|
| 2072 | #else |
---|
| 2073 | #endif |
---|
| 2074 | #if H_3D_ARP |
---|
| 2075 | , filterType |
---|
| 2076 | #endif |
---|
| 2077 | #if H_3D_IC |
---|
| 2078 | if( bICFlag ) |
---|
[189] | 2079 | { |
---|
[608] | 2080 | Int a, b, i, j; |
---|
| 2081 | const Int iShift = IC_CONST_SHIFT; |
---|
[1124] | 2082 | |
---|
[608] | 2083 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb |
---|
| 2084 | for ( i = 0; i < cxHeight; i++ ) |
---|
[189] | 2085 | { |
---|
[608] | 2086 | for ( j = 0; j < cxWidth; j++ ) |
---|
[189] | 2087 | { |
---|
[608] | 2088 | dstCb[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b ); |
---|
[189] | 2089 | } |
---|
| 2090 | dstCb += dstStride; |
---|
| 2091 | } |
---|
[608] | 2092 | xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr |
---|
| 2093 | for ( i = 0; i < cxHeight; i++ ) |
---|
[189] | 2094 | { |
---|
[608] | 2095 | for ( j = 0; j < cxWidth; j++ ) |
---|
[189] | 2096 | { |
---|
[608] | 2097 | dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b ); |
---|
[189] | 2098 | } |
---|
| 2099 | dstCr += dstStride; |
---|
| 2100 | } |
---|
[655] | 2101 | |
---|
[608] | 2102 | if(bi) |
---|
[296] | 2103 | { |
---|
[608] | 2104 | Pel* dstCb2 = dstPic->getCbAddr( partAddr ); |
---|
| 2105 | Pel* dstCr2 = dstPic->getCrAddr( partAddr ); |
---|
| 2106 | Int shift = IF_INTERNAL_PREC - g_bitDepthC; |
---|
| 2107 | for (i = 0; i < cxHeight; i++) |
---|
[296] | 2108 | { |
---|
[608] | 2109 | for (j = 0; j < cxWidth; j++) |
---|
[296] | 2110 | { |
---|
[608] | 2111 | Short val = dstCb2[j] << shift; |
---|
| 2112 | dstCb2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
[461] | 2113 | |
---|
[608] | 2114 | val = dstCr2[j] << shift; |
---|
| 2115 | dstCr2[j] = val - (Short)IF_INTERNAL_OFFS; |
---|
[296] | 2116 | } |
---|
[608] | 2117 | dstCb2 += dstStride; |
---|
| 2118 | dstCr2 += dstStride; |
---|
[443] | 2119 | } |
---|
| 2120 | } |
---|
[296] | 2121 | } |
---|
[443] | 2122 | #endif |
---|
[1200] | 2123 | Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths |
---|
| 2124 | ) |
---|
[2] | 2125 | { |
---|
[56] | 2126 | if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) |
---|
[2] | 2127 | { |
---|
[1200] | 2128 | pcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, clipBitDepths ); |
---|
[2] | 2129 | } |
---|
[56] | 2130 | else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) |
---|
[2] | 2131 | { |
---|
[1200] | 2132 | pcYuvSrc0->copyPartToPartYuv( pcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
[2] | 2133 | } |
---|
[56] | 2134 | else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) |
---|
[2] | 2135 | { |
---|
[1200] | 2136 | pcYuvSrc1->copyPartToPartYuv( pcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
[56] | 2137 | } |
---|
| 2138 | } |
---|
| 2139 | |
---|
| 2140 | // AMVP |
---|
[608] | 2141 | Void TComPrediction::getMvPredAMVP( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred ) |
---|
[56] | 2142 | { |
---|
| 2143 | AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
[1200] | 2144 | |
---|
[608] | 2145 | if( pcAMVPInfo->iN <= 1 ) |
---|
[56] | 2146 | { |
---|
| 2147 | rcMvPred = pcAMVPInfo->m_acMvCand[0]; |
---|
| 2148 | |
---|
| 2149 | pcCU->setMVPIdxSubParts( 0, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 2150 | pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr)); |
---|
| 2151 | return; |
---|
| 2152 | } |
---|
| 2153 | |
---|
| 2154 | assert(pcCU->getMVPIdx(eRefPicList,uiPartAddr) >= 0); |
---|
| 2155 | rcMvPred = pcAMVPInfo->m_acMvCand[pcCU->getMVPIdx(eRefPicList,uiPartAddr)]; |
---|
| 2156 | return; |
---|
| 2157 | } |
---|
| 2158 | |
---|
| 2159 | /** Function for deriving planar intra prediction. |
---|
[1200] | 2160 | * \param pSrc pointer to reconstructed sample array |
---|
| 2161 | * \param srcStride the stride of the reconstructed sample array |
---|
| 2162 | * \param rpDst reference to pointer for the prediction sample array |
---|
| 2163 | * \param dstStride the stride of the prediction sample array |
---|
| 2164 | * \param width the width of the block |
---|
| 2165 | * \param height the height of the block |
---|
| 2166 | * \param channelType type of pel array (luma, chroma) |
---|
| 2167 | * \param format chroma format |
---|
[56] | 2168 | * |
---|
| 2169 | * This function derives the prediction samples for planar mode (intra coding). |
---|
| 2170 | */ |
---|
[1200] | 2171 | //NOTE: Bit-Limit - 24-bit source |
---|
| 2172 | Void TComPrediction::xPredIntraPlanar( const Pel* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) |
---|
[56] | 2173 | { |
---|
[1200] | 2174 | assert(width <= height); |
---|
[56] | 2175 | |
---|
[655] | 2176 | Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; |
---|
[1200] | 2177 | UInt shift1Dhor = g_aucConvertToBit[ width ] + 2; |
---|
| 2178 | UInt shift1Dver = g_aucConvertToBit[ height ] + 2; |
---|
[56] | 2179 | |
---|
| 2180 | // Get left and above reference column and row |
---|
[1200] | 2181 | for(Int k=0;k<width+1;k++) |
---|
[56] | 2182 | { |
---|
| 2183 | topRow[k] = pSrc[k-srcStride]; |
---|
[1200] | 2184 | } |
---|
| 2185 | |
---|
| 2186 | for (Int k=0; k < height+1; k++) |
---|
| 2187 | { |
---|
[56] | 2188 | leftColumn[k] = pSrc[k*srcStride-1]; |
---|
| 2189 | } |
---|
| 2190 | |
---|
| 2191 | // Prepare intermediate variables used in interpolation |
---|
[1200] | 2192 | Int bottomLeft = leftColumn[height]; |
---|
| 2193 | Int topRight = topRow[width]; |
---|
| 2194 | |
---|
| 2195 | for(Int k=0;k<width;k++) |
---|
[56] | 2196 | { |
---|
[1200] | 2197 | bottomRow[k] = bottomLeft - topRow[k]; |
---|
| 2198 | topRow[k] <<= shift1Dver; |
---|
[56] | 2199 | } |
---|
| 2200 | |
---|
[1200] | 2201 | for(Int k=0;k<height;k++) |
---|
| 2202 | { |
---|
| 2203 | rightColumn[k] = topRight - leftColumn[k]; |
---|
| 2204 | leftColumn[k] <<= shift1Dhor; |
---|
| 2205 | } |
---|
| 2206 | |
---|
| 2207 | const UInt topRowShift = 0; |
---|
| 2208 | |
---|
[56] | 2209 | // Generate prediction signal |
---|
[1200] | 2210 | for (Int y=0;y<height;y++) |
---|
[56] | 2211 | { |
---|
[1200] | 2212 | Int horPred = leftColumn[y] + width; |
---|
| 2213 | for (Int x=0;x<width;x++) |
---|
[2] | 2214 | { |
---|
[1200] | 2215 | horPred += rightColumn[y]; |
---|
| 2216 | topRow[x] += bottomRow[x]; |
---|
| 2217 | |
---|
| 2218 | Int vertPred = ((topRow[x] + topRowShift)>>topRowShift); |
---|
| 2219 | rpDst[y*dstStride+x] = ( horPred + vertPred ) >> (shift1Dhor+1); |
---|
[2] | 2220 | } |
---|
| 2221 | } |
---|
| 2222 | } |
---|
| 2223 | |
---|
[608] | 2224 | /** Function for filtering intra DC predictor. |
---|
| 2225 | * \param pSrc pointer to reconstructed sample array |
---|
| 2226 | * \param iSrcStride the stride of the reconstructed sample array |
---|
[1200] | 2227 | * \param pDst reference to pointer for the prediction sample array |
---|
[608] | 2228 | * \param iDstStride the stride of the prediction sample array |
---|
| 2229 | * \param iWidth the width of the block |
---|
| 2230 | * \param iHeight the height of the block |
---|
[1200] | 2231 | * \param channelType type of pel array (luma, chroma) |
---|
[56] | 2232 | * |
---|
[608] | 2233 | * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). |
---|
[56] | 2234 | */ |
---|
[1200] | 2235 | Void TComPrediction::xDCPredFiltering( const Pel* pSrc, Int iSrcStride, Pel* pDst, Int iDstStride, Int iWidth, Int iHeight, ChannelType channelType ) |
---|
[56] | 2236 | { |
---|
[608] | 2237 | Int x, y, iDstStride2, iSrcStride2; |
---|
[2] | 2238 | |
---|
[1200] | 2239 | if (isLuma(channelType) && (iWidth <= MAXIMUM_INTRA_FILTERED_WIDTH) && (iHeight <= MAXIMUM_INTRA_FILTERED_HEIGHT)) |
---|
[2] | 2240 | { |
---|
[1200] | 2241 | //top-left |
---|
| 2242 | pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); |
---|
[2] | 2243 | |
---|
[1200] | 2244 | //top row (vertical filter) |
---|
| 2245 | for ( x = 1; x < iWidth; x++ ) |
---|
| 2246 | { |
---|
| 2247 | pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); |
---|
| 2248 | } |
---|
| 2249 | |
---|
| 2250 | //left column (horizontal filter) |
---|
| 2251 | for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) |
---|
| 2252 | { |
---|
| 2253 | pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); |
---|
| 2254 | } |
---|
[56] | 2255 | } |
---|
[2] | 2256 | |
---|
[608] | 2257 | return; |
---|
[2] | 2258 | } |
---|
[1200] | 2259 | |
---|
| 2260 | /* Static member function */ |
---|
| 2261 | Bool TComPrediction::UseDPCMForFirstPassIntraEstimation(TComTU &rTu, const UInt uiDirMode) |
---|
| 2262 | { |
---|
| 2263 | return (rTu.getCU()->isRDPCMEnabled(rTu.GetAbsPartIdxTU()) ) && |
---|
| 2264 | rTu.getCU()->getCUTransquantBypass(rTu.GetAbsPartIdxTU()) && |
---|
| 2265 | (uiDirMode==HOR_IDX || uiDirMode==VER_IDX); |
---|
| 2266 | } |
---|
[608] | 2267 | #if H_3D_IC |
---|
| 2268 | /** Function for deriving the position of first non-zero binary bit of a value |
---|
[56] | 2269 | * \param x input value |
---|
| 2270 | * |
---|
[608] | 2271 | * This function derives the position of first non-zero binary bit of a value |
---|
[56] | 2272 | */ |
---|
| 2273 | Int GetMSB( UInt x ) |
---|
| 2274 | { |
---|
| 2275 | Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; |
---|
| 2276 | |
---|
| 2277 | while( x > 1 ) |
---|
| 2278 | { |
---|
| 2279 | bits >>= 1; |
---|
| 2280 | y = x >> bits; |
---|
| 2281 | |
---|
| 2282 | if( y ) |
---|
| 2283 | { |
---|
| 2284 | x = y; |
---|
| 2285 | iMSB += bits; |
---|
| 2286 | } |
---|
| 2287 | } |
---|
| 2288 | |
---|
| 2289 | iMSB+=y; |
---|
| 2290 | |
---|
| 2291 | return iMSB; |
---|
| 2292 | } |
---|
| 2293 | |
---|
| 2294 | |
---|
[608] | 2295 | /** Function for deriving LM illumination compensation. |
---|
[56] | 2296 | */ |
---|
[608] | 2297 | Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType ) |
---|
[56] | 2298 | { |
---|
[608] | 2299 | TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); |
---|
| 2300 | Pel *pRec = NULL, *pRef = NULL; |
---|
| 2301 | UInt uiWidth, uiHeight, uiTmpPartIdx; |
---|
| 2302 | Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride(); |
---|
| 2303 | Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride(); |
---|
[1039] | 2304 | Int iRefOffset, iHor, iVer; |
---|
[608] | 2305 | iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 ); |
---|
| 2306 | iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 ); |
---|
| 2307 | if( eType != TEXT_LUMA ) |
---|
| 2308 | { |
---|
| 2309 | iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 ); |
---|
| 2310 | iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 ); |
---|
| 2311 | } |
---|
| 2312 | uiWidth = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 ) : ( pcCU->getWidth( 0 ) >> 1 ); |
---|
| 2313 | uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1 ); |
---|
[56] | 2314 | |
---|
| 2315 | Int i, j, iCountShift = 0; |
---|
| 2316 | |
---|
| 2317 | // LLS parameters estimation --> |
---|
| 2318 | |
---|
| 2319 | Int x = 0, y = 0, xx = 0, xy = 0; |
---|
[608] | 2320 | Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12); |
---|
[56] | 2321 | |
---|
[1039] | 2322 | if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) ) |
---|
[56] | 2323 | { |
---|
[608] | 2324 | iRefOffset = iHor + iVer * iRefStride - iRefStride; |
---|
| 2325 | if( eType == TEXT_LUMA ) |
---|
[56] | 2326 | { |
---|
[608] | 2327 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 2328 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
[56] | 2329 | } |
---|
[608] | 2330 | else if( eType == TEXT_CHROMA_U ) |
---|
[56] | 2331 | { |
---|
[608] | 2332 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 2333 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
[56] | 2334 | } |
---|
[608] | 2335 | else |
---|
| 2336 | { |
---|
| 2337 | assert( eType == TEXT_CHROMA_V ); |
---|
| 2338 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 2339 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; |
---|
| 2340 | } |
---|
[56] | 2341 | |
---|
[608] | 2342 | for( j = 0; j < uiWidth; j+=2 ) |
---|
[189] | 2343 | { |
---|
| 2344 | x += pRef[j]; |
---|
| 2345 | y += pRec[j]; |
---|
[1124] | 2346 | if ( eType == TEXT_LUMA ) |
---|
| 2347 | { |
---|
| 2348 | xx += (pRef[j] * pRef[j])>>precShift; |
---|
| 2349 | xy += (pRef[j] * pRec[j])>>precShift; |
---|
| 2350 | } |
---|
[189] | 2351 | } |
---|
[608] | 2352 | iCountShift += g_aucConvertToBit[ uiWidth ] + 1; |
---|
[189] | 2353 | } |
---|
| 2354 | |
---|
[1039] | 2355 | if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) ) |
---|
[189] | 2356 | { |
---|
[608] | 2357 | iRefOffset = iHor + iVer * iRefStride - 1; |
---|
| 2358 | if( eType == TEXT_LUMA ) |
---|
| 2359 | { |
---|
| 2360 | pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 2361 | pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 2362 | } |
---|
| 2363 | else if( eType == TEXT_CHROMA_U ) |
---|
| 2364 | { |
---|
| 2365 | pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 2366 | pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 2367 | } |
---|
| 2368 | else |
---|
| 2369 | { |
---|
| 2370 | assert( eType == TEXT_CHROMA_V ); |
---|
| 2371 | pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; |
---|
| 2372 | pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; |
---|
| 2373 | } |
---|
| 2374 | |
---|
| 2375 | for( i = 0; i < uiHeight; i+=2 ) |
---|
[189] | 2376 | { |
---|
| 2377 | x += pRef[0]; |
---|
| 2378 | y += pRec[0]; |
---|
[1124] | 2379 | if ( eType == TEXT_LUMA ) |
---|
| 2380 | { |
---|
| 2381 | xx += (pRef[0] * pRef[0])>>precShift; |
---|
| 2382 | xy += (pRef[0] * pRec[0])>>precShift; |
---|
| 2383 | } |
---|
[608] | 2384 | pRef += iRefStride*2; |
---|
| 2385 | pRec += iRecStride*2; |
---|
[189] | 2386 | } |
---|
[608] | 2387 | iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 1 ); |
---|
[189] | 2388 | } |
---|
| 2389 | |
---|
[1039] | 2390 | if( iCountShift == 0 ) |
---|
| 2391 | { |
---|
| 2392 | a = ( 1 << IC_CONST_SHIFT ); |
---|
| 2393 | b = 0; |
---|
| 2394 | return; |
---|
| 2395 | } |
---|
| 2396 | |
---|
[1124] | 2397 | if ( eType != TEXT_LUMA ) |
---|
| 2398 | { |
---|
| 2399 | a = 32; |
---|
| 2400 | b = ( y - x + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 2401 | } |
---|
| 2402 | else |
---|
| 2403 | { |
---|
[608] | 2404 | xy += xx >> IC_REG_COST_SHIFT; |
---|
| 2405 | xx += xx >> IC_REG_COST_SHIFT; |
---|
| 2406 | Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift); |
---|
| 2407 | Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift); |
---|
| 2408 | const Int iShift = IC_CONST_SHIFT; |
---|
| 2409 | { |
---|
[189] | 2410 | { |
---|
| 2411 | const Int iShiftA2 = 6; |
---|
| 2412 | const Int iAccuracyShift = 15; |
---|
| 2413 | |
---|
| 2414 | Int iScaleShiftA2 = 0; |
---|
| 2415 | Int iScaleShiftA1 = 0; |
---|
| 2416 | Int a1s = a1; |
---|
| 2417 | Int a2s = a2; |
---|
| 2418 | |
---|
[608] | 2419 | a1 = Clip3(0, 2*a2, a1); |
---|
| 2420 | iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; |
---|
| 2421 | iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF; |
---|
[189] | 2422 | |
---|
| 2423 | if( iScaleShiftA1 < 0 ) |
---|
| 2424 | { |
---|
| 2425 | iScaleShiftA1 = 0; |
---|
| 2426 | } |
---|
| 2427 | |
---|
| 2428 | if( iScaleShiftA2 < 0 ) |
---|
| 2429 | { |
---|
| 2430 | iScaleShiftA2 = 0; |
---|
| 2431 | } |
---|
| 2432 | |
---|
| 2433 | Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; |
---|
| 2434 | |
---|
[608] | 2435 | |
---|
[189] | 2436 | a2s = a2 >> iScaleShiftA2; |
---|
| 2437 | |
---|
| 2438 | a1s = a1 >> iScaleShiftA1; |
---|
| 2439 | |
---|
[608] | 2440 | a = a1s * m_uiaShift[ a2s ]; |
---|
| 2441 | a = a >> iScaleShiftA; |
---|
[189] | 2442 | b = ( y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; |
---|
| 2443 | } |
---|
| 2444 | } |
---|
[1124] | 2445 | } |
---|
[189] | 2446 | } |
---|
[608] | 2447 | #endif |
---|
[189] | 2448 | |
---|
[608] | 2449 | #if H_3D_DIM |
---|
| 2450 | Void TComPrediction::xPredBiSegDCs( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ) |
---|
[2] | 2451 | { |
---|
[608] | 2452 | Int refDC1, refDC2; |
---|
| 2453 | const Int iTR = ( patternStride - 1 ) - srcStride; |
---|
| 2454 | const Int iTM = ( ( patternStride - 1 ) >> 1 ) - srcStride; |
---|
| 2455 | const Int iLB = ( patternStride - 1 ) * srcStride - 1; |
---|
| 2456 | const Int iLM = ( ( patternStride - 1 ) >> 1 ) * srcStride - 1; |
---|
[2] | 2457 | |
---|
[608] | 2458 | Bool bL = ( biSegPattern[0] != biSegPattern[(patternStride-1)*patternStride] ); |
---|
| 2459 | Bool bT = ( biSegPattern[0] != biSegPattern[(patternStride-1)] ); |
---|
| 2460 | |
---|
| 2461 | if( bL == bT ) |
---|
[56] | 2462 | { |
---|
[833] | 2463 | const Int iTRR = ( patternStride * 2 - 1 ) - srcStride; |
---|
| 2464 | const Int iLBB = ( patternStride * 2 - 1 ) * srcStride - 1; |
---|
| 2465 | refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : (abs(ptrSrc[iTRR] - ptrSrc[-(Int)srcStride]) > abs(ptrSrc[iLBB] - ptrSrc[ -1]) ? ptrSrc[iTRR] : ptrSrc[iLBB]); |
---|
[608] | 2466 | refDC2 = ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1; |
---|
[56] | 2467 | } |
---|
| 2468 | else |
---|
| 2469 | { |
---|
[608] | 2470 | refDC1 = bL ? ptrSrc[iLB] : ptrSrc[iTR]; |
---|
| 2471 | refDC2 = bL ? ptrSrc[iTM] : ptrSrc[iLM]; |
---|
[56] | 2472 | } |
---|
| 2473 | |
---|
[608] | 2474 | predDC1 = biSegPattern[0] ? refDC1 : refDC2; |
---|
| 2475 | predDC2 = biSegPattern[0] ? refDC2 : refDC1; |
---|
[2] | 2476 | } |
---|
| 2477 | |
---|
[608] | 2478 | Void TComPrediction::xAssignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 ) |
---|
[56] | 2479 | { |
---|
[608] | 2480 | if( dstStride == patternStride ) |
---|
| 2481 | { |
---|
| 2482 | for( UInt k = 0; k < (patternStride * patternStride); k++ ) |
---|
| 2483 | { |
---|
[1196] | 2484 | if( true == biSegPattern[k] ) |
---|
| 2485 | { |
---|
| 2486 | ptrDst[k] = valDC2; |
---|
| 2487 | } |
---|
| 2488 | else |
---|
| 2489 | { |
---|
| 2490 | ptrDst[k] = valDC1; |
---|
| 2491 | } |
---|
[608] | 2492 | } |
---|
[443] | 2493 | } |
---|
[608] | 2494 | else |
---|
| 2495 | { |
---|
| 2496 | Pel* piTemp = ptrDst; |
---|
| 2497 | for( UInt uiY = 0; uiY < patternStride; uiY++ ) |
---|
| 2498 | { |
---|
| 2499 | for( UInt uiX = 0; uiX < patternStride; uiX++ ) |
---|
| 2500 | { |
---|
[1196] | 2501 | if( true == biSegPattern[uiX] ) |
---|
| 2502 | { |
---|
| 2503 | piTemp[uiX] = valDC2; |
---|
| 2504 | } |
---|
| 2505 | else |
---|
| 2506 | { |
---|
| 2507 | piTemp[uiX] = valDC1; |
---|
| 2508 | } |
---|
[608] | 2509 | } |
---|
| 2510 | piTemp += dstStride; |
---|
| 2511 | biSegPattern += patternStride; |
---|
| 2512 | } |
---|
[443] | 2513 | } |
---|
[56] | 2514 | } |
---|
| 2515 | |
---|
[608] | 2516 | #if H_3D_DIM_DMM |
---|
[56] | 2517 | |
---|
[608] | 2518 | Void TComPrediction::xPredContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) |
---|
[56] | 2519 | { |
---|
[608] | 2520 | pcContourWedge->clear(); |
---|
[56] | 2521 | |
---|
[608] | 2522 | // get copy of co-located texture luma block |
---|
| 2523 | TComYuv cTempYuv; |
---|
| 2524 | cTempYuv.create( uiWidth, uiHeight ); |
---|
| 2525 | cTempYuv.clear(); |
---|
| 2526 | Pel* piRefBlkY = cTempYuv.getLumaAddr(); |
---|
| 2527 | xCopyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); |
---|
| 2528 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
[56] | 2529 | |
---|
[608] | 2530 | // find contour for texture luma block |
---|
| 2531 | UInt iDC = 0; |
---|
[1084] | 2532 | |
---|
[1039] | 2533 | iDC = piRefBlkY[ 0 ]; |
---|
| 2534 | iDC += piRefBlkY[ uiWidth - 1 ]; |
---|
| 2535 | iDC += piRefBlkY[ uiWidth * (uiHeight - 1) ]; |
---|
| 2536 | iDC += piRefBlkY[ uiWidth * (uiHeight - 1) + uiWidth - 1 ]; |
---|
| 2537 | iDC = iDC >> 2; |
---|
[608] | 2538 | |
---|
| 2539 | piRefBlkY = cTempYuv.getLumaAddr(); |
---|
[56] | 2540 | |
---|
[608] | 2541 | Bool* pabContourPattern = pcContourWedge->getPattern(); |
---|
| 2542 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
[443] | 2543 | { |
---|
[608] | 2544 | pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; |
---|
[443] | 2545 | } |
---|
[608] | 2546 | |
---|
| 2547 | cTempYuv.destroy(); |
---|
[56] | 2548 | } |
---|
| 2549 | |
---|
[608] | 2550 | |
---|
| 2551 | Void TComPrediction::xCopyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) |
---|
[56] | 2552 | { |
---|
[608] | 2553 | TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); |
---|
| 2554 | assert( pcPicYuvRef != NULL ); |
---|
| 2555 | Int iRefStride = pcPicYuvRef->getStride(); |
---|
| 2556 | Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
[56] | 2557 | |
---|
[608] | 2558 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
[56] | 2559 | { |
---|
[608] | 2560 | ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); |
---|
| 2561 | piDestBlockY += uiWidth; |
---|
| 2562 | piRefY += iRefStride; |
---|
[56] | 2563 | } |
---|
| 2564 | } |
---|
[655] | 2565 | #endif |
---|
[56] | 2566 | |
---|
[2] | 2567 | |
---|
[608] | 2568 | #if H_3D_DIM_SDC |
---|
| 2569 | Void TComPrediction::analyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride |
---|
| 2570 | ,UInt uiIntraMode |
---|
| 2571 | ,Bool orgDC |
---|
| 2572 | ) |
---|
| 2573 | { |
---|
| 2574 | Int iSumDepth[2]; |
---|
| 2575 | memset(iSumDepth, 0, sizeof(Int)*2); |
---|
| 2576 | Int iSumPix[2]; |
---|
| 2577 | memset(iSumPix, 0, sizeof(Int)*2); |
---|
[1196] | 2578 | |
---|
[833] | 2579 | for( Int i = 0; i < uiNumSegments; i++ ) |
---|
| 2580 | { |
---|
[1196] | 2581 | rpSegMeans[i] = 0; |
---|
[833] | 2582 | } |
---|
[1196] | 2583 | |
---|
| 2584 | if ( !orgDC ) |
---|
[2] | 2585 | { |
---|
[976] | 2586 | Pel* pLeftTop = pOrig; |
---|
| 2587 | Pel* pRightTop = pOrig + (uiSize-1); |
---|
| 2588 | Pel* pLeftBottom = (pOrig+ (uiStride*(uiSize-1))); |
---|
| 2589 | Pel* pRightBottom = (pOrig+ (uiStride*(uiSize-1)) + (uiSize-1)); |
---|
[608] | 2590 | |
---|
[976] | 2591 | rpSegMeans[0] = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2; |
---|
[608] | 2592 | return; |
---|
[2] | 2593 | } |
---|
[608] | 2594 | |
---|
| 2595 | Int subSamplePix; |
---|
| 2596 | if ( uiSize == 64 || uiSize == 32 ) |
---|
[2] | 2597 | { |
---|
[608] | 2598 | subSamplePix = 2; |
---|
[2] | 2599 | } |
---|
[608] | 2600 | else |
---|
[2] | 2601 | { |
---|
[608] | 2602 | subSamplePix = 1; |
---|
[2] | 2603 | } |
---|
[1196] | 2604 | |
---|
[608] | 2605 | for (Int y=0; y<uiSize; y+=subSamplePix) |
---|
[2] | 2606 | { |
---|
[608] | 2607 | for (Int x=0; x<uiSize; x+=subSamplePix) |
---|
| 2608 | { |
---|
| 2609 | UChar ucSegment = pMask?(UChar)pMask[x]:0; |
---|
| 2610 | assert( ucSegment < uiNumSegments ); |
---|
| 2611 | |
---|
| 2612 | iSumDepth[ucSegment] += pOrig[x]; |
---|
| 2613 | iSumPix[ucSegment] += 1; |
---|
| 2614 | } |
---|
| 2615 | |
---|
| 2616 | pOrig += uiStride*subSamplePix; |
---|
| 2617 | pMask += uiMaskStride*subSamplePix; |
---|
[2] | 2618 | } |
---|
[608] | 2619 | |
---|
| 2620 | // compute mean for each segment |
---|
| 2621 | for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ ) |
---|
[2] | 2622 | { |
---|
[608] | 2623 | if( iSumPix[ucSeg] > 0 ) |
---|
[1196] | 2624 | { |
---|
[608] | 2625 | rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg]; |
---|
[1196] | 2626 | } |
---|
[608] | 2627 | else |
---|
[1196] | 2628 | { |
---|
[608] | 2629 | rpSegMeans[ucSeg] = 0; // this happens for zero-segments |
---|
[1196] | 2630 | } |
---|
[2] | 2631 | } |
---|
| 2632 | } |
---|
[608] | 2633 | #endif // H_3D_DIM_SDC |
---|
| 2634 | #endif |
---|
[1200] | 2635 | |
---|
[56] | 2636 | //! \} |
---|