Changeset 1390 in 3DVCSoftware for branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer
- Timestamp:
- 13 Nov 2015, 17:00:20 (9 years ago)
- Location:
- branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenFilter.cpp
r1386 r1390 36 36 #include "TRenFilter.h" 37 37 #include "TRenInterpFilter.h" 38 #if NH_3D_VSO39 38 40 ///// COMMON /////41 template<UInt bitDepth>42 Void TRenFilter<bitDepth>::setSubPelShiftLUT( Int iLutPrec, Int** piSubPelShiftLUT, Int iShift )43 {44 //ToDo: use same rounding for left and right45 AOT( iLutPrec < 0 || iLutPrec > 2 );46 Int iStep = 1 << iLutPrec;47 for (Int iDelta = 0; iDelta < (iStep << 1)+1; iDelta++ )48 {49 for (Int iCurDelta = 0; iCurDelta < (iStep << 1)+1; iCurDelta++ )50 {51 if (iCurDelta <= iDelta)52 {53 piSubPelShiftLUT[iDelta][iCurDelta] = (iDelta != 0) ?( ( iStep * iCurDelta + ( iDelta >> 1) )/ iDelta) + iShift * iStep : iShift * iStep;54 }55 else56 {57 piSubPelShiftLUT[iDelta][iCurDelta] = 0xdeaddead;58 }59 }60 }61 }62 template<UInt bitDepth>63 Void TRenFilter<bitDepth>::setupZLUT( Bool bBlendUseDistWeight, Int iBlendZThresPerc, Int iRelDistToLeft, Int** ppiBaseShiftLUTLeft, Int** ppiBaseShiftLUTRight, Int& riBlendZThres, Int& riBlendDistWeight, Int* piInvZLUTLeft, Int* piInvZLUTRight )64 {65 AOT( iRelDistToLeft == -1 );66 riBlendDistWeight = bBlendUseDistWeight ? iRelDistToLeft : 1 << (REN_VDWEIGHT_PREC - 1);67 68 for (UInt uiDepthValue = 0; uiDepthValue <= 256; uiDepthValue++)69 {70 //GT: retrieve depth approx from shift71 piInvZLUTLeft [uiDepthValue] = abs( ppiBaseShiftLUTLeft [0][uiDepthValue] );72 piInvZLUTRight[uiDepthValue] = abs( ppiBaseShiftLUTRight[0][uiDepthValue] );73 }74 // Set Threshold75 riBlendZThres = ( std::max( abs(piInvZLUTLeft[0]- piInvZLUTLeft[255]), abs(piInvZLUTRight[0]- piInvZLUTRight[255]) ) * iBlendZThresPerc + 50) / 100;76 }77 78 template<UInt bitDepth>79 Void TRenFilter<bitDepth>::filledToUsedPelMap( PelImage* pcFilledImage, PelImage* pcUsedPelsImage, Int iUsedPelMapMarExt )80 {81 // Convert to binary map82 Int iWidth = pcFilledImage ->getPlane(0)->getWidth ();83 Int iHeight = pcFilledImage ->getPlane(0)->getHeight();84 85 AOT( iWidth != pcUsedPelsImage ->getPlane(0)->getWidth () );86 AOT( iHeight != pcUsedPelsImage ->getPlane(0)->getHeight() );87 AOF( pcUsedPelsImage->is420() );88 89 Int iSrcStride = pcFilledImage ->getPlane(0)->getStride();90 Int iDstStrideY = pcUsedPelsImage->getPlane(0)->getStride();91 Int iDstStrideU = pcUsedPelsImage->getPlane(1)->getStride();92 Int iDstStrideV = pcUsedPelsImage->getPlane(2)->getStride();93 94 Pel* pcSrcData = pcFilledImage ->getPlane(0)->getPlaneData();95 Pel* pcDstDataY = pcUsedPelsImage->getPlane(0)->getPlaneData();96 Pel* pcDstDataU = pcUsedPelsImage->getPlane(1)->getPlaneData();97 Pel* pcDstDataV = pcUsedPelsImage->getPlane(2)->getPlaneData(); // Only used as buffer98 99 for (Int iPosY = 0; iPosY < iHeight; iPosY++ )100 {101 for (Int iPosX = 0; iPosX < iWidth; iPosX++ )102 {103 pcDstDataY[iPosX] = ( pcSrcData[iPosX] != REN_IS_FILLED ) ? REN_USED_PEL : REN_UNUSED_PEL;104 105 if ((iPosX & 1) && (iPosY & 1))106 {107 pcDstDataU[iPosX >> 1] = ( ( pcSrcData[iPosX ] != REN_IS_FILLED )108 || ( pcSrcData[iPosX - 1 ] != REN_IS_FILLED )109 || ( pcSrcData[iPosX - iSrcStride] != REN_IS_FILLED )110 || ( pcSrcData[iPosX - 1 - iSrcStride] != REN_IS_FILLED )111 ) ? REN_USED_PEL : REN_UNUSED_PEL;112 }113 }114 115 if ( iPosY & 1 )116 {117 pcDstDataU += iDstStrideU;118 }119 120 pcDstDataY += iDstStrideY;121 pcSrcData += iSrcStride;122 }123 124 //// Dilatation for Interpolation Filters ////125 //GT: should better be defined somewhere else ...126 const Int iLumaIntFiltHalfSize = 4;127 const Int iChromaIntFiltHalfSize = 2;128 129 Int iDilateSizeLuma = iLumaIntFiltHalfSize + iUsedPelMapMarExt ;130 Int iDilateSizeChroma = iChromaIntFiltHalfSize + ( iUsedPelMapMarExt >> 1);131 132 pcDstDataY = pcUsedPelsImage->getPlane(0)->getPlaneData();133 pcDstDataU = pcUsedPelsImage->getPlane(1)->getPlaneData();134 pcDstDataV = pcUsedPelsImage->getPlane(2)->getPlaneData();135 136 // Dilate Luma horizontally137 xDilate( pcDstDataY, iDstStrideY, iWidth, iHeight, pcDstDataY, iDstStrideY, iDilateSizeLuma, false, true );138 xDilate( pcDstDataY, iDstStrideY, iWidth, iHeight, pcDstDataY, iDstStrideY, iDilateSizeLuma, false, false );139 140 // Dilate Chorma vertically and horizontally (for UV-up)141 xDilate( pcDstDataU, iDstStrideU, iWidth>>1, iHeight>>1, pcDstDataU, iDstStrideU, iDilateSizeChroma, false, true );142 xDilate( pcDstDataU, iDstStrideU, iWidth>>1, iHeight>>1, pcDstDataU, iDstStrideU, iDilateSizeChroma, false, false );143 144 xDilate( pcDstDataU, iDstStrideU, iWidth>>1, iHeight>>1, pcDstDataU, iDstStrideU, iChromaIntFiltHalfSize, true, true );145 xDilate( pcDstDataU, iDstStrideU, iWidth>>1, iHeight>>1, pcDstDataU, iDstStrideU, iChromaIntFiltHalfSize, true, false );146 147 for (Int iPosY = 0; iPosY < (iHeight >> 1); iPosY++ )148 {149 for (Int iPosX = 0; iPosX < (iWidth >> 1); iPosX++ )150 {151 pcDstDataV[iPosX] = pcDstDataU[iPosX];152 }153 154 pcDstDataU += iDstStrideU;155 pcDstDataV += iDstStrideV;156 }157 }158 159 /////////// Copy /////////////160 template<UInt bitDepth>161 Void TRenFilter<bitDepth>::copy(const Pel* pcInputPlaneData, Int iInputStride, Int iWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride )162 {163 xDistributeArray(pcInputPlaneData, iInputStride, 1, 1, iWidth, iHeight ,pcOutputPlaneData, iOutputStride, 1 , 1 );164 165 }166 167 /////////// Horizontal Mirror ///////////168 template<UInt bitDepth> template <typename T>169 Void TRenFilter<bitDepth>::mirrorHor( TRenImage<T> *pcImage )170 {171 for (UInt uCurPlane = 0 ; uCurPlane < pcImage->getNumberOfPlanes(); uCurPlane++ )172 {173 mirrorHor( pcImage->getPlane(uCurPlane) );174 }175 }176 177 template<UInt bitDepth> template <typename T>178 Void TRenFilter<bitDepth>::mirrorHor( TRenImagePlane<T> *pcImagePlane )179 {180 T* pcPlaneData = pcImagePlane->getPlaneDataOrg();181 T cTemp;182 UInt uiStride = pcImagePlane->getStride();183 UInt uiHeight = pcImagePlane->getHeightOrg();184 UInt uiWidth = pcImagePlane->getWidthOrg();185 186 for (UInt uiPosY = 0; uiPosY < uiHeight; uiPosY++)187 {188 for (UInt uiPosX = 0; uiPosX < ( (uiWidth+1) >> 1); uiPosX++ )189 {190 cTemp = pcPlaneData[uiPosX];191 pcPlaneData[uiPosX] = pcPlaneData[uiWidth - uiPosX-1];192 pcPlaneData[uiWidth-uiPosX-1] = cTemp;193 }194 pcPlaneData += uiStride;195 }196 }197 198 /////////// Comparison ///////////199 template<UInt bitDepth>200 Int64 TRenFilter<bitDepth>::SSE (PelImagePlane* pcInputPlane1, PelImagePlane* pcInputPlane2, Bool bLuma )201 {202 UInt uiWidth = pcInputPlane1->getWidth();203 UInt uiHeight = pcInputPlane1->getHeight();204 205 UInt uiStride1 = pcInputPlane1->getStride();206 UInt uiStride2 = pcInputPlane2->getStride();207 208 Pel* pucImData1 = pcInputPlane1->getPlaneData();209 Pel* pucImData2 = pcInputPlane2->getPlaneData();210 211 return SSE( pucImData1, (Int) uiStride1, (Int) uiWidth, (Int) uiHeight, pucImData2, (Int) uiStride2, bLuma );212 }213 214 template<UInt bitDepth>215 Int64 TRenFilter<bitDepth>::SSE( Pel* piSrc1, Int iSrcStride1, Int iWidth, Int iHeight, Pel* piSrc2, Int iSrcStride2, Bool bLuma )216 {217 Int64 iSSE = 0;218 219 220 Int iShift = ( bitDepth - 8 ) << 1 ;221 for(Int iPosY = 0; iPosY < iHeight; iPosY++)222 {223 for(Int iPosX = 0; iPosX < iWidth; iPosX++)224 {225 Int iDiff = ( piSrc1[iPosX] - piSrc2[iPosX] );226 iSSE += (( iDiff * iDiff ) >> iShift);227 }228 piSrc1 += iSrcStride1;229 piSrc2 += iSrcStride2;230 }231 return iSSE;232 }233 234 template<UInt bitDepth> template <typename T>235 Bool TRenFilter<bitDepth>::compare( TRenImage<T> *pInputImage1, TRenImage<T> *pInputImage2 )236 {237 Bool bIsEqual = true;238 for (UInt uiCurPlane = 0 ; uiCurPlane < pInputImage1->getNumberOfPlanes(); uiCurPlane++ )239 {240 bIsEqual = bIsEqual && compare(pInputImage1->getPlane(uiCurPlane), pInputImage2->getPlane(uiCurPlane));241 }242 return bIsEqual;243 }244 245 template<UInt bitDepth> template <typename T>246 Bool TRenFilter<bitDepth>::compare (TRenImagePlane<T>* pcInputPlane1 , TRenImagePlane<T>* pcInputPlane2 )247 {248 UInt uiWidth = pcInputPlane1->getWidth();249 UInt uiHeight = pcInputPlane1->getHeight();250 251 UInt uiStride1 = pcInputPlane1->getStride();252 UInt uiStride2 = pcInputPlane2->getStride();253 254 T* pucImData1 = pcInputPlane1->getPlaneData();255 T* pucImData2 = pcInputPlane2->getPlaneData();256 257 Bool bEqual = true;258 for(UInt uiPosY = 0; uiPosY < uiHeight; uiPosY++)259 {260 261 for(UInt uiPosX = 0; uiPosX < uiWidth; uiPosX++)262 {263 bEqual = bEqual && ( pucImData1[uiPosX] == pucImData2[uiPosX]);264 }265 pucImData1 += uiStride1;266 pucImData2 += uiStride2;267 }268 return bEqual;269 }270 271 /////////// Sampling ///////////272 template<UInt bitDepth>273 inline Void TRenFilter<bitDepth>::sampleUp2Tap13(PelImage* pcInputImage, PelImage* pcOutputImage)274 { // UpSampling from JSVM Software (DownConvertStatic) ???275 276 UInt uiNumPlanes = pcInputImage->getNumberOfPlanes();277 278 for (UInt uiCurPlane = 0; uiCurPlane < uiNumPlanes; uiCurPlane++)279 {280 PelImagePlane* pcInputPlane = pcInputImage ->getPlane(uiCurPlane);281 PelImagePlane* pcOutputPlane = pcOutputImage->getPlane(uiCurPlane);282 283 Int iWidth = pcInputPlane->getWidth();284 Int iHeight = pcInputPlane->getHeight();285 286 Int iInputStride = pcInputPlane->getStride();287 Int iOutputStride = pcOutputPlane->getStride();288 289 assert( iWidth == 2 * pcOutputPlane->getWidth ());290 assert( iHeight == 2 * pcOutputPlane->getHeight());291 292 Int iOffset;293 294 Pel *pcInputPlaneData = pcInputPlane->getPlaneData();295 Int *piDataVerUp = new Int[iWidth * iHeight * 2];296 Pel *pcOutputPlaneData = pcOutputPlane->getPlaneData();297 298 // Up sampling filter.299 Int aiFilterCoeff[16] = { 0, 0, 1, 0, -5, 0, 20, 32, 20, 0, -5, 0, 1, 0, 0, 32 };300 301 // Normalization factors for filtered values.302 Int iDivH = 1, iDivV = 1, iAddH = 0, iAddV = 0;303 304 // Factors after horizontal and vertical filtering.305 iDivH = (aiFilterCoeff[15]*aiFilterCoeff[15]); iAddH = iDivH / 2;306 307 Int* piDst = new Int[2*iWidth];308 //1) VERTICAL UPSAMPLING.309 310 // Process all cols.311 for(Int i=0; i<iWidth; i++ )312 {313 // Set source (col) poInter.314 Pel* pcSrc = &pcInputPlaneData[i];315 316 // Process all rows.317 for( Int j=0; j<iHeight; j++ )318 {319 // Adjust indices of border samples.320 Int i00 = ((j < 3) ? 0 : j-3) * iInputStride;321 Int i01 = ((j < 2) ? 0 : j-2) * iInputStride;322 Int i02 = ((j < 1) ? 0 : j-1) * iInputStride;323 Int i03 = ((j < iHeight ) ? j : j-1) * iInputStride;324 Int i04 = ((j < iHeight-1) ? j+1 : j-1) * iInputStride;325 Int i05 = ((j < iHeight-2) ? j+2 : j-1) * iInputStride;326 Int i06 = ((j < iHeight-3) ? j+3 : j-1) * iInputStride;327 Int i07 = ((j < iHeight-4) ? j+4 : j-1) * iInputStride;328 329 // Calculate filtered (even) sample.330 piDst[2*j+0] = aiFilterCoeff[13] * pcSrc[i00]331 + aiFilterCoeff[11] * pcSrc[i01]332 + aiFilterCoeff[ 9] * pcSrc[i02]333 + aiFilterCoeff[ 7] * pcSrc[i03]334 + aiFilterCoeff[ 5] * pcSrc[i04]335 + aiFilterCoeff[ 3] * pcSrc[i05]336 + aiFilterCoeff[ 1] * pcSrc[i06];337 338 // Calculate filtered (odd) sample.339 piDst[2*j+1] = aiFilterCoeff[14] * pcSrc[i00]340 + aiFilterCoeff[12] * pcSrc[i01]341 + aiFilterCoeff[10] * pcSrc[i02]342 + aiFilterCoeff[ 8] * pcSrc[i03]343 + aiFilterCoeff[ 6] * pcSrc[i04]344 + aiFilterCoeff[ 4] * pcSrc[i05]345 + aiFilterCoeff[ 2] * pcSrc[i06]346 + aiFilterCoeff[ 0] * pcSrc[i07];347 }348 349 // Process all filtered samples.350 for(Int j=0; j<(2*iHeight); j++ )351 {352 // Scale and copy to image buffer.353 piDataVerUp[iWidth*j+i] = (piDst[j] + iAddV) / iDivV;354 }355 }356 357 // Update h358 iHeight *= 2;359 360 // 2) HORIZONTAL UPSAMPLING.361 362 // Process all rows.363 for( Int j=0; j<iHeight; j++ )364 {365 // Set source (row) poInter.366 Int* piSrc = &piDataVerUp[iWidth*j];367 368 // Process all cols.369 for( Int i=0; i<iWidth; i++ )370 {371 // Adjust indices of border samples.372 Int i00 = (i < 3) ? 0 : i-3;373 Int i01 = (i < 2) ? 0 : i-2;374 Int i02 = (i < 1) ? 0 : i-1;375 Int i03 = (i < iWidth ) ? i : iWidth-1;376 Int i04 = (i < iWidth-1) ? i+1 : iWidth-1;377 Int i05 = (i < iWidth-2) ? i+2 : iWidth-1;378 Int i06 = (i < iWidth-3) ? i+3 : iWidth-1;379 Int i07 = (i < iWidth-4) ? i+4 : iWidth-1;380 381 // Calculate filtered (even) sample.382 piDst[2*i+0] = aiFilterCoeff[13] * piSrc[i00]383 + aiFilterCoeff[11] * piSrc[i01]384 + aiFilterCoeff[ 9] * piSrc[i02]385 + aiFilterCoeff[ 7] * piSrc[i03]386 + aiFilterCoeff[ 5] * piSrc[i04]387 + aiFilterCoeff[ 3] * piSrc[i05]388 + aiFilterCoeff[ 1] * piSrc[i06];389 390 // Calculate filtered (odd) sample.391 piDst[2*i+1] = aiFilterCoeff[14] * piSrc[i00]392 + aiFilterCoeff[12] * piSrc[i01]393 + aiFilterCoeff[10] * piSrc[i02]394 + aiFilterCoeff[ 8] * piSrc[i03]395 + aiFilterCoeff[ 6] * piSrc[i04]396 + aiFilterCoeff[ 4] * piSrc[i05]397 + aiFilterCoeff[ 2] * piSrc[i06]398 + aiFilterCoeff[ 0] * piSrc[i07];399 }400 401 iOffset = 2* iOutputStride * j;402 // Process all filtered samples.403 for(Int i=0; i<iWidth*2; i++ )404 {405 // Scale and copy to image buffer.406 pcOutputPlaneData[iOffset+i] = ClipBD((Pel) ((piDst[i] + iAddH) / iDivH), bitDepth);407 }408 }409 410 delete [] piDataVerUp;411 delete [] piDst;412 413 }414 }415 416 template<UInt bitDepth>417 Void TRenFilter<bitDepth>::sampleDown2Tap13(PelImage* pcInputImage, PelImage* pcOutputImage)418 { // DownSampling from JSVM Software (DownConvertStatic) ??419 420 UInt uiNumPlanes = pcInputImage->getNumberOfPlanes();421 422 for (UInt uiCurPlane = 0; uiCurPlane < uiNumPlanes; uiCurPlane++)423 {424 sampleDown2Tap13( pcInputImage ->getPlane(uiCurPlane), pcOutputImage->getPlane(uiCurPlane) );425 }426 };427 428 template<UInt bitDepth>429 Void TRenFilter<bitDepth>::sampleDown2Tap13( Pel* pcInputPlaneData, Int iInputStride, Int iWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride )430 { // DownSampling from JSVM Software (DownConvertStatic) ??431 432 Int iOffset, iPosX, iPosY, k;433 Int* piDataHorDown = new Int[(Int)(iWidth * iHeight / 2)];434 435 // Downsampling filter.436 Int aiFilterCoeff[16] = { 0, 2, 0, -4, -3, 5, 19, 26, 19, 5, -3, -4, 0, 2, 0, 64 };437 438 // Normalization factors for filtered values.439 Int iDivH = 1, iDivV = 1, iAddH = 0, iAddV = 0;440 441 iDivV = (aiFilterCoeff[15]*aiFilterCoeff[15]); iAddV = iDivV / 2;442 443 // Allocate and init single row of filtered samples.444 Int* piDst = new Int[iWidth];445 446 // 1) HORIZONTAL DOWNSAMPLING.447 448 // Process all rows.449 for( iPosY=0; iPosY<iHeight; iPosY++ )450 {451 // Set source (row) poInter.452 Pel* pcSrc = &pcInputPlaneData[iInputStride*iPosY];453 454 // Process all cols.455 for( iPosX=0, k=0; iPosX<(iWidth/2); iPosX++, k+=2 )456 {457 // Adjust indices of border samples.458 Int i00 = (k < 7) ? 0 : k -7;459 Int i01 = (k < 6) ? 0 : k -6;460 Int i02 = (k < 5) ? 0 : k -5;461 Int i03 = (k < 4) ? 0 : k -4;462 Int i04 = (k < 3) ? 0 : k -3;463 Int i05 = (k < 2) ? 0 : k -2;464 Int i06 = (k < 1) ? 0 : k -1;465 Int i07 = (k < iWidth ) ? k : iWidth-1;466 Int i08 = (k < iWidth-1) ? k+1 : iWidth-1;467 Int i09 = (k < iWidth-2) ? k+2 : iWidth-1;468 Int i10 = (k < iWidth-3) ? k+3 : iWidth-1;469 Int i11 = (k < iWidth-4) ? k+4 : iWidth-1;470 Int i12 = (k < iWidth-5) ? k+5 : iWidth-1;471 Int i13 = (k < iWidth-6) ? k+6 : iWidth-1;472 Int i14 = (k < iWidth-7) ? k+7 : iWidth-1;473 474 // Calculate filtered sample.475 piDst[iPosX] = aiFilterCoeff[ 0] * pcSrc[i00]476 + aiFilterCoeff[ 1] * pcSrc[i01]477 + aiFilterCoeff[ 2] * pcSrc[i02]478 + aiFilterCoeff[ 3] * pcSrc[i03]479 + aiFilterCoeff[ 4] * pcSrc[i04]480 + aiFilterCoeff[ 5] * pcSrc[i05]481 + aiFilterCoeff[ 6] * pcSrc[i06]482 + aiFilterCoeff[ 7] * pcSrc[i07]483 + aiFilterCoeff[ 8] * pcSrc[i08]484 + aiFilterCoeff[ 9] * pcSrc[i09]485 + aiFilterCoeff[10] * pcSrc[i10]486 + aiFilterCoeff[11] * pcSrc[i11]487 + aiFilterCoeff[12] * pcSrc[i12]488 + aiFilterCoeff[13] * pcSrc[i13]489 + aiFilterCoeff[14] * pcSrc[i14];490 }491 492 iOffset = iPosY * iWidth/2;493 // Process all filtered samples.494 for( iPosX=0; iPosX<(iWidth/2); iPosX++ )495 {496 // Scale and copy back to image buffer.497 piDataHorDown[iOffset+iPosX] = (piDst[iPosX] + iAddH) / iDivH;498 }499 }500 501 // Update w.502 iWidth >>= 1;503 504 // 2) VERTICAL DOWNSAMPLING.505 506 // Process all cols.507 for( iPosX=0; iPosX<iWidth; iPosX++ )508 {509 // Set source (col) poInter.510 Int* piSrc = &piDataHorDown[iPosX];511 512 // Process all rows.513 for( iPosY=0, k=0; iPosY<(iHeight/2); iPosY++, k+=2 )514 {515 // Adjust indices of border samples.516 Int i00 = ((k < 7) ? 0 : k -7) * iWidth;517 Int i01 = ((k < 6) ? 0 : k -6) * iWidth;518 Int i02 = ((k < 5) ? 0 : k -5) * iWidth;519 Int i03 = ((k < 4) ? 0 : k -4) * iWidth;520 Int i04 = ((k < 3) ? 0 : k -3) * iWidth;521 Int i05 = ((k < 2) ? 0 : k -2) * iWidth;522 Int i06 = ((k < 1) ? 0 : k -1) * iWidth;523 Int i07 = ((k < iHeight ) ? k : iHeight-1) * iWidth;524 Int i08 = ((k < iHeight-1) ? k+1 : iHeight-1) * iWidth;525 Int i09 = ((k < iHeight-2) ? k+2 : iHeight-1) * iWidth;526 Int i10 = ((k < iHeight-3) ? k+3 : iHeight-1) * iWidth;527 Int i11 = ((k < iHeight-4) ? k+4 : iHeight-1) * iWidth;528 Int i12 = ((k < iHeight-5) ? k+5 : iHeight-1) * iWidth;529 Int i13 = ((k < iHeight-6) ? k+6 : iHeight-1) * iWidth;530 Int i14 = ((k < iHeight-7) ? k+7 : iHeight-1) * iWidth;531 532 // Calculate filtered sample.533 piDst[iPosY] = aiFilterCoeff[ 0] * piSrc[i00]534 + aiFilterCoeff[ 1] * piSrc[i01]535 + aiFilterCoeff[ 2] * piSrc[i02]536 + aiFilterCoeff[ 3] * piSrc[i03]537 + aiFilterCoeff[ 4] * piSrc[i04]538 + aiFilterCoeff[ 5] * piSrc[i05]539 + aiFilterCoeff[ 6] * piSrc[i06]540 + aiFilterCoeff[ 7] * piSrc[i07]541 + aiFilterCoeff[ 8] * piSrc[i08]542 + aiFilterCoeff[ 9] * piSrc[i09]543 + aiFilterCoeff[10] * piSrc[i10]544 + aiFilterCoeff[11] * piSrc[i11]545 + aiFilterCoeff[12] * piSrc[i12]546 + aiFilterCoeff[13] * piSrc[i13]547 + aiFilterCoeff[14] * piSrc[i14];548 }549 550 // Process all filtered samples.551 for( iPosY=0; iPosY<(iHeight/2); iPosY++ )552 {553 // Scale and copy back to image buffer.554 pcOutputPlaneData[iOutputStride*iPosY+iPosX] = ClipBD( ( Pel) ( (piDst[iPosY] + iAddV) / iDivV), bitDepth );555 }556 }557 558 delete [] piDataHorDown;559 delete [] piDst;560 }561 562 template<UInt bitDepth>563 Void TRenFilter<bitDepth>::sampleDown2Tap13(PelImagePlane* pcInputPlane, PelImagePlane* pcOutputPlane)564 { // DownSampling from JSVM Software (DownConvertStatic) ??565 Int iWidth = pcInputPlane->getWidth();566 Int iHeight = pcInputPlane->getHeight();567 568 assert( pcOutputPlane->getWidth () == (iWidth >> 1 ));569 assert( pcOutputPlane->getHeight() == (iHeight >> 1 ));570 571 Int iInputStride = pcInputPlane->getStride();572 Int iOutputStride = pcOutputPlane->getStride();573 574 Pel* pcInputPlaneData = pcInputPlane ->getPlaneData();575 Pel* pcOutputPlaneData = pcOutputPlane->getPlaneData();576 577 sampleDown2Tap13( pcInputPlaneData, iInputStride, iWidth, iHeight, pcOutputPlaneData, iOutputStride );578 };579 580 template<UInt bitDepth>581 Void TRenFilter<bitDepth>::sampleVerDown2Tap13( PelImagePlane* pcInputPlane, PelImagePlane* pcOutputPlane, Int uiPad)582 {583 // DownSampling from JSVM Software (DownConvertStatic) ??584 Int iWidth = pcInputPlane->getWidth();585 Int iHeight = pcInputPlane->getHeight();586 587 assert( pcOutputPlane->getWidth () == iWidth );588 assert( pcOutputPlane->getHeight() == (iHeight >> 1));589 assert (pcInputPlane ->getPad() >= 12 );590 assert (pcOutputPlane->getPad() >= uiPad );591 592 Int iInputStride = pcInputPlane->getStride();593 Int iOutputStride = pcOutputPlane->getStride();594 595 Pel* pcInputPlaneData = pcInputPlane ->getPlaneData();596 Pel* pcOutputPlaneData = pcOutputPlane->getPlaneData();597 598 Int iStr0 = 0;599 Int iStr1 = iInputStride;600 Int iStr2 = iStr1 + iInputStride;601 Int iStr3 = iStr2 + iInputStride;602 Int iStr4 = iStr3 + iInputStride;603 Int iStr5 = iStr4 + iInputStride;604 Int iStr6 = iStr5 + iInputStride;605 Int iStr7 = iStr6 + iInputStride;606 Int iStr8 = iStr7 + iInputStride;607 Int iStr9 = iStr8 + iInputStride;608 Int iStr10 = iStr9 + iInputStride;609 Int iStr11 = iStr10 + iInputStride;610 Int iStr12 = iStr11 + iInputStride;;611 612 613 // Downsampling filter { 0, 2, 0, -4, -3, 5, 19, 26, 19, 5, -3, -4, 0, 2, 0, 64 };614 for ( Int iYPos = 0; iYPos < (iHeight >> 1); iYPos++)615 {616 Pel* pcTmpIn = pcInputPlaneData - 12 * iInputStride - uiPad;617 for ( Int iXPos = -uiPad; iXPos < iWidth + uiPad; iXPos++)618 {619 Int iTmp0, iTmp1, iTmp2, iTmp3, iTmp4, iTmp5;620 iTmp0 = pcTmpIn[iStr0] + pcTmpIn[iStr12];621 iTmp1 = pcTmpIn[iStr2] + pcTmpIn[iStr10];622 iTmp2 = pcTmpIn[iStr3] + pcTmpIn[iStr9 ];623 iTmp3 = pcTmpIn[iStr4] + pcTmpIn[iStr8 ];624 iTmp4 = pcTmpIn[iStr5] + pcTmpIn[iStr7 ];625 iTmp5 = pcTmpIn[iStr6];626 627 Int iSum = iTmp4 + iTmp3 - iTmp2 + ((iTmp0 + iTmp4 + iTmp5 - iTmp2) << 1) + ( ( iTmp3 - iTmp1) << 2) + ( iTmp5 << 3 ) + (( iTmp4 + iTmp5 ) << 4);628 pcOutputPlaneData[ iXPos ] = (Pel) ClipBD((iSum + 32) >> 6, bitDepth);629 pcTmpIn++;630 }631 pcOutputPlaneData += iOutputStride;632 pcInputPlaneData += (iInputStride << 1);633 }634 };635 636 template<UInt bitDepth>637 Void TRenFilter<bitDepth>::sampleHorDown2Tap13( PelImagePlane* pcInputPlane, PelImagePlane* pcOutputPlane, Int uiPad )638 {639 // DownSampling from JSVM Software (DownConvertStatic) ??640 Int iWidth = pcInputPlane->getWidth();641 Int iHeight = pcInputPlane->getHeight();642 643 assert( pcOutputPlane->getWidth () == (iWidth >> 1));644 assert( pcOutputPlane->getHeight() == iHeight );645 assert (pcInputPlane ->getPad() >= 12 );646 assert (pcOutputPlane->getPad() >= uiPad );647 648 Int iInputStride = pcInputPlane ->getStride();649 Int iOutputStride = pcOutputPlane->getStride();650 651 Pel* pcInputPlaneData = pcInputPlane ->getPlaneData()- uiPad * iInputStride ;652 Pel* pcOutputPlaneData = pcOutputPlane->getPlaneData()- uiPad * iOutputStride;653 654 // Downsampling filter { 0, 2, 0, -4, -3, 5, 19, 26, 19, 5, -3, -4, 0, 2, 0, 64 };655 for ( Int iYPos = 0; iYPos < iHeight + 2*uiPad; iYPos++)656 {657 Pel* pcTmpIn = pcInputPlaneData - 12;658 for ( Int iXPos = 0; iXPos < ( iWidth >> 1); iXPos++)659 {660 Int iTmp0, iTmp1, iTmp2, iTmp3, iTmp4, iTmp5;661 iTmp0 = pcTmpIn[0]+ pcTmpIn[12];662 iTmp1 = pcTmpIn[2]+ pcTmpIn[10];663 iTmp2 = pcTmpIn[3]+ pcTmpIn[9 ];664 iTmp3 = pcTmpIn[4]+ pcTmpIn[8 ];665 iTmp4 = pcTmpIn[5]+ pcTmpIn[7 ];666 iTmp5 = pcTmpIn[6];667 668 Int iSum = iTmp4 + iTmp3 - iTmp2 + ((iTmp0 + iTmp4 + iTmp5 - iTmp2) << 1) + ( ( iTmp3 - iTmp1) << 2) + ( iTmp5 << 3 ) + (( iTmp4 + iTmp5 ) << 4);669 pcOutputPlaneData[ iXPos ] = (Pel) ClipBD((iSum + 32) >> 6, bitDepth);670 pcTmpIn += 2;671 }672 pcOutputPlaneData += iOutputStride;673 pcInputPlaneData += iInputStride ;674 }675 };676 677 template<UInt bitDepth>678 inline Pel TRenFilter<bitDepth>::xMedian3(Pel* pcData)679 {680 Bool bGT01 = pcData[0] > pcData[1];681 Bool bGT12 = pcData[1] > pcData[2];682 Bool bGT20 = pcData[2] > pcData[0];683 684 return ( (bGT01 && bGT20) || (!bGT01 && !bGT20) ) ? pcData[0] : ( ( (bGT12 && bGT01) || (!bGT12 && !bGT01) ) ? pcData[1] : pcData[2]) ;685 }686 687 template<UInt bitDepth>688 Void TRenFilter<bitDepth>::lineMedian3( PelImage* pcImage )689 {690 691 PelImage* pcTemp = pcImage->create();692 693 for (UInt uiCurPlane = 0; uiCurPlane < pcImage->getNumberOfPlanes(); uiCurPlane++)694 {695 PelImagePlane* pcImPlane = pcImage->getPlane(uiCurPlane);696 PelImagePlane* pcTempPlane = pcTemp ->getPlane(uiCurPlane);697 698 UInt uiWidth = pcImPlane->getWidth();699 UInt uiHeight = pcImPlane->getHeight();700 701 Pel* pcImData = pcImPlane ->getPlaneData();702 Pel* pcTempData = pcTempPlane->getPlaneData();703 704 UInt uiImDataStride = pcImPlane ->getStride();705 UInt uiTempDataStride = pcTempPlane->getStride();706 707 for(UInt uiPosY = 0; uiPosY < uiHeight; uiPosY++)708 {709 for(UInt uiPosX = 0; uiPosX < uiWidth; uiPosX++)710 {711 if ( (uiPosX >= 1) && (uiPosX < (uiWidth - 2)) )712 {713 pcTempData[uiPosX] = xMedian3(pcImData + uiPosX - 1);714 }715 else716 {717 pcTempData[uiPosX] = pcImData[uiPosX];718 }719 }720 pcTempData += uiTempDataStride;721 pcImData += uiImDataStride;722 }723 }724 725 pcImage->assign(pcTemp);726 delete pcTemp;727 }728 729 template<UInt bitDepth>730 Void TRenFilter<bitDepth>::convRect( PelImage* pcImage, UInt uiSize )731 {732 DoubleImage cKernel(uiSize, uiSize,1,0);733 cKernel.getPlane(0)->assign( 1 / ( Double( uiSize ) * Double( uiSize) ));734 conv(pcImage, &cKernel);735 }736 737 template<UInt bitDepth>738 Void TRenFilter<bitDepth>::binominal( PelImage* pcInputImage, PelImage* pcOutputImage, UInt uiSize )739 {740 assert( pcInputImage->getNumberOfFullPlanes() == pcOutputImage->getNumberOfFullPlanes () );741 assert( pcInputImage->getNumberOfQuaterPlanes() == pcOutputImage->getNumberOfQuaterPlanes() );742 743 UInt uiPlane;744 for (uiPlane = 0; uiPlane < pcInputImage->getNumberOfPlanes(); uiPlane ++)745 {746 binominal( pcInputImage->getPlane(uiPlane), pcOutputImage->getPlane(uiPlane), uiSize );747 }748 749 for ( ; uiPlane < pcInputImage->getNumberOfPlanes(); uiPlane ++)750 {751 binominal( pcInputImage->getPlane(uiPlane), pcOutputImage->getPlane(uiPlane), uiSize >> 1 );752 }753 }754 755 template<UInt bitDepth>756 Void TRenFilter<bitDepth>::binominal( PelImagePlane* pcInputPlane, PelImagePlane* pcOutputPlane, UInt uiSize )757 {758 Int iWidth = pcInputPlane ->getWidth ();759 Int iHeight = pcInputPlane ->getHeight();760 761 assert( pcOutputPlane->getWidth () == iWidth );762 assert( pcOutputPlane->getHeight() == iHeight );763 assert( pcInputPlane ->getPad () >= uiSize );764 assert( pcOutputPlane->getPad () >= uiSize );765 766 if (uiSize == 0)767 {768 pcOutputPlane->assign( pcInputPlane );769 return;770 };771 772 Int iInputStride = pcInputPlane ->getStride();773 Int iOutputStride = pcOutputPlane->getStride();774 Int iTempStride = iWidth + (uiSize << 1);775 776 777 Pel* pcCurInputData = pcInputPlane ->getPlaneData() - uiSize;778 Pel* pcTempData = new Pel[iTempStride * iHeight];779 Pel* pcCurTempData = pcTempData;780 781 Pel (*fpFilter) ( Pel*, Int ) = NULL;782 783 switch( uiSize )784 {785 case 1:786 fpFilter = &TRenFilter<bitDepth>::xFiltBinom3;787 break;788 case 2:789 fpFilter = &TRenFilter<bitDepth>::xFiltBinom5;790 break;791 case 3:792 fpFilter = &TRenFilter<bitDepth>::xFiltBinom7;793 break;794 case 4:795 fpFilter = &TRenFilter<bitDepth>::xFiltBinom9;796 break;797 default:798 AOT(true);799 }800 801 for (Int iPosY = 0; iPosY < iHeight; iPosY++ )802 {803 for (Int iPosX = 0; iPosX < iWidth + (uiSize << 1); iPosX++)804 {805 pcCurTempData[iPosX] = (*fpFilter)(pcCurInputData + iPosX, iInputStride );806 }807 pcCurTempData += iTempStride;808 pcCurInputData += iInputStride;809 }810 811 pcCurTempData = pcTempData + uiSize;812 Pel* pcCurOutputData = pcOutputPlane->getPlaneData();813 814 for (Int iPosY = 0; iPosY < iHeight; iPosY++ )815 {816 for (Int iPosX = 0; iPosX < iWidth; iPosX++)817 {818 pcCurOutputData[iPosX] = (*fpFilter)(pcCurTempData + iPosX, 1);819 }820 pcCurTempData += iTempStride;821 pcCurOutputData += iOutputStride;822 }823 824 delete[] pcTempData;825 }826 827 template<UInt bitDepth>828 Pel TRenFilter<bitDepth>::xFiltBinom3( Pel* pcInputData, Int iStride )829 {830 Int iSum = pcInputData[-1 * iStride ] + pcInputData[ 0 ] + (pcInputData[iStride ] << 1 );831 return ClipBD( (iSum + 2) >> 2 , bitDepth);832 }833 834 template<UInt bitDepth>835 Pel TRenFilter<bitDepth>::xFiltBinom5( Pel* pcInputData, Int iStride )836 {837 // { 1,4,6,4,1 }838 Int iStride0 = 0;839 Int iStrideM1 = iStride0 - iStride;840 Int iStrideM2 = iStrideM1 - iStride;841 Int iStrideP1 = iStride0 + iStride;842 Int iStrideP2 = iStrideP1 + iStride;843 844 Int iTmp0 = pcInputData[iStrideM2] + pcInputData[iStrideP2];845 Int iTmp1 = pcInputData[iStrideM1] + pcInputData[iStrideP1];846 Int iTmp2 = pcInputData[iStride0 ];847 848 Int iSum = iTmp0 + (iTmp2 << 1) + ((iTmp1 + iTmp2) << 2);849 return ClipBD( (iSum + 8) >> 4 , bitDepth);850 }851 852 template<UInt bitDepth>853 Pel TRenFilter<bitDepth>::xFiltBinom7( Pel* pcInputData, Int iStride )854 {855 // { 1,6,15,20,15,6,1 }856 Int iStride0 = 0;857 Int iStrideM1 = iStride0 - iStride;858 Int iStrideM2 = iStrideM1 - iStride;859 Int iStrideM3 = iStrideM1 - iStride;860 Int iStrideP1 = iStride0 + iStride;861 Int iStrideP2 = iStrideP1 + iStride;862 Int iStrideP3 = iStrideP1 + iStride;863 864 Int iTmp0 = pcInputData[iStrideM3] + pcInputData[iStrideP3];865 Int iTmp1 = pcInputData[iStrideM2] + pcInputData[iStrideP2];866 Int iTmp2 = pcInputData[iStrideM1] + pcInputData[iStrideP1];867 Int iTmp3 = pcInputData[iStride0];868 869 Int iSum = iTmp0 - iTmp2 + ( iTmp1 << 1) + ( (iTmp1 + iTmp3) << 2) + ((iTmp2 + iTmp3) << 4);870 871 return ClipBD( (iSum + 32) >> 6 , bitDepth);872 }873 874 template<UInt bitDepth>875 Pel TRenFilter<bitDepth>::xFiltBinom9( Pel* pcInputData, Int iStride )876 {877 // { 1 8 28 56 70 56 28 8 1 }878 Int iStride0 = 0;879 Int iStrideM1 = iStride0 - iStride;880 Int iStrideM2 = iStrideM1 - iStride;881 Int iStrideM3 = iStrideM1 - iStride;882 Int iStrideM4 = iStrideM1 - iStride;883 Int iStrideP1 = iStride0 + iStride;884 Int iStrideP2 = iStrideP1 + iStride;885 Int iStrideP3 = iStrideP1 + iStride;886 Int iStrideP4 = iStrideP1 + iStride;887 888 Int iTmp0 = pcInputData[iStrideM4] + pcInputData[iStrideP4];889 Int iTmp1 = pcInputData[iStrideM3] + pcInputData[iStrideP3];890 Int iTmp2 = pcInputData[iStrideM2] + pcInputData[iStrideP2];891 Int iTmp3 = pcInputData[iStrideM1] + pcInputData[iStrideP1];892 Int iTmp4 = pcInputData[iStride0];893 894 Int iSum = iTmp0 + ((iTmp4 ) << 1) + ( ( iTmp4 - iTmp2 ) << 2) + ( (iTmp1 - iTmp3) << 3 ) + ((iTmp2 ) << 5) + ((iTmp3+ iTmp4 ) << 6);895 896 return ClipBD( (iSum + 128) >> 8 , bitDepth);897 }898 899 template<UInt bitDepth>900 Pel TRenFilter<bitDepth>::interpCHSpline(Double dX, Double dS0, Double dS1, Int iQ0, Int iQ1, Int iQ2, Int iQ3)901 {902 Double dSq = (dX - dS0) / (dS1 - dS0);903 904 Double adP[4];905 Double dSqP2 = dSq * dSq;906 Double dSqP3 = dSqP2 * dSq;907 908 adP[0] = 1 - 3 * dSqP2 + 2 * dSqP3;909 adP[1] = dSq - 2 * dSqP2 + dSqP3;910 adP[2] = 3 * dSqP2 - 2 * dSqP3;911 adP[3] = -dSqP2 + dSqP3;912 913 Double dQ = adP[0] * iQ0 + adP[1] * iQ1 + adP[2] * iQ2 + adP[3] * iQ3 ;914 915 Pel cQ = (Pel) ( dQ + 0.5);916 917 cQ = ( cQ < 0 ? 0 : cQ );918 cQ = ( cQ > 255 ? 255 : cQ );919 920 return cQ;921 922 }923 924 template<UInt bitDepth>925 Void TRenFilter<bitDepth>::diffHorSym(PelImage* pcInputImage, IntImage* pcOutputImage)926 {927 for (UInt uiCurPlane = 0; uiCurPlane < pcInputImage->getNumberOfPlanes(); uiCurPlane++)928 {929 diffHorSym( pcInputImage->getPlane(uiCurPlane), pcOutputImage->getPlane(uiCurPlane));930 };931 }932 933 template<UInt bitDepth>934 Void TRenFilter<bitDepth>::diffHorSym(PelImagePlane* pcInputPlane, IntImagePlane* pcOutputPlane)935 {936 UInt uiInputStride = pcInputPlane ->getStride();937 UInt uiOutputStride = pcOutputPlane->getStride();938 UInt uiWidth = pcInputPlane ->getWidth();939 UInt uiHeight = pcInputPlane ->getHeight();940 941 Pel* pcInputData = pcInputPlane ->getPlaneData();942 Int* piOutputData = pcOutputPlane->getPlaneData();943 944 for (UInt uiPosY = 0; uiPosY < uiHeight; uiPosY++)945 {946 for (UInt uiPosX = 1; uiPosX < uiWidth-1; uiPosX++)947 {948 piOutputData[uiPosX] = ((Int) pcInputData[uiPosX+1] - (Int) pcInputData[uiPosX-1]);949 piOutputData[uiPosX] /= 2;950 };951 952 piOutputData[0] = piOutputData[1];953 piOutputData[uiWidth-1] = piOutputData[uiWidth-2];954 pcInputData += uiInputStride;955 piOutputData += uiOutputStride;956 957 };958 }959 960 template<UInt bitDepth>961 Void TRenFilter<bitDepth>::laplace( DoubleImage* pcInputImage, DoubleImage* pcOutputImage )962 {963 for (UInt uiCurPlane = 0; uiCurPlane < pcInputImage->getNumberOfPlanes(); uiCurPlane++)964 {965 DoubleImagePlane* pcInputPlane = pcInputImage ->getPlane(uiCurPlane);966 DoubleImagePlane* pcOutputPlane = pcOutputImage ->getPlane(uiCurPlane);967 968 UInt uiWidth = pcInputPlane->getWidth();969 UInt uiHeight = pcInputPlane->getHeight();970 971 Double* pdInputData = pcInputPlane ->getPlaneData();972 Double* pdOutputData = pcOutputPlane ->getPlaneData();973 974 for (UInt uiPosY = 1; uiPosY < uiHeight-1; uiPosY++)975 {976 UInt uOff = uiPosY * uiWidth;977 for(UInt uiPosX = 1; uiPosX < uiWidth-1; uiPosX++)978 {979 UInt uOff2 = uOff + uiPosX;980 pdOutputData[uOff2] = 4 * pdInputData[uOff2]981 - pdInputData[uOff2 - 1]982 - pdInputData[uOff2 + 1]983 - pdInputData[uOff2 - uiWidth]984 - pdInputData[uOff2 + uiWidth];985 }986 };987 988 // left and right margin989 for (UInt uiPosY = 1; uiPosY < uiHeight-1; uiPosY++)990 {991 UInt uOff = uiPosY * uiWidth;992 pdOutputData[uOff] = 3 * pdInputData[uOff]993 - pdInputData[uOff + 1]994 - pdInputData[uOff - uiWidth]995 - pdInputData[uOff + uiWidth];996 997 998 uOff = (uiPosY + 1) * uiWidth - 1;999 pdOutputData[uOff] = 3 * pdInputData[uOff]1000 - pdInputData[uOff - 1]1001 - pdInputData[uOff - uiWidth]1002 - pdInputData[uOff + uiWidth];1003 }1004 1005 for (UInt uiPosX = 1; uiPosX < uiWidth-1; uiPosX++)1006 {1007 UInt uOff = uiPosX;1008 pdOutputData[uOff] = 3 * pdInputData[uOff]1009 - pdInputData[uOff + 1]1010 - pdInputData[uOff - 1]1011 - pdInputData[uOff + uiWidth];1012 1013 1014 uOff = (uiHeight - 1) * uiWidth + uiPosX;1015 pdOutputData[uOff] = 3 * pdInputData[uOff]1016 - pdInputData[uOff + 1]1017 - pdInputData[uOff - 1]1018 - pdInputData[uOff - uiWidth];1019 }1020 1021 UInt uOff = 0;1022 pdOutputData[uOff] = 2 * pdInputData[uOff] - pdInputData[uOff+1] - pdInputData[ uOff + uiWidth];1023 uOff = uiWidth - 1;1024 pdOutputData[uOff] = 2 * pdInputData[uOff] - pdInputData[uOff-1] - pdInputData[ uOff + uiWidth ];1025 uOff = (uiHeight - 1) * uiWidth;1026 pdOutputData[uOff] = 2 * pdInputData[uOff] - pdInputData[uOff+1] - pdInputData[ uOff - uiWidth];1027 uOff = uiHeight * uiWidth - 1;1028 pdOutputData[uOff] = 2 * pdInputData[uOff] - pdInputData[uOff-1] - pdInputData[ uOff - uiWidth];1029 1030 }1031 }1032 1033 template<UInt bitDepth>1034 Void TRenFilter<bitDepth>::conv( PelImage* pcImage, DoubleImage* pcKernel )1035 {1036 PelImage* pcTemp = pcImage->create();1037 1038 DoubleImagePlane* pcKernelPlane = 0;1039 for (UInt uiCurPlane = 0; uiCurPlane < pcImage->getNumberOfPlanes(); uiCurPlane++) {1040 1041 PelImagePlane* pcPlane = pcImage->getPlane(uiCurPlane);1042 PelImagePlane* pcTempPlane = pcTemp ->getPlane(uiCurPlane);1043 1044 if ( uiCurPlane <= pcKernel->getNumberOfPlanes() )1045 {1046 pcKernelPlane = pcKernel->getPlane(uiCurPlane);1047 };1048 1049 UInt uiWidth = pcPlane->getWidth();1050 UInt uiHeight = pcPlane->getHeight();1051 1052 UInt uiKernelWidth = pcKernelPlane->getWidth();1053 UInt uiKernelHeight = pcKernelPlane->getHeight();1054 1055 Pel* pcData = pcPlane ->getPlaneData();1056 Pel* pcTempData = pcTempPlane ->getPlaneData();1057 Double* pdKernelData = pcKernelPlane->getPlaneData();1058 1059 UInt uiDataStride = pcPlane ->getStride();1060 UInt uiTempDataStride = pcTempPlane ->getStride();1061 UInt uiKernelDataStride = pcKernelPlane->getStride();1062 1063 for(UInt uiPosY = 0; uiPosY < uiHeight; uiPosY++)1064 {1065 UInt uOff = uiPosY * uiTempDataStride;1066 for(UInt uiPosX = 0; uiPosX < uiWidth; uiPosX++)1067 {1068 Double dSum = 0;1069 for(UInt uKY = 0; uKY < uiKernelHeight; uKY++)1070 {1071 UInt uKOff = uKY * uiKernelDataStride;1072 1073 Int iYSrc = uiPosY - (uiKernelHeight/2) + uKY;1074 1075 if (iYSrc < 0)1076 iYSrc = -iYSrc;1077 1078 if (iYSrc >= (Int)uiHeight)1079 iYSrc = 2*uiHeight - iYSrc - 1;1080 1081 UInt uSrcOff = iYSrc * uiDataStride;1082 1083 for(UInt uKX = 0; uKX < uiKernelWidth; uKX++)1084 {1085 Int iXSrc = uiPosX - (uiKernelWidth/2) + uKX;1086 1087 if (iXSrc < 0)1088 iXSrc = -iXSrc;1089 1090 if (iXSrc >= (Int)uiWidth)1091 iXSrc = 2*uiWidth - iXSrc - 1;1092 1093 dSum += pcData[uSrcOff + iXSrc] * pdKernelData[uKOff + uKX];1094 }1095 }1096 pcTempData[uOff + uiPosX] = (Pel) (dSum + ( ( dSum < 0 ) ? -0.5 : 0.5) );1097 }1098 }1099 }1100 1101 pcImage->assign(pcTemp);1102 delete pcTemp;1103 }1104 1105 1106 // Horizontal Up sampling luma1107 template<UInt bitDepth>1108 Void TRenFilter<bitDepth>::sampleHorUp( Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride )1109 {1110 TRenInterpFilter<bitDepth> cFilter;1111 switch ( iLog2HorSampFac )1112 {1113 case 0:1114 xDistributeArray ( pcInputPlaneData, iInputStride, 1 , 1, iInputWidth, iHeight, pcOutputPlaneData, iOutputStride, 1, 1 );1115 break;1116 case 1:1117 xDistributeArray ( pcInputPlaneData, iInputStride, 1 , 1, iInputWidth, iHeight, pcOutputPlaneData, iOutputStride, 2, 1 );1118 cFilter.xCTI_FilterHalfHor ( pcInputPlaneData, iInputStride, 1, iInputWidth, iHeight, iOutputStride, 2, ++pcOutputPlaneData );1119 break;1120 case 2:1121 xDistributeArray ( pcInputPlaneData, iInputStride, 1 , 1, iInputWidth, iHeight, pcOutputPlaneData, iOutputStride, 4, 1 );1122 cFilter.xCTI_FilterQuarter0Hor( pcInputPlaneData, iInputStride, 1, iInputWidth, iHeight, iOutputStride, 4, ++pcOutputPlaneData );1123 cFilter.xCTI_FilterHalfHor ( pcInputPlaneData, iInputStride, 1, iInputWidth, iHeight, iOutputStride, 4, ++pcOutputPlaneData );1124 cFilter.xCTI_FilterQuarter1Hor( pcInputPlaneData, iInputStride, 1, iInputWidth, iHeight, iOutputStride, 4, ++pcOutputPlaneData );1125 break;1126 }1127 }1128 1129 // horizontal up sampling chroma1130 template<UInt bitDepth>1131 Void TRenFilter<bitDepth>::sampleCHorUp(Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride )1132 {1133 switch ( iLog2HorSampFac )1134 {1135 case 0:1136 xDistributeArray( pcInputPlaneData, iInputStride , 1, 1, iInputWidth, iHeight , pcOutputPlaneData , iOutputStride, 1 , 1 );1137 break;1138 case 1:1139 xDistributeArray( pcInputPlaneData, iInputStride , 1, 1, iInputWidth, iHeight , pcOutputPlaneData , iOutputStride, 2 , 1 );1140 xInterpHorChroma( pcInputPlaneData , iInputStride , 1, 1, iInputWidth, iHeight , pcOutputPlaneData +1, iOutputStride, 2 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VPS04_C_HAL );1141 break;1142 case 2:1143 xDistributeArray( pcInputPlaneData, iInputStride , 1, 1, iInputWidth, iHeight , pcOutputPlaneData , iOutputStride, 4 , 1 );1144 xInterpHorChroma( pcInputPlaneData , iInputStride , 1, 1, iInputWidth, iHeight , pcOutputPlaneData +1, iOutputStride, 4 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VP04_C_QUA0 );1145 xInterpHorChroma( pcInputPlaneData , iInputStride , 1, 1, iInputWidth, iHeight , pcOutputPlaneData +2, iOutputStride, 4 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VPS04_C_HAL );1146 xInterpHorChroma( pcInputPlaneData , iInputStride , 1, 1, iInputWidth, iHeight , pcOutputPlaneData +3, iOutputStride, 4 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VP04_C_QUA1 );1147 break;1148 }1149 }1150 1151 template<UInt bitDepth>1152 Void TRenFilter<bitDepth>::sampleCUpHorUp( Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride )1153 {1154 1155 switch ( iLog2HorSampFac )1156 {1157 case 0:1158 xDistributeArray( pcInputPlaneData-1, iInputStride , 1, 1, iInputWidth+3, iHeight , pcOutputPlaneData -2, iOutputStride, 2, 2 );1159 xInterpVerChroma( pcInputPlaneData-1, iInputStride , 1, 1, iInputWidth+3, iHeight , pcOutputPlaneData+1*iOutputStride-2, iOutputStride, 2 , 2, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VPS04_C_HAL );1160 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 2, 1, iInputWidth, iHeight*2 , pcOutputPlaneData+1 , iOutputStride, 2 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VPS04_C_HAL );1161 break;1162 case 1:1163 xDistributeArray( pcInputPlaneData-1, iInputStride , 1, 1, iInputWidth+3, iHeight , pcOutputPlaneData -4, iOutputStride, 4 , 2 );1164 xInterpVerChroma( pcInputPlaneData-1, iInputStride , 1, 1, iInputWidth+3, iHeight , pcOutputPlaneData+1*iOutputStride-4, iOutputStride, 4 , 2, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VPS04_C_HAL );1165 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 4, 1, iInputWidth, iHeight*2 , pcOutputPlaneData +1, iOutputStride, 4 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VP04_C_QUA0 );1166 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 4, 1, iInputWidth, iHeight*2 , pcOutputPlaneData +2, iOutputStride, 4 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VPS04_C_HAL );1167 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 4, 1, iInputWidth, iHeight*2 , pcOutputPlaneData +3, iOutputStride, 4 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VP04_C_QUA1 );1168 break;1169 case 2:1170 xDistributeArray( pcInputPlaneData-1, iInputStride , 1, 1, iInputWidth+3, iHeight , pcOutputPlaneData -8, iOutputStride, 8 , 2 );1171 xInterpVerChroma( pcInputPlaneData-1, iInputStride , 1, 1, iInputWidth+3, iHeight , pcOutputPlaneData+1*iOutputStride-8, iOutputStride, 8 , 2, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VPS04_C_HAL );1172 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 8, 1, iInputWidth, iHeight*2 , pcOutputPlaneData +1, iOutputStride, 8 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VP04_C_OCT0 );1173 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 8, 1, iInputWidth, iHeight*2 , pcOutputPlaneData +2, iOutputStride, 8 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VP04_C_QUA0 );1174 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 8, 1, iInputWidth, iHeight*2 , pcOutputPlaneData +3, iOutputStride, 8 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VP04_C_OCT1 );1175 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 8, 1, iInputWidth, iHeight*2 , pcOutputPlaneData +4, iOutputStride, 8 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VPS04_C_HAL );1176 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 8, 1, iInputWidth, iHeight*2 , pcOutputPlaneData +5, iOutputStride, 8 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VP04_C_OCT2 );1177 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 8, 1, iInputWidth, iHeight*2 , pcOutputPlaneData +6, iOutputStride, 8 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VP04_C_QUA1 );1178 xInterpHorChroma( pcOutputPlaneData , iOutputStride , 8, 1, iInputWidth, iHeight*2 , pcOutputPlaneData +7, iOutputStride, 8 , 1, &TRenInterpFilter<REN_BIT_DEPTH>::xCTI_Filter_VP04_C_OCT3 );1179 break;1180 }1181 }1182 1183 // Down Sampling1184 // Down sample luma1185 template<UInt bitDepth>1186 Void TRenFilter<bitDepth>::sampleHorDown(Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride )1187 {1188 switch ( iLog2HorSampFac )1189 {1190 case 0:1191 xDistributeArray( pcInputPlaneData, iInputStride, 1, 1, iInputWidth,iHeight, pcOutputPlaneData, iOutputStride, 1 , 1 );1192 break;1193 case 1:1194 xSampleDownHor2(pcInputPlaneData, iInputStride, iInputWidth, iHeight, pcOutputPlaneData, iOutputStride);1195 break;1196 case 2:1197 xSampleDownHor4(pcInputPlaneData, iInputStride, iInputWidth, iHeight, pcOutputPlaneData, iOutputStride);1198 break;1199 }1200 }1201 1202 template<UInt bitDepth>1203 Void TRenFilter<bitDepth>::sampleCHorDown(Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride )1204 {1205 //GT: currently the same as for luma1206 sampleHorDown( iLog2HorSampFac, pcInputPlaneData, iInputStride, iInputWidth, iHeight, pcOutputPlaneData, iOutputStride);1207 }1208 1209 1210 1211 // Up sampling chroma1212 template<UInt bitDepth>1213 Void TRenFilter<bitDepth>::sampleCDownHorDown( Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iInputHeight, Pel* pcOutputPlaneData, Int iOutputStride )1214 {1215 // create buffer1216 Int iBufferStride = iInputWidth >> (iLog2HorSampFac + 1);1217 Pel* piBuffer = new Pel[ iBufferStride * (iInputHeight+2) ];1218 1219 switch ( iLog2HorSampFac )1220 {1221 case 0:1222 xSampleDownHor2( pcInputPlaneData - iInputStride, iInputStride, iInputWidth , iInputHeight+1, piBuffer, iBufferStride);1223 break;1224 case 1:1225 xSampleDownHor4( pcInputPlaneData - iInputStride , iInputStride, iInputWidth , iInputHeight+1, piBuffer, iBufferStride);1226 break;1227 case 2:1228 xSampleDownHor8( pcInputPlaneData - iInputStride , iInputStride, iInputWidth , iInputHeight+1, piBuffer, iBufferStride);1229 break;1230 }1231 xSampleDownVer2( piBuffer + iBufferStride , iBufferStride, iBufferStride, iInputHeight, pcOutputPlaneData, iOutputStride);1232 delete[] piBuffer;1233 }1234 1235 template<UInt bitDepth>1236 Void TRenFilter<bitDepth>::xDistributeArray(const Pel* pcSrc, Int iSrcStride, Int iSrcStepX, Int iSrcStepY, Int iWidth, Int iHeight, Pel* pcDst, Int iDstStride, Int iDstStepX, Int iDstStepY)1237 {1238 iDstStride *= iDstStepY;1239 iSrcStride *= iSrcStepY;1240 for (Int iYPos = 0; iYPos < iHeight; iYPos++ )1241 {1242 Pel* pcCurDst = pcDst;1243 const Pel* pcCurSrc = pcSrc;1244 for (Int iXPos = 0; iXPos < iWidth; iXPos ++)1245 {1246 *pcCurDst = *pcCurSrc;1247 1248 pcCurDst += iDstStepX;1249 pcCurSrc += iSrcStepX;1250 }1251 pcDst += iDstStride;1252 pcSrc += iSrcStride;1253 }1254 }1255 1256 template<UInt bitDepth>1257 Void TRenFilter<bitDepth>::xInterpHorChroma( Pel* piSrc, Int iSrcStride, Int iSrcStepX, Int iSrcStepY, Int iWidth, Int iHeight, Pel* piDst, Int iDstStride, Int iDstStepX, Int iDstStepY, FpChromaIntFilt fpFilter )1258 {1259 Int iSum;1260 Pel* piSrcTmp;1261 1262 TRenInterpFilter<REN_BIT_DEPTH> cFilter;1263 for ( Int y = iHeight; y != 0; y-- )1264 {1265 piSrcTmp = piSrc - iSrcStepX;1266 for ( Int x = 0; x < iWidth; x++ )1267 {1268 iSum = (cFilter.*fpFilter)( piSrcTmp, iSrcStepX );1269 piDst[x * iDstStepX ] = ClipBD ((iSum + 32) >> 6 , bitDepth);1270 piSrcTmp+= iSrcStepX;1271 }1272 piSrc += iSrcStride * iSrcStepY;1273 piDst += iDstStride * iDstStepY;1274 }1275 }1276 1277 template<UInt bitDepth>1278 Void TRenFilter<bitDepth>::xInterpVerChroma( Pel* piSrc, Int iSrcStride, Int iSrcStepX, Int iSrcStepY, Int iWidth, Int iHeight, Pel* piDst, Int iDstStride, Int iDstStepX, Int iDstStepY, FpChromaIntFilt fpFilter )1279 {1280 Int iSum;1281 Pel* piSrcTmp;1282 1283 TRenInterpFilter<bitDepth> cFilter;1284 for ( Int y = iHeight; y != 0; y-- )1285 {1286 piSrcTmp = piSrc - iSrcStepY * iSrcStride;1287 for ( Int x = 0; x < iWidth; x++ )1288 {1289 iSum = (cFilter.*fpFilter)( piSrcTmp, iSrcStepY * iSrcStride );1290 piDst[x * iDstStepX ] = ClipBD ((iSum + 32) >> 6, bitDepth );1291 piSrcTmp += iSrcStepX;1292 }1293 piSrc += iSrcStride * iSrcStepY;1294 piDst += iDstStride * iDstStepY;1295 }1296 }1297 1298 template<UInt bitDepth>1299 Void TRenFilter<bitDepth>::xSampleDownHor2( Pel* piSrc, Int iSrcStride, Int iSrcWidth, Int iHeight, Pel* piDst, Int iDstStride )1300 {1301 1302 Int iSum;1303 Pel* piSrcTmp;1304 1305 1306 for ( Int y = iHeight; y != 0; y-- )1307 {1308 piSrcTmp = piSrc - 1 ;1309 for ( Int x = 0; x < (iSrcWidth >> 1); x++ )1310 {1311 // { 1,2,1 }1312 iSum = piSrcTmp[0] + piSrcTmp[2] + (piSrcTmp[1] << 1);1313 piDst[x] = ClipBD( (iSum + 2) >> 2 , bitDepth);1314 piSrcTmp += 2;1315 }1316 piSrc += iSrcStride;1317 piDst += iDstStride;1318 }1319 };1320 1321 template<UInt bitDepth>1322 Void TRenFilter<bitDepth>::xSampleDownVer2( Pel* piSrc, Int iSrcStride, Int iSrcWidth, Int iSrcHeight, Pel* piDst, Int iDstStride )1323 {1324 Int iSum;1325 Pel* piSrcTmp;1326 1327 for ( Int y = (iSrcHeight >> 1); y != 0; y-- )1328 {1329 piSrcTmp = piSrc -1 * iSrcStride;1330 for ( Int x = 0; x < iSrcWidth; x++ )1331 {1332 // { 1,2,1 }1333 iSum = piSrcTmp[0] + piSrcTmp[ iSrcStride << 1] + (piSrcTmp[ iSrcStride ] << 1);1334 piDst[x] = ClipBD( (iSum + 2) >> 2, bitDepth );1335 piSrcTmp += 1;1336 }1337 piSrc += (iSrcStride << 1);1338 piDst += iDstStride;1339 }1340 };1341 1342 template<UInt bitDepth>1343 Void TRenFilter<bitDepth>::xSampleDownHor4( Pel* piSrc, Int iSrcStride, Int iSrcWidth, Int iHeight, Pel* piDst, Int iDstStride )1344 {1345 1346 Int iSum;1347 Pel* piSrcTmp;1348 1349 Int iTmp0, iTmp1, iTmp2;1350 1351 for ( Int y = iHeight; y != 0; y-- )1352 {1353 piSrcTmp = piSrc -2 ;1354 for ( Int x = 0; x < (iSrcWidth >> 2); x++ )1355 {1356 // { 1,4,6,4,1 }1357 iTmp0 = piSrcTmp[0] + piSrcTmp[4];1358 iTmp1 = piSrcTmp[1] + piSrcTmp[3];1359 iTmp2 = piSrcTmp[2];1360 1361 iSum = iTmp0 + (iTmp2 << 1) + ((iTmp1 + iTmp2) << 2);1362 piDst[x] = ClipBD( (iSum + 8) >> 4, bitDepth );1363 piSrcTmp += 4;1364 }1365 piSrc += iSrcStride;1366 piDst += iDstStride;1367 }1368 };1369 1370 template<UInt bitDepth>1371 Void TRenFilter<bitDepth>::xSampleDownHor8( Pel* piSrc, Int iSrcStride, Int iSrcWidth, Int iHeight, Pel* piDst, Int iDstStride )1372 {1373 Int iSum;1374 Pel* piSrcTmp;1375 1376 Int iTmp0, iTmp1, iTmp2, iTmp3;1377 1378 for ( Int y = iHeight; y != 0; y-- )1379 {1380 piSrcTmp = piSrc -3;1381 for ( Int x = 0; x < (iSrcWidth >> 3); x++ )1382 {1383 // { 1,6,15,20,15,6,1 }1384 iTmp0 = piSrcTmp[0] + piSrcTmp[6];1385 iTmp1 = piSrcTmp[1] + piSrcTmp[5];1386 iTmp2 = piSrcTmp[2] + piSrcTmp[4];1387 iTmp3 = piSrcTmp[3];1388 1389 iSum = iTmp0 - iTmp2 + ( iTmp1 << 1) + ( (iTmp1 + iTmp3) << 2) + ((iTmp2 + iTmp3) << 4);1390 piDst[x] = ClipBD( (iSum + 32) >> 6 , bitDepth);1391 piSrcTmp += 8;1392 }1393 piSrc += iSrcStride;1394 piDst += iDstStride;1395 }1396 };1397 1398 template<UInt bitDepth>1399 Void TRenFilter<bitDepth>::xDilate( Pel* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Pel* piDst, Int iDstStride, Int iSize, Bool bVerticalDir, Bool bToTopOrLeft )1400 {1401 Int iFDimStart = 0;1402 Int iInc = 1;1403 Int iSDimStart = 0;1404 1405 Int iFDimSrcStrd = bVerticalDir ? 1 : iSrcStride;1406 Int iFDimDstStrd = bVerticalDir ? 1 : iDstStride;1407 1408 Int iSDimSrcStrd = bVerticalDir ? iSrcStride : 1;1409 Int iSDimDstStrd = bVerticalDir ? iDstStride : 1;1410 1411 Int iFDimEnd = bVerticalDir ? iWidth -1 : iHeight - 1;1412 Int iSDimEnd = bVerticalDir ? iHeight-1 : iWidth - 1;1413 1414 if ( bToTopOrLeft )1415 {1416 iSDimStart = iSDimEnd;1417 iSDimEnd = 0;1418 iInc *= -1;1419 }1420 1421 for (Int iPosFDim = iFDimStart; iPosFDim <= iFDimEnd; iPosFDim++ )1422 {1423 Int iCount = 0;1424 Bool bLastWasOne = false;1425 Bool bDilate = false;1426 Int iPosSDim = iSDimStart;1427 Bool bContinue = true;1428 1429 while ( bContinue )1430 {1431 if ( iCount == iSize )1432 {1433 iCount = 0;1434 bDilate = false;1435 }1436 1437 Pel iVal = piSrc[iPosSDim*iSDimSrcStrd];1438 if( iVal == 0 && bLastWasOne )1439 {1440 iCount = 0;1441 bDilate = true;1442 }1443 1444 if( bDilate )1445 {1446 piDst[iPosSDim*iSDimDstStrd] = REN_USED_PEL;1447 iCount++;1448 }1449 else1450 {1451 piDst[iPosSDim*iSDimDstStrd] = iVal;1452 }1453 1454 1455 bLastWasOne = (iVal == REN_USED_PEL);1456 bContinue = (iPosSDim != iSDimEnd);1457 iPosSDim += iInc;1458 }1459 1460 piSrc += iFDimSrcStrd;1461 piDst += iFDimDstStrd;1462 }1463 };1464 1465 1466 template class TRenFilter<REN_BIT_DEPTH>;1467 1468 template Bool TRenFilter<REN_BIT_DEPTH>::compare (TRenImage<Pel >*, TRenImage<Pel>* );1469 template Bool TRenFilter<REN_BIT_DEPTH>::compare (TRenImagePlane<Pel>*, TRenImagePlane<Pel>* );1470 1471 template Void TRenFilter<REN_BIT_DEPTH>::mirrorHor( TRenImage<Double> *pcImage );1472 template Void TRenFilter<REN_BIT_DEPTH>::mirrorHor( TRenImage<Pel> *pcImage );1473 template Void TRenFilter<REN_BIT_DEPTH>::mirrorHor( TRenImage<Int> *pcImage );1474 template Void TRenFilter<REN_BIT_DEPTH>::mirrorHor( TRenImagePlane<Pel> *pcImagePlane );1475 1476 #endif1477 -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenFilter.h
r1386 r1390 39 39 #include "TRenImage.h" 40 40 #include "TRenInterpFilter.h" 41 #if NH_3D_VSO42 43 typedef Int (TRenInterpFilter<REN_BIT_DEPTH>::*FpChromaIntFilt) ( Pel*, Int );44 45 template<UInt bitDepthLuma>46 class TRenFilter47 {48 public:49 50 /////////// Helpers ////////51 static Void setSubPelShiftLUT ( Int iLutPrec, Int** piSubPelShiftLUT, Int iShift );52 static Void setupZLUT ( Bool bBlendUseDistWeight, Int iBlendZThresPerc, Int iRelDistToLeft, Int** ppiBaseShiftLUTLeft, Int** ppiBaseShiftLUTRight, Int& riBlendZThres, Int& riBlendDistWeight, Int* piInvZLUTLeft, Int* piInvZLUTRight );53 static Void filledToUsedPelMap( PelImage* pcFilledImage, PelImage* pcUsedPelsImage, Int iUsedPelMapMarExt );54 55 /////////// Copy ///////////56 static Void copy( const Pel* pcInputPlaneData, Int iInputStride, Int iWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride);57 58 /////////// Horizontal Mirroring ///////////59 template <typename T> static Void mirrorHor( TRenImage<T> *pcInputImage );60 //Plane61 template <typename T> static Void mirrorHor( TRenImagePlane<T> *pcImagePlane );62 63 /////////// Comparison ///////////64 65 static Int64 SSE ( PelImagePlane* pcInputPlane1, PelImagePlane* pcInputPlane2, Bool bLuma );66 static Int64 SSE ( Pel* piSrc1, Int iSrcStride1, Int iWidth, Int iHeight, Pel* piSrc2, Int iSrcStride2, Bool bLuma );67 68 template <typename T> static Bool compare (TRenImage<T> *pcInputImage1 , TRenImage<T> *pcInputImage2);69 //Plane70 template <typename T> static Bool compare (TRenImagePlane<T>* pcInputPlane1, TRenImagePlane<T>* pcInputPlane2 );71 72 /////////// other Filters ///////////73 static Void binominal ( PelImage* pcInputImage, PelImage* pcOutputPlane, UInt uiSize);74 static Void binominal ( PelImagePlane* pcInputPlane, PelImagePlane* pcOutputPlane, UInt uiSize );75 76 static Void lineMedian3( PelImage* pcImage );77 static Void convRect ( PelImage* pcImage, UInt uiSize);78 static Void laplace ( DoubleImage* pcInputImage, DoubleImage* pcOutputImage);79 static Void diffHorSym ( PelImage* pcInputImage, IntImage* pcOutputImage);80 81 //Plane82 static Void diffHorSym (PelImagePlane* pcInputPlane, IntImagePlane* pcOutputPlane);83 84 /////////// Convolution ///////////85 static Void conv (PelImage* pcImage, DoubleImage* pcKernel);86 87 /////////// InterPolation ///////////88 static Pel interpCHSpline(Double dX, Double dS0, Double dS1, Int iQ0, Int iQ1, Int iQ2, Int iQ3);89 90 91 /////////// HEVC/ binomial Up and Down sampling ///////////92 //// Down sampling (binomial)93 // Horizontally94 static Void sampleHorDown (Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iHeight , Pel* pcOutputPlaneData, Int iOutputStride );95 static Void sampleCHorDown (Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iInputHeight, Pel* pcOutputPlaneData, Int iOutputStride );96 // 444->420 and horizontally97 static Void sampleCDownHorDown(Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iInputHeight, Pel* pcOutputPlaneData, Int iOutputStride );98 99 //// Up sampling (HEVC 8/4 tap)100 // Horizontally101 static Void sampleHorUp (Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride );102 static Void sampleCHorUp (Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride );103 // 420->444 and horizontally104 static Void sampleCUpHorUp (Int iLog2HorSampFac, Pel* pcInputPlaneData, Int iInputStride, Int iInputWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride );105 106 //// Down sampling (13 tap)107 108 static Void sampleDown2Tap13 ( Pel* pcInputPlaneData, Int iInputStride, Int iWidth, Int iHeight, Pel* pcOutputPlaneData, Int iOutputStride );109 // Plane110 static Void sampleHorDown2Tap13(PelImagePlane* pcInputPlane, PelImagePlane* pcOutputPlane, Int uiPad);111 static Void sampleVerDown2Tap13(PelImagePlane* pcInputPlane, PelImagePlane* pcOutputPlane, Int uiPad);112 static Void sampleDown2Tap13 (PelImagePlane* pcInputPlane, PelImagePlane* pcOutputPlane);113 // Image114 static Void sampleDown2Tap13 (PelImage* pcInputImage, PelImage* pcOutputImage);115 static Void sampleUp2Tap13 (PelImage* pcInputImage, PelImage* pcOutImage );116 private:117 118 // Helper Functions119 static inline Pel xMedian3 (Pel* pcData);120 static Void xDilate (Pel* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Pel* piDst, Int iDstStride, Int iSize, Bool bVerticalDir, Bool bToTopOrLeft );121 122 // Down sampling (binomial)123 static Void xSampleDownHor2 (Pel* piSrc, Int iSrcStride, Int iSrcWidth, Int iHeight, Pel* piDst, Int iDstStride );124 static Void xSampleDownHor4 (Pel* piSrc, Int iSrcStride, Int iSrcWidth, Int iHeight, Pel* piDst, Int iDstStride );125 static Void xSampleDownHor8 (Pel* piSrc, Int iSrcStride, Int iSrcWidth, Int iHeight, Pel* piDst, Int iDstStride );126 127 static Void xSampleDownVer2 (Pel* piSrc, Int iSrcStride, Int iSrcWidth, Int iSrcHeight, Pel* piDst, Int iDstStride );128 129 // Up sampling (8/4-Tap HEVC)130 static Void xInterpVerChroma(Pel* piSrc, Int iSrcStride, Int iSrcStepX, Int iSrcStepY, Int iWidth, Int iHeight, Pel* piDst, Int iDstStride, Int iDstStepX, Int iDstStepY, FpChromaIntFilt fpFilter);131 static Void xInterpHorChroma(Pel* piSrc, Int iSrcStride, Int iSrcStepX, Int iSrcStepY, Int iWidth, Int iHeight, Pel* piDst, Int iDstStride, Int iDstStepX, Int iDstStepY, FpChromaIntFilt fpFilter);132 static Void xDistributeArray(const Pel* pcSrc, Int iSrcStride, Int iSrcStepX, Int iSrcStepY, Int iWidth, Int iHeight, Pel* pcDst, Int iDstStride, Int iDstStepX, Int iDstStepY );133 134 // Binominal Filtering135 static Pel xFiltBinom3 (Pel* pcInputData, Int iStride );136 static Pel xFiltBinom5 (Pel* pcInputData, Int iStride );137 static Pel xFiltBinom7 (Pel* pcInputData, Int iStride );138 static Pel xFiltBinom9 (Pel* pcInputData, Int iStride );139 };140 141 #endif142 41 #endif //__TRENFILTER__ -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenImage.cpp
r1386 r1390 37 37 #include "TRenFilter.h" 38 38 #include "assert.h" 39 #if NH_3D_VSO40 41 42 template<typename T>43 TRenImage<T>::TRenImage( TRenImage& rcIn )44 {45 allocatePlanes( rcIn.getPlane(0)->getWidth(), rcIn.getPlane(0)->getHeight(), rcIn.getNumberOfFullPlanes(), rcIn.getNumberOfQuaterPlanes() ) ; assign(&rcIn);46 }47 48 template<typename T>49 TRenImage<T>::TRenImage( UInt uiWidth, UInt uiHeight, UInt uiNumberOfFullPlanes, UInt uiNumberOfQuaterPlanes )50 {51 allocatePlanes( uiWidth, uiHeight, uiNumberOfFullPlanes, uiNumberOfQuaterPlanes );52 }53 54 template<typename T>55 TRenImage<T>::TRenImage() : m_uiNumberOfFullPlanes(0), m_uiNumberOfQuaterPlanes(0), m_uiNumberOfPlanes(0), m_apcPlanes(0)56 {57 58 }59 60 61 template<>62 TRenImage<Pel>::TRenImage( TComPicYuv* pcPicYuv, Bool bFirstPlaneOnly )63 {64 if (bFirstPlaneOnly) //40065 {66 m_uiNumberOfPlanes = 1;67 m_uiNumberOfFullPlanes = 1;68 m_uiNumberOfQuaterPlanes = 0;69 m_apcPlanes = new TRenImagePlane<Pel>*[ m_uiNumberOfPlanes ];70 m_apcPlanes[0] = new TRenImagePlane<Pel>( pcPicYuv->getBuf( COMPONENT_Y ), pcPicYuv->getWidth( COMPONENT_Y ) + (REN_LUMA_MARGIN << 1), pcPicYuv->getHeight( COMPONENT_Y ) + (REN_LUMA_MARGIN << 1), pcPicYuv->getStride( COMPONENT_Y ), REN_LUMA_MARGIN );71 }72 else //42073 {74 m_uiNumberOfPlanes = 3;75 m_uiNumberOfFullPlanes = 1;76 m_uiNumberOfQuaterPlanes = 2;77 78 m_apcPlanes = new TRenImagePlane<Pel>*[ m_uiNumberOfPlanes ];79 m_apcPlanes[0] = new TRenImagePlane<Pel>( pcPicYuv->getBuf( COMPONENT_Y ), pcPicYuv->getWidth( COMPONENT_Y ) + (REN_LUMA_MARGIN << 1), pcPicYuv->getHeight( COMPONENT_Y ) + (REN_LUMA_MARGIN << 1), pcPicYuv->getStride( COMPONENT_Y ), REN_LUMA_MARGIN );80 m_apcPlanes[1] = new TRenImagePlane<Pel>( pcPicYuv->getBuf( COMPONENT_Cb ), pcPicYuv->getWidth( COMPONENT_Cb ) + REN_LUMA_MARGIN , pcPicYuv->getHeight( COMPONENT_Cb ) + REN_LUMA_MARGIN , pcPicYuv->getStride( COMPONENT_Cb), REN_LUMA_MARGIN >> 1 );81 m_apcPlanes[2] = new TRenImagePlane<Pel>( pcPicYuv->getBuf( COMPONENT_Cr ), pcPicYuv->getWidth( COMPONENT_Cr ) + REN_LUMA_MARGIN , pcPicYuv->getHeight( COMPONENT_Cr ) + REN_LUMA_MARGIN , pcPicYuv->getStride( COMPONENT_Cr), REN_LUMA_MARGIN >> 1 );82 }83 }84 85 template<typename T>86 TRenImage<T>* TRenImage<T>::create()87 {88 return new TRenImage( m_apcPlanes[0]->getWidth(), m_apcPlanes[0]->getHeight(), m_uiNumberOfFullPlanes, m_uiNumberOfQuaterPlanes );89 }90 91 92 template<typename T>93 TRenImage<T>::TRenImage( TComPicYuv* pcPicYuv, Bool bFirstPlaneOnly )94 {95 assert(0);96 }97 98 template<class T>99 TRenImagePlane<T>* TRenImage<T>::getPlane(UInt uiPlaneNumber) const100 {101 return m_apcPlanes[uiPlaneNumber];102 }103 104 template<class T>105 TRenImagePlane<T>** TRenImage<T>::getPlanes() const106 {107 return m_apcPlanes;108 }109 110 template<typename T>111 Void TRenImage<T>::getDataAndStrides( T** pptData, Int* piStrides ) const112 {113 for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++ )114 {115 piStrides[uiCurPlane] = m_apcPlanes[uiCurPlane]->getStride ();116 pptData [uiCurPlane] = m_apcPlanes[uiCurPlane]->getPlaneData();117 }118 }119 120 121 template<typename T>122 Void TRenImage<T>::getWidthAndHeight( Int* ppiWidths, Int* ppiHeights ) const123 {124 for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++ )125 {126 ppiWidths [uiCurPlane] = m_apcPlanes[uiCurPlane]->getWidth ();127 ppiHeights[uiCurPlane] = m_apcPlanes[uiCurPlane]->getHeight();128 }129 }130 131 template<typename T>132 Void TRenImage<T>::allocatePlanes( UInt uiWidth, UInt uiHeight, UInt uiNumberOfFullPlanes, UInt uiNumberOfQuaterPlanes )133 {134 assert( uiNumberOfFullPlanes + uiNumberOfQuaterPlanes);135 136 UInt uiHalfWidth = uiWidth / 2;137 UInt uiHalfHeight = uiHeight / 2;138 139 uiHalfWidth = (uiHalfWidth == 0) ? 1 : uiHalfWidth ;140 uiHalfHeight = (uiHalfHeight == 0) ? 1 : uiHalfHeight;141 142 m_uiNumberOfPlanes = uiNumberOfFullPlanes + uiNumberOfQuaterPlanes; ;143 m_uiNumberOfFullPlanes = uiNumberOfFullPlanes;144 m_uiNumberOfQuaterPlanes = uiNumberOfQuaterPlanes;145 146 this->m_apcPlanes = new TRenImagePlane<T>*[m_uiNumberOfPlanes];147 148 for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfFullPlanes; uiCurPlane++)149 {150 this->m_apcPlanes[uiCurPlane] = new TRenImagePlane<T>(uiWidth, uiHeight, REN_LUMA_MARGIN);151 };152 153 for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfQuaterPlanes; uiCurPlane++)154 {155 this->m_apcPlanes[uiCurPlane+uiNumberOfFullPlanes] = new TRenImagePlane<T>(uiHalfWidth, uiHalfHeight, REN_LUMA_MARGIN >> 1);156 };157 }158 159 160 template<class T>161 Void TRenImage<T>::assign(Int iVal)162 {163 for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++)164 {165 m_apcPlanes[uiCurPlane]->assign( iVal);166 }167 }168 169 170 template<class T>171 Void TRenImage<T>::devide( Double dDevisor )172 {173 for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++)174 {175 m_apcPlanes[uiCurPlane]->devide(dDevisor);176 }177 }178 179 180 template<class T> template<class S>181 Void TRenImage<T>::assign( TRenImage<S>* pcSrcImage )182 {183 if (pcSrcImage->getNumberOfPlanes() != m_uiNumberOfPlanes )184 {185 assert(0);186 }187 188 for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++)189 {190 m_apcPlanes[uiCurPlane]->assign(pcSrcImage->getPlane(uiCurPlane)->getPlaneDataOrg(),pcSrcImage->getPlane(uiCurPlane)->getStride());191 }192 }193 194 195 template<typename T>196 Void TRenImage<T>::setData( TRenImage* pcInputImage, Bool bClean )197 {198 for (UInt uiPlane = 0; uiPlane < m_uiNumberOfPlanes; uiPlane++)199 {200 m_apcPlanes[uiPlane]->setData( pcInputImage->getPlane( uiPlane ), bClean );201 }202 }203 204 template<typename T>205 Void TRenImage<T>::extendMargin()206 {207 for (UInt uiPlane = 0; uiPlane < m_uiNumberOfPlanes; uiPlane++)208 {209 m_apcPlanes[uiPlane]->extendMargin();210 }211 }212 213 template<class T>214 Void TRenImage<T>::xDeletePlanes()215 {216 for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++)217 {218 if ( m_apcPlanes[uiCurPlane])219 {220 delete m_apcPlanes[uiCurPlane];221 }222 m_apcPlanes[uiCurPlane] = 0;223 }224 }225 226 227 template<class T>228 Void TRenImage<T>::init()229 {230 // YUV-init231 m_apcPlanes[0]->assign((Pel) 0 );232 233 for (UInt uiCurPlane = 1; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++)234 {235 m_apcPlanes[uiCurPlane]->assign( (Pel) ( 1 << ( REN_BIT_DEPTH - 1 ) ) );236 }237 }238 239 240 template<class T>241 TRenImage<T>::~TRenImage()242 {243 xDeletePlanes();244 delete[] m_apcPlanes;245 }246 247 248 249 template<class T>250 UInt TRenImage<T>::getNumberOfPlanes() const251 {252 return m_uiNumberOfPlanes;253 }254 255 template<class T>256 UInt TRenImage<T>::getNumberOfQuaterPlanes() const257 {258 return m_uiNumberOfQuaterPlanes;259 }260 261 template<class T>262 UInt TRenImage<T>::getNumberOfFullPlanes() const263 {264 return m_uiNumberOfFullPlanes;265 }266 267 template class TRenImage<Pel>;268 template class TRenImage<Int>;269 template class TRenImage<Double>;270 template class TRenImage<Bool>;271 272 273 template Void TRenImage<Pel>::assign<Pel> (TRenImage<Pel>* );274 275 #endif // NH_3D -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenImage.h
r1386 r1390 39 39 #include "../TLibCommon/TComPicYuv.h" 40 40 #include "TRenImagePlane.h" 41 #if NH_3D_VSO42 43 44 #define PelImage TRenImage<Pel>45 #define DoubleImage TRenImage<Double>46 #define IntImage TRenImage<Int>47 48 49 template<typename T>50 class TRenImage51 {52 public:53 54 // Construction55 TRenImage( TRenImage& rcInputImage );56 TRenImage();57 // TRenImage( TRenImagePlane<T>** ppcYPlanes, UInt uiNumberOfFullPlanes, UInt uiNumberOfQuaterPlanes );58 59 TRenImage( UInt uiWidth, UInt uiHeight, UInt uiNumPlanes, UInt uiNumQPlanes );60 TRenImage( TComPicYuv* pcPicYuvIn, Bool bFirstPlaneOnly = false );61 62 Void allocatePlanes(UInt uiWidth, UInt uiHeight, UInt uiNumFullPlanes, UInt uiNumQuaterPlanes);63 ~TRenImage();64 65 TRenImage* create();66 Void init();67 68 // Get Planes and data69 TRenImagePlane<T>* getPlane(UInt uiPlaneNumber) const;70 TRenImagePlane<T>** getPlanes() const;71 72 Void getDataAndStrides ( T** pptData, Int* piStrides ) const ;73 Void getWidthAndHeight ( Int* piWidths, Int* piHeights ) const ;74 75 UInt getNumberOfPlanes() const;76 UInt getNumberOfQuaterPlanes() const;77 UInt getNumberOfFullPlanes() const;78 Bool is420() const {return m_uiNumberOfFullPlanes == 1 && m_uiNumberOfQuaterPlanes == 2; };79 Bool is444() const {return m_uiNumberOfFullPlanes == 3 && m_uiNumberOfQuaterPlanes == 0; };80 Bool is400() const {return m_uiNumberOfFullPlanes == 1 && m_uiNumberOfQuaterPlanes == 0; };81 82 // Assign83 Void assign(Int iVal);84 template<typename S> Void assign(TRenImage<S>* pcSrcImage);85 Void setData( TRenImage* pcInputImage, Bool bClean );86 87 Void extendMargin();88 // Operators89 Void devide( Double dDevisor );90 91 92 private:93 94 UInt m_uiNumberOfFullPlanes;95 UInt m_uiNumberOfQuaterPlanes;96 UInt m_uiNumberOfPlanes;97 UInt m_bitDepth;98 TRenImagePlane<T> ** m_apcPlanes; // First Full Planes, then Quater Planes99 100 Void xDeletePlanes();101 };102 103 #endif // NH_3D104 41 #endif // __TRENIMAGE__ 105 42 -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenImagePlane.cpp
r1386 r1390 36 36 #include "TRenFilter.h" 37 37 #include <string.h> 38 #if NH_3D_VSO39 38 40 /////// TRenImagePlane ///////41 42 template<class T>43 TRenImagePlane<T>::TRenImagePlane() { m_bClean = true; }44 45 template<class T>46 TRenImagePlane<T>::TRenImagePlane(UInt uiWidth, UInt uiHeight, UInt uiPad)47 : m_uiWidth(uiWidth), m_uiHeight(uiHeight), m_uiStride(uiWidth+2*uiPad), m_uiWidthOrg(uiWidth+2*uiPad), m_uiHeightOrg(uiHeight+2*uiPad), m_uiPad(uiPad)48 {49 m_pcDataOrg = new T[ m_uiWidthOrg * m_uiHeightOrg ];50 m_pcData = m_pcDataOrg + m_uiPad * m_uiStride + m_uiPad;51 m_bClean = true;52 }53 54 template<class T>55 TRenImagePlane<T>::TRenImagePlane(TRenImagePlane* pcPlane)56 : m_uiWidth (pcPlane->getWidth ())57 , m_uiHeight (pcPlane->getHeight ())58 , m_uiStride (pcPlane->getStride ())59 , m_uiWidthOrg(pcPlane->getWidthOrg())60 , m_uiHeightOrg(pcPlane->getHeightOrg())61 , m_uiPad (pcPlane->getPad ())62 {63 m_pcData = new T[m_uiWidthOrg*m_uiHeightOrg];64 m_bClean = true;65 assign( pcPlane );66 }67 68 template<typename T>69 TRenImagePlane<T>::TRenImagePlane( T* pcDataOrg, UInt uiWidthOrg, UInt uiHeightOrg, UInt uiStride, UInt uiPad )70 : m_pcData (pcDataOrg + uiStride * uiPad + uiPad )71 , m_uiWidth (uiWidthOrg - 2* uiPad )72 , m_uiHeight (uiHeightOrg - 2* uiPad )73 , m_uiStride (uiStride )74 , m_pcDataOrg (pcDataOrg )75 , m_uiWidthOrg (uiWidthOrg )76 , m_uiHeightOrg(uiHeightOrg)77 , m_uiPad (uiPad )78 , m_bClean (false )79 {80 81 }82 83 template<typename T>84 Void TRenImagePlane<T>::setData( T* pDataOrg, UInt uiWidthOrg, UInt uiHeightOrg, UInt uiStride, UInt uiPad, Bool bClean /*= false*/ )85 {86 deleteData();87 m_uiPad = uiPad;88 m_pcDataOrg = pDataOrg;89 m_uiWidthOrg = uiWidthOrg;90 m_uiHeightOrg = uiHeightOrg;91 m_uiWidth = uiWidthOrg - 2* uiPad;92 m_uiHeight = uiHeightOrg - 2* uiPad;93 m_uiStride = uiStride;94 m_pcData = m_pcDataOrg + uiPad * m_uiStride + uiPad;95 m_bClean = bClean;96 }97 98 template<typename T>99 Void TRenImagePlane<T>::setData( TRenImagePlane<T>* pcInPlane, Bool bClean )100 {101 deleteData();102 m_uiPad = pcInPlane->getPad();103 m_pcDataOrg = pcInPlane->getPlaneDataOrg();104 m_uiWidthOrg = pcInPlane->getWidthOrg();105 m_uiHeightOrg = pcInPlane->getHeightOrg();106 m_uiWidth = pcInPlane->getWidth();107 m_uiHeight = pcInPlane->getHeight();108 m_uiStride = pcInPlane->getStride();109 m_pcData = pcInPlane->getPlaneData();110 m_bClean = bClean;111 pcInPlane->setClean( !m_bClean );112 }113 114 template<typename T>115 Void TRenImagePlane<T>::setClean( Bool bClean )116 {117 m_bClean = bClean;118 }119 120 template<class T>121 T* TRenImagePlane<T>::getPlaneData()122 {123 return m_pcData;124 }125 126 127 template<class T>128 T* TRenImagePlane<T>::getPlaneDataOrg()129 {130 return m_pcDataOrg;131 }132 133 134 template<class T>135 Void TRenImagePlane<T>::assign(Pel* pcSourceData, UInt uiSourceStride )136 {137 T* pcTargetData = m_pcDataOrg;138 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)139 {140 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)141 {142 pcTargetData[uiXPos] = (T) pcSourceData[uiXPos];143 }144 pcTargetData += m_uiStride;145 pcSourceData += uiSourceStride;146 }147 }148 149 template<class T>150 Void TRenImagePlane<T>::assign(Pel cData)151 {152 T* pcTargetData = m_pcDataOrg;153 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)154 {155 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)156 {157 pcTargetData[uiXPos] = (T) cData;158 }159 pcTargetData += m_uiStride;160 }161 }162 163 template<class T>164 Void TRenImagePlane<T>::assign(Double* pdData, UInt uiSourceStride )165 {166 T* pcTargetData = m_pcDataOrg;167 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)168 {169 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)170 {171 pcTargetData[uiXPos] = (T) pdData[uiXPos];172 }173 pcTargetData += m_uiStride;174 pdData += uiSourceStride;175 176 }177 }178 179 template<class T>180 Void TRenImagePlane<T>::assign(Double dData)181 {182 T* pcTargetData = m_pcDataOrg;183 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)184 {185 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)186 {187 pcTargetData[uiXPos] = (T) dData;188 }189 pcTargetData += m_uiStride;190 }191 }192 193 194 template<class T>195 Void TRenImagePlane<T>::assign(Bool* pbData, UInt uiSourceStride )196 {197 T* pcTargetData = m_pcDataOrg;198 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)199 {200 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)201 {202 pcTargetData[uiXPos] = (T) pbData[uiXPos];203 }204 pcTargetData += m_uiStride;205 pbData += uiSourceStride;206 }207 }208 209 template<class T>210 Void TRenImagePlane<T>::assign(Int iData)211 {212 T* pcTargetData = m_pcDataOrg;213 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)214 {215 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)216 {217 pcTargetData[uiXPos] = (T) iData;218 }219 pcTargetData += m_uiStride;220 }221 }222 223 template<class T>224 Void TRenImagePlane<T>::assign(Int* piData, UInt uiSourceStride )225 {226 T* pcTargetData = m_pcDataOrg;227 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)228 {229 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)230 {231 pcTargetData[uiXPos] = (T) piData[uiXPos];232 }233 pcTargetData += m_uiStride;234 piData += uiSourceStride;235 }236 }237 238 template<class T>239 Void TRenImagePlane<T>::assign(Bool data)240 {241 T* pcTargetData = m_pcDataOrg;242 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)243 {244 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)245 {246 pcTargetData[uiXPos] = (T) data;247 }248 pcTargetData += m_uiStride;249 }250 }251 252 // Assignments to Bool253 254 template<>255 Void TRenImagePlane<Bool>::assign(Int* piData, UInt uiSourceStride )256 {257 Bool* pcTargetData = m_pcDataOrg;258 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)259 {260 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)261 {262 pcTargetData[uiXPos] = (piData[uiXPos] == 0);263 }264 pcTargetData += m_uiStride;265 piData += uiSourceStride;266 267 }268 }269 270 template<>271 Void TRenImagePlane<Bool>::assign(Int iData)272 {273 Bool* pcTargetData = m_pcDataOrg;274 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)275 {276 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)277 {278 pcTargetData[uiXPos] = (iData == 0);279 }280 pcTargetData += m_uiStride;281 }282 }283 284 template<>285 Void TRenImagePlane<Bool>::assign(Pel* pcData, UInt uiSourceStride )286 {287 Bool* pcTargetData = m_pcDataOrg;288 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)289 {290 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)291 {292 pcTargetData[uiXPos] = (pcData[uiXPos] == 0);293 }294 pcTargetData += m_uiStride;295 pcData += uiSourceStride;296 297 }298 }299 300 template<>301 Void TRenImagePlane<Bool>::assign(Pel cData)302 {303 Bool* pcTargetData = m_pcDataOrg;304 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)305 {306 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)307 {308 pcTargetData[uiXPos] = (cData == 0);309 }310 pcTargetData += m_uiStride;311 }312 }313 314 template<>315 Void TRenImagePlane<Bool>::assign(Double* pdData, UInt uiSourceStride )316 {317 Bool* pcTargetData = m_pcDataOrg;318 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)319 {320 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)321 {322 pcTargetData[uiXPos] = ( pdData[uiXPos] == 0);323 }324 pcTargetData += m_uiStride;325 pdData += uiSourceStride;326 327 }328 }329 330 331 332 template<>333 Void TRenImagePlane<Bool>::assign(Double dData)334 {335 Bool* pcTargetData = m_pcDataOrg;336 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)337 {338 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)339 {340 pcTargetData [uiXPos] = (dData == 0);341 }342 pcTargetData += m_uiStride;343 }344 }345 346 347 // Assignments to Pel348 template<>349 Void TRenImagePlane<Pel>::assign(Double* pdData, UInt uiSourceStride )350 {351 Pel* pcTargetData = m_pcDataOrg;352 for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++)353 {354 for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++)355 {356 pcTargetData[uiXPos] = (Pel) ( pdData[uiXPos] + pdData[uiXPos] < 0 ? -0.5 : 0.5 ) ;357 }358 pcTargetData += m_uiStride;359 pdData += uiSourceStride;360 }361 }362 363 template<class T>364 Void TRenImagePlane<T>::assign(TRenImagePlane<T>* pcPlane)365 {366 assign(pcPlane->getPlaneDataOrg(), pcPlane->getStride());367 }368 369 template<class T>370 Void TRenImagePlane<T>::assign(TRenImagePlane<T>* pcPlane, UInt uiRow, UInt uiStartOffset, UInt uiEndOffset)371 {372 T* pcTargetData = m_pcData + uiRow * m_uiStride;373 T* pcSourceData = pcPlane->getPlaneData() + uiRow * pcPlane->getStride();374 375 for (UInt uiPosX = uiStartOffset; uiPosX <= uiEndOffset; uiPosX++)376 {377 pcTargetData[uiPosX] = pcSourceData[uiPosX];378 }379 380 }381 382 template<class T>383 Void TRenImagePlane<T>::assign(TRenImagePlane<T>* pcSourcePlane, UInt uiSourceRowStart, UInt uiSourceColStart, UInt uiWidth, UInt uiHeight)384 {385 T* acSourceData;386 T* acDestData;387 388 acSourceData = pcSourcePlane->getPlaneData();389 acSourceData += uiSourceRowStart * pcSourcePlane->getStride() + uiSourceColStart;390 acDestData = m_pcData;391 392 for (UInt uiPosY = 0; uiPosY < uiHeight ; uiPosY++)393 {394 for (UInt uiPosX = 0; uiPosX < uiWidth ; uiPosX++)395 {396 acDestData[uiPosX] = acSourceData[uiPosX];397 }398 acSourceData += pcSourcePlane->getStride();399 acDestData += this ->getStride();400 };401 }402 403 404 405 template<class T>406 Void TRenImagePlane<T>::assign( T data , UInt uiRow, UInt uiStartOffset, UInt uiEndOffset)407 {408 T* pcTargetData = m_pcData + uiRow * m_uiStride;409 for (UInt uiPosX = uiStartOffset; uiPosX <= uiEndOffset; uiPosX++)410 {411 pcTargetData[uiPosX] = data;412 }413 }414 415 416 template<class T>417 Void TRenImagePlane<T>::devide( Double dDevisor )418 {419 T* pcTargetData = m_pcDataOrg;420 for (UInt uiPosY = 0; uiPosY < (m_uiHeightOrg); uiPosY++)421 {422 for (UInt uiPosX = 0; uiPosX < m_uiWidthOrg; uiPosX++)423 {424 pcTargetData[uiPosX] = (T) ( ( Double )pcTargetData[uiPosX] / dDevisor );425 }426 pcTargetData += m_uiStride;427 }428 };429 430 template<class T>431 Void TRenImagePlane<T>::multiply( Double dMultiplier ) {432 T* pcTargetData = m_pcDataOrg;433 for (UInt uiPosY = 0; uiPosY < (m_uiHeightOrg); uiPosY++)434 {435 for (UInt uiPosX = 0; uiPosX < m_uiWidthOrg; uiPosX++)436 {437 pcTargetData[uiPosX] = (T) ( ( Double )pcTargetData[uiPosX] * dMultiplier );438 }439 pcTargetData += m_uiStride;440 }441 };442 443 444 template<>445 Void TRenImagePlane<Bool>::devide( Double dDevisor )446 {447 assert(0);448 };449 450 template<>451 Void TRenImagePlane<Bool>::multiply( Double dMultiplier )452 {453 assert(0);454 };455 456 457 template<class T>458 Void TRenImagePlane<T>::deleteData()459 {460 if (m_bClean)461 {462 if (m_pcDataOrg)463 {464 delete[] m_pcDataOrg;465 };466 }467 }468 469 template<class T>470 TRenImagePlane<T>::~TRenImagePlane()471 {472 deleteData();473 }474 475 476 template<typename T>477 Void TRenImagePlane<T>::extendMargin()478 {479 Int iPad = (Int) m_uiPad;480 T* pcData = m_pcData;481 482 for ( Int iPosY = 0; iPosY < (Int) m_uiHeight; iPosY++)483 {484 for ( Int iPosX = 0; iPosX < (Int) iPad; iPosX++ )485 {486 pcData[ -iPad + iPosX ] = pcData[0];487 pcData[m_uiWidth + iPosX ] = pcData[m_uiWidth -1 ];488 }489 pcData += m_uiStride;490 }491 492 493 pcData -= (m_uiStride + iPad);494 for ( Int iPosY = 0; iPosY < iPad; iPosY++ )495 {496 memcpy( pcData + (iPosY+1)*m_uiStride, pcData, sizeof(T)*(m_uiWidth + (iPad<<1)) );497 }498 499 pcData -= ((m_uiHeight-1) * m_uiStride);500 for ( Int iPosY = 0; iPosY < iPad; iPosY++ )501 {502 memcpy( pcData - (iPosY+1)*m_uiStride, pcData, sizeof(T)*(m_uiWidth + (iPad<<1)) );503 }504 }505 506 template class TRenImagePlane<Pel>;507 template class TRenImagePlane<Double>;508 template class TRenImagePlane<Bool>;509 template class TRenImagePlane<Int>;510 511 /////// TRenImagePlanePart ///////512 513 template<typename T>514 TRenImagePlanePart<T>::TRenImagePlanePart( TRenImagePlane<T>* pPlane, UInt uHorOff, UInt uVerOff, UInt uWidth, UInt uHeight )515 : TRenImagePlane<T>( pPlane->getPlaneData() + uHorOff + uVerOff * pPlane->getStride(), uWidth, uHeight, pPlane->getStride(),0)516 {517 518 }519 520 template<typename T>521 TRenImagePlanePart<T>::~TRenImagePlanePart()522 {523 this->m_pcData = NULL;524 }525 526 template class TRenImagePlanePart<Pel>;527 template class TRenImagePlanePart<Double>;528 template class TRenImagePlanePart<Bool>;529 template class TRenImagePlanePart<Int>;530 #endif // NH_3D531 -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenImagePlane.h
r1386 r1390 39 39 #include "../TLibCommon/TComPicYuv.h" 40 40 41 #if NH_3D_VSO42 #define PelImagePlane TRenImagePlane<Pel>43 #define DoubleImagePlane TRenImagePlane<Double>44 #define IntImagePlane TRenImagePlane<Int>45 46 template<typename T>47 class TRenImagePlane48 {49 public:50 // Construction51 TRenImagePlane();52 TRenImagePlane( UInt uiWidth, UInt uiHeight, UInt uiPad);53 TRenImagePlane( TRenImagePlane* pcInputPlane );54 TRenImagePlane( T* pcDataOrg, UInt uiWidthOrg, UInt uiHeightOrg, UInt uiStride, UInt uiPad );55 56 ~TRenImagePlane();57 58 // Get Data59 T* getPlaneData();60 UInt getWidth () { return m_uiWidth; };61 UInt getHeight () { return m_uiHeight; };62 63 T* getPlaneDataOrg();64 UInt getWidthOrg () { return m_uiWidthOrg; };65 UInt getHeightOrg() { return m_uiHeightOrg; };66 UInt getPad () { return m_uiPad; };67 UInt getStride () { return m_uiStride; };68 69 Void setData ( T* pDataOrg, UInt uiWidthOrg, UInt uiHeightOrg, UInt uiStride, UInt uiPad, Bool bClean /*= false*/ );70 71 Void setData ( TRenImagePlane<T>* pcInPlane, Bool bClean );72 Void setClean( Bool bClean );73 Void extendMargin();74 75 // Assignment76 Void assign( Pel* data, UInt uiSourceStride );77 Void assign( Pel data );78 79 Void assign( Double* data, UInt uiSourceStride );80 Void assign( Double data );81 82 Void assign( Bool* data, UInt uiSourceStride );83 Void assign( Bool data );84 85 Void assign( Int* data, UInt uiSourceStride );86 Void assign( Int data );87 88 Void assign( TRenImagePlane<T>* pcPlane);89 90 Void assign( T data , UInt uRow, UInt uStartOffset, UInt uEndOffset);91 Void assign( TRenImagePlane<T>* pcPlane, UInt uRow, UInt uStartOffset, UInt uEndOffset);92 Void assign( TRenImagePlane<T>* pcSourcePlane, UInt uSourceRowStart, UInt uSourceColStart, UInt uWidth, UInt uHeight);93 94 // Operators95 Void devide( Double dDevisor );96 Void multiply( Double dMultiplier );97 98 protected:99 T *m_pcData;100 UInt m_uiWidth;101 UInt m_uiHeight;102 UInt m_uiStride;103 104 T *m_pcDataOrg;105 UInt m_uiWidthOrg;106 UInt m_uiHeightOrg;107 UInt m_uiPad;108 109 Double m_dRatio;110 Bool m_bClean;111 112 private:113 Void deleteData();114 };115 116 template<typename T>117 class TRenImagePlanePart : public TRenImagePlane< T >118 {119 public:120 TRenImagePlanePart( TRenImagePlane<T>* pcPlane, UInt uHorOff, UInt uVerOff, UInt uWidth, UInt uHeight);;121 ~TRenImagePlanePart();;122 };123 124 #endif // NH_3D125 41 #endif // __TRENIMAGEPLANE__ -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenInterpFilter.cpp
r1386 r1390 39 39 40 40 #include "TRenInterpFilter.h" 41 #if NH_3D_VSO42 41 43 // ====================================================================================================================44 // Constructor45 // ====================================================================================================================46 47 template<UInt bitDepthLuma>48 TRenInterpFilter<bitDepthLuma>::TRenInterpFilter()49 {50 // initial number of taps for Luma51 }52 53 template class TRenInterpFilter<REN_BIT_DEPTH>;54 #endif // NH_3D55 -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenInterpFilter.h
r1386 r1390 44 44 #include "TLibCommon/CommonDef.h" 45 45 #include "assert.h" 46 #if NH_3D_VSO47 48 // ====================================================================================================================49 // Constants50 // ====================================================================================================================51 52 // Local type definitions53 #define HAL_IDX 154 #define QU0_IDX 055 #define QU1_IDX 256 57 // ====================================================================================================================58 // Class definition59 // ====================================================================================================================60 61 /// interpolation filter class62 template<UInt bitDepth>63 class TRenInterpFilter64 {65 public:66 TRenInterpFilter();67 68 // DIF filter interface (for half & quarter)69 __inline Void xCTI_FilterHalfHor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);70 __inline Void xCTI_FilterHalfHor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);71 72 __inline Void xCTI_FilterQuarter0Hor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);73 __inline Void xCTI_FilterQuarter0Hor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);74 75 __inline Void xCTI_FilterQuarter1Hor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);76 __inline Void xCTI_FilterQuarter1Hor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);77 78 __inline Void xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst, Int iDstStridePel, Pel*& rpiDstPel );79 __inline Void xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst );80 __inline Void xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst );81 82 __inline Void xCTI_FilterQuarter0Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst );83 __inline Void xCTI_FilterQuarter0Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst );84 85 __inline Void xCTI_FilterQuarter1Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst );86 __inline Void xCTI_FilterQuarter1Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst );87 88 __inline Void xCTI_Filter2DVerC (Pel* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Int iDstStride, Int*& rpiDst, Int iMv);89 __inline Void xCTI_Filter2DHorC (Int* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Int iDstStride, Pel*& rpiDst, Int iMV);90 __inline Void xCTI_Filter1DHorC (Pel* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Int iDstStride, Pel*& rpiDst, Int iMV);91 __inline Void xCTI_Filter1DVerC (Pel* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Int iDstStride, Pel*& rpiDst, Int iMV);92 93 __inline Int xCTI_Filter_VPS04_C_HAL( Pel* pSrc, Int iStride );94 __inline Int xCTI_Filter_VIS04_C_HAL( Int* pSrc, Int iStride );95 __inline Int xCTI_Filter_VP04_C_OCT0( Pel* pSrc, Int iStride );96 __inline Int xCTI_Filter_VI04_C_OCT0( Int* pSrc, Int iStride );97 __inline Int xCTI_Filter_VP04_C_QUA0( Pel* pSrc, Int iStride );98 __inline Int xCTI_Filter_VI04_C_QUA0( Int* pSrc, Int iStride );99 __inline Int xCTI_Filter_VP04_C_OCT1( Pel* pSrc, Int iStride );100 __inline Int xCTI_Filter_VI04_C_OCT1( Int* pSrc, Int iStride );101 __inline Int xCTI_Filter_VP04_C_OCT2( Pel* pSrc, Int iStride );102 __inline Int xCTI_Filter_VI04_C_OCT2( Int* pSrc, Int iStride );103 __inline Int xCTI_Filter_VP04_C_QUA1( Pel* pSrc, Int iStride );104 __inline Int xCTI_Filter_VI04_C_QUA1( Int* pSrc, Int iStride );105 __inline Int xCTI_Filter_VP04_C_OCT3( Pel* pSrc, Int iStride );106 __inline Int xCTI_Filter_VI04_C_OCT3( Int* pSrc, Int iStride );107 private:108 __inline Int xClipY( Pel x ) { return std::min<Pel>(Pel((1 << bitDepth)-1), std::max<Pel>( Pel(0), x)); }109 __inline Int xClipC( Pel x ) { return std::min<Pel>(Pel((1 << bitDepth)-1), std::max<Pel>( Pel(0), x)); }110 111 };112 113 114 // ------------------------------------------------------------------------------------------------115 // DCTIF filters116 // ------------------------------------------------------------------------------------------------117 template<UInt bitDepth>118 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterHalfHor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)119 {120 Pel* piDst = rpiDst;121 Int iSum;122 Pel* piSrcTmp;123 Int iSrcStep2 = iSrcStep*2;124 Int iSrcStep3 = iSrcStep*3;125 Int iSrcStep4 = iSrcStep*4;126 Int iSrcStep5 = iSrcStep*5;127 Int iSrcStep6 = iSrcStep*6;128 Int iSrcStep7 = iSrcStep*7;129 130 Int iTmp0, iTmp1, iTmp2, iTmp3, iTmpA;131 132 for ( Int y = iHeight; y != 0; y-- )133 {134 piSrcTmp = &piSrc[ -3*iSrcStep ];135 for ( Int x = 0; x < iWidth; x++ )136 {137 // { -1,4,-11,40,40,-11,4,-1 }138 iTmp0 = piSrcTmp[ 0]+piSrcTmp[iSrcStep7];139 iTmp1 = piSrcTmp[iSrcStep]+piSrcTmp[iSrcStep6];140 iTmp2 = piSrcTmp[iSrcStep2]+piSrcTmp[iSrcStep5];141 iTmp3 = piSrcTmp[iSrcStep3]+piSrcTmp[iSrcStep4];142 143 iTmpA = (iTmp3 << 2) - iTmp2;144 145 iSum = ( iTmp1 << 2 )146 + ( iTmpA << 3 )147 + ( iTmpA << 1 )148 - iTmp0 - iTmp2;149 150 piDst [x * iDstStep] = xClipY( (iSum + 32) >> 6 );151 piSrcTmp += iSrcStep;152 }153 piSrc += iSrcStride;154 piDst += iDstStride;155 }156 return;157 }158 159 template<UInt bitDepth>160 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterHalfHor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)161 {162 Pel* piDst = rpiDst;163 Int iSum;164 Int* piSrcTmp;165 Int iSrcStep2 = iSrcStep*2;166 Int iSrcStep3 = iSrcStep*3;167 Int iSrcStep4 = iSrcStep*4;168 Int iSrcStep5 = iSrcStep*5;169 Int iSrcStep6 = iSrcStep*6;170 Int iSrcStep7 = iSrcStep*7;171 172 Int iTmp0, iTmp1, iTmp2, iTmp3, iTmpA;173 174 for ( Int y = iHeight; y != 0; y-- )175 {176 piSrcTmp = &piSrc[ -3*iSrcStep ];177 for ( Int x = 0; x < iWidth; x++ )178 {179 // { -1,4,-11,40,40,-11,4,-1 }180 iTmp0 = piSrcTmp[ 0]+piSrcTmp[iSrcStep7];181 iTmp1 = piSrcTmp[iSrcStep ]+piSrcTmp[iSrcStep6];182 iTmp2 = piSrcTmp[iSrcStep2]+piSrcTmp[iSrcStep5];183 iTmp3 = piSrcTmp[iSrcStep3]+piSrcTmp[iSrcStep4];184 185 iTmpA = (iTmp3 << 2) - iTmp2;186 187 iSum = ( iTmp1 << 2 )188 + ( iTmpA << 3 )189 + ( iTmpA << 1 )190 - iTmp0 - iTmp2;191 192 piDst [x * iDstStep] = xClipY( (iSum + 2048) >> 12 );193 piSrcTmp += iSrcStep;194 }195 piSrc += iSrcStride;196 piDst += iDstStride;197 }198 return;199 }200 201 template<UInt bitDepth>202 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter0Hor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)203 {204 Pel* piDst = rpiDst;205 Int iSum;206 Pel* piSrcTmp;207 Int iSrcStep2 = iSrcStep*2;208 Int iSrcStep3 = iSrcStep*3;209 Int iSrcStep4 = iSrcStep*4;210 Int iSrcStep5 = iSrcStep*5;211 Int iSrcStep6 = iSrcStep*6;212 Int iSrcStep7 = iSrcStep*7;213 214 Int iTmp1, iTmp2;215 216 for ( Int y = iHeight; y != 0; y-- )217 {218 piSrcTmp = &piSrc[ -3*iSrcStep ];219 for ( Int x = 0; x < iWidth; x++ )220 {221 // {-1, 4, -10, 57, 19, -7, 3, -1 },222 223 iTmp1 = piSrcTmp[iSrcStep3] + piSrcTmp[iSrcStep5];224 iTmp2 = piSrcTmp[iSrcStep6] + piSrcTmp[iSrcStep4];225 226 iSum = iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStep7]227 - ( ( piSrcTmp[iSrcStep2] - iTmp2 ) << 1 )228 + ( piSrcTmp[iSrcStep] << 2 )229 - ( ( piSrcTmp[iSrcStep2] + iTmp1 ) << 3 )230 + ( piSrcTmp[iSrcStep4] << 4 );231 232 piDst [x * iDstStep] = xClipY(( (iSum + 32) >> 6 )+ piSrcTmp[iSrcStep3]);233 piSrcTmp += iSrcStep;234 }235 piSrc += iSrcStride;236 piDst += iDstStride;237 }238 return;239 }240 241 template<UInt bitDepth>242 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter0Hor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)243 {244 Pel* piDst = rpiDst;245 Int iSum;246 Int* piSrcTmp;247 Int iSrcStep2 = iSrcStep*2;248 Int iSrcStep3 = iSrcStep*3;249 Int iSrcStep4 = iSrcStep*4;250 Int iSrcStep5 = iSrcStep*5;251 Int iSrcStep6 = iSrcStep*6;252 Int iSrcStep7 = iSrcStep*7;253 254 Int iTmp1, iTmp2;255 256 for ( Int y = iHeight; y != 0; y-- )257 {258 piSrcTmp = &piSrc[ -3*iSrcStep ];259 for ( Int x = 0; x < iWidth; x++ )260 {261 // {-1, 4, -10, 57, 19, -7, 3, -1 },262 263 iTmp1 = piSrcTmp[iSrcStep3] + piSrcTmp[iSrcStep5];264 iTmp2 = piSrcTmp[iSrcStep6] + piSrcTmp[iSrcStep4];265 266 iSum = iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStep7]267 - ( ( piSrcTmp[iSrcStep2] - iTmp2 ) << 1 )268 + ( piSrcTmp[iSrcStep] << 2 )269 - ( ( piSrcTmp[iSrcStep2] + iTmp1 ) << 3 )270 + ( piSrcTmp[iSrcStep4] << 4 )271 + ( piSrcTmp[iSrcStep3] << 6 );272 273 piDst [x * iDstStep] = xClipY( (iSum + 2048) >> 12 );274 piSrcTmp += iSrcStep;275 }276 piSrc += iSrcStride;277 piDst += iDstStride;278 }279 return;280 }281 282 template<UInt bitDepth>283 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter1Hor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)284 {285 Pel* piDst = rpiDst;286 Int iSum;287 Pel* piSrcTmp;288 Int iSrcStep2 = iSrcStep*2;289 Int iSrcStep3 = iSrcStep*3;290 Int iSrcStep4 = iSrcStep*4;291 Int iSrcStep5 = iSrcStep*5;292 Int iSrcStep6 = iSrcStep*6;293 Int iSrcStep7 = iSrcStep*7;294 295 Int iTmp1, iTmp2;296 for ( Int y = iHeight; y != 0; y-- )297 {298 piSrcTmp = &piSrc[ -3*iSrcStep ];299 for ( Int x = 0; x < iWidth; x++ )300 {301 // {-1, 3, -7, 19, 57, -10, 4, -1 },302 303 iTmp1 = piSrcTmp[iSrcStep4] + piSrcTmp[iSrcStep2];304 iTmp2 = piSrcTmp[iSrcStep ] + piSrcTmp[iSrcStep3];305 306 iSum = iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStep7]307 - ( ( piSrcTmp[iSrcStep5] - iTmp2 ) << 1 )308 + ( piSrcTmp[iSrcStep6] << 2 )309 - ( ( piSrcTmp[iSrcStep5] + iTmp1 ) << 3 )310 + ( piSrcTmp[iSrcStep3] << 4 );311 312 piDst [x * iDstStep] = xClipY( ((iSum + 32) >> 6) + piSrcTmp[iSrcStep4] );313 piSrcTmp += iSrcStep;314 }315 piSrc += iSrcStride;316 piDst += iDstStride;317 }318 return;319 }320 321 template<UInt bitDepth>322 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter1Hor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)323 {324 Pel* piDst = rpiDst;325 Int iSum;326 Int* piSrcTmp;327 Int iSrcStep2 = iSrcStep*2;328 Int iSrcStep3 = iSrcStep*3;329 Int iSrcStep4 = iSrcStep*4;330 Int iSrcStep5 = iSrcStep*5;331 Int iSrcStep6 = iSrcStep*6;332 Int iSrcStep7 = iSrcStep*7;333 334 Int iTmp1, iTmp2;335 for ( Int y = iHeight; y != 0; y-- )336 {337 piSrcTmp = &piSrc[ -3*iSrcStep ];338 for ( Int x = 0; x < iWidth; x++ )339 {340 // {-1, 3, -7, 19, 57, -10, 4, -1 },341 342 iTmp1 = piSrcTmp[iSrcStep4] + piSrcTmp[iSrcStep2];343 iTmp2 = piSrcTmp[iSrcStep ] + piSrcTmp[iSrcStep3];344 345 iSum = iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStep7]346 - ( ( piSrcTmp[iSrcStep5] - iTmp2 ) << 1 )347 + ( piSrcTmp[iSrcStep6] << 2 )348 - ( ( piSrcTmp[iSrcStep5] + iTmp1 ) << 3 )349 + ( piSrcTmp[iSrcStep3] << 4 )350 + ( piSrcTmp[iSrcStep4] << 6 );351 352 piDst [x * iDstStep] = xClipY( (iSum + 2048) >> 12 );353 piSrcTmp += iSrcStep;354 }355 piSrc += iSrcStride;356 piDst += iDstStride;357 }358 return;359 }360 361 template<UInt bitDepth>362 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst, Int iDstStridePel, Pel*& rpiDstPel )363 {364 Int* piDst = rpiDst;365 Pel* piDstPel = rpiDstPel;366 Int iSum;367 Pel* piSrcTmp;368 Int iSrcStride2 = iSrcStride*2;369 Int iSrcStride3 = iSrcStride*3;370 Int iSrcStride4 = iSrcStride*4;371 Int iSrcStride5 = iSrcStride*5;372 Int iSrcStride6 = iSrcStride*6;373 Int iSrcStride7 = iSrcStride*7;374 375 Int iTmp0, iTmp1, iTmp2, iTmp3, iTmpA;376 for ( Int y = iHeight; y != 0; y-- )377 {378 piSrcTmp = &piSrc[ -3*iSrcStride ];379 for ( Int x = 0; x < iWidth; x++ )380 {381 // { -1,4,-11,40,40,-11,4,-1 }382 iTmp0 = piSrcTmp[ 0]+piSrcTmp[iSrcStride7];383 iTmp1 = piSrcTmp[iSrcStride ]+piSrcTmp[iSrcStride6];384 iTmp2 = piSrcTmp[iSrcStride2]+piSrcTmp[iSrcStride5];385 iTmp3 = piSrcTmp[iSrcStride3]+piSrcTmp[iSrcStride4];386 387 iTmpA = (iTmp3 << 2) - iTmp2;388 389 iSum = ( iTmp1 << 2 )390 + ( iTmpA << 3 )391 + ( iTmpA << 1 )392 - iTmp0 - iTmp2;393 394 piDst[x * iDstStep] = iSum;395 piDstPel[x * iDstStep] = xClipY( (iSum + 32) >> 6 );396 piSrcTmp += iSrcStep;397 }398 piSrc += iSrcStride;399 piDst += iDstStride;400 piDstPel += iDstStridePel;401 }402 return;403 }404 405 template<UInt bitDepth>406 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst)407 {408 Int* piDst = rpiDst;409 Int iSum;410 Pel* piSrcTmp;411 Int iSrcStride2 = iSrcStride*2;412 Int iSrcStride3 = iSrcStride*3;413 Int iSrcStride4 = iSrcStride*4;414 Int iSrcStride5 = iSrcStride*5;415 Int iSrcStride6 = iSrcStride*6;416 Int iSrcStride7 = iSrcStride*7;417 418 Int iTmp0, iTmp1, iTmp2, iTmp3, iTmpA;419 for ( Int y = iHeight; y != 0; y-- )420 {421 piSrcTmp = &piSrc[ -3*iSrcStride ];422 for ( Int x = 0; x < iWidth; x++ )423 {424 // { -1,4,-11,40,40,-11,4,-1 }425 iTmp0 = piSrcTmp[ 0]+piSrcTmp[iSrcStride7];426 iTmp1 = piSrcTmp[iSrcStride ]+piSrcTmp[iSrcStride6];427 iTmp2 = piSrcTmp[iSrcStride2]+piSrcTmp[iSrcStride5];428 iTmp3 = piSrcTmp[iSrcStride3]+piSrcTmp[iSrcStride4];429 430 iTmpA = (iTmp3 << 2) - iTmp2;431 432 iSum = ( iTmp1 << 2 )433 + ( iTmpA << 3 )434 + ( iTmpA << 1 )435 - iTmp0 - iTmp2;436 437 piDst[x * iDstStep] = iSum;438 piSrcTmp += iSrcStep;439 }440 piSrc += iSrcStride;441 piDst += iDstStride;442 }443 return;444 }445 446 template<UInt bitDepth>447 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)448 {449 Pel* piDst = rpiDst;450 Int iSum;451 Pel* piSrcTmp;452 453 Int iSrcStride2 = iSrcStride*2;454 Int iSrcStride3 = iSrcStride*3;455 Int iSrcStride4 = iSrcStride*4;456 Int iSrcStride5 = iSrcStride*5;457 Int iSrcStride6 = iSrcStride*6;458 Int iSrcStride7 = iSrcStride*7;459 460 Int iTmp0, iTmp1, iTmp2, iTmp3, iTmpA;461 for ( Int y = iHeight; y != 0; y-- )462 {463 piSrcTmp = &piSrc[ -3*iSrcStride ];464 for ( Int x = 0; x < iWidth; x++ )465 {466 // { -1,4,-11,40,40,-11,4,-1 }467 iTmp0 = piSrcTmp[ 0]+piSrcTmp[iSrcStride7];468 iTmp1 = piSrcTmp[iSrcStride ]+piSrcTmp[iSrcStride6];469 iTmp2 = piSrcTmp[iSrcStride2]+piSrcTmp[iSrcStride5];470 iTmp3 = piSrcTmp[iSrcStride3]+piSrcTmp[iSrcStride4];471 472 iTmpA = (iTmp3 << 2) - iTmp2;473 474 iSum = ( iTmp1 << 2 )475 + ( iTmpA << 3 )476 + ( iTmpA << 1 )477 - iTmp0 - iTmp2;478 479 piDst[x * iDstStep] = xClipY( (iSum + 32) >> 6 );480 piSrcTmp += iSrcStep;481 }482 piSrc += iSrcStride;483 piDst += iDstStride;484 }485 return;486 }487 488 template<UInt bitDepth>489 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter0Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst)490 {491 Int* piDst = rpiDst;492 Int iSum;493 Pel* piSrcTmp;494 Int iSrcStride2 = iSrcStride*2;495 Int iSrcStride3 = iSrcStride*3;496 Int iSrcStride4 = iSrcStride*4;497 Int iSrcStride5 = iSrcStride*5;498 Int iSrcStride6 = iSrcStride*6;499 Int iSrcStride7 = iSrcStride*7;500 501 Int iTmp1, iTmp2;502 for ( Int y = iHeight; y != 0; y-- )503 {504 piSrcTmp = &piSrc[ -3*iSrcStride ];505 for ( Int x = 0; x < iWidth; x++ )506 {507 // {-1, 4, -10, 57, 19, -7, 3, -1 },508 509 iTmp1 = piSrcTmp[iSrcStride3] + piSrcTmp[iSrcStride5];510 iTmp2 = piSrcTmp[iSrcStride6] + piSrcTmp[iSrcStride4];511 512 iSum = iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStride7]513 - ( ( piSrcTmp[iSrcStride2] - iTmp2 ) << 1 )514 + ( piSrcTmp[iSrcStride] << 2 )515 - ( ( piSrcTmp[iSrcStride2] + iTmp1 ) << 3 )516 + ( piSrcTmp[iSrcStride4] << 4 )517 + ( piSrcTmp[iSrcStride3] << 6 );518 519 piDst[x * iDstStep] = iSum;520 piSrcTmp += iSrcStep;521 }522 piSrc += iSrcStride;523 piDst += iDstStride;524 }525 return;526 }527 528 template<UInt bitDepth>529 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter0Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)530 {531 Pel* piDst = rpiDst;532 Int iSum;533 Pel* piSrcTmp;534 535 Int iSrcStride2 = iSrcStride*2;536 Int iSrcStride3 = iSrcStride*3;537 Int iSrcStride4 = iSrcStride*4;538 Int iSrcStride5 = iSrcStride*5;539 Int iSrcStride6 = iSrcStride*6;540 Int iSrcStride7 = iSrcStride*7;541 542 Int iTmp1, iTmp2;543 for ( Int y = iHeight; y != 0; y-- )544 {545 piSrcTmp = &piSrc[ -3*iSrcStride ];546 for ( Int x = 0; x < iWidth; x++ )547 {548 // {-1, 4, -10, 57, 19, -7, 3, -1 },549 550 iTmp1 = piSrcTmp[iSrcStride3] + piSrcTmp[iSrcStride5];551 iTmp2 = piSrcTmp[iSrcStride6] + piSrcTmp[iSrcStride4];552 553 iSum = iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStride7]554 - ( ( piSrcTmp[iSrcStride2] - iTmp2 ) << 1 )555 + ( piSrcTmp[iSrcStride] << 2 )556 - ( ( piSrcTmp[iSrcStride2] + iTmp1 ) << 3 )557 + ( piSrcTmp[iSrcStride4] << 4 );558 559 piDst[x * iDstStep] = xClipY( ((iSum + 32) >> 6) + piSrcTmp[iSrcStride3] );560 piSrcTmp += iSrcStep;561 }562 piSrc += iSrcStride;563 piDst += iDstStride;564 }565 return;566 }567 568 template<UInt bitDepth>569 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter1Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst)570 {571 Int* piDst = rpiDst;572 Int iSum;573 Pel* piSrcTmp;574 Int iSrcStride2 = iSrcStride*2;575 Int iSrcStride3 = iSrcStride*3;576 Int iSrcStride4 = iSrcStride*4;577 Int iSrcStride5 = iSrcStride*5;578 Int iSrcStride6 = iSrcStride*6;579 Int iSrcStride7 = iSrcStride*7;580 581 Int iTmp1, iTmp2;582 583 for ( Int y = iHeight; y != 0; y-- )584 {585 piSrcTmp = &piSrc[ -3*iSrcStride ];586 for ( Int x = 0; x < iWidth; x++ )587 {588 /// {-1, 3, -7, 19, 57, -10, 4, -1 },589 iTmp1 = piSrcTmp[iSrcStride4] + piSrcTmp[iSrcStride2];590 iTmp2 = piSrcTmp[iSrcStride ] + piSrcTmp[iSrcStride3];591 592 iSum = iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStride7]593 - ( ( piSrcTmp[iSrcStride5] - iTmp2 ) << 1 )594 + ( piSrcTmp[iSrcStride6] << 2 )595 - ( ( piSrcTmp[iSrcStride5] + iTmp1 ) << 3 )596 + ( piSrcTmp[iSrcStride3] << 4 )597 + ( piSrcTmp[iSrcStride4] << 6 );598 599 piDst[x * iDstStep] = iSum;600 piSrcTmp += iSrcStep;601 }602 piSrc += iSrcStride;603 piDst += iDstStride;604 }605 return;606 }607 608 template<UInt bitDepth>609 __inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter1Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)610 {611 Pel* piDst = rpiDst;612 Int iSum;613 Pel* piSrcTmp;614 Int iSrcStride2 = iSrcStride*2;615 Int iSrcStride3 = iSrcStride*3;616 Int iSrcStride4 = iSrcStride*4;617 Int iSrcStride5 = iSrcStride*5;618 Int iSrcStride6 = iSrcStride*6;619 Int iSrcStride7 = iSrcStride*7;620 621 Int iTmp1, iTmp2;622 623 for ( Int y = iHeight; y != 0; y-- )624 {625 piSrcTmp = &piSrc[ -3*iSrcStride ];626 for ( Int x = 0; x < iWidth; x++ )627 {628 /// {-1, 3, -7, 19, 57, -10, 4, -1 },629 iTmp1 = piSrcTmp[iSrcStride4] + piSrcTmp[iSrcStride2];630 iTmp2 = piSrcTmp[iSrcStride ] + piSrcTmp[iSrcStride3];631 632 iSum = iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStride7]633 - ( ( piSrcTmp[iSrcStride5] - iTmp2 ) << 1 )634 + ( piSrcTmp[iSrcStride6] << 2 )635 - ( ( piSrcTmp[iSrcStride5] + iTmp1 ) << 3 )636 + ( piSrcTmp[iSrcStride3] << 4 );637 638 piDst[x * iDstStep] = xClipY( ((iSum + 32) >> 6) + piSrcTmp[iSrcStride4] );639 piSrcTmp += iSrcStep;640 }641 piSrc += iSrcStride;642 piDst += iDstStride;643 }644 return;645 }646 647 // ------------------------------------------------------------------------------------------------648 // DCTIF filters for Chroma649 // ------------------------------------------------------------------------------------------------650 template<UInt bitDepth>651 __inline Void TRenInterpFilter<bitDepth>::xCTI_Filter2DVerC (Pel* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Int iDstStride, Int*& rpiDst, Int iMV)652 {653 Int* piDst = rpiDst;654 Int iSum;655 Pel* piSrcTmp;656 657 switch (iMV)658 {659 case 1:660 {661 for ( Int y = iHeight; y != 0; y-- )662 {663 piSrcTmp = &piSrc[ -iSrcStride ];664 for ( Int x = 0; x < iWidth; x++ )665 {666 iSum = xCTI_Filter_VP04_C_OCT0( piSrcTmp, iSrcStride );667 piDst[x ] = iSum;668 piSrcTmp++;669 }670 piSrc += iSrcStride;671 piDst += iDstStride;672 }673 }674 break;675 case 2:676 {677 for ( Int y = iHeight; y != 0; y-- )678 {679 piSrcTmp = &piSrc[ -iSrcStride ];680 for ( Int x = 0; x < iWidth; x++ )681 {682 iSum = xCTI_Filter_VP04_C_QUA0( piSrcTmp, iSrcStride );683 piDst[x ] = iSum;684 piSrcTmp++;685 }686 piSrc += iSrcStride;687 piDst += iDstStride;688 }689 }690 break;691 case 6:692 {693 for ( Int y = iHeight; y != 0; y-- )694 {695 piSrcTmp = &piSrc[ -iSrcStride ];696 for ( Int x = 0; x < iWidth; x++ )697 {698 iSum = xCTI_Filter_VP04_C_QUA1( piSrcTmp, iSrcStride );699 piDst[x ] = iSum;700 piSrcTmp++;701 }702 piSrc += iSrcStride;703 piDst += iDstStride;704 }705 }706 break;707 case 3:708 {709 for ( Int y = iHeight; y != 0; y-- )710 {711 piSrcTmp = &piSrc[ -iSrcStride ];712 for ( Int x = 0; x < iWidth; x++ )713 {714 iSum = xCTI_Filter_VP04_C_OCT1( piSrcTmp, iSrcStride );715 piDst[x ] = iSum;716 piSrcTmp++;717 }718 piSrc += iSrcStride;719 piDst += iDstStride;720 }721 }722 break;723 case 5:724 {725 for ( Int y = iHeight; y != 0; y-- )726 {727 piSrcTmp = &piSrc[ -iSrcStride ];728 for ( Int x = 0; x < iWidth; x++ )729 {730 iSum = xCTI_Filter_VP04_C_OCT2( piSrcTmp, iSrcStride );731 piDst[x ] = iSum;732 piSrcTmp++;733 }734 piSrc += iSrcStride;735 piDst += iDstStride;736 }737 }738 break;739 case 7:740 {741 for ( Int y = iHeight; y != 0; y-- )742 {743 piSrcTmp = &piSrc[ -iSrcStride ];744 for ( Int x = 0; x < iWidth; x++ )745 {746 iSum = xCTI_Filter_VP04_C_OCT3( piSrcTmp, iSrcStride );747 piDst[x ] = iSum;748 piSrcTmp++;749 }750 piSrc += iSrcStride;751 piDst += iDstStride;752 }753 }754 break;755 case 4:756 {757 758 for ( Int y = iHeight; y != 0; y-- )759 {760 piSrcTmp = &piSrc[ -iSrcStride ];761 for ( Int x = 0; x < iWidth; x++ )762 {763 iSum = xCTI_Filter_VPS04_C_HAL( piSrcTmp, iSrcStride );764 piDst[x ] = iSum;765 piSrcTmp++;766 }767 piSrc += iSrcStride;768 piDst += iDstStride;769 }770 }771 break;772 default:773 assert( 0 );774 }775 return;776 }777 778 template<UInt bitDepth>779 __inline Void TRenInterpFilter<bitDepth>::xCTI_Filter2DHorC(Int* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Int iDstStride, Pel*& rpiDst, Int iMV)780 {781 Pel* piDst = rpiDst;782 Int iSum;783 Int* piSrcTmp;784 785 switch (iMV)786 {787 case 1:788 {789 for ( Int y = iHeight; y != 0; y-- )790 {791 piSrcTmp = &piSrc[ -1 ];792 for ( Int x = 0; x < iWidth; x++ )793 {794 iSum = xCTI_Filter_VI04_C_OCT0( piSrcTmp, 1 );795 piDst [x ] = xClipC ((iSum + 2048) >> 12 );796 piSrcTmp++;797 }798 piSrc += iSrcStride;799 piDst += iDstStride;800 }801 }802 break;803 case 2:804 {805 for ( Int y = iHeight; y != 0; y-- )806 {807 piSrcTmp = &piSrc[ -1 ];808 for ( Int x = 0; x < iWidth; x++ )809 {810 iSum = xCTI_Filter_VI04_C_QUA0( piSrcTmp, 1 );811 piDst [x ] = xClipC ((iSum + 2048) >> 12 );812 piSrcTmp++;813 }814 piSrc += iSrcStride;815 piDst += iDstStride;816 }817 }818 break;819 case 6:820 {821 for ( Int y = iHeight; y != 0; y-- )822 {823 piSrcTmp = &piSrc[ -1 ];824 for ( Int x = 0; x < iWidth; x++ )825 {826 iSum = xCTI_Filter_VI04_C_QUA1( piSrcTmp, 1 );827 piDst [x ] = xClipC ((iSum + 2048) >> 12 );828 piSrcTmp++;829 }830 piSrc += iSrcStride;831 piDst += iDstStride;832 }833 }834 break;835 case 3:836 {837 for ( Int y = iHeight; y != 0; y-- )838 {839 piSrcTmp = &piSrc[ -1 ];840 for ( Int x = 0; x < iWidth; x++ )841 {842 iSum = xCTI_Filter_VI04_C_OCT1( piSrcTmp, 1 );843 piDst [x ] = xClipC ((iSum + 2048) >> 12 );844 piSrcTmp++;845 }846 piSrc += iSrcStride;847 piDst += iDstStride;848 }849 }850 break;851 case 5:852 {853 for ( Int y = iHeight; y != 0; y-- )854 {855 piSrcTmp = &piSrc[ -1 ];856 for ( Int x = 0; x < iWidth; x++ )857 {858 iSum = xCTI_Filter_VI04_C_OCT2( piSrcTmp, 1 );859 piDst [x ] = xClipC ((iSum + 2048) >> 12 );860 piSrcTmp++;861 }862 piSrc += iSrcStride;863 piDst += iDstStride;864 }865 }866 break;867 case 7:868 {869 for ( Int y = iHeight; y != 0; y-- )870 {871 piSrcTmp = &piSrc[ -1 ];872 for ( Int x = 0; x < iWidth; x++ )873 {874 iSum = xCTI_Filter_VI04_C_OCT3( piSrcTmp, 1 );875 piDst [x ] = xClipC ((iSum + 2048) >> 12 );876 piSrcTmp++;877 }878 piSrc += iSrcStride;879 piDst += iDstStride;880 }881 }882 break;883 case 4:884 {885 for ( Int y = iHeight; y != 0; y-- )886 {887 piSrcTmp = &piSrc[ -1 ];888 for ( Int x = 0; x < iWidth; x++ )889 {890 iSum = xCTI_Filter_VIS04_C_HAL( piSrcTmp, 1 );891 piDst [x ] = xClipC ((iSum + 2048) >> 12 );892 piSrcTmp++;893 }894 piSrc += iSrcStride;895 piDst += iDstStride;896 }897 }898 break;899 default:900 assert( 0 );901 }902 903 return;904 }905 906 template<UInt bitDepth>907 __inline Void TRenInterpFilter<bitDepth>::xCTI_Filter1DVerC (Pel* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Int iDstStride, Pel*& rpiDst, Int iMV)908 {909 Pel* piDst = rpiDst;910 Int iSum;911 Pel* piSrcTmp;912 913 switch (iMV)914 {915 case 1:916 {917 for ( Int y = iHeight; y != 0; y-- )918 {919 piSrcTmp = &piSrc[ -iSrcStride ];920 for ( Int x = 0; x < iWidth; x++ )921 {922 iSum = xCTI_Filter_VP04_C_OCT0( piSrcTmp, iSrcStride );923 piDst[x ] = xClipC ((iSum + 32) >> 6 );924 piSrcTmp++;925 }926 piSrc += iSrcStride;927 piDst += iDstStride;928 }929 }930 break;931 case 2:932 {933 for ( Int y = iHeight; y != 0; y-- )934 {935 piSrcTmp = &piSrc[ -iSrcStride ];936 for ( Int x = 0; x < iWidth; x++ )937 {938 iSum = xCTI_Filter_VP04_C_QUA0( piSrcTmp, iSrcStride );939 piDst[x ] = xClipC ((iSum + 32) >> 6 );940 piSrcTmp++;941 }942 piSrc += iSrcStride;943 piDst += iDstStride;944 }945 }946 break;947 case 6:948 {949 for ( Int y = iHeight; y != 0; y-- )950 {951 piSrcTmp = &piSrc[ -iSrcStride ];952 for ( Int x = 0; x < iWidth; x++ )953 {954 iSum = xCTI_Filter_VP04_C_QUA1( piSrcTmp, iSrcStride );955 piDst[x ] = xClipC ((iSum + 32) >> 6 );956 piSrcTmp++;957 }958 piSrc += iSrcStride;959 piDst += iDstStride;960 }961 }962 break;963 case 3:964 {965 for ( Int y = iHeight; y != 0; y-- )966 {967 piSrcTmp = &piSrc[ -iSrcStride ];968 for ( Int x = 0; x < iWidth; x++ )969 {970 iSum = xCTI_Filter_VP04_C_OCT1( piSrcTmp, iSrcStride );971 piDst[x ] = xClipC ((iSum + 32) >> 6 );972 piSrcTmp++;973 }974 piSrc += iSrcStride;975 piDst += iDstStride;976 }977 }978 break;979 case 5:980 {981 for ( Int y = iHeight; y != 0; y-- )982 {983 piSrcTmp = &piSrc[ -iSrcStride ];984 for ( Int x = 0; x < iWidth; x++ )985 {986 iSum = xCTI_Filter_VP04_C_OCT2( piSrcTmp, iSrcStride );987 piDst[x ] = xClipC ((iSum + 32) >> 6 );988 piSrcTmp++;989 }990 piSrc += iSrcStride;991 piDst += iDstStride;992 }993 }994 break;995 case 7:996 {997 for ( Int y = iHeight; y != 0; y-- )998 {999 piSrcTmp = &piSrc[ -iSrcStride ];1000 for ( Int x = 0; x < iWidth; x++ )1001 {1002 iSum = xCTI_Filter_VP04_C_OCT3( piSrcTmp, iSrcStride );1003 piDst[x ] = xClipC ((iSum + 32) >> 6 );1004 piSrcTmp++;1005 }1006 piSrc += iSrcStride;1007 piDst += iDstStride;1008 }1009 }1010 break;1011 case 4:1012 {1013 for ( Int y = iHeight; y != 0; y-- )1014 {1015 piSrcTmp = &piSrc[-iSrcStride ];1016 for ( Int x = 0; x < iWidth; x++ )1017 {1018 iSum = xCTI_Filter_VPS04_C_HAL( piSrcTmp, iSrcStride );1019 piDst[x ] = xClipC ((iSum + 32) >> 6 );1020 piSrcTmp++;1021 }1022 piSrc += iSrcStride;1023 piDst += iDstStride;1024 }1025 }1026 break;1027 default:1028 assert( 0 );1029 }1030 return;1031 }1032 1033 template<UInt bitDepth>1034 __inline Void TRenInterpFilter<bitDepth>::xCTI_Filter1DHorC(Pel* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Int iDstStride, Pel*& rpiDst, Int iMV)1035 {1036 Pel* piDst = rpiDst;1037 Int iSum;1038 Pel* piSrcTmp;1039 1040 switch (iMV)1041 {1042 case 1:1043 {1044 for ( Int y = iHeight; y != 0; y-- )1045 {1046 piSrcTmp = &piSrc[ -1 ];1047 for ( Int x = 0; x < iWidth; x++ )1048 {1049 iSum = xCTI_Filter_VP04_C_OCT0( piSrcTmp, 1 );1050 piDst[x ] = xClipC ((iSum + 32) >> 6 );1051 piSrcTmp++;1052 }1053 piSrc += iSrcStride;1054 piDst += iDstStride;1055 }1056 }1057 break;1058 case 2:1059 {1060 for ( Int y = iHeight; y != 0; y-- )1061 {1062 piSrcTmp = &piSrc[ -1 ];1063 for ( Int x = 0; x < iWidth; x++ )1064 {1065 iSum = xCTI_Filter_VP04_C_QUA0( piSrcTmp, 1 );1066 piDst[x ] = xClipC ((iSum + 32) >> 6 );1067 piSrcTmp++;1068 }1069 piSrc += iSrcStride;1070 piDst += iDstStride;1071 }1072 }1073 break;1074 case 6:1075 {1076 for ( Int y = iHeight; y != 0; y-- )1077 {1078 piSrcTmp = &piSrc[ -1 ];1079 for ( Int x = 0; x < iWidth; x++ )1080 {1081 iSum = xCTI_Filter_VP04_C_QUA1( piSrcTmp, 1 );1082 piDst[x ] = xClipC ((iSum + 32) >> 6 );1083 piSrcTmp++;1084 }1085 piSrc += iSrcStride;1086 piDst += iDstStride;1087 }1088 }1089 break;1090 case 3:1091 {1092 for ( Int y = iHeight; y != 0; y-- )1093 {1094 piSrcTmp = &piSrc[ -1 ];1095 for ( Int x = 0; x < iWidth; x++ )1096 {1097 iSum = xCTI_Filter_VP04_C_OCT1( piSrcTmp, 1 );1098 piDst[x ] = xClipC ((iSum + 32) >> 6 );1099 piSrcTmp++;1100 }1101 piSrc += iSrcStride;1102 piDst += iDstStride;1103 }1104 }1105 break;1106 case 5:1107 {1108 for ( Int y = iHeight; y != 0; y-- )1109 {1110 piSrcTmp = &piSrc[ -1 ];1111 for ( Int x = 0; x < iWidth; x++ )1112 {1113 iSum = xCTI_Filter_VP04_C_OCT2( piSrcTmp, 1 );1114 piDst[x ] = xClipC ((iSum + 32) >> 6 );1115 piSrcTmp++;1116 }1117 piSrc += iSrcStride;1118 piDst += iDstStride;1119 }1120 }1121 break;1122 case 7:1123 {1124 for ( Int y = iHeight; y != 0; y-- )1125 {1126 piSrcTmp = &piSrc[ -1 ];1127 for ( Int x = 0; x < iWidth; x++ )1128 {1129 iSum = xCTI_Filter_VP04_C_OCT3( piSrcTmp, 1 );1130 piDst[x ] = xClipC ((iSum + 32) >> 6 );1131 piSrcTmp++;1132 }1133 piSrc += iSrcStride;1134 piDst += iDstStride;1135 }1136 }1137 break;1138 case 4:1139 {1140 for ( Int y = iHeight; y != 0; y-- )1141 {1142 piSrcTmp = &piSrc[ -1 ];1143 for ( Int x = 0; x < iWidth; x++ )1144 {1145 iSum = xCTI_Filter_VPS04_C_HAL( piSrcTmp, 1 );1146 piDst[x ] = xClipC ((iSum + 32) >> 6 );1147 piSrcTmp++;1148 }1149 piSrc += iSrcStride;1150 piDst += iDstStride;1151 }1152 }1153 break;1154 default:1155 assert( 0 );1156 }1157 return;1158 }1159 1160 template<UInt bitDepth>1161 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_OCT0( Pel* pSrc, Int iStride )1162 {// { -3, 60, 8, -1,} // 1/81163 Int iSum, iIdx = 0;1164 1165 Int p0 = pSrc[0]; iIdx+= iStride;1166 Int p1 = pSrc[iIdx]; iIdx+= iStride;1167 Int p2 = pSrc[iIdx]; iIdx+= iStride;1168 Int p3 = pSrc[iIdx];1169 iSum = (p1<<6) -((p1+p0)<<2) +p0 +(p2<<3) -p3;1170 1171 return iSum;1172 }1173 template<UInt bitDepth>1174 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_OCT0( Int* pSrc, Int iStride )1175 { // { -3, 60, 8, -1,} //1/81176 Int iSum, iIdx = 0;1177 1178 Int p0 = pSrc[0]; iIdx+= iStride;1179 Int p1 = pSrc[iIdx]; iIdx+= iStride;1180 Int p2 = pSrc[iIdx]; iIdx+= iStride;1181 Int p3 = pSrc[iIdx];1182 iSum = (p1<<6) -((p1+p0)<<2) +p0 +(p2<<3) -p3;1183 1184 return iSum;1185 }1186 template<UInt bitDepth>1187 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_QUA0( Pel* pSrc, Int iStride )1188 {// { -4, 54, 16, -2,} // 1/41189 Int iSum, iIdx = 0;1190 1191 Int p0 = pSrc[0]; iIdx+= iStride;1192 Int p1 = pSrc[iIdx]; iIdx+= iStride;1193 Int p2 = pSrc[iIdx]; iIdx+= iStride;1194 Int p3 = pSrc[iIdx];1195 iSum = (p1 << 6) + (p2 << 4) - (p1 << 3) - ( p0 << 2) - ((p1 + p3) << 1);1196 1197 return iSum;1198 }1199 1200 template<UInt bitDepth>1201 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_QUA0( Int* pSrc, Int iStride )1202 { // { -4, 54, 16, -2,} //1/41203 Int iSum, iIdx = 0;1204 1205 Int p0 = pSrc[0]; iIdx+= iStride;1206 Int p1 = pSrc[iIdx]; iIdx+= iStride;1207 Int p2 = pSrc[iIdx]; iIdx+= iStride;1208 Int p3 = pSrc[iIdx];1209 iSum = (p1 << 6) + (p2 << 4) - (p1 << 3) - ( p0 << 2) - ((p1 + p3) << 1);1210 1211 return iSum;1212 }1213 template<UInt bitDepth>1214 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_QUA1( Pel* pSrc, Int iStride )1215 {// { -2, 16, 54, -4,}// 3/41216 Int iSum, iIdx = 0;1217 1218 Int p0 = pSrc[0]; iIdx+= iStride;1219 Int p1 = pSrc[iIdx]; iIdx+= iStride;1220 Int p2 = pSrc[iIdx]; iIdx+= iStride;1221 Int p3 = pSrc[iIdx];1222 iSum = (p2 << 6) + (p1 << 4) - (p2 << 3) - ( p3 << 2) - ((p2 + p0) << 1);1223 1224 return iSum;1225 }1226 1227 template<UInt bitDepth>1228 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_QUA1( Int* pSrc, Int iStride )1229 {// { -2, 16, 54, -4,}// 3/41230 Int iSum, iIdx = 0;1231 1232 Int p0 = pSrc[0]; iIdx+= iStride;1233 Int p1 = pSrc[iIdx]; iIdx+= iStride;1234 Int p2 = pSrc[iIdx]; iIdx+= iStride;1235 Int p3 = pSrc[iIdx];1236 iSum = (p2 << 6) + (p1 << 4) - (p2 << 3) - ( p3 << 2) - ((p2 + p0) << 1);1237 1238 return iSum;1239 }1240 1241 template<UInt bitDepth>1242 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_OCT1( Pel* pSrc, Int iStride )1243 {// { -5, 46, 27, -4,} // 3/81244 Int iSum, iIdx = 0;1245 1246 Int p0 = pSrc[0]; iIdx+= iStride;1247 Int p1 = pSrc[iIdx]; iIdx+= iStride;1248 Int p2 = pSrc[iIdx]; iIdx+= iStride;1249 Int p3 = pSrc[iIdx];1250 Int t = p0 + p2;1251 iSum = ((p1 + p2) << 5) + (p1 << 4) - ( (t + p3) << 2) - ( p1 << 1) - t;1252 1253 return iSum;1254 }1255 1256 template<UInt bitDepth>1257 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_OCT1( Int* pSrc, Int iStride )1258 { // { -5, 46, 27, -4,} //3/81259 Int iSum, iIdx = 0;1260 1261 Int p0 = pSrc[0]; iIdx+= iStride;1262 Int p1 = pSrc[iIdx]; iIdx+= iStride;1263 Int p2 = pSrc[iIdx]; iIdx+= iStride;1264 Int p3 = pSrc[iIdx];1265 Int t = p0 + p2;1266 iSum = ((p1 + p2) << 5) + (p1 << 4) - ( (t + p3) << 2) - ( p1 << 1) - t;1267 1268 return iSum;1269 }1270 1271 template<UInt bitDepth>1272 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VPS04_C_HAL( Pel* pSrc, Int iStride )1273 {1274 // { -4, 36, 36, -4,}, // 1/21275 Int iSum;1276 Int iTemp0 = pSrc[iStride*1]+pSrc[iStride*2];1277 Int iTemp1 = pSrc[ 0]+pSrc[iStride*3];1278 1279 iSum = ((iTemp0<<3) + iTemp0 -iTemp1)<<2;1280 1281 return iSum;1282 }1283 1284 template<UInt bitDepth>1285 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VIS04_C_HAL( Int* pSrc, Int iStride )1286 {1287 // { -4, 36, 36, -4,}, //1/21288 Int iSum;1289 Int iTemp0 = pSrc[iStride*1]+pSrc[iStride*2];1290 Int iTemp1 = pSrc[ 0]+pSrc[iStride*3];1291 1292 iSum = ((iTemp0<<3) + iTemp0 -iTemp1)<<2;1293 1294 return iSum;1295 }1296 1297 template<UInt bitDepth>1298 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_OCT2( Pel* pSrc, Int iStride )1299 {// { -4, 27, 46, -5,}, // 5/81300 Int iSum, iIdx = 0;1301 1302 Int p0 = pSrc[0]; iIdx+= iStride;1303 Int p1 = pSrc[iIdx]; iIdx+= iStride;1304 Int p2 = pSrc[iIdx]; iIdx+= iStride;1305 Int p3 = pSrc[iIdx];1306 Int t = p1 + p3;1307 iSum = ((p1 + p2) << 5) + (p2 << 4) - ( (t + p0) << 2) - ( p2 << 1) - t;1308 1309 return iSum;1310 }1311 1312 template<UInt bitDepth>1313 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_OCT2( Int* pSrc, Int iStride )1314 { // { -4, 27, 46, -5,}, // 5/81315 Int iSum, iIdx = 0;1316 1317 Int p0 = pSrc[0]; iIdx+= iStride;1318 Int p1 = pSrc[iIdx]; iIdx+= iStride;1319 Int p2 = pSrc[iIdx]; iIdx+= iStride;1320 Int p3 = pSrc[iIdx];1321 Int t = p1 + p3;1322 iSum = ((p1 + p2) << 5) + (p2 << 4) - ( (t + p0) << 2) - ( p2 << 1) - t;1323 1324 return iSum;1325 }1326 1327 template<UInt bitDepth>1328 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_OCT3( Pel* pSrc, Int iStride )1329 {// { -1, 8, 60, -3,} // 7/81330 Int iSum, iIdx = 0;1331 1332 Int p0 = pSrc[0]; iIdx+= iStride;1333 Int p1 = pSrc[iIdx]; iIdx+= iStride;1334 Int p2 = pSrc[iIdx]; iIdx+= iStride;1335 Int p3 = pSrc[iIdx];1336 iSum = (p2<<6) -((p2+p3)<<2) +p3 +(p1<<3) -p0;1337 1338 return iSum;1339 }1340 1341 template<UInt bitDepth>1342 __inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_OCT3( Int* pSrc, Int iStride )1343 { // { -1, 8, 60, -3,} // 7/81344 Int iSum, iIdx = 0;1345 1346 Int p0 = pSrc[0]; iIdx+= iStride;1347 Int p1 = pSrc[iIdx]; iIdx+= iStride;1348 Int p2 = pSrc[iIdx]; iIdx+= iStride;1349 Int p3 = pSrc[iIdx];1350 iSum = (p2<<6) -((p2+p3)<<2) +p3 +(p1<<3) -p0;1351 1352 return iSum;1353 }1354 1355 #endif // NH_3D1356 46 #endif // __TRENINTERP__ -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp
r1386 r1390 37 37 #include "TRenModSetupStrParser.h" 38 38 39 #if NH_3D_VSO40 Int41 TRenModSetupStrParser::getNumOfModels()42 {43 return m_iNumberOfModels;44 }45 39 46 Int47 TRenModSetupStrParser::getNumOfBaseViews()48 {49 return (Int) m_aiAllBaseViewIdx .size();50 }51 52 Int53 TRenModSetupStrParser::getNumOfModelsForView( Int iViewIdx, Int iContent )54 {55 return (Int) m_aaaiModelNums[iContent][iViewIdx].size();56 }57 58 Int59 TRenModSetupStrParser::getNumOfBaseViewsForView( Int iViewIdx, Int iContent )60 {61 return (Int) m_aaaiBaseViewsIdx[iContent][iViewIdx].size();62 }63 64 Void65 TRenModSetupStrParser::getSingleModelData( Int iSrcViewIdx,66 Int iSrcCnt,67 Int iCurModel,68 Int& riModelNum,69 Int& riBlendMode,70 Int& riLeftBaseViewIdx,71 Int& riRightBaseViewIdx,72 Int& riOrgRefBaseViewIdx,73 Int& riSynthViewRelNum )74 {75 Bool bExtrapolate = m_aaabExtrapolate[iSrcCnt][iSrcViewIdx][iCurModel];76 Bool bOrgRef = m_aaabOrgRef [iSrcCnt][iSrcViewIdx][iCurModel];77 78 riOrgRefBaseViewIdx = bOrgRef ? m_aaaiSynthViewNums[iSrcCnt][iSrcViewIdx][iCurModel] / ( (Int) VIEW_NUM_PREC ) : -1;79 riSynthViewRelNum = m_aaaiSynthViewNums[iSrcCnt][iSrcViewIdx][iCurModel];80 riModelNum = m_aaaiModelNums [iSrcCnt][iSrcViewIdx][iCurModel];81 riBlendMode = m_aaaiBlendMode [iSrcCnt][iSrcViewIdx][iCurModel];82 83 84 Int iSrcViewNum = iSrcViewIdx * ((Int) VIEW_NUM_PREC );85 if ( iSrcViewNum < riSynthViewRelNum )86 {87 riLeftBaseViewIdx = iSrcViewIdx;88 riRightBaseViewIdx = -1;89 }90 else91 {92 riLeftBaseViewIdx = -1;93 riRightBaseViewIdx = iSrcViewIdx;94 }95 96 if ( !bExtrapolate )97 {98 std::vector<Int> cCurBaseViews = m_aaaiBaseViewsIdx[iSrcCnt][iSrcViewIdx];99 100 Int iMinDist = MAX_INT;101 Int iNearestNum = -1;102 103 for (Int iCurBaseView = 0; iCurBaseView < cCurBaseViews.size(); iCurBaseView++ )104 {105 Int iCurBaseNum = m_aaaiBaseViewsIdx [iSrcCnt][iSrcViewIdx][iCurBaseView];106 107 if ( iCurBaseNum == iSrcViewNum )108 continue;109 110 Int iDist = iCurBaseNum - riSynthViewRelNum;111 112 if ( ( iDist <= 0 && riLeftBaseViewIdx == -1) || ( iDist >= 0 && riRightBaseViewIdx == -1 ) )113 {114 if ( abs(iDist) < iMinDist )115 {116 iMinDist = abs(iDist);117 iNearestNum = iCurBaseNum;118 }119 }120 }121 xError(iNearestNum == -1);122 123 if (riLeftBaseViewIdx == -1 )124 {125 riLeftBaseViewIdx = iNearestNum / (Int) (VIEW_NUM_PREC);126 }127 else128 {129 riRightBaseViewIdx = iNearestNum / (Int) (VIEW_NUM_PREC);130 }131 132 xError(riLeftBaseViewIdx == -1 );133 xError(riRightBaseViewIdx == -1 );134 xError(riLeftBaseViewIdx >= riRightBaseViewIdx );135 }136 }137 138 Void139 TRenModSetupStrParser::getBaseViewData( Int iSourceViewIdx, Int iSourceContent, Int iCurView, Int& riBaseViewSIdx, Int& riVideoDistMode, Int& riDepthDistMode )140 {141 riBaseViewSIdx = m_aaaiBaseViewsIdx [iSourceContent][iSourceViewIdx][iCurView] / (Int) VIEW_NUM_PREC;142 riVideoDistMode = m_aaaiVideoDistMode [iSourceContent][iSourceViewIdx][iCurView];143 riDepthDistMode = m_aaaiDepthDistMode [iSourceContent][iSourceViewIdx][iCurView];144 }145 146 TRenModSetupStrParser::TRenModSetupStrParser()147 {148 m_pchSetStr = NULL;149 m_iPosInStr = 0;150 m_iNumberOfModels = 0;151 m_bCurrentViewSet = false;152 }153 154 Void155 TRenModSetupStrParser::setString( Int iNumOfBaseViews, TChar* pchSetStr )156 {157 for (Int iContent = 0; iContent < 2; iContent++)158 {159 m_aaaiBaseViewsIdx [iContent].resize( iNumOfBaseViews );160 m_aaaiDepthDistMode [iContent].resize( iNumOfBaseViews );161 m_aaaiVideoDistMode [iContent].resize( iNumOfBaseViews );162 m_aaaiSynthViewNums [iContent].resize( iNumOfBaseViews );163 m_aaaiModelNums [iContent].resize( iNumOfBaseViews );164 m_aaabOrgRef [iContent].resize( iNumOfBaseViews );165 m_aaabExtrapolate [iContent].resize( iNumOfBaseViews );166 m_aaaiBlendMode [iContent].resize( iNumOfBaseViews );167 }168 169 AOT( m_pchSetStr );170 m_pchSetStr = pchSetStr;171 m_iPosInStr = 0;172 m_bCurrentViewSet = false;173 174 xParseString();175 }176 177 Void178 TRenModSetupStrParser::xParseString()179 {180 TChar cChar;181 xGetNextChar(cChar);182 while( cChar != '\0' )183 {184 xParseSourceView();185 xGetNextChar(cChar);186 }187 // CHECK188 size_t iNumOfSrcViews = m_aaaiBaseViewsIdx[0].size();189 190 for (Int iSrcView = 0; iSrcView < iNumOfSrcViews; iSrcView++)191 {192 for (Int iContent = 0; iContent < 2; iContent++ )193 {194 size_t iNumOfBase = m_aaaiBaseViewsIdx [iContent][iSrcView].size();195 AOF( iNumOfBase == m_aaaiDepthDistMode [iContent][iSrcView].size());196 AOF( iNumOfBase == m_aaaiVideoDistMode [iContent][iSrcView].size());197 198 size_t iNumOfModels = m_aaaiSynthViewNums[iContent][iSrcView].size();199 AOF( iNumOfModels == m_aaaiModelNums [iContent][iSrcView].size());200 AOF( iNumOfModels == m_aaabOrgRef [iContent][iSrcView].size());201 AOF( iNumOfModels == m_aaabExtrapolate [iContent][iSrcView].size());202 }203 }204 205 // SORT206 std::vector<Int>::iterator cIterNewEnd;207 208 std::sort( m_aiAllBaseViewIdx.begin(), m_aiAllBaseViewIdx.end() );209 cIterNewEnd = std::unique( m_aiAllBaseViewIdx.begin(), m_aiAllBaseViewIdx.end() );210 m_aiAllBaseViewIdx.erase( cIterNewEnd, m_aiAllBaseViewIdx.end() );211 212 std::sort( m_aiAllSynthViewNums.begin(), m_aiAllSynthViewNums.end() );213 cIterNewEnd = std::unique( m_aiAllSynthViewNums.begin(), m_aiAllSynthViewNums.end() );214 m_aiAllSynthViewNums.erase( cIterNewEnd, m_aiAllSynthViewNums.end() );215 }216 217 Void218 TRenModSetupStrParser::xParseSourceView()219 {220 m_bCurrentViewSet = false;221 222 TChar cChar;223 xGetNextCharGoOn( cChar );224 xError( cChar != '[' );225 xReadViewInfo('B');226 227 Bool bContinueReading = true;228 while( bContinueReading )229 {230 xGetNextCharGoOn( cChar );231 switch ( cChar )232 {233 case 'B':234 case 'I':235 case 'E':236 case 'L':237 case 'R':238 xReadViews( cChar );239 break;240 case ']':241 bContinueReading = false;242 break;243 default:244 xError(true);245 break;246 }247 }248 }249 250 Void251 TRenModSetupStrParser::xReadViews( TChar cType )252 {253 TChar cChar;254 xGetNextCharGoOn( cChar );255 xError( cChar != '(' );256 257 Bool bContinue = true;258 while ( bContinue )259 {260 xGetNextChar( cChar );261 if (cChar == ')')262 {263 xGetNextCharGoOn( cChar );264 bContinue = false;265 }266 else267 {268 xReadViewInfo( cType );269 }270 }271 }272 273 Void274 TRenModSetupStrParser::xReadViewInfo( TChar cType )275 {276 std::vector<Int> aiViewNums;277 aiViewNums.clear();278 279 switch ( cType )280 {281 case 'B':282 TChar cVideoType;283 TChar cDepthType;284 285 xGetNextCharGoOn ( cVideoType );286 xGetNextCharGoOn ( cDepthType );287 xGetViewNumberRange( aiViewNums );288 289 if ( !m_bCurrentViewSet )290 {291 xError( aiViewNums.size() != 1 );292 m_iCurrentView = aiViewNums[0] / (Int) VIEW_NUM_PREC;293 if ( cVideoType == 'x' )294 {295 m_iCurrentContent = 0;296 m_bCurrentViewSet = true;297 }298 else if ( cDepthType == 'x' )299 {300 m_iCurrentContent = 1;301 m_bCurrentViewSet = true;302 }303 else304 {305 xError( true );306 }307 }308 309 for ( Int iIdx = 0; iIdx < aiViewNums.size(); iIdx++ )310 {311 xAddBaseView( aiViewNums[iIdx], cVideoType, cDepthType );312 }313 break;314 315 case 'E':316 case 'I':317 case 'L':318 case 'R':319 TChar cRefType;320 xGetNextCharGoOn ( cRefType );321 xGetViewNumberRange( aiViewNums );322 for ( Int iIdx = 0; iIdx < aiViewNums.size(); iIdx++ )323 {324 xAddSynthView( aiViewNums[iIdx], cType, cRefType );325 }326 }327 }328 329 Void330 TRenModSetupStrParser::xAddBaseView( Int iViewIdx, TChar cVideoType, TChar cDepthType )331 {332 AOF( m_bCurrentViewSet );333 334 if ( cDepthType == 'x' ) cDepthType = 'o';335 if ( cVideoType == 'x' ) cVideoType = 'o';336 337 xError( cDepthType != 'o' && cDepthType != 'c' && cVideoType != 'r' );338 xError( cVideoType != 'o' && cVideoType != 'c' && cVideoType != 'r' );339 m_aiAllBaseViewIdx.push_back( iViewIdx );340 m_aaaiBaseViewsIdx [m_iCurrentContent][m_iCurrentView].push_back( iViewIdx );341 m_aaaiVideoDistMode [m_iCurrentContent][m_iCurrentView].push_back( ( cVideoType == 'c' ) ? 2 : ( (cVideoType == 'r') ? 1 : 0 ) );342 m_aaaiDepthDistMode [m_iCurrentContent][m_iCurrentView].push_back( ( cDepthType == 'c' ) ? 2 : ( (cDepthType == 'r') ? 1 : 0 ) );343 }344 345 Void346 TRenModSetupStrParser::xAddSynthView( Int iViewNum, TChar cType, TChar cRefType )347 {348 AOF( m_bCurrentViewSet );349 350 xError( cRefType != 's' && cRefType != 'o' );351 352 m_aiAllSynthViewNums.push_back( iViewNum );353 354 Int iBlendMode;355 switch ( cType )356 {357 case 'E':358 iBlendMode = BLEND_NONE;359 break;360 case 'I':361 iBlendMode = BLEND_AVRG;362 break;363 case 'L':364 iBlendMode = BLEND_LEFT;365 break;366 case 'R':367 iBlendMode = BLEND_RIGHT;368 break;369 default:370 xError(false);371 break;372 }373 374 m_aaaiBlendMode [m_iCurrentContent][m_iCurrentView].push_back( iBlendMode );375 m_aaaiSynthViewNums[m_iCurrentContent][m_iCurrentView].push_back( iViewNum );376 m_aaabExtrapolate [m_iCurrentContent][m_iCurrentView].push_back( cType == 'E' );377 m_aaabOrgRef [m_iCurrentContent][m_iCurrentView].push_back( cRefType == 'o' );378 m_aaaiModelNums [m_iCurrentContent][m_iCurrentView].push_back( m_iNumberOfModels );379 380 m_iNumberOfModels++;381 }382 383 Void384 TRenModSetupStrParser::xError( Bool bIsError )385 {386 if ( bIsError )387 {388 std::cout << "RenModel setup string invalid. Last character read: " << m_iPosInStr << std::endl;389 AOF( false );390 exit(0);391 }392 }393 394 Void395 TRenModSetupStrParser::xGetViewNumberRange( std::vector<Int>& raiViewNumbers )396 {397 size_t iStartPos;398 size_t iEndPos;399 TChar cChar;400 xGetNextCharGoOn(cChar );401 if (cChar == '{')402 {403 iStartPos = m_iPosInStr;404 while( m_pchSetStr[m_iPosInStr] != '}' )405 {406 xError( m_iPosInStr == '\0' );407 m_iPosInStr++;408 }409 iEndPos = m_iPosInStr - 1;410 m_iPosInStr++;411 }412 else413 {414 iStartPos = m_iPosInStr - 1;415 while( m_pchSetStr[m_iPosInStr] != ' ' && m_pchSetStr[m_iPosInStr] != ',' && m_pchSetStr[m_iPosInStr] != ')' )416 {417 xError( m_iPosInStr == '\0' );418 m_iPosInStr++;419 }420 iEndPos = m_iPosInStr - 1;421 }422 423 size_t iNumElem = iEndPos - iStartPos + 1;424 TChar* pcTempBuffer = new TChar[ iNumElem + 1];425 strncpy( pcTempBuffer, m_pchSetStr + iStartPos, iNumElem );426 pcTempBuffer[iNumElem] = '\0';427 428 TAppComCamPara::convertNumberString( pcTempBuffer, raiViewNumbers, VIEW_NUM_PREC );429 delete[] pcTempBuffer;430 }431 432 Void433 TRenModSetupStrParser::xGetNextCharGoOn( TChar& rcNextChar )434 {435 while ( m_pchSetStr[m_iPosInStr] == ' ' || m_pchSetStr[m_iPosInStr] == ',' )436 {437 xError( m_pchSetStr[m_iPosInStr] == '\0' );438 m_iPosInStr++;439 }440 rcNextChar = m_pchSetStr[m_iPosInStr];441 m_iPosInStr++;442 }443 444 Void445 TRenModSetupStrParser::xGetNextChar( TChar& rcNextChar )446 {447 size_t iPos = m_iPosInStr;448 while ( ( m_pchSetStr[iPos] == ' ' || m_pchSetStr[iPos] == ',' ) && m_pchSetStr[iPos] != '\0' ) iPos++;449 rcNextChar = m_pchSetStr[iPos];450 }451 #endif // NH_3D452 -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenModSetupStrParser.h
r1386 r1390 39 39 #include "../TLibCommon/TypeDef.h" 40 40 #include "../TAppCommon/TAppComCamPara.h" 41 #if NH_3D_VSO42 43 44 45 #include <list>46 #include <vector>47 #include <math.h>48 #include <errno.h>49 #include <vector>50 #include <iostream>51 #include <algorithm>52 #include <functional>53 #include <string>54 #include <cstdio>55 #include <cstring>56 57 58 using namespace std;59 60 class TRenModSetupStrParser61 {62 public:63 64 Int getNumOfModels ();65 Int getNumOfBaseViews ();66 67 Int getNumOfModelsForView ( Int iViewIdx, Int iContent );68 Int getNumOfBaseViewsForView( Int iViewIdx, Int iContent );69 70 Void getSingleModelData ( Int iSrcViewIdx,71 Int iSrcCnt,72 Int iCurModel,73 Int& riModelNum,74 Int& riInterpolationType,75 Int& riLeftBaseViewIdx,76 Int& riRightBaseViewIdx,77 Int& riOrgRefBaseViewIdx,78 Int& riSynthViewRelNum79 );80 81 Void getBaseViewData ( Int iSourceViewIdx,82 Int iSourceContent,83 Int iCurView,84 Int& riBaseViewSIdx,85 Int& riVideoDistMode,86 Int& riDepthDistMode87 );88 89 IntAry1d* getSynthViews() { return &m_aiAllSynthViewNums; }90 IntAry1d* getBaseViews() { return &m_aiAllBaseViewIdx; }91 92 TRenModSetupStrParser();93 94 Void setString( Int iNumOfBaseViews, TChar* pchSetStr );95 96 private:97 IntAry2d m_aaaiBaseViewsIdx [2];98 IntAry2d m_aaaiVideoDistMode [2];99 IntAry2d m_aaaiDepthDistMode [2];100 IntAry2d m_aaaiModelNums [2];101 IntAry2d m_aaaiSynthViewNums [2];102 BoolAry2d m_aaabOrgRef [2];103 BoolAry2d m_aaabExtrapolate [2];104 IntAry2d m_aaaiBlendMode [2];105 106 IntAry1d m_aiAllBaseViewIdx;107 IntAry1d m_aiAllSynthViewNums;108 109 Bool m_bCurrentViewSet;110 Int m_iCurrentView;111 Int m_iCurrentContent;112 Int m_iNumberOfModels;113 114 TChar* m_pchSetStr;115 size_t m_iPosInStr;116 117 private:118 Void xParseString();119 Void xParseSourceView();120 Void xReadViews ( TChar cType );121 Void xReadViewInfo ( TChar cType );122 Void xAddBaseView ( Int iViewIdx, TChar cVideoType, TChar cDepthType );123 Void xAddSynthView ( Int iViewNum, TChar cType, TChar cRefType );124 Void xError ( Bool bIsError );125 Void xGetViewNumberRange( std::vector<Int>& raiViewNumbers );126 Void xGetNextCharGoOn ( TChar& rcNextChar );127 Void xGetNextChar ( TChar& rcNextChar );128 };129 130 #endif // NH_3D131 41 #endif //__TRENMODEL__ 132 42 -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenModel.cpp
r1313 r1390 36 36 #include "TRenModel.h" 37 37 38 #if NH_3D_VSO39 /////////// TRENMODEL //////////////////////40 TRenModel::TRenModel()41 {42 m_iPad = PICYUV_PAD;43 m_iWidth = -1;44 m_iHeight = -1;45 m_iUsedHeight = -1;46 m_iNumOfBaseViews = -1;47 m_iSampledWidth = -1;48 m_iShiftPrec = 0;49 m_iHoleMargin = 1;50 m_uiHorOff = -1;51 #if H_3D_VSO_EARLY_SKIP52 m_bEarlySkip = false;53 #endif54 55 // Current Error Type ///56 m_iCurrentView = -1;57 m_iCurrentContent = -1;58 m_iCurrentPlane = -1;59 60 // Array of Models used to determine the Current Error ///61 m_iNumOfCurRenModels = -1;62 m_apcCurRenModels = NULL;63 m_aiCurPosInModels = NULL;64 65 // Array of Models ///66 m_iNumOfRenModels = -1;67 m_apcRenModels = NULL;68 69 // Mapping from View number to models ///70 m_aiNumOfModelsForDepthView = NULL;71 m_aapcRenModelForDepthView = NULL;72 m_aaePosInModelForDepthView = NULL;73 74 m_aiNumOfModelsForVideoView = NULL;75 m_aapcRenModelForVideoView = NULL;76 m_aaePosInModelForVideoView = NULL;77 m_aaeBaseViewPosInModel = NULL;78 79 // Data80 m_aapiCurVideoPel = NULL;81 m_aaiCurVideoStrides = NULL;82 m_apiCurDepthPel = NULL;83 m_aiCurDepthStrides = NULL;84 85 m_aapiOrgVideoPel = NULL;86 m_aaiOrgVideoStrides = NULL;87 m_apiOrgDepthPel = NULL;88 m_aiOrgDepthStrides = NULL;89 90 m_aaaiSubPelShiftLut[0]= NULL;91 m_aaaiSubPelShiftLut[1]= NULL;92 93 /// Current Setup data ///94 m_abSetupVideoFromOrgForView = NULL;95 m_abSetupDepthFromOrgForView = NULL;96 }97 98 TRenModel::~TRenModel()99 {100 if ( m_apcRenModels )101 {102 for (Int iNumModel = 0; iNumModel < m_iNumOfRenModels; iNumModel++)103 {104 if ( m_apcRenModels[iNumModel] ) delete m_apcRenModels[iNumModel];105 }106 107 delete[] m_apcRenModels;108 }109 110 for (Int iViewNum = 0; iViewNum < m_iNumOfBaseViews; iViewNum++)111 {112 if ( m_aapcRenModelForDepthView && m_aapcRenModelForDepthView [iViewNum] )113 {114 delete[] m_aapcRenModelForDepthView [iViewNum];115 }116 117 if ( m_aaePosInModelForDepthView && m_aaePosInModelForDepthView[iViewNum] )118 {119 delete[] m_aaePosInModelForDepthView[iViewNum];120 }121 122 if ( m_aapcRenModelForVideoView && m_aapcRenModelForVideoView[iViewNum] )123 {124 delete[] m_aapcRenModelForVideoView[iViewNum];125 }126 127 if ( m_aaePosInModelForVideoView && m_aaePosInModelForVideoView[iViewNum] )128 {129 delete[] m_aaePosInModelForVideoView[iViewNum];130 }131 132 if ( m_aaeBaseViewPosInModel && m_aaeBaseViewPosInModel[iViewNum] )133 {134 delete[] m_aaeBaseViewPosInModel[iViewNum];135 }136 137 if ( m_aapiCurVideoPel && m_aapiCurVideoPel [iViewNum] )138 {139 delete[] ( m_aapiCurVideoPel [iViewNum][0] - m_iPad * m_aaiCurVideoStrides[iViewNum][0] - m_iPad );140 delete[] ( m_aapiCurVideoPel [iViewNum][1] - m_iPad * m_aaiCurVideoStrides[iViewNum][1] - m_iPad );141 delete[] ( m_aapiCurVideoPel [iViewNum][2] - m_iPad * m_aaiCurVideoStrides[iViewNum][2] - m_iPad );142 delete[] m_aapiCurVideoPel [iViewNum];143 }144 145 if ( m_aaiCurVideoStrides && m_aaiCurVideoStrides [iViewNum] )146 {147 delete[] m_aaiCurVideoStrides [iViewNum];148 }149 150 if ( m_apiCurDepthPel )151 {152 delete[] ( m_apiCurDepthPel [iViewNum] - m_iPad * m_aiCurDepthStrides [iViewNum] - m_iPad );153 }154 155 if ( m_aapiOrgVideoPel && m_aapiOrgVideoPel [iViewNum] )156 {157 delete[] ( m_aapiOrgVideoPel [iViewNum][0] - m_iPad * m_aaiOrgVideoStrides[iViewNum][0] - m_iPad );158 delete[] ( m_aapiOrgVideoPel [iViewNum][1] - m_iPad * m_aaiOrgVideoStrides[iViewNum][1] - m_iPad );159 delete[] ( m_aapiOrgVideoPel [iViewNum][2] - m_iPad * m_aaiOrgVideoStrides[iViewNum][2] - m_iPad );160 delete[] m_aapiOrgVideoPel [iViewNum];161 }162 163 if ( m_aaiOrgVideoStrides && m_aaiOrgVideoStrides [iViewNum] )164 {165 delete[] m_aaiOrgVideoStrides [iViewNum];166 }167 168 if ( m_apiOrgDepthPel && m_apiOrgDepthPel [iViewNum ] )169 {170 delete[] ( m_apiOrgDepthPel [iViewNum] - m_iPad * m_aiOrgDepthStrides [iViewNum] - m_iPad );171 }172 }173 174 if(m_aiNumOfModelsForDepthView) delete[] m_aiNumOfModelsForDepthView;175 if(m_aapcRenModelForDepthView ) delete[] m_aapcRenModelForDepthView ;176 if(m_aaePosInModelForDepthView) delete[] m_aaePosInModelForDepthView;177 178 if(m_aiNumOfModelsForVideoView) delete[] m_aiNumOfModelsForVideoView;179 if(m_aapcRenModelForVideoView ) delete[] m_aapcRenModelForVideoView ;180 if(m_aaePosInModelForVideoView) delete[] m_aaePosInModelForVideoView;181 182 183 if(m_aaeBaseViewPosInModel ) delete[] m_aaeBaseViewPosInModel ;184 if(m_aapiCurVideoPel ) delete[] m_aapiCurVideoPel ;185 if(m_aaiCurVideoStrides ) delete[] m_aaiCurVideoStrides ;186 187 if(m_abSetupVideoFromOrgForView) delete[] m_abSetupVideoFromOrgForView;188 if(m_abSetupDepthFromOrgForView) delete[] m_abSetupDepthFromOrgForView;189 190 if(m_aapiOrgVideoPel ) delete[] m_aapiOrgVideoPel ;191 if(m_aaiOrgVideoStrides ) delete[] m_aaiOrgVideoStrides ;192 193 if(m_apiOrgDepthPel ) delete[] m_apiOrgDepthPel ;194 if(m_aiOrgDepthStrides ) delete[] m_aiOrgDepthStrides ;195 196 if(m_apiCurDepthPel ) delete[] m_apiCurDepthPel ;197 if(m_aiCurDepthStrides ) delete[] m_aiCurDepthStrides ;198 199 Int iNumEntries = (1 << ( m_iShiftPrec + 1) ) + 1 ;200 201 for (UInt uiEntry = 0; uiEntry < iNumEntries; uiEntry++)202 {203 if ( m_aaaiSubPelShiftLut[0] && m_aaaiSubPelShiftLut[0][uiEntry] )204 delete[] m_aaaiSubPelShiftLut[0][uiEntry];205 206 if ( m_aaaiSubPelShiftLut[1] && m_aaaiSubPelShiftLut[1][uiEntry] )207 delete[] m_aaaiSubPelShiftLut[1][uiEntry];208 }209 210 if( m_aaaiSubPelShiftLut[0] ) delete[] m_aaaiSubPelShiftLut[0];211 if( m_aaaiSubPelShiftLut[1] ) delete[] m_aaaiSubPelShiftLut[1];212 }213 214 215 216 Void217 #if H_3D_VSO_EARLY_SKIP218 TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bEarlySkip )219 #else220 TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin )221 #endif222 {223 m_iNumOfBaseViews = iNumOfBaseViews;224 m_iNumOfRenModels = iNumOfModels;225 m_iWidth = iWidth;226 m_iHeight = iHeight;227 m_iShiftPrec = iShiftPrec;228 m_iHoleMargin = iHoleMargin;229 #if H_3D_VSO_EARLY_SKIP230 m_bEarlySkip = bEarlySkip;231 #endif232 233 234 // LUTs for sub pel shifting235 Int iNumEntries = (1 << ( m_iShiftPrec + 1) ) + 1 ;236 m_aaaiSubPelShiftLut[0] = new Int*[ iNumEntries ];237 m_aaaiSubPelShiftLut[1] = new Int*[ iNumEntries ];238 for (UInt uiEntry = 0; uiEntry < iNumEntries; uiEntry++)239 {240 m_aaaiSubPelShiftLut[0][uiEntry] = new Int[ iNumEntries ];241 m_aaaiSubPelShiftLut[1][uiEntry] = new Int[ iNumEntries ];242 }243 244 TRenFilter<REN_BIT_DEPTH>::setSubPelShiftLUT( m_iShiftPrec, m_aaaiSubPelShiftLut[0], 0 );245 TRenFilter<REN_BIT_DEPTH>::setSubPelShiftLUT( m_iShiftPrec, m_aaaiSubPelShiftLut[1], 0 );246 247 m_iSampledWidth = iWidth << m_iShiftPrec;248 249 250 m_aapiCurVideoPel = new Pel** [m_iNumOfBaseViews];251 m_aaiCurVideoStrides = new Int* [m_iNumOfBaseViews];252 m_apiCurDepthPel = new Pel* [m_iNumOfBaseViews];253 m_aiCurDepthStrides = new Int [m_iNumOfBaseViews];254 255 m_aapiOrgVideoPel = new Pel** [m_iNumOfBaseViews];256 m_aaiOrgVideoStrides = new Int* [m_iNumOfBaseViews];257 258 m_apiOrgDepthPel = new Pel* [m_iNumOfBaseViews];259 m_aiOrgDepthStrides = new Int [m_iNumOfBaseViews];260 261 m_abSetupVideoFromOrgForView = new Bool[m_iNumOfBaseViews];262 m_abSetupDepthFromOrgForView = new Bool[m_iNumOfBaseViews];263 264 m_iNumOfCurRenModels = 0;265 m_apcCurRenModels = NULL;266 m_aiCurPosInModels = NULL;267 268 m_apcRenModels = new TRenSingleModel* [m_iNumOfRenModels];269 270 m_aiNumOfModelsForDepthView = new Int [m_iNumOfBaseViews];271 m_aapcRenModelForDepthView = new TRenSingleModel** [m_iNumOfBaseViews];272 m_aaePosInModelForDepthView = new Int* [m_iNumOfBaseViews];273 274 m_aiNumOfModelsForVideoView = new Int [m_iNumOfBaseViews];275 m_aapcRenModelForVideoView = new TRenSingleModel** [m_iNumOfBaseViews];276 m_aaePosInModelForVideoView = new Int* [m_iNumOfBaseViews];277 m_aaeBaseViewPosInModel = new Int* [m_iNumOfBaseViews];278 279 280 for (Int iModelNum = 0; iModelNum < m_iNumOfRenModels; iModelNum++)281 {282 m_apcRenModels [iModelNum] = NULL;283 }284 285 for (Int iViewNum = 0; iViewNum < m_iNumOfBaseViews; iViewNum++ )286 {287 m_aiNumOfModelsForDepthView[ iViewNum ] = 0;288 m_aiNumOfModelsForVideoView[ iViewNum ] = 0;289 290 m_aapcRenModelForDepthView [iViewNum] = new TRenSingleModel*[m_iNumOfRenModels];291 m_aapcRenModelForVideoView [iViewNum] = new TRenSingleModel*[m_iNumOfRenModels];292 293 m_aaePosInModelForDepthView[iViewNum] = new Int [m_iNumOfRenModels];294 m_aaePosInModelForVideoView[iViewNum] = new Int [m_iNumOfRenModels];295 m_aaeBaseViewPosInModel [iViewNum] = new Int [m_iNumOfRenModels];296 297 for (Int iModelNum = 0; iModelNum< m_iNumOfRenModels; iModelNum++)298 {299 m_aapcRenModelForDepthView [iViewNum] [iModelNum] = NULL;300 m_aapcRenModelForVideoView [iViewNum] [iModelNum] = NULL;301 m_aaePosInModelForDepthView[iViewNum] [iModelNum] = VIEWPOS_INVALID;302 m_aaePosInModelForVideoView[iViewNum] [iModelNum] = VIEWPOS_INVALID;303 m_aaeBaseViewPosInModel [iViewNum] [iModelNum] = VIEWPOS_INVALID;304 };305 306 m_aaiCurVideoStrides [iViewNum] = new Int[3];307 m_aaiCurVideoStrides [iViewNum][0] = m_iSampledWidth + (m_iPad << 1);308 m_aaiCurVideoStrides [iViewNum][1] = m_iSampledWidth + (m_iPad << 1);309 m_aaiCurVideoStrides [iViewNum][2] = m_iSampledWidth + (m_iPad << 1);310 311 m_aapiCurVideoPel [iViewNum] = new Pel*[3];312 m_aapiCurVideoPel [iViewNum][0] = new Pel [ m_aaiCurVideoStrides[iViewNum][0] * ( m_iHeight + (m_iPad << 1) )];313 m_aapiCurVideoPel [iViewNum][1] = new Pel [ m_aaiCurVideoStrides[iViewNum][1] * ( m_iHeight + (m_iPad << 1) )];314 m_aapiCurVideoPel [iViewNum][2] = new Pel [ m_aaiCurVideoStrides[iViewNum][2] * ( m_iHeight + (m_iPad << 1) )];315 316 m_aapiCurVideoPel [iViewNum][0] += m_aaiCurVideoStrides[iViewNum][0] * m_iPad + m_iPad;317 m_aapiCurVideoPel [iViewNum][1] += m_aaiCurVideoStrides[iViewNum][1] * m_iPad + m_iPad;318 m_aapiCurVideoPel [iViewNum][2] += m_aaiCurVideoStrides[iViewNum][2] * m_iPad + m_iPad;319 320 m_aiCurDepthStrides [iViewNum] = m_iWidth + (m_iPad << 1);321 m_apiCurDepthPel [iViewNum] = new Pel[ m_aiCurDepthStrides[iViewNum] * ( m_iHeight + (m_iPad << 1) ) ];322 m_apiCurDepthPel [iViewNum] += m_aiCurDepthStrides[iViewNum] * m_iPad + m_iPad;323 324 m_aaiOrgVideoStrides [iViewNum] = new Int[3];325 m_aaiOrgVideoStrides [iViewNum][0] = m_iSampledWidth + (m_iPad << 1);326 m_aaiOrgVideoStrides [iViewNum][1] = m_iSampledWidth + (m_iPad << 1);327 m_aaiOrgVideoStrides [iViewNum][2] = m_iSampledWidth + (m_iPad << 1);328 329 m_aapiOrgVideoPel [iViewNum] = new Pel*[3];330 m_aapiOrgVideoPel [iViewNum][0] = new Pel [ m_aaiOrgVideoStrides[iViewNum][0] * ( m_iHeight + (m_iPad << 1) )];331 m_aapiOrgVideoPel [iViewNum][1] = new Pel [ m_aaiOrgVideoStrides[iViewNum][1] * ( m_iHeight + (m_iPad << 1) )];332 m_aapiOrgVideoPel [iViewNum][2] = new Pel [ m_aaiOrgVideoStrides[iViewNum][2] * ( m_iHeight + (m_iPad << 1) )];333 334 m_aapiOrgVideoPel [iViewNum][0] += m_aaiOrgVideoStrides[iViewNum][0] * m_iPad + m_iPad;335 m_aapiOrgVideoPel [iViewNum][1] += m_aaiOrgVideoStrides[iViewNum][1] * m_iPad + m_iPad;336 m_aapiOrgVideoPel [iViewNum][2] += m_aaiOrgVideoStrides[iViewNum][2] * m_iPad + m_iPad;337 338 m_aiOrgDepthStrides [iViewNum] = m_iWidth + (m_iPad << 1);339 m_apiOrgDepthPel [iViewNum] = new Pel[ m_aiOrgDepthStrides[iViewNum] * ( m_iHeight + (m_iPad << 1) ) ];340 m_apiOrgDepthPel [iViewNum] += m_aiOrgDepthStrides[iViewNum] * m_iPad + m_iPad;341 342 m_abSetupVideoFromOrgForView[iViewNum] = false;343 m_abSetupDepthFromOrgForView[iViewNum] = false;344 }345 }346 347 Void348 TRenModel::createSingleModel( Int iBaseViewNum, Int iContent, Int iModelNum, Int iLeftViewNum, Int iRightViewNum, Bool bUseOrgRef, Int iBlendMode )349 {350 Int iMode = ( (iLeftViewNum != -1) && ( iRightViewNum != -1 ) ) ? 2 : ( iLeftViewNum != -1 ? 0 : ( iRightViewNum != -1 ? 1 : -1 ) );351 352 AOT( iMode == -1);353 AOT( iModelNum < 0 || iModelNum > m_iNumOfRenModels );354 AOT( iLeftViewNum < -1 || iLeftViewNum > m_iNumOfBaseViews );355 AOT( iRightViewNum < -1 || iRightViewNum > m_iNumOfBaseViews );356 AOT( iBaseViewNum < -1 || iBaseViewNum > m_iNumOfBaseViews );357 AOT( iBaseViewNum != -1 && iBaseViewNum != iLeftViewNum && iBaseViewNum != iRightViewNum );358 AOT( iContent < -1 || iContent > 1 );359 AOT( iBlendMode < -1 || iBlendMode > 2 );360 361 Bool bBitInc = ( REN_BIT_DEPTH != ENC_INTERNAL_BIT_DEPTH );362 363 AOT( m_apcRenModels[iModelNum] );364 365 if ( bBitInc )366 {367 if ( iMode != 2 )368 { // No Blending369 m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_NONE, true>;370 }371 else372 {373 switch ( iBlendMode )374 {375 case BLEND_AVRG: // average376 m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_AVRG, true>;377 break;378 case BLEND_LEFT: // left view is main view379 m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_LEFT, true>;380 break;381 case BLEND_RIGHT: // right view is main view382 m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_RIGHT, true>;383 break;384 default:385 AOT(true);386 break;387 }388 }389 }390 else391 {392 if ( iMode != 2 )393 { // No Blending394 m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_NONE, false>;395 }396 else397 {398 switch ( iBlendMode )399 {400 case BLEND_AVRG: // average401 m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_AVRG, false>;402 break;403 case BLEND_LEFT: // left view is main view404 m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_LEFT, false>;405 break;406 case BLEND_RIGHT: // right view is main view407 m_apcRenModels[iModelNum] = new TRenSingleModelC<BLEND_RIGHT, false>;408 break;409 default:410 AOT(true);411 break;412 }413 }414 }415 416 417 #if H_3D_VSO_EARLY_SKIP418 m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin, bUseOrgRef, iBlendMode, m_bEarlySkip );419 #else420 m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin, bUseOrgRef, iBlendMode );421 #endif422 423 if ( iLeftViewNum != -1 )424 {425 xSetLRViewAndAddModel( iModelNum, iLeftViewNum, iContent, VIEWPOS_LEFT, (iBaseViewNum == -1 || iBaseViewNum == iLeftViewNum ) );426 }427 428 if ( iRightViewNum != -1)429 {430 xSetLRViewAndAddModel( iModelNum, iRightViewNum, iContent, VIEWPOS_RIGHT, (iBaseViewNum == -1 || iBaseViewNum == iRightViewNum ) );431 }432 }433 434 Void435 TRenModel::setBaseView( Int iViewNum, TComPicYuv* pcPicYuvVideoData, TComPicYuv* pcPicYuvDepthData, TComPicYuv* pcPicYuvOrgVideoData, TComPicYuv* pcPicYuvOrgDepthData )436 {437 AOT( iViewNum < 0 || iViewNum > m_iNumOfBaseViews );438 AOF( pcPicYuvVideoData->getHeight( COMPONENT_Y ) >= m_iUsedHeight + m_uiHorOff && pcPicYuvVideoData->getWidth( COMPONENT_Y ) == m_iWidth );439 AOF( pcPicYuvDepthData->getHeight( COMPONENT_Y ) >= m_iUsedHeight + m_uiHorOff && pcPicYuvDepthData->getWidth( COMPONENT_Y ) == m_iWidth );440 441 AOF( pcPicYuvVideoData ->getChromaFormat() == CHROMA_420 );442 443 pcPicYuvVideoData->extendPicBorder();444 445 TRenFilter<REN_BIT_DEPTH>::sampleHorUp ( m_iShiftPrec, pcPicYuvVideoData->getAddr( COMPONENT_Y ) + m_uiHorOff * pcPicYuvVideoData->getStride( COMPONENT_Y ) , pcPicYuvVideoData->getStride( COMPONENT_Y ) , m_iWidth, m_iUsedHeight, m_aapiCurVideoPel[ iViewNum ][0], m_aaiCurVideoStrides[iViewNum][0] );446 TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getAddr( COMPONENT_Cb ) + (m_uiHorOff >> 1 ) * pcPicYuvVideoData->getStride( COMPONENT_Cb) , pcPicYuvVideoData->getStride( COMPONENT_Cb ), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiCurVideoPel[ iViewNum ][1], m_aaiCurVideoStrides[iViewNum][1] );447 TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getAddr( COMPONENT_Cr ) + (m_uiHorOff >> 1 ) * pcPicYuvVideoData->getStride( COMPONENT_Cr) , pcPicYuvVideoData->getStride( COMPONENT_Cr ), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiCurVideoPel[ iViewNum ][2], m_aaiCurVideoStrides[iViewNum][2] );448 TRenFilter<REN_BIT_DEPTH>::copy ( pcPicYuvDepthData->getAddr( COMPONENT_Y ) + m_uiHorOff * pcPicYuvDepthData->getStride( COMPONENT_Y ) , pcPicYuvDepthData->getStride( COMPONENT_Y ), m_iWidth, m_iUsedHeight, m_apiCurDepthPel [ iViewNum], m_aiCurDepthStrides [iViewNum] );449 450 // Used for rendering reference pic from original video data451 m_abSetupVideoFromOrgForView[iViewNum] = (pcPicYuvOrgVideoData != NULL);452 m_abSetupDepthFromOrgForView[iViewNum] = (pcPicYuvOrgDepthData != NULL);453 454 if ( m_abSetupVideoFromOrgForView[iViewNum] )455 {456 AOF( pcPicYuvOrgVideoData->getChromaFormat() == CHROMA_420 );457 AOF( pcPicYuvOrgVideoData->getHeight( COMPONENT_Y ) >= m_iUsedHeight + m_uiHorOff && pcPicYuvOrgVideoData->getWidth( COMPONENT_Y) == m_iWidth );458 pcPicYuvOrgVideoData->extendPicBorder();459 TRenFilter<REN_BIT_DEPTH>::sampleHorUp ( m_iShiftPrec, pcPicYuvOrgVideoData->getAddr( COMPONENT_Y ) + m_uiHorOff * pcPicYuvOrgVideoData->getStride( COMPONENT_Y ), pcPicYuvOrgVideoData->getStride( COMPONENT_Y ) , m_iWidth, m_iUsedHeight, m_aapiOrgVideoPel[ iViewNum ][0], m_aaiOrgVideoStrides[iViewNum][0] );460 TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getAddr( COMPONENT_Cb ) + (m_uiHorOff >> 1 ) * pcPicYuvOrgVideoData->getStride( COMPONENT_Cb ), pcPicYuvOrgVideoData->getStride( COMPONENT_Cb ), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][1], m_aaiOrgVideoStrides[iViewNum][1] );461 TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getAddr( COMPONENT_Cr ) + (m_uiHorOff >> 1 ) * pcPicYuvOrgVideoData->getStride( COMPONENT_Cr ), pcPicYuvOrgVideoData->getStride( COMPONENT_Cr ), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][2], m_aaiOrgVideoStrides[iViewNum][2] );462 }463 464 if ( m_abSetupDepthFromOrgForView[iViewNum] )465 {466 AOF( pcPicYuvOrgDepthData->getHeight( COMPONENT_Y ) >= m_iUsedHeight + m_uiHorOff && pcPicYuvOrgDepthData->getWidth( COMPONENT_Y ) == m_iWidth );467 TRenFilter<REN_BIT_DEPTH>::copy ( pcPicYuvOrgDepthData->getAddr( COMPONENT_Y ) + m_uiHorOff * pcPicYuvOrgDepthData->getStride( COMPONENT_Y) , pcPicYuvOrgDepthData->getStride( COMPONENT_Y), m_iWidth, m_iUsedHeight, m_apiOrgDepthPel [ iViewNum], m_aiOrgDepthStrides [iViewNum] );468 }469 }470 471 Void472 TRenModel::setSingleModel( Int iModelNum, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, TComPicYuv* pcPicYuvRefView )473 {474 AOT( iModelNum < 0 || iModelNum > m_iNumOfRenModels );475 476 m_apcRenModels[iModelNum]->setupPart( m_uiHorOff, m_iUsedHeight );477 478 // Switch model to original data for setup if given to render reference479 Bool bAnyRefFromOrg = false;480 for (Int iBaseViewIdx = 0; iBaseViewIdx < m_iNumOfBaseViews; iBaseViewIdx++ )481 {482 Bool bSetupFromOrgVideo = m_abSetupVideoFromOrgForView[iBaseViewIdx];483 Bool bSetupFromOrgDepth = m_abSetupDepthFromOrgForView[iBaseViewIdx];484 bAnyRefFromOrg = bAnyRefFromOrg || bSetupFromOrgVideo || bSetupFromOrgDepth;485 486 if ( m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum] != VIEWPOS_INVALID )487 {488 bAnyRefFromOrg = true;489 m_apcRenModels[iModelNum]->setLRView( m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum],490 ( bSetupFromOrgVideo ? m_aapiOrgVideoPel : m_aapiCurVideoPel ) [iBaseViewIdx],491 ( bSetupFromOrgVideo ? m_aaiOrgVideoStrides: m_aaiCurVideoStrides) [iBaseViewIdx],492 ( bSetupFromOrgDepth ? m_apiOrgDepthPel : m_apiCurDepthPel ) [iBaseViewIdx],493 ( bSetupFromOrgDepth ? m_aiOrgDepthStrides : m_aiCurDepthStrides ) [iBaseViewIdx] );494 }495 }496 497 m_apcRenModels[iModelNum]->setup ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, false );498 499 // Setup to Org500 if ( bAnyRefFromOrg )501 {502 // Restore old values503 for (Int iBaseViewIdx = 0; iBaseViewIdx < m_iNumOfBaseViews; iBaseViewIdx++ )504 {505 if ( m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum] != VIEWPOS_INVALID )506 {507 m_apcRenModels[iModelNum]->setLRView(508 m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum],509 m_aapiCurVideoPel [iBaseViewIdx],510 m_aaiCurVideoStrides [iBaseViewIdx],511 m_apiCurDepthPel [iBaseViewIdx],512 m_aiCurDepthStrides [iBaseViewIdx]513 );514 }515 }516 517 // setup keeping reference rendered from original data518 m_apcRenModels[iModelNum]->setup ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, true );519 }520 }521 522 Void523 TRenModel::setErrorMode( Int iView, Int iContent, int iPlane )524 {525 AOT(iView > m_iNumOfBaseViews || iView < 0);526 AOT(iContent != 0 && iContent != 1);527 AOT(iPlane < 0 || iPlane > 3);528 529 m_iCurrentView = iView;530 m_iCurrentContent = iContent;531 m_iCurrentPlane = iPlane;532 533 if ( iContent == 1 )534 {535 m_iNumOfCurRenModels = m_aiNumOfModelsForDepthView[iView];536 m_apcCurRenModels = m_aapcRenModelForDepthView [iView];537 m_aiCurPosInModels = m_aaePosInModelForDepthView[iView];538 }539 else540 {541 m_iNumOfCurRenModels = m_aiNumOfModelsForVideoView[iView];542 m_apcCurRenModels = m_aapcRenModelForVideoView [iView];543 m_aiCurPosInModels = m_aaePosInModelForVideoView[iView];544 }545 }546 547 548 Void549 TRenModel::setupPart ( UInt uiHorOff, Int iUsedHeight )550 {551 AOT( iUsedHeight > m_iHeight );552 m_uiHorOff = uiHorOff;553 m_iUsedHeight = iUsedHeight;554 }555 556 #if H_3D_VSO_EARLY_SKIP557 RMDist558 TRenModel::getDist( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel * piOrgData, Int iOrgStride)559 #else560 RMDist561 TRenModel::getDist( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData )562 #endif563 {564 iStartPosY -= m_uiHorOff;565 566 AOT( iWidth + iStartPosX > m_iWidth );567 AOT( iHeight + iStartPosY > m_iUsedHeight );568 569 AOT( iStartPosX < 0);570 AOT( iStartPosY < 0);571 AOT( iWidth < 0);572 AOT( iHeight < 0);573 574 RMDist iDist = 0;575 576 for (Int iModelNum = 0; iModelNum < m_iNumOfCurRenModels; iModelNum++ )577 {578 if (m_iCurrentContent == 1)579 {580 #if H_3D_VSO_EARLY_SKIP581 iDist += m_apcCurRenModels[iModelNum]->getDistDepth ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData , piOrgData, iOrgStride);582 #else583 iDist += m_apcCurRenModels[iModelNum]->getDistDepth ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData );584 #endif585 }586 else587 {588 iDist += m_apcCurRenModels[iModelNum]->getDistVideo ( m_aiCurPosInModels[iModelNum], m_iCurrentPlane ,iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData );589 }590 }591 592 return ( iDist + (m_iNumOfCurRenModels >> 1) ) / m_iNumOfCurRenModels;593 }594 595 Void596 TRenModel::setData( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )597 {598 iStartPosY -= m_uiHorOff;599 600 iWidth = min(iWidth , m_iWidth - iStartPosX );601 iHeight = min(iHeight, m_iUsedHeight - iStartPosY );602 603 AOT( iStartPosX < 0);604 AOT( iStartPosY < 0);605 AOT( iWidth < 0);606 AOT( iHeight < 0);607 608 for (Int iModelNum = 0; iModelNum < m_iNumOfCurRenModels; iModelNum++ )609 {610 if (m_iCurrentContent == 1)611 {612 #if H_3D_VSO_EARLY_SKIP613 Int iTargetStride = m_aiCurDepthStrides[ m_iCurrentView ];614 m_apcCurRenModels[iModelNum]->setDepth ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,m_apiCurDepthPel[ m_iCurrentView ] + iStartPosY * iTargetStride + iStartPosX ,iTargetStride );615 #else616 m_apcCurRenModels[iModelNum]->setDepth ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData );617 #endif618 }619 else620 {621 m_apcCurRenModels[iModelNum]->setVideo ( m_aiCurPosInModels[iModelNum], m_iCurrentPlane ,iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData );622 }623 }624 625 #if H_3D_VSO_EARLY_SKIP626 if (m_iCurrentContent == 1)627 {628 Int iTargetStride = m_aiCurDepthStrides[ m_iCurrentView ];629 TRenFilter<REN_BIT_DEPTH>::copy( piNewData, iStride, iWidth, iHeight, m_apiCurDepthPel[ m_iCurrentView ] + iStartPosY * iTargetStride + iStartPosX, iTargetStride );630 }631 #endif632 }633 634 Void635 TRenModel::getSynthVideo( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuv )636 {637 m_apcRenModels[iModelNum]->getSynthVideo(iViewNum, pcPicYuv );638 }639 640 Void641 TRenModel::getSynthDepth( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuv )642 {643 m_apcRenModels[iModelNum]->getSynthDepth(iViewNum, pcPicYuv );644 }645 646 Void647 TRenModel::getTotalSSE( Int64& riSSEY, Int64& riSSEU, Int64& riSSEV )648 {649 TComPicYuv cPicYuvSynth;650 cPicYuvSynth.create( m_iWidth, m_iUsedHeight, CHROMA_420, 1, 1, 1, true);651 652 TComPicYuv cPicYuvTempRef;653 cPicYuvTempRef.create( m_iWidth, m_iUsedHeight, CHROMA_420, 1, 1, 1, true);654 655 Int64 iSSEY = 0;656 Int64 iSSEU = 0;657 Int64 iSSEV = 0;658 659 for (Int iCurModel = 0; iCurModel < m_iNumOfCurRenModels; iCurModel++)660 {661 m_apcCurRenModels[iCurModel]->getSynthVideo( m_aiCurPosInModels[iCurModel], &cPicYuvSynth );662 m_apcCurRenModels[iCurModel]->getRefVideo ( m_aiCurPosInModels[iCurModel], &cPicYuvTempRef );663 664 iSSEY += TRenFilter<REN_BIT_DEPTH>::SSE( cPicYuvSynth.getAddr( COMPONENT_Y ), cPicYuvSynth.getStride( COMPONENT_Y ), m_iWidth, m_iUsedHeight , cPicYuvTempRef.getAddr( COMPONENT_Y ), cPicYuvTempRef.getStride( COMPONENT_Y ), true );665 iSSEU += TRenFilter<REN_BIT_DEPTH>::SSE( cPicYuvSynth.getAddr( COMPONENT_Cb ), cPicYuvSynth.getStride( COMPONENT_Cb ), m_iWidth >> 1, m_iUsedHeight >> 1, cPicYuvTempRef.getAddr( COMPONENT_Cb ), cPicYuvTempRef.getStride( COMPONENT_Cb ), false );666 iSSEV += TRenFilter<REN_BIT_DEPTH>::SSE( cPicYuvSynth.getAddr( COMPONENT_Cr ), cPicYuvSynth.getStride( COMPONENT_Cr ), m_iWidth >> 1, m_iUsedHeight >> 1, cPicYuvTempRef.getAddr( COMPONENT_Cr ), cPicYuvTempRef.getStride( COMPONENT_Cr ), false );667 }668 669 riSSEY = ( iSSEY + (m_iNumOfCurRenModels >> 1) ) / m_iNumOfCurRenModels;670 riSSEU = ( iSSEU + (m_iNumOfCurRenModels >> 1) ) / m_iNumOfCurRenModels;671 riSSEV = ( iSSEV + (m_iNumOfCurRenModels >> 1) ) / m_iNumOfCurRenModels;672 673 cPicYuvTempRef.destroy();674 cPicYuvSynth .destroy();675 }676 677 Void678 TRenModel::xSetLRViewAndAddModel( Int iModelNum, Int iBaseViewNum, Int iContent, Int iViewPos, Bool bAdd )679 {680 AOF(iViewPos == VIEWPOS_LEFT || iViewPos == VIEWPOS_RIGHT);681 AOF(iContent == -1 || iContent == 0 || iContent == 1);682 AOT( iBaseViewNum < 0 || iBaseViewNum > m_iNumOfBaseViews );683 AOT( m_aaeBaseViewPosInModel[iBaseViewNum][iModelNum] != VIEWPOS_INVALID );684 m_aaeBaseViewPosInModel[iBaseViewNum][iModelNum] = iViewPos;685 686 if (bAdd)687 {688 if (iContent == 0 || iContent == -1 )689 {690 Int iNewModelIdxForView = m_aiNumOfModelsForVideoView[iBaseViewNum]++;691 m_aapcRenModelForVideoView [ iBaseViewNum ][ iNewModelIdxForView ] = m_apcRenModels[iModelNum];692 m_aaePosInModelForVideoView[ iBaseViewNum ][ iNewModelIdxForView ] = iViewPos;693 }694 695 if (iContent == 1 || iContent == -1 )696 {697 Int iNewModelIdxForView = m_aiNumOfModelsForDepthView[iBaseViewNum]++;698 m_aapcRenModelForDepthView [ iBaseViewNum ][ iNewModelIdxForView ] = m_apcRenModels[iModelNum];699 m_aaePosInModelForDepthView[ iBaseViewNum ][ iNewModelIdxForView ] = iViewPos;700 }701 }702 }703 #endif // NH_3D -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenModel.h
r1313 r1390 42 42 #include "../TLibCommon/TypeDef.h" 43 43 44 #if NH_3D_VSO45 46 class TRenModel47 {48 public:49 50 TRenModel();51 ~TRenModel();52 53 // Creation54 #if H_3D_VSO_EARLY_SKIP55 Void create ( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin, Bool bEarlySkip );56 #else57 Void create ( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin );58 #endif59 Void createSingleModel( Int iBaseViewNum, Int iContent, Int iModelNum, Int iLeftViewNum, Int iRightViewNum, Bool bUseOrgRef, Int iBlendMode );60 61 // Set new Frame62 Void setBaseView ( Int iViewNum, TComPicYuv* pcPicYuvVideoData, TComPicYuv* pcPicYuvDepthData, TComPicYuv* pcPicYuvOrgVideoData, TComPicYuv* pcPicYuvOrgDepthData );63 Void setSingleModel ( Int iModelNum, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, TComPicYuv* pcPicYuvRefView );64 65 // Set horizontal offset66 Void setupPart ( UInt uiHorOff, Int iUsedHeight );67 68 // Set Mode69 Void setErrorMode ( Int iView, Int iContent, Int iPlane );70 71 // Get Distortion, set Data72 #if H_3D_VSO_EARLY_SKIP73 Int64 getDist ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Pel * piOrgData, Int iOrgStride);74 #else75 Int64 getDist ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );76 #endif77 Void setData ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );78 79 // Get Rendered View80 81 Void getSynthVideo ( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuvSynthVideo );82 Void getSynthDepth ( Int iModelNum, Int iViewNum, TComPicYuv* pcPicYuvSynthDepth );83 84 // Get Total Distortion85 Void getTotalSSE (Int64& riSSEY, Int64& riSSEU, Int64& riSSEV );86 87 private:88 // helpers89 Void xSetLRViewAndAddModel( Int iModelNum, Int iBaseViewNum, Int iContent, Int iViewPos, Bool bAdd );90 91 // Settings92 Int m_iShiftPrec;93 Int** m_aaaiSubPelShiftLut[2];94 Int m_iHoleMargin;95 #if H_3D_VSO_EARLY_SKIP96 Bool m_bEarlySkip;97 #endif98 99 /// Size of Video and Depth100 Int m_iWidth;101 Int m_iHeight;102 Int m_iSampledWidth;103 Int m_iPad;104 Int m_iUsedHeight; // height currently used in buffer, whereas m_iHeight is the total height of the buffer105 106 107 Int m_iNumOfBaseViews;108 109 // Horizontal Offset in input data110 UInt m_uiHorOff;111 112 /// Current Error Type ///113 Int m_iCurrentView;114 Int m_iCurrentContent;115 Int m_iCurrentPlane;116 117 /// Array of Models used to determine the Current Error ///118 Int m_iNumOfCurRenModels;119 TRenSingleModel** m_apcCurRenModels; // Array of pointers used for determination of current error120 Int* m_aiCurPosInModels; // Position of Current View in Model121 122 /// Array of Models ///123 Int m_iNumOfRenModels;124 TRenSingleModel** m_apcRenModels; // Array of pointers to all created models125 126 /// Mapping from View number and Content type to models ///127 Int* m_aiNumOfModelsForDepthView;128 TRenSingleModel*** m_aapcRenModelForDepthView; // Dim1: ViewNumber129 Int** m_aaePosInModelForDepthView; // Position in Model ( Left or Right)130 131 Int* m_aiNumOfModelsForVideoView;132 TRenSingleModel*** m_aapcRenModelForVideoView; // Dim1: ViewNumber133 Int** m_aaePosInModelForVideoView; // Position in Model ( Left or Right) (local model numbering)134 135 /// Position of Base Views in Models ( global model numbering )136 Int** m_aaeBaseViewPosInModel;137 138 /// Current Setup data ///139 Bool* m_abSetupVideoFromOrgForView; //: Dim1: ViewNumber, 0 ... use org; 1 ... use coded; 2; use org ref and coded in RDO140 Bool* m_abSetupDepthFromOrgForView;141 142 /// DATA //143 // Cur144 145 /// Number of Base Views146 Pel*** m_aapiCurVideoPel ; // Dim1: ViewNumber: Plane 0-> Y, 1->U, 2->V147 Int** m_aaiCurVideoStrides; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane 0-> Y, 1->U, 2->V148 149 Pel** m_apiCurDepthPel ; // Dim1: ViewPosition150 Int* m_aiCurDepthStrides ; // Dim1: ViewPosition151 152 Pel*** m_aapiOrgVideoPel ; // Dim1: ViewPosition Dim2: Plane 0-> Y, 1->U, 2->V153 Int** m_aaiOrgVideoStrides; // Dim1: ViewPosition Dim2: Plane 0-> Y, 1->U, 2->V154 155 Pel** m_apiOrgDepthPel ; // Dim1: ViewPosition156 Int* m_aiOrgDepthStrides ; // Dim1: ViewPosition157 };158 159 #endif // NH_3D160 44 #endif //__TRENMODEL__ 161 45 -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenSingleModel.cpp
r1313 r1390 36 36 #include "TRenSingleModel.h" 37 37 38 #if NH_3D_VSO39 38 40 ////////////// TRENSINGLE MODEL ///////////////41 template <BlenMod iBM, Bool bBitInc>42 TRenSingleModelC<iBM,bBitInc>::TRenSingleModelC()43 : m_iDistShift ( ( ENC_INTERNAL_BIT_DEPTH - REN_BIT_DEPTH) << 1 )44 {45 m_iWidth = -1;46 m_iHeight = -1;47 m_iStride = -1;48 m_iUsedHeight = -1;49 m_iHorOffset = -1;50 m_iMode = -1;51 m_iPad = PICYUV_PAD;52 m_iGapTolerance = -1;53 m_bUseOrgRef = false;54 55 m_pcPicYuvRef = NULL;56 57 m_pcOutputSamples = NULL;58 m_pcOutputSamplesRow = NULL;59 m_iOutputSamplesStride = -1;60 61 m_ppiCurLUT = NULL;62 m_piInvZLUTLeft = NULL;63 m_piInvZLUTRight = NULL;64 65 m_aapiRefVideoPel[0] = NULL;66 m_aapiRefVideoPel[1] = NULL;67 m_aapiRefVideoPel[2] = NULL;68 69 m_aiRefVideoStrides[0] = -1;70 m_aiRefVideoStrides[1] = -1;71 m_aiRefVideoStrides[2] = -1;72 73 74 for (UInt uiViewNum = 0 ; uiViewNum < 2; uiViewNum++)75 {76 // LUT77 m_appiShiftLut[uiViewNum] = NULL;78 79 m_pcInputSamples[uiViewNum] = NULL;80 m_iInputSamplesStride = -1;81 82 m_ppiCurLUT = NULL;83 m_piInvZLUTLeft = NULL;84 m_piInvZLUTRight = NULL;85 }86 87 #if H_3D_VSO_EARLY_SKIP88 m_pbHorSkip = NULL;89 #endif90 }91 92 template <BlenMod iBM, Bool bBitInc>93 TRenSingleModelC<iBM,bBitInc>::~TRenSingleModelC()94 {95 #if H_3D_VSO_EARLY_SKIP96 if ( m_pbHorSkip )97 {98 delete[] m_pbHorSkip;99 m_pbHorSkip = NULL;100 }101 #endif102 103 if ( m_pcInputSamples [0] ) delete[] m_pcInputSamples [0];104 if ( m_pcInputSamples [1] ) delete[] m_pcInputSamples [1];105 106 if ( m_pcOutputSamples ) delete[] m_pcOutputSamples ;107 108 if ( m_piInvZLUTLeft ) delete[] m_piInvZLUTLeft ;109 if ( m_piInvZLUTRight ) delete[] m_piInvZLUTRight;110 111 if ( m_aapiRefVideoPel[0] ) delete[] ( m_aapiRefVideoPel[0] - ( m_aiRefVideoStrides[0] * m_iPad + m_iPad ) );112 if ( m_aapiRefVideoPel[1] ) delete[] ( m_aapiRefVideoPel[1] - ( m_aiRefVideoStrides[1] * m_iPad + m_iPad ) );113 if ( m_aapiRefVideoPel[2] ) delete[] ( m_aapiRefVideoPel[2] - ( m_aiRefVideoStrides[2] * m_iPad + m_iPad ) );114 }115 116 template <BlenMod iBM, Bool bBitInc> Void117 #if H_3D_VSO_EARLY_SKIP118 TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bEarlySkip )119 #else120 TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode )121 #endif122 123 {124 #if H_3D_VSO_EARLY_SKIP125 m_pbHorSkip = new Bool [MAX_CU_SIZE];126 m_bEarlySkip = bEarlySkip;127 #endif128 129 AOF( iBlendMode == iBM );130 131 m_iMode = iMode;132 133 m_iWidth = iWidth;134 m_iHeight = iHeight;135 m_iStride = iWidth;136 137 m_iSampledWidth = m_iWidth << iShiftPrec;138 m_iSampledStride = m_iStride << iShiftPrec;139 140 m_iShiftPrec = iShiftPrec;141 m_aaiSubPelShiftL = aaaiSubPelShiftTable[0];142 m_aaiSubPelShiftR = aaaiSubPelShiftTable[1];143 144 if (m_iMode == 2)145 {146 m_piInvZLUTLeft = new Int[257];147 m_piInvZLUTRight = new Int[257];148 }149 150 m_iGapTolerance = ( 2 << iShiftPrec );151 m_iHoleMargin = iHoleMargin;152 153 m_bUseOrgRef = bUseOrgRef;154 155 m_aiRefVideoStrides[0] = m_iStride + (m_iPad << 1);156 m_aiRefVideoStrides[1] = m_iStride + (m_iPad << 1);157 m_aiRefVideoStrides[2] = m_iStride + (m_iPad << 1);158 159 m_aapiRefVideoPel [0] = new Pel[ m_aiRefVideoStrides[0] * (m_iHeight + (m_iPad << 1))];160 m_aapiRefVideoPel [1] = new Pel[ m_aiRefVideoStrides[1] * (m_iHeight + (m_iPad << 1))];161 m_aapiRefVideoPel [2] = new Pel[ m_aiRefVideoStrides[2] * (m_iHeight + (m_iPad << 1))];162 163 m_aapiRefVideoPel [0] += m_aiRefVideoStrides[0] * m_iPad + m_iPad;164 m_aapiRefVideoPel [1] += m_aiRefVideoStrides[1] * m_iPad + m_iPad;165 m_aapiRefVideoPel [2] += m_aiRefVideoStrides[2] * m_iPad + m_iPad;166 167 m_iInputSamplesStride = m_iWidth+1;168 m_iOutputSamplesStride = m_iWidth;169 170 m_pcInputSamples[0] = new RenModelInPels[m_iInputSamplesStride*m_iHeight];171 m_pcInputSamples[1] = new RenModelInPels[m_iInputSamplesStride*m_iHeight];172 173 m_pcOutputSamples = new RenModelOutPels[m_iOutputSamplesStride*m_iHeight];174 }175 176 template <BlenMod iBM, Bool bBitInc> Void177 TRenSingleModelC<iBM,bBitInc>::setLRView( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride )178 {179 AOF(( iViewPos == 0) || (iViewPos == 1) );180 181 RenModelInPels* pcCurInputSampleRow = m_pcInputSamples[iViewPos];182 183 Pel* piDRow = piCurDepthPel;184 Pel* piYRow = apiCurVideoPel[0];185 #if H_3D_VSO_COLOR_PLANES186 Pel* piURow = apiCurVideoPel[1];187 Pel* piVRow = apiCurVideoPel[2];188 #endif189 190 191 Int iOffsetX = ( iViewPos == VIEWPOS_RIGHT ) ? 1 : 0;192 193 for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )194 {195 if ( iViewPos == VIEWPOS_RIGHT )196 {197 Int iSubPosX = (1 << m_iShiftPrec);198 pcCurInputSampleRow[0].aiY[iSubPosX] = piYRow[0];199 #if H_3D_VSO_COLOR_PLANES200 pcCurInputSampleRow[0].aiU[iSubPosX] = piURow[0];201 pcCurInputSampleRow[0].aiV[iSubPosX] = piVRow[0];202 #endif203 }204 205 for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )206 {207 pcCurInputSampleRow[iPosX].iD = piDRow[iPosX];208 209 for (Int iSubPosX = 0; iSubPosX < (1 << m_iShiftPrec)+1; iSubPosX++ )210 {211 Int iShift = (iPosX << m_iShiftPrec) + iSubPosX;212 pcCurInputSampleRow[iPosX+iOffsetX].aiY[iSubPosX] = piYRow[iShift];213 #if H_3D_VSO_COLOR_PLANES214 pcCurInputSampleRow[iPosX+iOffsetX].aiU[iSubPosX] = piURow[iShift];215 pcCurInputSampleRow[iPosX+iOffsetX].aiV[iSubPosX] = piVRow[iShift];216 #endif217 }218 }219 220 pcCurInputSampleRow += m_iInputSamplesStride;221 222 piDRow += iCurDepthStride;223 piYRow += aiCurVideoStride[0];224 #if H_3D_VSO_COLOR_PLANES225 piURow += aiCurVideoStride[1];226 piVRow += aiCurVideoStride[2];227 #endif228 }229 230 231 m_aapiBaseVideoPel [iViewPos] = apiCurVideoPel;232 m_aaiBaseVideoStrides [iViewPos] = aiCurVideoStride;233 m_apiBaseDepthPel [iViewPos] = piCurDepthPel;234 m_aiBaseDepthStrides [iViewPos] = iCurDepthStride;235 236 }237 template <BlenMod iBM, Bool bBitInc> Void238 TRenSingleModelC<iBM,bBitInc>::setupPart ( UInt uiHorOffset, Int iUsedHeight )239 {240 AOT( iUsedHeight > m_iHeight );241 242 m_iUsedHeight = iUsedHeight;243 m_iHorOffset = (Int) uiHorOffset;244 }245 246 template <BlenMod iBM, Bool bBitInc> Void247 TRenSingleModelC<iBM,bBitInc>::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, Bool bKeepReference )248 {249 AOT( !m_bUseOrgRef && pcOrgVideo );250 AOT( (ppiShiftLutLeft == NULL) && (m_iMode == 0 || m_iMode == 2) );251 AOT( (ppiShiftLutRight == NULL) && (m_iMode == 1 || m_iMode == 2) );252 253 m_appiShiftLut[0] = ppiShiftLutLeft;254 m_appiShiftLut[1] = ppiShiftLutRight;255 256 // Copy Reference257 m_pcPicYuvRef = pcOrgVideo;258 259 if ( pcOrgVideo && !bKeepReference )260 {261 assert( pcOrgVideo->getChromaFormat() != CHROMA_420 );262 263 TRenFilter<REN_BIT_DEPTH>::copy( pcOrgVideo->getAddr( COMPONENT_Y ) + m_iHorOffset * pcOrgVideo->getStride( COMPONENT_Y ), pcOrgVideo->getStride( COMPONENT_Y ), m_iWidth, m_iUsedHeight, m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]);264 TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp(0, pcOrgVideo->getAddr( COMPONENT_Cb ) + (m_iHorOffset >> 1) * pcOrgVideo->getStride( COMPONENT_Cb ), pcOrgVideo->getStride( COMPONENT_Cb ), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);265 TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp(0, pcOrgVideo->getAddr( COMPONENT_Cr ) + (m_iHorOffset >> 1) * pcOrgVideo->getStride( COMPONENT_Cr ), pcOrgVideo->getStride( COMPONENT_Cr ), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);266 xSetStructRefView();267 }268 269 // Initial Rendering270 xResetStructError();271 xInitSampleStructs();272 switch ( m_iMode )273 {274 case 0:275 #if H_3D_VSO_EARLY_SKIP276 xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false );277 #else278 xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );279 #endif280 break;281 case 1:282 #if H_3D_VSO_EARLY_SKIP283 xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);284 #else285 xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );286 #endif287 break;288 case 2:289 TRenFilter<REN_BIT_DEPTH>::setupZLUT( true, 30, iDistToLeft, ppiBaseShiftLutLeft, ppiBaseShiftLutRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight );290 #if H_3D_VSO_EARLY_SKIP291 xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false);292 xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);293 #else294 xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );295 xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );296 #endif297 break;298 default:299 AOT(true);300 }301 302 // Get Rendered View as Reference303 if ( !pcOrgVideo && !bKeepReference )304 {305 xResetStructError();306 xSetStructSynthViewAsRefView();307 }308 }309 310 template <BlenMod iBM, Bool bBitInc> Void311 #if H_3D_VSO_COLOR_PLANES312 TRenSingleModelC<iBM,bBitInc>::xGetSampleStrTextPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY, Pel RenModelOutPels::*& rpiSrcU, Pel RenModelOutPels::*& rpiSrcV )313 #else314 TRenSingleModelC<iBM,bBitInc>::xGetSampleStrTextPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY )315 #endif316 {317 switch ( iViewNum )318 {319 case 0:320 rpiSrcY = &RenModelOutPels::iYLeft;321 #if H_3D_VSO_COLOR_PLANES322 rpiSrcU = &RenModelOutPels::iULeft;323 rpiSrcV = &RenModelOutPels::iVLeft;324 #endif325 break;326 case 1:327 rpiSrcY = &RenModelOutPels::iYRight;328 #if H_3D_VSO_COLOR_PLANES329 rpiSrcU = &RenModelOutPels::iURight;330 rpiSrcV = &RenModelOutPels::iVRight;331 #endif332 break;333 case 2:334 rpiSrcY = &RenModelOutPels::iYBlended;335 #if H_3D_VSO_COLOR_PLANES336 rpiSrcU = &RenModelOutPels::iUBlended;337 rpiSrcV = &RenModelOutPels::iVBlended;338 #endif339 break;340 }341 }342 343 344 template <BlenMod iBM, Bool bBitInc> Void345 TRenSingleModelC<iBM,bBitInc>::xGetSampleStrDepthPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcD )346 {347 AOT(iViewNum != 0 && iViewNum != 1);348 rpiSrcD = (iViewNum == 1) ? &RenModelOutPels::iDRight : &RenModelOutPels::iDLeft;349 }350 351 352 template <BlenMod iBM, Bool bBitInc> Void353 TRenSingleModelC<iBM,bBitInc>::xSetStructRefView( )354 {355 RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;356 357 Pel* piYRow = m_aapiRefVideoPel[0];358 #if H_3D_VSO_COLOR_PLANES359 Pel* piURow = m_aapiRefVideoPel[1];360 Pel* piVRow = m_aapiRefVideoPel[2];361 #endif362 363 for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )364 {365 for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )366 {367 pcCurOutSampleRow[iPosX].iYRef = piYRow[iPosX];368 #if H_3D_VSO_COLOR_PLANES369 pcCurOutSampleRow[iPosX].iURef = piURow[iPosX];370 pcCurOutSampleRow[iPosX].iVRef = piVRow[iPosX];371 #endif372 }373 374 pcCurOutSampleRow += m_iOutputSamplesStride;375 376 piYRow += m_aiRefVideoStrides[0];377 #if H_3D_VSO_COLOR_PLANES378 piURow += m_aiRefVideoStrides[1];379 piVRow += m_aiRefVideoStrides[2];380 #endif381 }382 }383 384 template <BlenMod iBM, Bool bBitInc> Void385 TRenSingleModelC<iBM,bBitInc>::xResetStructError( )386 {387 RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;388 389 for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )390 {391 for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )392 {393 pcCurOutSampleRow[iPosX].iError = 0;394 }395 pcCurOutSampleRow += m_iOutputSamplesStride;396 }397 }398 399 template <BlenMod iBM, Bool bBitInc> Void400 TRenSingleModelC<iBM,bBitInc>::xSetStructSynthViewAsRefView( )401 {402 AOT( m_iMode < 0 || m_iMode > 2);403 404 RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;405 406 Pel RenModelOutPels::* piSrcY = NULL;407 408 #if H_3D_VSO_COLOR_PLANES409 Pel RenModelOutPels::* piSrcU = NULL;410 Pel RenModelOutPels::* piSrcV = NULL;411 xGetSampleStrTextPtrs( m_iMode, piSrcY, piSrcU, piSrcV );412 #else413 xGetSampleStrTextPtrs( m_iMode, piSrcY );414 #endif415 416 for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )417 {418 for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )419 {420 pcCurOutSampleRow[iPosX].iYRef = pcCurOutSampleRow[iPosX].*piSrcY;421 #if H_3D_VSO_COLOR_PLANES422 pcCurOutSampleRow[iPosX].iURef = pcCurOutSampleRow[iPosX].*piSrcU;423 pcCurOutSampleRow[iPosX].iVRef = pcCurOutSampleRow[iPosX].*piSrcV;424 #endif425 }426 pcCurOutSampleRow += m_iOutputSamplesStride;427 }428 }429 430 template <BlenMod iBM, Bool bBitInc> Void431 TRenSingleModelC<iBM,bBitInc>::xInitSampleStructs()432 {433 RenModelOutPels* pcOutSampleRow = m_pcOutputSamples;434 RenModelInPels * pcLeftInSampleRow = m_pcInputSamples[0];435 RenModelInPels * pcRightInSampleRow = m_pcInputSamples[1];436 437 438 for (Int iPosY = 0; iPosY < m_iHeight; iPosY++)439 {440 for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)441 {442 //// Output Samples443 pcOutSampleRow[iPosX].iFilledLeft = REN_IS_HOLE;444 pcOutSampleRow[iPosX].iFilledRight = REN_IS_HOLE;445 446 pcOutSampleRow[iPosX].iDLeft = 0;447 pcOutSampleRow[iPosX].iDRight = 0;448 pcOutSampleRow[iPosX].iDBlended = 0;449 450 // Y Planes451 pcOutSampleRow[iPosX].iYLeft = 0;452 pcOutSampleRow[iPosX].iYRight = 0;453 pcOutSampleRow[iPosX].iYBlended = 0;454 #if H_3D_VSO_COLOR_PLANES455 // U Planes456 pcOutSampleRow[iPosX].iULeft = 1 << (REN_BIT_DEPTH - 1);457 pcOutSampleRow[iPosX].iURight = 1 << (REN_BIT_DEPTH - 1);458 pcOutSampleRow[iPosX].iUBlended = 1 << (REN_BIT_DEPTH - 1);459 460 // V Planes461 pcOutSampleRow[iPosX].iVLeft = 1 << (REN_BIT_DEPTH - 1);462 pcOutSampleRow[iPosX].iVRight = 1 << (REN_BIT_DEPTH - 1);463 pcOutSampleRow[iPosX].iVBlended = 1 << (REN_BIT_DEPTH - 1);464 #endif465 //// Input Samples466 pcLeftInSampleRow [iPosX].bOccluded = false;467 pcRightInSampleRow[iPosX].bOccluded = false;468 }469 470 pcOutSampleRow += m_iOutputSamplesStride;471 pcLeftInSampleRow += m_iInputSamplesStride;472 pcRightInSampleRow += m_iInputSamplesStride;473 }474 }475 476 477 #if H_3D_VSO_EARLY_SKIP478 template <BlenMod iBM, Bool bBitInc> RMDist479 TRenSingleModelC<iBM,bBitInc>::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData , const Pel * piOrgData, Int iOrgStride )480 #else481 template <BlenMod iBM, Bool bBitInc> RMDist482 TRenSingleModelC<iBM,bBitInc>::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )483 #endif484 {485 RMDist iSSE = 0;486 #if H_3D_VSO_EARLY_SKIP487 Bool bEarlySkip;488 #endif489 switch ( iViewPos )490 {491 case 0:492 #if H_3D_VSO_EARLY_SKIP493 bEarlySkip = m_bEarlySkip ? xDetectEarlySkipL(iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, piOrgData, iOrgStride) : false;494 if( !bEarlySkip )495 {496 iSSE = xRenderL<false>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,true );497 }498 #else499 iSSE = xRenderL<false>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData );500 #endif501 break;502 case 1:503 #if H_3D_VSO_EARLY_SKIP504 bEarlySkip = m_bEarlySkip ? xDetectEarlySkipR(iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, piOrgData, iOrgStride) : false;505 if( !bEarlySkip )506 {507 iSSE = xRenderR<false>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,true );508 }509 #else510 iSSE = xRenderR<false>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData );511 #endif512 break;513 default:514 assert(0);515 }516 517 return iSSE;518 }519 #if H_3D_VSO_EARLY_SKIP520 template <BlenMod iBM, Bool bBitInc> Void521 TRenSingleModelC<iBM,bBitInc>::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride )522 #else523 template <BlenMod iBM, Bool bBitInc> Void524 TRenSingleModelC<iBM,bBitInc>::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )525 #endif526 {527 #ifdef H_3D_VSO_EARLY_SKIP528 Bool bEarlySkip;529 #endif530 switch ( iViewPos )531 {532 case 0:533 #if H_3D_VSO_EARLY_SKIP534 bEarlySkip = m_bEarlySkip ? xDetectEarlySkipL(iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, piOrgData,iOrgStride) : false;535 if( !bEarlySkip )536 {537 xRenderL<true>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,true );538 }539 #else540 xRenderL<true>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData );541 #endif542 break;543 case 1:544 #if H_3D_VSO_EARLY_SKIP545 bEarlySkip = m_bEarlySkip ? xDetectEarlySkipR(iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, piOrgData,iOrgStride) : false;546 if( !bEarlySkip )547 {548 xRenderR<true>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,true );549 }550 #else551 xRenderR<true>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData );552 #endif553 break;554 default:555 assert(0);556 }557 }558 559 template <BlenMod iBM, Bool bBitInc> Void560 TRenSingleModelC<iBM,bBitInc>::getSynthVideo( Int iViewPos, TComPicYuv* pcPicYuv )561 {562 AOT( pcPicYuv->getWidth( COMPONENT_Y ) != m_iWidth );563 AOT( pcPicYuv->getChromaFormat() != CHROMA_420 );564 565 AOT( pcPicYuv->getHeight( COMPONENT_Y ) < m_iUsedHeight + m_iHorOffset );566 567 #if H_3D_VSO_COLOR_PLANES568 Pel RenModelOutPels::* piText[3] = { NULL, NULL, NULL };569 xGetSampleStrTextPtrs(iViewPos, piText[0], piText[1], piText[2]);570 571 // Temp image for chroma down sampling572 PelImage cTempImage( m_iWidth, m_iUsedHeight, 3, 0);573 574 Int aiStrides[3];575 Pel* apiData [3];576 577 cTempImage.getDataAndStrides( apiData, aiStrides );578 579 for (UInt uiCurPlane = 0; uiCurPlane < 3; uiCurPlane++ )580 {581 xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iUsedHeight);582 }583 xCopy2PicYuv( apiData, aiStrides, pcPicYuv );584 #else585 Pel RenModelOutPels::* piY;586 xGetSampleStrTextPtrs(iViewPos, piY);587 xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piY, pcPicYuv->getLumaAddr() + m_iHorOffset * pcPicYuv->getStride(), pcPicYuv->getStride(), m_iWidth, m_iUsedHeight );588 pcPicYuv->setChromaTo( 1 << (g_bitDepthC - 1) );589 #endif590 }591 592 template <BlenMod iBM, Bool bBitInc> Void593 TRenSingleModelC<iBM,bBitInc>::getSynthDepth( Int iViewPos, TComPicYuv* pcPicYuv )594 {595 AOT( iViewPos != 0 && iViewPos != 1);596 AOT( pcPicYuv->getWidth( COMPONENT_Y) != m_iWidth );597 AOT( pcPicYuv->getChromaFormat( ) != CHROMA_420 );598 AOT( pcPicYuv->getHeight( COMPONENT_Y ) < m_iUsedHeight + m_iHorOffset );599 600 Pel RenModelOutPels::* piD = 0;601 xGetSampleStrDepthPtrs(iViewPos, piD);602 xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piD, pcPicYuv->getAddr( COMPONENT_Y ) + pcPicYuv->getStride( COMPONENT_Y ) * m_iHorOffset, pcPicYuv->getStride( COMPONENT_Y ), m_iWidth, m_iUsedHeight );603 pcPicYuv->setChromaTo( 1 << (REN_BIT_DEPTH - 1) );604 }605 606 607 template <BlenMod iBM, Bool bBitInc> Void608 TRenSingleModelC<iBM,bBitInc>::getRefVideo ( Int iViewPos, TComPicYuv* pcPicYuv )609 {610 AOT( pcPicYuv->getChromaFormat( ) != CHROMA_420 );611 AOT( pcPicYuv->getWidth( COMPONENT_Y ) != m_iWidth );612 AOT( pcPicYuv->getHeight( COMPONENT_Y ) < m_iUsedHeight + m_iHorOffset);613 614 #if H_3D_VSO_COLOR_PLANES615 Pel RenModelOutPels::* piText[3];616 piText[0] = &RenModelOutPels::iYRef;617 piText[1] = &RenModelOutPels::iURef;618 piText[2] = &RenModelOutPels::iVRef;619 620 // Temp image for chroma down sampling621 622 PelImage cTempImage( m_iWidth, m_iUsedHeight, 3, 0);623 Int aiStrides[3];624 Pel* apiData [3];625 626 cTempImage.getDataAndStrides( apiData, aiStrides );627 628 for (UInt uiCurPlane = 0; uiCurPlane < 3; uiCurPlane++ )629 {630 xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iUsedHeight);631 }632 633 xCopy2PicYuv( apiData, aiStrides, pcPicYuv );634 #else635 xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, &RenModelOutPels::iYRef, pcPicYuv->getLumaAddr() * pcPicYuv->getStride() + m_iHorOffset, pcPicYuv->getStride(), m_iWidth, m_iUsedHeight );636 pcPicYuv->setChromaTo( 1 << ( g_bitDepthC - 1 ) );637 #endif638 }639 640 template <BlenMod iBM, Bool bBitInc> RMDist641 TRenSingleModelC<iBM,bBitInc>::getDistVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )642 {643 AOF(false);644 return 0;645 }646 647 template <BlenMod iBM, Bool bBitInc> Void648 TRenSingleModelC<iBM,bBitInc>::setVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )649 {650 AOF(false);651 }652 653 654 655 template <BlenMod iBM, Bool bBitInc> __inline Void656 TRenSingleModelC<iBM,bBitInc>::xSetViewRow( Int iPosY )657 {658 m_pcInputSamplesRow[0] = m_pcInputSamples[0] + m_iInputSamplesStride * iPosY;659 m_pcInputSamplesRow[1] = m_pcInputSamples[1] + m_iInputSamplesStride * iPosY;660 m_pcOutputSamplesRow = m_pcOutputSamples + m_iOutputSamplesStride * iPosY;661 662 }663 664 template <BlenMod iBM, Bool bBitInc> __inline Void665 TRenSingleModelC<iBM,bBitInc>::xIncViewRow( )666 {667 m_pcInputSamplesRow[0] += m_iInputSamplesStride ;668 m_pcInputSamplesRow[1] += m_iInputSamplesStride ;669 m_pcOutputSamplesRow += m_iOutputSamplesStride;670 }671 #if H_3D_VSO_EARLY_SKIP672 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist673 TRenSingleModelC<iBM,bBitInc>::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast)674 #else675 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist676 TRenSingleModelC<iBM,bBitInc>::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData)677 #endif678 {679 const Int iCurViewPos = 0;680 const Int iOtherViewPos = 1;681 682 m_iCurViewPos = iCurViewPos ;683 m_iOtherViewPos = iOtherViewPos;684 685 m_piNewDepthData = piNewData;686 m_iNewDataWidth = iWidth;687 m_iStartChangePosX = iStartPosX;688 689 if ((iWidth == 0) || (iHeight == 0))690 return 0;691 692 // Get Data693 m_ppiCurLUT = m_appiShiftLut [iCurViewPos];694 xSetViewRow ( iStartPosY);695 696 // Init Start697 RMDist iError = 0;698 Int iStartChangePos;699 700 iStartChangePos = m_iStartChangePosX;701 702 for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )703 {704 #if H_3D_VSO_EARLY_SKIP705 if( m_bEarlySkip && bFast )706 {707 if ( m_pbHorSkip[iPosY-iStartPosY] )708 {709 xIncViewRow();710 m_piNewDepthData += iStride;711 continue;712 }713 }714 #endif715 m_bInOcclusion = false;716 717 Int iLastSPos;718 Int iEndChangePos = m_iStartChangePosX + iWidth - 1;719 Int iPosXinNewData = iWidth - 1;720 Int iMinChangedSPos = m_iSampledWidth;721 722 if ( iEndChangePos == ( m_iWidth -1 )) // Special processing for rightmost depth sample723 {724 m_iCurDepth = m_piNewDepthData[iPosXinNewData];725 Int iCurSPos = xShiftNewData(iEndChangePos, iPosXinNewData);726 m_iLastOccludedSPos = iCurSPos + 1;727 m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos );728 xExtrapolateMarginL<bSet> ( iCurSPos, iEndChangePos, iError );729 730 iMinChangedSPos = std::min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD, m_piNewDepthData[iPosXinNewData] )) ]);731 iLastSPos = iCurSPos;732 m_iLastDepth = m_iCurDepth;733 734 if ( bSet )735 {736 m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD = m_piNewDepthData[iPosXinNewData];737 }738 739 iPosXinNewData--;740 iEndChangePos--;741 }742 else743 {744 iLastSPos = xShift(iEndChangePos+1);745 m_iLastDepth = m_pcInputSamplesRow [iCurViewPos][iEndChangePos+1].iD;746 xInitRenderPartL( iEndChangePos, iLastSPos );747 }748 749 //// RENDER NEW DATA750 Int iCurPosX;751 for ( iCurPosX = iEndChangePos; iCurPosX >= iStartChangePos; iCurPosX-- )752 {753 // Get minimal changed sample position754 755 iMinChangedSPos = std::min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD, m_piNewDepthData[iPosXinNewData] )) ]);756 Int iCurSPos = xShiftNewData(iCurPosX,iPosXinNewData);757 m_iCurDepth = m_piNewDepthData[iPosXinNewData];758 xRenderRangeL<bSet>(iCurSPos, iLastSPos, iCurPosX, iError );759 iLastSPos = iCurSPos;760 m_iLastDepth = m_iCurDepth;761 762 if ( bSet )763 {764 m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData];765 }766 767 iPosXinNewData--;768 }769 770 //// RE-RENDER DATA LEFT TO NEW DATA771 while ( iCurPosX >= 0 )772 {773 Int iCurSPos = xShift(iCurPosX);774 775 m_iCurDepth = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;776 xRenderRangeL<bSet>( iCurSPos, iLastSPos, iCurPosX, iError );777 778 if ( iCurSPos < iMinChangedSPos )779 {780 break;781 }782 783 iCurPosX--;784 iLastSPos = iCurSPos;785 m_iLastDepth = m_iCurDepth;786 }787 788 789 xIncViewRow();790 m_piNewDepthData += iStride;791 }792 return iError;793 }794 795 #ifdef H_3D_VSO_EARLY_SKIP796 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist797 TRenSingleModelC<iBM,bBitInc>::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData , Bool bFast)798 #else799 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist800 TRenSingleModelC<iBM,bBitInc>::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )801 #endif802 {803 804 const Int iCurViewPos = 1;805 const Int iOtherViewPos = 0;806 807 m_iCurViewPos = iCurViewPos;808 m_iOtherViewPos = iOtherViewPos;809 810 m_piNewDepthData = piNewData;811 m_iNewDataWidth = iWidth;812 m_iStartChangePosX = iStartPosX;813 814 if ((iWidth == 0) || (iHeight == 0))815 return 0;816 817 // Get Data818 m_ppiCurLUT = m_appiShiftLut [iCurViewPos];819 xSetViewRow ( iStartPosY);820 821 // Init Start822 RMDist iError = 0;823 Int iEndChangePos;824 825 iEndChangePos = m_iStartChangePosX + iWidth - 1;826 827 for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )828 {829 #if H_3D_VSO_EARLY_SKIP830 if( m_bEarlySkip && bFast )831 {832 if ( m_pbHorSkip[iPosY-iStartPosY] )833 {834 xIncViewRow();835 m_piNewDepthData += iStride;836 continue;837 }838 }839 #endif840 m_bInOcclusion = false;841 842 Int iLastSPos;843 Int iStartChangePos = m_iStartChangePosX;844 Int iPosXinNewData = 0;845 Int iMaxChangedSPos = -1;846 847 if ( iStartChangePos == 0 ) // Special processing for leftmost depth sample848 {849 m_iCurDepth = m_piNewDepthData[iPosXinNewData];850 Int iCurSPos = xShiftNewData(iStartChangePos, iPosXinNewData);851 m_iLastOccludedSPos = iCurSPos - 1;852 m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos );853 xExtrapolateMarginR<bSet> ( iCurSPos, iStartChangePos, iError );854 855 iMaxChangedSPos = std::max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iStartChangePos].iD, m_piNewDepthData[iPosXinNewData] )) ]);856 iLastSPos = iCurSPos;857 m_iLastDepth = m_iCurDepth;858 if ( bSet )859 {860 m_pcInputSamplesRow[iCurViewPos][iStartChangePos].iD = m_piNewDepthData[iPosXinNewData];861 }862 863 864 iPosXinNewData++;865 iStartChangePos++;866 }867 else868 {869 iLastSPos = xShift(iStartChangePos-1);870 871 m_iLastDepth = m_pcInputSamplesRow[iCurViewPos][iStartChangePos-1].iD;872 xInitRenderPartR( iStartChangePos, iLastSPos );873 }874 875 //// RENDER NEW DATA876 Int iCurPosX;877 for ( iCurPosX = iStartChangePos; iCurPosX <= iEndChangePos; iCurPosX++ )878 {879 // Get minimal changed sample position880 881 iMaxChangedSPos = std::max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD, m_piNewDepthData[iPosXinNewData] )) ]);882 Int iCurSPos = xShiftNewData(iCurPosX,iPosXinNewData);883 m_iCurDepth = m_piNewDepthData[iPosXinNewData];884 xRenderRangeR<bSet>(iCurSPos, iLastSPos, iCurPosX, iError );885 iLastSPos = iCurSPos;886 m_iLastDepth = m_iCurDepth;887 888 if ( bSet )889 {890 m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData];891 }892 893 iPosXinNewData++;894 }895 896 //// RE-RENDER DATA LEFT TO NEW DATA897 while ( iCurPosX < m_iWidth )898 {899 Int iCurSPos = xShift(iCurPosX);900 901 m_iCurDepth = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;902 xRenderRangeR<bSet>( iCurSPos, iLastSPos, iCurPosX, iError );903 904 if ( iCurSPos > iMaxChangedSPos )905 {906 break;907 }908 iCurPosX++;909 iLastSPos = iCurSPos;910 m_iLastDepth = m_iCurDepth;911 }912 913 xIncViewRow();914 m_piNewDepthData += iStride;915 }916 return iError;917 }918 919 920 template <BlenMod iBM, Bool bBitInc> __inline Void921 TRenSingleModelC<iBM,bBitInc>::xInitRenderPartL( Int iEndChangePos, Int iLastSPos )922 {923 const Int iCurViewPos = 0;924 // GET MINIMAL OCCLUDED SAMPLE POSITION925 Int iCurPosX = iEndChangePos;926 927 928 if ( ( iCurPosX + 1 < m_iWidth ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX + 1].bOccluded ) )929 {930 iCurPosX++;931 932 while ( (iCurPosX + 1 < m_iWidth) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX + 1].bOccluded ) )933 934 iCurPosX++;935 936 if ( iCurPosX + 1 < m_iWidth )937 {938 iCurPosX++;939 m_iLastOccludedSPos = xShift(iCurPosX);940 }941 else942 {943 m_iLastOccludedSPos = xShift(iCurPosX) + 1;944 }945 946 m_iLastOccludedSPosFP = xRoundL( m_iLastOccludedSPos );947 }948 else949 {950 m_iLastOccludedSPos = iLastSPos+1;951 m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos );952 }953 954 m_bInOcclusion = iLastSPos >= m_iLastOccludedSPos;955 };956 957 template <BlenMod iBM, Bool bBitInc> __inline Void958 TRenSingleModelC<iBM,bBitInc>::xInitRenderPartR( Int iStartChangePos, Int iLastSPos )959 {960 const Int iCurViewPos = 1;961 // GET MINIMAL OCCLUDED SAMPLE POSITION962 Int iCurPosX = iStartChangePos;963 964 if ( ( iCurPosX - 1 > -1 ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX - 1].bOccluded ) )965 {966 iCurPosX--;967 968 while ( (iCurPosX - 1 > -1 ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX - 1].bOccluded ) )969 iCurPosX--;970 971 if ( iCurPosX - 1 > -1 )972 {973 iCurPosX--;974 m_iLastOccludedSPos = xShift(iCurPosX);975 }976 else977 {978 m_iLastOccludedSPos = xShift(iCurPosX) - 1;979 }980 m_iLastOccludedSPosFP = xRoundR( m_iLastOccludedSPos );981 }982 else983 {984 m_iLastOccludedSPos = iLastSPos-1;985 m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos );986 }987 988 m_bInOcclusion = iLastSPos <= m_iLastOccludedSPos;989 };990 991 992 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void993 TRenSingleModelC<iBM,bBitInc>::xRenderShiftedRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )994 {995 assert( iCurSPos <= iLastSPos );996 //assert( iRightSPos < m_iWidth );997 998 Int iDeltaSPos = iLastSPos - iCurSPos;999 if ( iDeltaSPos > m_iGapTolerance )1000 {1001 xFillHoleL<bSet>( iCurSPos, iLastSPos, iCurPos, riError );1002 }1003 else1004 {1005 if (iLastSPos < 0 )1006 return;1007 1008 RM_AOT( iDeltaSPos > m_iGapTolerance );1009 1010 m_iThisDepth = m_iCurDepth;1011 for (Int iFillSPos = std::max(0, xRangeLeftL(iCurSPos) ); iFillSPos <= min(xRangeRightL( iLastSPos ) ,m_iLastOccludedSPosFP-1); iFillSPos++ )1012 {1013 Int iDeltaCurSPos = (iFillSPos << m_iShiftPrec) - iCurSPos;1014 1015 RM_AOT( iDeltaCurSPos > iDeltaSPos );1016 RM_AOT( iDeltaCurSPos < 0 );1017 RM_AOT( m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);1018 1019 xSetShiftedPelL<bSet>( iCurPos, m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError );1020 }1021 };1022 }1023 1024 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1025 TRenSingleModelC<iBM,bBitInc>::xRenderShiftedRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )1026 {1027 assert( iCurSPos >= iLastSPos );1028 1029 Int iDeltaSPos = iCurSPos - iLastSPos;1030 if ( iDeltaSPos > m_iGapTolerance )1031 {1032 xFillHoleR<bSet>( iCurSPos, iLastSPos, iCurPos, riError );1033 }1034 else1035 {1036 if (iLastSPos > m_iSampledWidth - 1 )1037 return;1038 1039 m_iThisDepth = m_iCurDepth;1040 RM_AOT( iDeltaSPos > m_iGapTolerance );1041 for (Int iFillSPos = max(m_iLastOccludedSPosFP+1, xRangeLeftR(iLastSPos) ); iFillSPos <= min(xRangeRightR( iCurSPos ) ,m_iWidth -1); iFillSPos++ )1042 {1043 Int iDeltaCurSPos = (iFillSPos << m_iShiftPrec) - iLastSPos;1044 1045 RM_AOT( iDeltaCurSPos > iDeltaSPos );1046 RM_AOT( iDeltaCurSPos < 0 );1047 RM_AOT( m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);1048 1049 xSetShiftedPelR<bSet>( iCurPos, m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError );1050 }1051 };1052 }1053 1054 1055 1056 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1057 TRenSingleModelC<iBM,bBitInc>::xRenderRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )1058 {1059 const Int iCurViewPos = 0;1060 if ( !m_bInOcclusion )1061 {1062 if ( iCurSPos >= iLastSPos )1063 {1064 m_iLastOccludedSPos = iLastSPos;1065 1066 Int iRightSPosFP = xRoundL( iLastSPos );1067 if ( ( iRightSPosFP == xRangeRightL(iLastSPos)) && (iRightSPosFP >= 0) )1068 {1069 m_iThisDepth = m_iLastDepth;1070 1071 xSetShiftedPelL<bSet>( iCurPos+1, 0, iRightSPosFP, REN_IS_FILLED, riError );1072 }1073 m_iLastOccludedSPosFP = iRightSPosFP;1074 1075 m_bInOcclusion = true;1076 1077 if ( bSet )1078 {1079 m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true;1080 }1081 }1082 else1083 {1084 if ( bSet )1085 {1086 m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false;1087 }1088 1089 xRenderShiftedRangeL<bSet>(iCurSPos, iLastSPos, iCurPos, riError );1090 }1091 }1092 else1093 {1094 if ( iCurSPos < m_iLastOccludedSPos )1095 {1096 m_bInOcclusion = false;1097 if ( bSet )1098 {1099 m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false;1100 }1101 1102 xRenderShiftedRangeL<bSet>(iCurSPos, iLastSPos, iCurPos, riError );1103 }1104 else1105 {1106 if ( bSet )1107 {1108 m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true;1109 }1110 }1111 }1112 }1113 1114 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1115 TRenSingleModelC<iBM,bBitInc>::xRenderRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )1116 {1117 const Int iCurViewPos = 1;1118 // Find out if current sample is occluded1119 if ( !m_bInOcclusion )1120 {1121 if ( iCurSPos <= iLastSPos )1122 {1123 m_iLastOccludedSPos = iLastSPos;1124 1125 Int iLeftSPosFP = xRoundR( iLastSPos );1126 if ( ( iLeftSPosFP == xRangeLeftR(iLastSPos)) && (iLeftSPosFP <= m_iWidth - 1) )1127 {1128 m_iThisDepth = m_iLastDepth;1129 xSetShiftedPelR<bSet>( iCurPos-1,1 << m_iShiftPrec , iLeftSPosFP, REN_IS_FILLED, riError );1130 }1131 m_iLastOccludedSPosFP = iLeftSPosFP;1132 1133 m_bInOcclusion = true;1134 1135 if ( bSet )1136 {1137 m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true;1138 }1139 }1140 else1141 {1142 if ( bSet )1143 {1144 m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false;1145 }1146 1147 xRenderShiftedRangeR<bSet>(iCurSPos, iLastSPos, iCurPos, riError );1148 }1149 }1150 else1151 {1152 if ( iCurSPos > m_iLastOccludedSPos )1153 {1154 m_bInOcclusion = false;1155 if ( bSet )1156 {1157 m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false;1158 }1159 1160 xRenderShiftedRangeR<bSet>(iCurSPos, iLastSPos, iCurPos, riError );1161 }1162 else1163 {1164 if ( bSet )1165 {1166 m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true;1167 }1168 }1169 }1170 }1171 1172 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1173 TRenSingleModelC<iBM,bBitInc>::xFillHoleL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )1174 {1175 if (iLastSPos < 0)1176 return;1177 1178 Int iStartFillSPos = iCurSPos;1179 Int iStartFillPos = iCurPos;1180 Int iLastPos = iCurPos + 1;1181 1182 Int iStartFillSPosFP = xRangeLeftL(iStartFillSPos);1183 1184 if (iStartFillSPosFP == xRoundL(iStartFillSPos))1185 {1186 if ((iStartFillSPosFP >= 0) && (iStartFillSPosFP < m_iLastOccludedSPosFP) )1187 {1188 m_iThisDepth = m_iCurDepth;1189 xSetShiftedPelL<bSet> ( iStartFillPos, 0, iStartFillSPosFP, REN_IS_FILLED, riError );1190 }1191 }1192 else1193 {1194 iStartFillSPosFP--;1195 }1196 1197 m_iThisDepth = m_iLastDepth;1198 for (Int iFillSPos = std::max(iStartFillSPosFP+1,0); iFillSPos <= min(xRangeRightL( iLastSPos ), m_iLastOccludedSPosFP-1 ); iFillSPos++ )1199 {1200 xSetShiftedPelL<bSet>( iLastPos, 0, iFillSPos, REN_IS_HOLE, riError );1201 }1202 }1203 1204 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1205 TRenSingleModelC<iBM,bBitInc>::xFillHoleR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )1206 {1207 if (iLastSPos < 0)1208 return;1209 1210 Int iStartFillSPos = iCurSPos;1211 Int iEndFillPos = iCurPos;1212 Int iLastPos = iCurPos - 1;1213 1214 Int iStartFillSPosFP = xRangeRightR(iStartFillSPos);1215 1216 if (iStartFillSPosFP == xRoundR(iStartFillSPos))1217 {1218 if ((iStartFillSPosFP < m_iWidth) && (iStartFillSPosFP > m_iLastOccludedSPosFP) )1219 {1220 m_iThisDepth = m_iCurDepth;1221 xSetShiftedPelR<bSet>( iEndFillPos, 1 << m_iShiftPrec , iStartFillSPosFP, REN_IS_FILLED, riError );1222 }1223 }1224 else1225 {1226 iStartFillSPosFP++;1227 }1228 1229 m_iThisDepth = m_iLastDepth;1230 for (Int iFillSPos = max(xRangeLeftR( iLastSPos ), m_iLastOccludedSPosFP+1); iFillSPos <= min(iStartFillSPosFP,m_iWidth)-1 ; iFillSPos++ )1231 {1232 xSetShiftedPelR<bSet>( iLastPos, 1 << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );1233 }1234 }1235 1236 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1237 TRenSingleModelC<iBM,bBitInc>::xExtrapolateMarginL(Int iCurSPos, Int iCurPos, RMDist& riError )1238 {1239 // if (iLeftSPos < 0 )1240 // return;1241 1242 Int iSPosFullPel = std::max(0,xRangeLeftL(iCurSPos));1243 1244 m_iThisDepth = m_iCurDepth;1245 if (iSPosFullPel < m_iWidth)1246 {1247 xSetShiftedPelL<bSet>( iCurPos, 0, iSPosFullPel, REN_IS_FILLED, riError );1248 }1249 1250 for (Int iFillSPos = iSPosFullPel +1; iFillSPos < m_iWidth; iFillSPos++ )1251 {1252 xSetShiftedPelL<bSet>( iCurPos, 0, iFillSPos, REN_IS_HOLE, riError );1253 }1254 }1255 1256 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1257 TRenSingleModelC<iBM,bBitInc>::xExtrapolateMarginR(Int iCurSPos, Int iCurPos, RMDist& riError )1258 {1259 // if (iLeftSPos < 0 )1260 // return;1261 1262 Int iSPosFullPel = std::min(m_iWidth-1,xRangeRightR(iCurSPos));1263 1264 m_iThisDepth = m_iCurDepth;1265 if (iSPosFullPel > -1)1266 {1267 xSetShiftedPelR<bSet>( iCurPos, 1 << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError );1268 }1269 1270 for (Int iFillSPos = iSPosFullPel -1; iFillSPos > -1; iFillSPos-- )1271 {1272 xSetShiftedPelR<bSet>( iCurPos , 1 << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError );1273 }1274 }1275 1276 template <BlenMod iBM, Bool bBitInc> __inline Int1277 TRenSingleModelC<iBM,bBitInc>::xShiftNewData( Int iPosX, Int iPosInNewData )1278 {1279 RM_AOT( iPosInNewData < 0 );1280 RM_AOF( iPosInNewData < m_iNewDataWidth );1281 1282 return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_piNewDepthData[iPosInNewData] )];1283 }1284 1285 template <BlenMod iBM, Bool bBitInc> __inline Int1286 TRenSingleModelC<iBM,bBitInc>::xShift( Int iPosX )1287 {1288 RM_AOT( iPosX < 0);1289 RM_AOF( iPosX < m_iWidth);1290 1291 return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_pcInputSamplesRow[m_iCurViewPos][iPosX].iD )];1292 }1293 1294 1295 template <BlenMod iBM, Bool bBitInc> __inline Int1296 TRenSingleModelC<iBM,bBitInc>::xShift( Int iPos, Int iPosInNewData )1297 {1298 if ( (iPosInNewData >= 0) && (iPosInNewData < m_iNewDataWidth) )1299 {1300 return xShiftNewData(iPos ,iPosInNewData );1301 }1302 else1303 {1304 return xShift(iPos);1305 }1306 }1307 1308 template <BlenMod iBM, Bool bBitInc> __inline Int1309 TRenSingleModelC<iBM,bBitInc>::xRangeLeftL( Int iPos )1310 {1311 return ( iPos + (1 << m_iShiftPrec) - 1) >> m_iShiftPrec;1312 }1313 1314 1315 template <BlenMod iBM, Bool bBitInc> __inline Int1316 TRenSingleModelC<iBM,bBitInc>::xRangeLeftR( Int iPos )1317 {1318 1319 return xRangeRightR( iPos ) + 1;1320 }1321 1322 1323 template <BlenMod iBM, Bool bBitInc> __inline Int1324 TRenSingleModelC<iBM,bBitInc>::xRangeRightL( Int iPos )1325 {1326 return xRangeLeftL(iPos) - 1;1327 }1328 1329 template <BlenMod iBM, Bool bBitInc> __inline Int1330 TRenSingleModelC<iBM,bBitInc>::xRangeRightR( Int iPos )1331 {1332 return iPos >> m_iShiftPrec;1333 }1334 1335 1336 template <BlenMod iBM, Bool bBitInc> __inline Int1337 TRenSingleModelC<iBM,bBitInc>::xRoundL( Int iPos )1338 {1339 return (iPos + (( 1 << m_iShiftPrec ) >> 1 )) >> m_iShiftPrec;1340 }1341 1342 template <BlenMod iBM, Bool bBitInc> __inline Int1343 TRenSingleModelC<iBM,bBitInc>::xRoundR( Int iPos )1344 {1345 return (m_iShiftPrec == 0) ? iPos : xRoundL(iPos - 1);1346 }1347 1348 1349 template <BlenMod iBM, Bool bBitInc> Void1350 TRenSingleModelC<iBM,bBitInc>::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal )1351 {1352 for (Int iYPos = 0; iYPos < iHeight; iYPos++)1353 {1354 for (Int iXPos = 0; iXPos < iWidth; iXPos++)1355 {1356 piPelSource[iXPos] = iVal;1357 }1358 piPelSource += iSourceStride;1359 }1360 }1361 1362 template <BlenMod iBM, Bool bBitInc> Void1363 TRenSingleModelC<iBM,bBitInc>::xSetInts( Int* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal )1364 {1365 for (Int iYPos = 0; iYPos < iHeight; iYPos++)1366 {1367 for (Int iXPos = 0; iXPos < iWidth; iXPos++)1368 {1369 piPelSource[iXPos] = iVal;1370 }1371 piPelSource += iSourceStride;1372 }1373 }1374 1375 1376 template <BlenMod iBM, Bool bBitInc> Void1377 TRenSingleModelC<iBM,bBitInc>::xSetBools( Bool* pbPelSource , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal )1378 {1379 for (Int iYPos = 0; iYPos < iHeight; iYPos++)1380 {1381 for (Int iXPos = 0; iXPos < iWidth; iXPos++)1382 {1383 pbPelSource[iXPos] = bVal;1384 }1385 pbPelSource += iSourceStride;1386 }1387 }1388 1389 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1390 TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelL(Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )1391 {1392 RM_AOT( iSourcePos < 0 );1393 RM_AOT( iSourcePos >= m_iWidth );1394 RM_AOT( iSubSourcePos < 0 );1395 RM_AOT( iSubSourcePos > (1 << m_iShiftPrec) );1396 RM_AOT( iTargetSPos < 0 );1397 RM_AOT( iTargetSPos >= m_iWidth );1398 1399 RenModelOutPels* pcOutSample = m_pcOutputSamplesRow + iTargetSPos;1400 RenModelInPels * pcInSample = m_pcInputSamplesRow[VIEWPOS_LEFT] + iSourcePos ;1401 1402 if ( iBM != BLEND_NONE )1403 {1404 xSetShiftedPelBlendL<bSet> (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);1405 }1406 else1407 {1408 xSetShiftedPelNoBlendL<bSet>(pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);1409 }1410 }1411 1412 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1413 TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelNoBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )1414 {1415 if ( bSet )1416 {1417 // Filled1418 pcOutSample->iFilledLeft = iFilled;1419 1420 // Yuv1421 pcOutSample->iYLeft = pcInSample->aiY[iSubSourcePos];1422 #if H_3D_VSO_COLOR_PLANES1423 pcOutSample->iULeft = pcInSample->aiU[iSubSourcePos];1424 pcOutSample->iVLeft = pcInSample->aiV[iSubSourcePos];1425 1426 pcOutSample->iError = xGetDist( pcOutSample->iYLeft - pcOutSample->iYRef,1427 pcOutSample->iULeft - pcOutSample->iURef,1428 pcOutSample->iVLeft - pcOutSample->iVRef1429 );1430 #else1431 pcOutSample->iError = xGetDist( pcOutSample->iYLeft - pcOutSample->iYRef );1432 #endif1433 1434 }1435 else1436 {1437 #if H_3D_VSO_COLOR_PLANES1438 riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef,1439 pcInSample->aiU[iSubSourcePos] - pcOutSample->iURef,1440 pcInSample->aiV[iSubSourcePos] - pcOutSample->iVRef1441 );1442 #else1443 riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef );1444 #endif1445 1446 riError -= pcOutSample->iError;1447 }1448 }1449 1450 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1451 TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )1452 {1453 Pel piBlendedValueY;1454 #if H_3D_VSO_COLOR_PLANES1455 Pel piBlendedValueU;1456 Pel piBlendedValueV;1457 #endif1458 1459 xGetBlendedValue (1460 pcInSample ->aiY[iSubSourcePos],1461 pcOutSample->iYRight,1462 #if H_3D_VSO_COLOR_PLANES1463 pcInSample ->aiU[iSubSourcePos],1464 pcOutSample->iURight,1465 pcInSample ->aiV[iSubSourcePos],1466 pcOutSample->iVRight,1467 #endif1468 m_piInvZLUTLeft [RenModRemoveBitInc(m_iThisDepth) ],1469 m_piInvZLUTRight[RenModRemoveBitInc(pcOutSample->iDRight)],1470 iFilled,1471 pcOutSample->iFilledRight ,1472 piBlendedValueY1473 #if H_3D_VSO_COLOR_PLANES1474 , piBlendedValueU,1475 piBlendedValueV1476 #endif1477 );1478 1479 if ( bSet )1480 {1481 // Set values1482 pcOutSample->iDLeft = m_iThisDepth;1483 pcOutSample->iYLeft = pcInSample ->aiY[iSubSourcePos];1484 pcOutSample->iYBlended = piBlendedValueY;1485 #if H_3D_VSO_COLOR_PLANES1486 pcOutSample->iULeft = pcInSample ->aiU[iSubSourcePos];1487 pcOutSample->iUBlended = piBlendedValueU;1488 pcOutSample->iVLeft = pcInSample ->aiV[iSubSourcePos];1489 pcOutSample->iVBlended = piBlendedValueV;1490 #endif1491 pcOutSample->iFilledLeft = iFilled;1492 1493 // Get Error1494 Int iDiffY = pcOutSample->iYRef - piBlendedValueY;1495 #if H_3D_VSO_COLOR_PLANES1496 Int iDiffU = pcOutSample->iURef - piBlendedValueU;1497 Int iDiffV = pcOutSample->iVRef - piBlendedValueV;1498 pcOutSample->iError = xGetDist(iDiffY, iDiffU, iDiffV );1499 #else1500 pcOutSample->iError = xGetDist(iDiffY );1501 #endif1502 }1503 else1504 {1505 Int iDiffY = pcOutSample->iYRef - piBlendedValueY;1506 #if H_3D_VSO_COLOR_PLANES1507 Int iDiffU = pcOutSample->iURef - piBlendedValueU;1508 Int iDiffV = pcOutSample->iVRef - piBlendedValueV;1509 riError += ( xGetDist( iDiffY, iDiffU, iDiffV ) - pcOutSample->iError );1510 1511 #else1512 riError += ( xGetDist( iDiffY ) - pcOutSample->iError );1513 #endif1514 1515 }1516 }1517 1518 1519 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1520 TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelR(Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )1521 {1522 RM_AOT( iSourcePos < 0 );1523 RM_AOT( iSourcePos >= m_iWidth );1524 RM_AOT( iSubSourcePos < 0 );1525 RM_AOT( iSubSourcePos >= (1 << m_iShiftPrec)+1 );1526 RM_AOT( iTargetSPos < 0 );1527 RM_AOT( iTargetSPos >= m_iWidth );1528 1529 RenModelOutPels* pcOutSample = m_pcOutputSamplesRow + iTargetSPos;1530 RenModelInPels * pcInSample = m_pcInputSamplesRow[VIEWPOS_RIGHT] + iSourcePos ;1531 1532 if ( iBM != BLEND_NONE )1533 {1534 xSetShiftedPelBlendR<bSet> (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);1535 }1536 else1537 {1538 xSetShiftedPelNoBlendR<bSet> (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError);1539 }1540 }1541 1542 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1543 TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelNoBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )1544 {1545 if ( bSet )1546 {1547 // Filled1548 pcOutSample->iFilledRight = iFilled;1549 1550 // Yuv1551 pcOutSample->iYRight = pcInSample->aiY[iSubSourcePos];1552 #if H_3D_VSO_COLOR_PLANES1553 pcOutSample->iURight = pcInSample->aiU[iSubSourcePos];1554 pcOutSample->iVRight = pcInSample->aiV[iSubSourcePos];1555 1556 pcOutSample->iError = xGetDist(1557 pcOutSample->iYRight - pcOutSample->iYRef,1558 pcOutSample->iURight - pcOutSample->iURef,1559 pcOutSample->iVRight - pcOutSample->iVRef1560 );1561 #else1562 pcOutSample->iError = xGetDist( pcOutSample->iYRight - pcOutSample->iYRef );1563 #endif1564 1565 }1566 else1567 {1568 #if H_3D_VSO_COLOR_PLANES1569 riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef,1570 pcInSample->aiU[iSubSourcePos] - pcOutSample->iURef,1571 pcInSample->aiV[iSubSourcePos] - pcOutSample->iVRef1572 );1573 #else1574 riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef );1575 #endif1576 1577 riError -= pcOutSample->iError;1578 }1579 }1580 1581 template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void1582 TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError )1583 {1584 Pel piBlendedValueY;1585 #if H_3D_VSO_COLOR_PLANES1586 Pel piBlendedValueU;1587 Pel piBlendedValueV;1588 #endif1589 1590 xGetBlendedValue (1591 pcOutSample->iYLeft,1592 pcInSample ->aiY[iSubSourcePos],1593 #if H_3D_VSO_COLOR_PLANES1594 pcOutSample->iULeft,1595 pcInSample ->aiU[iSubSourcePos],1596 pcOutSample->iVLeft,1597 pcInSample ->aiV[iSubSourcePos],1598 #endif1599 m_piInvZLUTLeft [RenModRemoveBitInc(pcOutSample->iDLeft)],1600 m_piInvZLUTRight [RenModRemoveBitInc(m_iThisDepth) ],1601 pcOutSample->iFilledLeft,1602 iFilled,1603 piBlendedValueY1604 #if H_3D_VSO_COLOR_PLANES1605 , piBlendedValueU,1606 piBlendedValueV1607 #endif1608 );1609 1610 if ( bSet )1611 {1612 // Set values1613 pcOutSample->iDRight = m_iThisDepth;1614 pcOutSample->iYRight = pcInSample ->aiY[iSubSourcePos];1615 pcOutSample->iYBlended = piBlendedValueY;1616 #if H_3D_VSO_COLOR_PLANES1617 pcOutSample->iURight = pcInSample ->aiU[iSubSourcePos];1618 pcOutSample->iUBlended = piBlendedValueU;1619 pcOutSample->iVRight = pcInSample ->aiV[iSubSourcePos];1620 pcOutSample->iVBlended = piBlendedValueV;1621 #endif1622 pcOutSample->iFilledRight = iFilled;1623 1624 // Get Error1625 Int iDiffY = pcOutSample->iYRef - piBlendedValueY;1626 #if H_3D_VSO_COLOR_PLANES1627 Int iDiffU = pcOutSample->iURef - piBlendedValueU;1628 Int iDiffV = pcOutSample->iVRef - piBlendedValueV;1629 pcOutSample->iError = xGetDist(iDiffY, iDiffU, iDiffV );1630 #else1631 pcOutSample->iError = xGetDist(iDiffY );1632 #endif1633 }1634 else1635 {1636 Int iDiffY = pcOutSample->iYRef - piBlendedValueY;1637 #if H_3D_VSO_COLOR_PLANES1638 Int iDiffU = pcOutSample->iURef - piBlendedValueU;1639 Int iDiffV = pcOutSample->iVRef - piBlendedValueV;1640 riError += ( xGetDist( iDiffY, iDiffU, iDiffV ) - pcOutSample->iError );1641 #else1642 riError += ( xGetDist( iDiffY ) - pcOutSample->iError );1643 #endif1644 }1645 }1646 1647 template <BlenMod iBM, Bool bBitInc> __inline Int1648 TRenSingleModelC<iBM,bBitInc>::xGetDist( Int iDiffY, Int iDiffU, Int iDiffV )1649 {1650 1651 if ( !bBitInc )1652 {1653 return ( (iDiffY * iDiffY )1654 + ((( (iDiffU * iDiffU )1655 +(iDiffV * iDiffV )1656 )1657 ) >> 21658 )1659 );1660 }1661 else1662 {1663 return ( ((iDiffY * iDiffY) >> m_iDistShift)1664 + ((( ((iDiffU * iDiffU) >> m_iDistShift)1665 +((iDiffV * iDiffV) >> m_iDistShift)1666 )1667 ) >> 21668 )1669 );1670 1671 }1672 }1673 1674 template <BlenMod iBM, Bool bBitInc> __inline Int1675 TRenSingleModelC<iBM,bBitInc>::xGetDist( Int iDiffY )1676 {1677 if ( !bBitInc )1678 {1679 return (iDiffY * iDiffY);1680 }1681 else1682 {1683 return ((iDiffY * iDiffY) >> m_iDistShift);1684 }1685 1686 }1687 1688 1689 #if H_3D_VSO_COLOR_PLANES1690 template <BlenMod iBM, Bool bBitInc> __inline Void1691 TRenSingleModelC<iBM,bBitInc>::xGetBlendedValue( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )1692 #else1693 template <BlenMod iBM, Bool bBitInc> __inline Void1694 TRenSingleModelC<iBM,bBitInc>::xGetBlendedValue( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )1695 #endif1696 {1697 1698 RM_AOT( iBM != BLEND_AVRG && iBM != BLEND_LEFT && iBM != BLEND_RIGHT );1699 1700 if (iBM != BLEND_AVRG )1701 {1702 if (iBM == BLEND_LEFT )1703 {1704 #if H_3D_VSO_COLOR_PLANES1705 xGetBlendedValueBM1( iYL, iYR, iUL, iUR, iVL, iVR, iDepthL, iDepthR, iFilledL, iFilledR, riY, riU, riV );1706 #else1707 xGetBlendedValueBM1( iYL, iYR, iDepthL, iDepthR, iFilledL, iFilledR, riY );1708 #endif1709 }1710 else1711 {1712 #if H_3D_VSO_COLOR_PLANES1713 xGetBlendedValueBM2( iYL, iYR, iUL, iUR, iVL, iVR, iDepthL, iDepthR, iFilledL, iFilledR, riY, riU, riV );1714 #else1715 xGetBlendedValueBM2( iYL, iYR, iDepthL, iDepthR, iFilledL, iFilledR, riY );1716 #endif1717 }1718 return;1719 }1720 1721 if ( (iFilledL != REN_IS_HOLE ) && ( iFilledR != REN_IS_HOLE) )1722 {1723 Int iDepthDifference = iDepthR - iDepthL;1724 1725 if ( abs ( iDepthDifference ) <= m_iBlendZThres )1726 {1727 if ((iFilledL == REN_IS_FILLED) && ( iFilledR != REN_IS_FILLED))1728 {1729 riY = xBlend( iYL, iYR, iFilledR >> 1 );1730 #if H_3D_VSO_COLOR_PLANES1731 riU = xBlend( iUL, iUR, iFilledR >> 1 );1732 riV = xBlend( iVL, iVR, iFilledR >> 1 );1733 #endif1734 1735 }1736 else if ((iFilledL != REN_IS_FILLED) && ( iFilledR == REN_IS_FILLED))1737 {1738 riY = xBlend( iYR, iYL, (iFilledL >> 1) );1739 #if H_3D_VSO_COLOR_PLANES1740 riU = xBlend( iUR, iUL, (iFilledL >> 1) );1741 riV = xBlend( iVR, iVL, (iFilledL >> 1) );1742 #endif1743 }1744 else1745 {1746 riY = xBlend( iYL, iYR, m_iBlendDistWeight );1747 #if H_3D_VSO_COLOR_PLANES1748 riU = xBlend( iUL, iUR, m_iBlendDistWeight );1749 riV = xBlend( iVL, iVR, m_iBlendDistWeight );1750 #endif1751 }1752 }1753 else if ( iDepthDifference < 0 )1754 {1755 riY = iYL;1756 #if H_3D_VSO_COLOR_PLANES1757 riU = iUL;1758 riV = iVL;1759 #endif1760 }1761 else1762 {1763 riY = iYR;1764 #if H_3D_VSO_COLOR_PLANES1765 riU = iUR;1766 riV = iVR;1767 #endif1768 }1769 }1770 else if ( (iFilledL == REN_IS_HOLE) && (iFilledR == REN_IS_HOLE))1771 {1772 if ( iDepthR < iDepthL )1773 {1774 riY = iYR;1775 #if H_3D_VSO_COLOR_PLANES1776 riU = iUR;1777 riV = iVR;1778 #endif1779 }1780 else1781 {1782 riY = iYL;1783 #if H_3D_VSO_COLOR_PLANES1784 riU = iUL;1785 riV = iVL;1786 #endif1787 }1788 }1789 else1790 {1791 if (iFilledR == REN_IS_HOLE)1792 {1793 riY = iYL;1794 #if H_3D_VSO_COLOR_PLANES1795 riU = iUL;1796 riV = iVL;1797 #endif1798 }1799 else1800 {1801 riY = iYR;1802 #if H_3D_VSO_COLOR_PLANES1803 riU = iUR;1804 riV = iVR;1805 #endif1806 }1807 }1808 }1809 1810 template <BlenMod iBM, Bool bBitInc> __inline Void1811 #if H_3D_VSO_COLOR_PLANES1812 TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )1813 #else1814 TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )1815 #endif1816 {1817 if ( iFilledL == REN_IS_FILLED || iFilledR == REN_IS_HOLE )1818 {1819 riY = iYL;1820 #if H_3D_VSO_COLOR_PLANES1821 riU = iUL;1822 riV = iVL;1823 #endif1824 }1825 else if ( iFilledL == REN_IS_HOLE )1826 {1827 riY = iYR;1828 #if H_3D_VSO_COLOR_PLANES1829 riU = iUR;1830 riV = iVR;1831 #endif1832 }1833 else1834 {1835 riY = xBlend( iYR, iYL, iFilledL );1836 #if H_3D_VSO_COLOR_PLANES1837 riU = xBlend( iUR, iUL, iFilledL );1838 riV = xBlend( iVR, iUL, iFilledL );1839 #endif1840 }1841 }1842 1843 template <BlenMod iBM, Bool bBitInc> __inline Void1844 #if H_3D_VSO_COLOR_PLANES1845 TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV )1846 #else1847 TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY )1848 #endif1849 {1850 if ( iFilledR == REN_IS_FILLED || iFilledL == REN_IS_HOLE )1851 {1852 riY = iYR;1853 #if H_3D_VSO_COLOR_PLANES1854 riU = iUR;1855 riV = iVR;1856 #endif1857 }1858 else if ( iFilledR == REN_IS_HOLE )1859 {1860 riY = iYL;1861 #if H_3D_VSO_COLOR_PLANES1862 riU = iUL;1863 riV = iVL;1864 #endif1865 }1866 else1867 {1868 riY = xBlend( iYL, iYR, iFilledR );1869 #if H_3D_VSO_COLOR_PLANES1870 riU = xBlend( iUL, iUR, iFilledR );1871 riV = xBlend( iVL, iUR, iFilledR );1872 #endif1873 }1874 }1875 1876 template <BlenMod iBM, Bool bBitInc> __inline Pel1877 TRenSingleModelC<iBM,bBitInc>::xBlend( Pel pVal1, Pel pVal2, Int iWeightVal2 )1878 {1879 return pVal1 + (Pel) ( ( (Int) ( pVal2 - pVal1) * iWeightVal2 + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC );1880 }1881 1882 template <BlenMod iBM, Bool bBitInc> Void1883 TRenSingleModelC<iBM,bBitInc>::xCopy2PicYuv( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget )1884 {1885 TRenFilter<REN_BIT_DEPTH>::copy ( ppiSrcVideoPel[0], piStrides[0], m_iWidth, m_iUsedHeight, rpcPicYuvTarget->getAddr( COMPONENT_Y ) + m_iHorOffset * rpcPicYuvTarget->getStride( COMPONENT_Y ), rpcPicYuvTarget->getStride( COMPONENT_Y ) );1886 TRenFilter<REN_BIT_DEPTH>::sampleDown2Tap13( ppiSrcVideoPel[1], piStrides[1], m_iWidth, m_iUsedHeight, rpcPicYuvTarget->getAddr( COMPONENT_Cb ) + (m_iHorOffset >> 1) * rpcPicYuvTarget->getStride( COMPONENT_Cb ), rpcPicYuvTarget->getStride( COMPONENT_Cb) );1887 TRenFilter<REN_BIT_DEPTH>::sampleDown2Tap13( ppiSrcVideoPel[2], piStrides[2], m_iWidth, m_iUsedHeight, rpcPicYuvTarget->getAddr( COMPONENT_Cr ) + (m_iHorOffset >> 1) * rpcPicYuvTarget->getStride( COMPONENT_Cr ), rpcPicYuvTarget->getStride( COMPONENT_Cr) );1888 }1889 1890 template class TRenSingleModelC<BLEND_NONE ,true>;1891 template class TRenSingleModelC<BLEND_AVRG ,true>;1892 template class TRenSingleModelC<BLEND_LEFT ,true>;1893 template class TRenSingleModelC<BLEND_RIGHT,true>;1894 1895 template class TRenSingleModelC<BLEND_NONE ,false>;1896 template class TRenSingleModelC<BLEND_AVRG ,false>;1897 template class TRenSingleModelC<BLEND_LEFT ,false>;1898 template class TRenSingleModelC<BLEND_RIGHT,false>;1899 1900 #if H_3D_VSO_EARLY_SKIP1901 template <BlenMod iBM, Bool bBitInc>1902 __inline Bool1903 TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkipL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride)1904 {1905 RM_AOF( m_bEarlySkip );1906 const Int iCurViewPos = 0;1907 Int** ppiCurLUT = m_appiShiftLut [ iCurViewPos ];1908 1909 Bool bNoDiff = true;1910 1911 for (Int iPosY=0; iPosY < iHeight; iPosY++)1912 {1913 m_pbHorSkip[iPosY] = true;1914 1915 for (Int iPosX = 0; iPosX < iWidth; iPosX++)1916 {1917 Int iDisparityRec = abs(ppiCurLUT[0][ RenModRemoveBitInc(piNewData[iPosX])]);1918 Int iDispartyOrg = abs(ppiCurLUT[0][ RenModRemoveBitInc(piOrgData[iPosX])]);1919 1920 if( iDispartyOrg != iDisparityRec)1921 {1922 m_pbHorSkip[iPosY] = false;1923 bNoDiff = false;1924 break;1925 }1926 }1927 piNewData += iStride;1928 piOrgData += iOrgStride;1929 }1930 return bNoDiff;1931 }1932 1933 template <BlenMod iBM, Bool bBitInc>1934 __inline Bool1935 TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkipR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride)1936 {1937 RM_AOF( m_bEarlySkip );1938 Bool bNoDiff = true;1939 1940 const Int iCurViewPos = 1;1941 Int** ppiCurLUT = m_appiShiftLut [ iCurViewPos ];1942 1943 for ( Int iPosY = 0; iPosY < iHeight; iPosY++ )1944 {1945 m_pbHorSkip[iPosY] = true;1946 1947 for (Int iPosX = 0; iPosX < iWidth; iPosX++)1948 {1949 Int iDisparityRec = abs( ppiCurLUT[0][ RenModRemoveBitInc(piNewData[iPosX])] );1950 Int iDisparityOrg = abs( ppiCurLUT[0][ RenModRemoveBitInc(piOrgData[iPosX])] );1951 1952 if( iDisparityRec != iDisparityOrg )1953 {1954 m_pbHorSkip[iPosY] = false;1955 bNoDiff = false;1956 break;1957 }1958 }1959 1960 piNewData += iStride;1961 piOrgData += iOrgStride;1962 }1963 return bNoDiff;1964 }1965 #endif1966 #endif // NH_3D1967 -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenSingleModel.h
r1313 r1390 51 51 #include <cstring> 52 52 53 #if NH_3D_VSO54 using namespace std;55 56 #if H_3D_VSO_RM_ASSERTIONS57 #define RM_AOT( exp ) AOT ( exp )58 #define RM_AOF( exp ) AOF ( exp )59 #else60 #define RM_AOT( exp ) ((void)0)61 #define RM_AOF( exp ) ((void)0)62 #endif63 64 #define RenModRemoveBitInc( exp ) bBitInc ? ( RemoveBitIncrement( exp ) ) : ( exp )65 66 class TRenSingleModel67 {68 public:69 70 virtual ~TRenSingleModel() { }71 #if H_3D_VSO_EARLY_SKIP72 virtual Void create ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bEarlySkip ) = 0;73 #else74 virtual Void create ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode ) = 0;75 #endif76 77 // Set Frame dependent data78 virtual Void setLRView ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride ) = 0;79 virtual Void setupPart ( UInt uiHorOffset, Int iUsedHeight ) = 0;80 virtual Void setup ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, Bool bKeepReference ) = 0;81 82 // Set Data83 #if H_3D_VSO_EARLY_SKIP84 virtual Void setDepth ( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride ) = 0;85 #else86 virtual Void setDepth ( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData ) = 0;87 #endif88 virtual Void setVideo ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData ) = 0;89 90 // Get Distortion91 #if H_3D_VSO_EARLY_SKIP92 virtual RMDist getDistDepth ( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel * piOrgData , Int iOrgStride)=0;93 #else94 virtual RMDist getDistDepth ( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData ) = 0;95 #endif96 virtual RMDist getDistVideo ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData ) = 0;97 98 virtual Void getSynthVideo ( Int iViewPos, TComPicYuv* pcPicYuv ) = 0;99 virtual Void getSynthDepth ( Int iViewPos, TComPicYuv* pcPicYuv ) = 0;100 virtual Void getRefVideo ( Int iViewPos, TComPicYuv* pcPicYuv ) = 0;101 };102 103 template < BlenMod iBM, Bool bBitInc >104 class TRenSingleModelC : public TRenSingleModel105 {106 struct RenModelInPels107 {108 // video109 Pel aiY[5] ; // y-value110 #if H_3D_VSO_COLOR_PLANES111 Pel aiU[5] ; // u-value112 Pel aiV[5] ; // v-value113 #endif114 // depth115 Pel iD ; // depth116 117 // state118 Bool bOccluded; // Occluded119 };120 121 struct RenModelOutPels122 {123 // video124 Pel iYLeft ;125 Pel iYRight ;126 Pel iYBlended ;127 #if H_3D_VSO_COLOR_PLANES128 Pel iULeft ;129 Pel iURight ;130 Pel iUBlended ;131 Pel iVLeft ;132 Pel iVRight ;133 Pel iVBlended ;134 #endif135 // depth136 Pel iDLeft ;137 Pel iDRight ;138 Pel iDBlended ;139 140 // state141 Int iFilledLeft ;142 Int iFilledRight;143 144 // error145 Int iError ;146 147 // reference148 Pel iYRef ;149 #if H_3D_VSO_COLOR_PLANES150 Pel iURef ;151 Pel iVRef ;152 #endif153 };154 155 156 157 public:158 TRenSingleModelC();159 ~TRenSingleModelC();160 161 // Create Model162 #if H_3D_VSO_EARLY_SKIP163 Void create ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bEarlySkip );164 #else165 Void create ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode );166 #endif167 168 // Set Frame dependent data169 Void setLRView ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride );170 Void setupPart ( UInt uiHorOffset, Int uiUsedHeight );171 Void setup ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, Bool bKeepReference );172 173 #if H_3D_VSO_EARLY_SKIP174 Void setDepth ( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride );175 #else176 Void setDepth ( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );177 #endif178 Void setVideo ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );179 180 // Get Distortion181 #if H_3D_VSO_EARLY_SKIP182 RMDist getDistDepth ( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel * piOrgData , Int iOrgStride);183 #else184 RMDist getDistDepth ( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );185 #endif186 RMDist getDistVideo ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );187 188 Void getSynthVideo ( Int iViewPos, TComPicYuv* pcPicYuv );189 Void getSynthDepth ( Int iViewPos, TComPicYuv* pcPicYuv );190 Void getRefVideo ( Int iViewPos, TComPicYuv* pcPicYuv );191 192 private:193 // Set and inc Current Row194 __inline Void xSetViewRow( Int iPosY );195 __inline Void xIncViewRow();196 197 ///// Rendering /////198 // Left to Right199 #if H_3D_VSO_EARLY_SKIP200 __inline Bool xDetectEarlySkipL ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride );201 __inline Bool xDetectEarlySkipR ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride );202 template<Bool bSet> __inline RMDist xRenderL ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast );203 template<Bool bSet> __inline RMDist xRenderR ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast );204 #else205 template<Bool bSet> __inline RMDist xRenderR ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );206 template<Bool bSet> __inline RMDist xRenderL ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData );207 #endif208 __inline Void xInitRenderPartL ( Int iEndChangePos, Int iLastSPos );209 template<Bool bSet> __inline Void xRenderRangeL ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );210 template<Bool bSet> __inline Void xRenderShiftedRangeL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );211 template<Bool bSet> __inline Void xFillHoleL ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );212 template<Bool bSet> __inline Void xExtrapolateMarginL ( Int iCurSPos, Int iCurPos, RMDist& riError );213 __inline Int xRangeLeftL ( Int iPos );214 __inline Int xRangeRightL ( Int iPos );215 __inline Int xRoundL ( Int iPos );216 217 // Right to Left218 __inline Void xInitRenderPartR ( Int iStartChangePos, Int iLastSPos );219 template<Bool bSet> __inline Void xRenderShiftedRangeR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );220 template<Bool bSet> __inline Void xRenderRangeR ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );221 template<Bool bSet> __inline Void xFillHoleR ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );222 template<Bool bSet> __inline Void xExtrapolateMarginR ( Int iCurSPos, Int iCurPos, RMDist& riError );223 __inline Int xRangeLeftR ( Int iPos );224 __inline Int xRangeRightR ( Int iPos );225 __inline Int xRoundR ( Int iPos );226 227 // Blending228 template<Bool bSet> __inline Void xSetShiftedPelBlend ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );229 230 #if H_3D_VSO_COLOR_PLANES231 __inline Void xGetBlendedValue ( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV );232 __inline Void xGetBlendedValueBM1 ( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV );233 __inline Void xGetBlendedValueBM2 ( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV );234 #else235 __inline Void xGetBlendedValue ( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );236 __inline Void xGetBlendedValueBM1 ( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );237 __inline Void xGetBlendedValueBM2 ( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );238 #endif239 __inline Pel xBlend ( Pel pVal1, Pel pVal2, Int iWeightVal2 );240 241 // General242 template<Bool bSet> __inline Void xSetShiftedPelL (Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );243 template<Bool bSet> __inline Void xSetShiftedPelBlendL (RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );244 template<Bool bSet> __inline Void xSetShiftedPelNoBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );245 246 template<Bool bSet> __inline Void xSetShiftedPelR (Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );247 template<Bool bSet> __inline Void xSetShiftedPelBlendR (RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );248 template<Bool bSet> __inline Void xSetShiftedPelNoBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError );249 250 __inline Int xShiftNewData ( Int iPos, Int iPosInNewData );251 __inline Int xShift ( Int iPos );252 __inline Int xShift ( Int iPos, Int iPosInNewData );253 __inline Int xGetDist ( Int iDiffY, Int iDiffU, Int iDiffV );254 __inline Int xGetDist ( Int iDiffY );255 256 // Utilities257 __inline Void xSetPels ( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal );258 __inline Void xSetBools ( Bool* pbSource , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal );259 __inline Void xSetInts ( Int* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal );260 261 #if H_3D_VSO_COLOR_PLANES262 Void xGetSampleStrTextPtrs ( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY, Pel RenModelOutPels::*& rpiSrcU, Pel RenModelOutPels::*& rpiSrcV );263 #else264 Void xGetSampleStrTextPtrs ( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY );265 #endif266 Void xGetSampleStrDepthPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcD );267 268 Void xSetStructRefView ();269 Void xResetStructError ();270 Void xInitSampleStructs ();271 Void xSetStructSynthViewAsRefView ();272 Void xCopy2PicYuv ( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget );273 274 template< typename S, typename T>275 Void xCopyFromSampleStruct ( S* ptSource , Int iSourceStride, T S::* ptSourceElement, T* ptTarget, Int iTargetStride, Int iWidth, Int iHeight )276 {277 AOT( iWidth != m_iWidth );278 for (Int iPosY = 0; iPosY < iHeight; iPosY++)279 {280 for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)281 {282 ptTarget[iPosX] = ptSource[iPosX].*ptSourceElement;283 }284 ptSource += iSourceStride;285 ptTarget += iTargetStride;286 }287 }288 289 template< typename S, typename T>290 Void xCopyToSampleStruct ( T* ptSource , Int iSourceStride, S* ptTarget, Int iTargetStride, T S::* ptSourceElement, Int iWidth, Int iHeight )291 {292 AOT( iWidth != m_iWidth );293 for (Int iPosY = 0; iPosY < iHeight; iPosY++)294 {295 for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)296 {297 ptTarget[iPosX] = ptSource[iPosX].*ptSourceElement;298 }299 ptSource += iSourceStride;300 ptTarget += iTargetStride;301 }302 }303 304 private:305 306 // Image sizes307 Int m_iWidth;308 Int m_iHeight;309 Int m_iStride;310 Int m_iPad;311 Int m_iUsedHeight;312 Int m_iHorOffset;313 314 Int m_iSampledWidth;315 Int m_iSampledStride;316 317 RenModelInPels* m_pcInputSamples[2];318 Int m_iInputSamplesStride;319 320 // Base321 Pel** m_aapiBaseVideoPel [2]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane 0-> Y, 1->U, 2->V322 Int* m_aaiBaseVideoStrides [2]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane 0-> Y, 1->U, 2->V323 324 Pel* m_apiBaseDepthPel [2]; // Dim1: ViewPosition325 Int m_aiBaseDepthStrides [2]; // Dim1: ViewPosition326 327 328 // LUT329 Int** m_appiShiftLut [2];330 Int** m_ppiCurLUT;331 Int** m_aaiSubPelShiftL;332 Int** m_aaiSubPelShiftR;333 334 Int* m_piInvZLUTLeft;335 Int* m_piInvZLUTRight;336 337 338 //// Reference Data ////339 TComPicYuv* m_pcPicYuvRef ; // Reference PIcYuv340 341 //// Output Samples342 RenModelOutPels* m_pcOutputSamples;343 Int m_iOutputSamplesStride;344 345 Pel* m_aapiRefVideoPel [3]; // Dim1: Plane 0-> Y, 1->U, 2->V346 Int m_aiRefVideoStrides [3]; // Dim1: Plane 0-> Y, 1->U, 2->V347 348 // Rendering State349 Bool m_bInOcclusion; // Currently rendering in occluded area350 Int m_iLastOccludedSPos; // Position of last topmost shifted position351 Int m_iLastOccludedSPosFP; // Position of last topmost shifted position in FullPels352 353 Int m_iCurViewPos; // Current View Position 0: Left, 1: Right354 Int m_iOtherViewPos; // Other View Position 0: Left, 1: Right355 const Pel* m_piNewDepthData; // Pointer to new depth data356 Int m_iStartChangePosX; // Start Position of new data357 Int m_iNewDataWidth; // Width of new data358 Pel m_iCurDepth; // Current Depth Value359 Pel m_iLastDepth; // Last Depth Value360 Pel m_iThisDepth; // Depth value to use for setting361 362 //// Settings ////363 // Input364 Int m_iMode; // 0: Left to Right, 1: Right to Left, 2: Merge365 Bool m_bUseOrgRef;366 Int m_iShiftPrec;367 Int m_iHoleMargin;368 #if H_3D_VSO_EARLY_SKIP369 Bool m_bEarlySkip;370 #endif371 372 // Derived settings373 Int m_iGapTolerance;374 Int m_iBlendZThres;375 Int m_iBlendDistWeight;376 377 //// Current Pointers ////378 379 RenModelInPels* m_pcInputSamplesRow [2];380 RenModelOutPels* m_pcOutputSamplesRow;381 382 //// MISC ////383 const Int m_iDistShift; // Shift in Distortion computation384 385 //// Early Skip386 #if H_3D_VSO_EARLY_SKIP387 Bool* m_pbHorSkip;388 #endif389 };390 391 #endif // NH_3D392 53 #endif //__TRENSINGLEMODEL__ 393 54 -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenTop.cpp
r1386 r1390 40 40 #include <math.h> 41 41 #include "../TLibCommon/CommonDef.h" 42 #if NH_3D_VSO43 42 44 45 Void TRenTop::xGetDataPointers( PelImage*& rpcInputImage, PelImage*& rpcOutputImage, PelImage*& rpcInputDepth, PelImage*& rpcOutputDepth, PelImage*& rpcFilled, Bool bRenderDepth )46 {47 UInt uiWidth = m_auiInputResolution[0] << m_iLog2SamplingFactor;48 49 UInt uiSubPelWidth = uiWidth;50 51 if ( m_iInterpolationMode == eRenInt8Tap )52 {53 uiSubPelWidth <<= m_iRelShiftLUTPrec;54 }55 56 UInt uiHeight = m_auiInputResolution[1];57 58 if ( m_bUVUp )59 {60 rpcInputDepth = new PelImage(uiSubPelWidth, uiHeight,1,0);61 rpcInputImage = new PelImage(uiSubPelWidth, uiHeight,3,0);62 rpcOutputImage = new PelImage(uiWidth, uiHeight,3,0);63 rpcOutputDepth = bRenderDepth ? new PelImage(uiWidth, uiHeight,1,0) : 0;64 rpcFilled = new PelImage(uiWidth, uiHeight,1,0);65 }66 else67 {68 rpcInputDepth = new PelImage(uiSubPelWidth, uiHeight,1,1);69 rpcInputImage = new PelImage(uiSubPelWidth, uiHeight,1,2);70 rpcOutputImage = new PelImage(uiWidth, uiHeight,1,2);71 rpcOutputDepth = bRenderDepth ? new PelImage(uiWidth, uiHeight,1,1) : 0;72 rpcFilled = new PelImage(uiWidth, uiHeight,1,1);73 }74 75 }76 77 Void TRenTop::xGetDataPointerOutputImage( PelImage*& rpcOutputImage, PelImage*& rpcOutputDepth )78 {79 80 UInt uiWidth = m_auiInputResolution[0] << m_iLog2SamplingFactor;81 UInt uiHeight = m_auiInputResolution[1];82 83 if ( m_bUVUp )84 {85 rpcOutputImage = new PelImage(uiWidth, uiHeight,3,0);86 rpcOutputDepth = (m_iBlendMode == eRenBlendDepthFirst ) ? new PelImage(uiWidth, uiHeight,1,0) : NULL;87 }88 else89 {90 rpcOutputImage = new PelImage(uiWidth, uiHeight,1,2);91 rpcOutputDepth = (m_iBlendMode == eRenBlendDepthFirst ) ? new PelImage(uiWidth, uiHeight,1,1) : NULL;92 }93 }94 95 Void TRenTop::xConvertInputVideo( PelImage* pcOrgInputImage, PelImage* pcConvInputImage)96 {97 TRenImagePlane<Pel>* pcOrgPlane ;98 TRenImagePlane<Pel>* pcConvPlane;99 100 Int iLog2SamplingFactor = m_iLog2SamplingFactor;101 102 if ( m_iInterpolationMode == eRenInt8Tap)103 {104 iLog2SamplingFactor += m_iRelShiftLUTPrec;105 }106 107 AOT( iLog2SamplingFactor > 2);108 109 for (UInt uiPlane = 0; uiPlane < 3; uiPlane++)110 {111 pcOrgPlane = pcOrgInputImage ->getPlane(uiPlane);112 pcConvPlane = pcConvInputImage->getPlane(uiPlane);113 114 if (uiPlane == 0)115 {116 TRenFilter<REN_BIT_DEPTH>::sampleHorUp ( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride());117 }118 else119 {120 if ( m_bUVUp )121 {122 TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride());123 }124 else125 {126 TRenFilter<REN_BIT_DEPTH>::sampleCHorUp ( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride());127 }128 }129 }130 }131 132 Void TRenTop::xConvertInputDepth( PelImage* pcOrgInputImage, PelImage* pcConvInputImage)133 {134 PelImagePlane* pcOrgPlane ;135 PelImagePlane* pcConvPlane;136 137 // Full Plane138 pcOrgPlane = pcOrgInputImage ->getPlane(0);139 pcConvPlane = pcConvInputImage->getPlane(0);140 141 Int iLog2SamplingFactor = m_iLog2SamplingFactor;142 143 if ( m_iInterpolationMode == eRenInt8Tap)144 {145 iLog2SamplingFactor += m_iRelShiftLUTPrec;146 }147 AOT( iLog2SamplingFactor > 2);148 149 TRenFilter<REN_BIT_DEPTH>::sampleHorUp(iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride());150 151 if ( !m_bUVUp ) //GT: depth down152 {153 // Quarter Plane154 PelImagePlane* pcTempPlane = new PelImagePlane(pcOrgInputImage->getPlane(0)->getWidth(), ( pcOrgInputImage->getPlane(0)->getHeight() >> 1), REN_LUMA_MARGIN );155 156 TRenFilter<REN_BIT_DEPTH>::sampleVerDown2Tap13(pcOrgInputImage->getPlane(0), pcTempPlane, PICYUV_PAD);157 pcConvPlane = pcConvInputImage->getPlane(1);158 159 if ( iLog2SamplingFactor == 0 )160 {161 TRenFilter<REN_BIT_DEPTH>::sampleHorDown2Tap13(pcTempPlane, pcConvPlane, 0 );162 }163 else164 {165 TRenFilter<REN_BIT_DEPTH>::sampleHorUp ( iLog2SamplingFactor - 1, pcTempPlane->getPlaneData(), pcTempPlane->getStride(), pcTempPlane->getWidth(), pcTempPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride());166 }167 delete pcTempPlane;168 }169 }170 171 Void TRenTop::xConvertInputData( PelImage* pcOrgInputImage, PelImage* pcOrgInputDepth, PelImage* pcConvInputImage, PelImage* pcConvInputDepth, Bool bMirror )172 {173 //ToDo: remove unnecessary copying174 if ( bMirror )175 {176 m_pcTempImage->assign( pcOrgInputImage );177 TRenFilter<REN_BIT_DEPTH>::mirrorHor( m_pcTempImage );178 m_pcTempImage->extendMargin();179 xConvertInputVideo( m_pcTempImage, pcConvInputImage );180 181 m_pcTempImage->getPlane(0)->assign( pcOrgInputDepth->getPlane(0) );182 TRenFilter<REN_BIT_DEPTH>::mirrorHor( m_pcTempImage->getPlane(0) );183 m_pcTempImage->getPlane(0)->extendMargin();184 xConvertInputDepth( m_pcTempImage, pcConvInputDepth );185 }186 else187 {188 m_pcTempImage->assign( pcOrgInputImage );189 m_pcTempImage->extendMargin();190 xConvertInputVideo( m_pcTempImage, pcConvInputImage );191 192 m_pcTempImage->getPlane(0)->assign( pcOrgInputDepth->getPlane(0) );193 m_pcTempImage->getPlane(0)->extendMargin();194 xConvertInputDepth( m_pcTempImage, pcConvInputDepth );195 }196 }197 198 Void TRenTop::xConvertOutputData( PelImage* pcOrgOutputImage, PelImage* pcConvOutputImage, Bool bMirror )199 {200 Int iLog2SamplingFactor = m_iLog2SamplingFactor;201 202 for ( UInt uiPlane = 0; uiPlane < 3; uiPlane++)203 {204 PelImagePlane* pcOrgPlane = pcOrgOutputImage ->getPlane(uiPlane);205 PelImagePlane* pcConvPlane = pcConvOutputImage->getPlane(uiPlane);206 207 pcOrgPlane->extendMargin();208 209 if ( uiPlane == 0 )210 {211 TRenFilter<REN_BIT_DEPTH>::sampleHorDown( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride());212 }213 else214 {215 if ( m_bUVUp )216 {217 TRenFilter<REN_BIT_DEPTH>::sampleCDownHorDown( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride());218 }219 else220 {221 TRenFilter<REN_BIT_DEPTH>::sampleCHorDown ( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride());222 }223 }224 }225 226 if ( bMirror )227 {228 TRenFilter<REN_BIT_DEPTH>::mirrorHor( pcConvOutputImage );229 }230 231 }232 233 Void TRenTop::setShiftLUTs( Double** ppdShiftLUTLeft, Int** ppiShiftLUTLeft, Int** ppiBaseShiftLUTLeft, Double** ppdShiftLUTRight, Int** ppiShiftLUTRight, Int** ppiBaseShiftLUTRight, Int iRelDistToLeft )234 {235 m_ppdShiftLUTLeft = ppdShiftLUTLeft;236 m_ppdShiftLUTRight = ppdShiftLUTRight;237 238 m_ppiShiftLUTLeft = ppiShiftLUTLeft;239 m_ppiShiftLUTRight = ppiShiftLUTRight;240 241 if ( m_ppdShiftLUTRight != NULL && m_ppiShiftLUTRight != NULL )242 {243 for( UInt uiPlane = 0; uiPlane < 2; uiPlane++)244 {245 for (UInt uiDepthValue = 0; uiDepthValue <= 256; uiDepthValue++)246 {247 m_ppdShiftLUTRightMirror[uiPlane][uiDepthValue] = - m_ppdShiftLUTRight[uiPlane][uiDepthValue];248 m_ppiShiftLUTRightMirror[uiPlane][uiDepthValue] = - m_ppiShiftLUTRight[uiPlane][uiDepthValue];249 }250 }251 }252 253 if ( !m_bExtrapolate )254 {255 TRenFilter<REN_BIT_DEPTH>::setupZLUT( m_bBlendUseDistWeight, m_iBlendZThresPerc, iRelDistToLeft, ppiBaseShiftLUTLeft, ppiBaseShiftLUTRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight);256 }257 }258 259 Void TRenTop::extrapolateView( TComPicYuv* pcPicYuvVideo, TComPicYuv* pcPicYuvDepth, TComPicYuv* pcPicYuvSynthOut, Bool bRenderFromLeft )260 {261 AOF( m_bExtrapolate );262 AOF( bRenderFromLeft ? m_ppiShiftLUTLeft || m_ppdShiftLUTLeft : m_ppiShiftLUTRight || m_ppdShiftLUTRight );263 AOF( m_auiInputResolution[0] == pcPicYuvVideo->getWidth ( COMPONENT_Y ));264 AOF( m_auiInputResolution[1] == pcPicYuvVideo->getHeight( COMPONENT_Y ));265 266 PelImage cInputImage ( pcPicYuvVideo );267 PelImage cInputDepth ( pcPicYuvDepth , true);268 PelImage cOutputImage( pcPicYuvSynthOut );269 270 m_pcOutputImage->init();271 m_pcFilled ->assign(REN_IS_HOLE);272 273 xPreProcessDepth ( &cInputDepth, &cInputDepth);274 xConvertInputData( &cInputImage, &cInputDepth, m_pcInputImage, m_pcInputDepth, !bRenderFromLeft );275 xShiftPixels(m_pcInputImage, m_pcInputDepth, m_pcOutputImage, m_pcFilled, bRenderFromLeft);276 xRemBoundaryNoise ( m_pcOutputImage, m_pcFilled, m_pcOutputImage, bRenderFromLeft); // Erode277 xFillHoles ( m_pcOutputImage, m_pcFilled, m_pcOutputImage, bRenderFromLeft);278 xConvertOutputData( m_pcOutputImage, &cOutputImage, !bRenderFromLeft );279 xPostProcessImage (&cOutputImage, &cOutputImage);280 xCutMargin ( &cOutputImage );281 };282 283 Void TRenTop::getUsedSamplesMap( TComPicYuv* pcPicYuvDepth, TComPicYuv* pcUsedSampleMap, Bool bRenderFromLeft )284 {285 AOF( bRenderFromLeft ? m_ppiShiftLUTLeft && m_ppdShiftLUTLeft : m_ppiShiftLUTRight && m_ppdShiftLUTRight );286 AOF(m_auiInputResolution[0] == pcPicYuvDepth->getWidth (COMPONENT_Y));287 AOF(m_auiInputResolution[1] == pcPicYuvDepth->getHeight(COMPONENT_Y));288 289 PelImage cInputDepth ( pcPicYuvDepth , true);290 PelImage cOutputImage( pcUsedSampleMap );291 PelImage cInputImage ( m_auiInputResolution[0], m_auiInputResolution[1], 1, 2 );292 cInputImage.assign(0);293 294 m_pcFilled ->assign(REN_IS_HOLE);295 xConvertInputData( &cInputImage, &cInputDepth, m_pcInputImage, m_pcInputDepth, !bRenderFromLeft );296 xShiftPixels (m_pcInputImage, m_pcInputDepth, m_pcOutputImage, m_pcFilled, bRenderFromLeft);297 298 xCreateAlphaMap ( m_pcFilled, m_pcFilled, bRenderFromLeft );299 300 if ( !bRenderFromLeft )301 {302 TRenFilter<REN_BIT_DEPTH>::mirrorHor( m_pcFilled );303 }304 305 TRenFilter<REN_BIT_DEPTH>::filledToUsedPelMap( m_pcFilled, &cOutputImage, m_iUsedPelMapMarExt );306 };307 308 309 Void TRenTop::interpolateView( TComPicYuv* pcPicYuvVideoLeft, TComPicYuv* pcPicYuvDepthLeft, TComPicYuv* pcPicYuvVideoRight, TComPicYuv* pcPicYuvDepthRight, TComPicYuv* pcPicYuvSynthOut, Int iBlendMode, Int iSimEnhBaseView )310 {311 assert( !m_bExtrapolate );312 assert( m_auiInputResolution[0] == pcPicYuvVideoLeft ->getWidth ( COMPONENT_Y ) );313 assert( m_auiInputResolution[1] == pcPicYuvVideoRight->getHeight( COMPONENT_Y ) );314 315 AOT( iBlendMode == 3);316 m_iBlendMode = iBlendMode;317 m_iSimEnhBaseView = iSimEnhBaseView;318 319 PelImage cLeftInputImage ( pcPicYuvVideoLeft );320 PelImage cLeftInputDepth ( pcPicYuvDepthLeft, true );321 PelImage cRightInputImage ( pcPicYuvVideoRight );322 PelImage cRightInputDepth ( pcPicYuvDepthRight, true );323 PelImage cOutputImage ( pcPicYuvSynthOut );324 325 m_pcLeftOutputImage ->init();326 m_pcRightOutputImage->init();327 m_pcOutputImage ->init();328 329 if ( m_iBlendMode == eRenBlendDepthFirst )330 {331 m_pcOutputDepth->init();332 }333 334 m_pcLeftFilled ->assign(REN_IS_HOLE);335 m_pcRightFilled->assign(REN_IS_HOLE);336 337 xPreProcessDepth(&cLeftInputDepth , &cLeftInputDepth );338 xPreProcessDepth(&cRightInputDepth, &cRightInputDepth);339 340 xConvertInputData( &cLeftInputImage, &cLeftInputDepth, m_pcLeftInputImage, m_pcLeftInputDepth ,false );341 xConvertInputData( &cRightInputImage, &cRightInputDepth, m_pcRightInputImage, m_pcRightInputDepth ,true );342 343 // Render from Left View to Right view344 if ( m_iBlendMode != eRenBlendDepthFirst )345 {346 xShiftPixels(m_pcLeftInputImage, m_pcLeftInputDepth, m_pcLeftOutputImage, m_pcLeftFilled, true );347 xFillHoles (m_pcLeftOutputImage, m_pcLeftFilled, m_pcLeftOutputImage, true );348 }349 350 xShiftPixels(m_pcLeftInputDepth, m_pcLeftInputDepth, m_pcLeftOutputDepth, m_pcLeftFilled, true );351 xFillHoles ( m_pcLeftOutputDepth, m_pcLeftFilled, m_pcLeftOutputDepth, true);352 xCreateAlphaMap( m_pcLeftFilled, m_pcLeftFilled, true );353 354 // Render from Right View to Left view355 if ( m_iBlendMode != eRenBlendDepthFirst )356 {357 xShiftPixels(m_pcRightInputImage , m_pcRightInputDepth, m_pcRightOutputImage, m_pcRightFilled, false );358 xFillHoles (m_pcRightOutputImage, m_pcRightFilled, m_pcRightOutputImage, false);359 }360 361 xShiftPixels(m_pcRightInputDepth, m_pcRightInputDepth, m_pcRightOutputDepth, m_pcRightFilled, false);362 xFillHoles ( m_pcRightOutputDepth, m_pcRightFilled, m_pcRightOutputDepth, false);363 xCreateAlphaMap( m_pcRightFilled, m_pcRightFilled, false );364 365 TRenFilter<REN_BIT_DEPTH>::mirrorHor( m_pcRightOutputImage );366 TRenFilter<REN_BIT_DEPTH>::mirrorHor( m_pcRightOutputDepth );367 TRenFilter<REN_BIT_DEPTH>::mirrorHor( m_pcRightFilled );368 369 xEnhSimilarity( m_pcLeftOutputImage, m_pcRightOutputImage, m_pcLeftFilled, m_pcRightFilled );370 371 if ( m_iBlendMode == eRenBlendDepthFirst )372 {373 xBlend ( m_pcLeftOutputDepth, m_pcRightOutputDepth, m_pcLeftFilled, m_pcRightFilled, m_pcLeftOutputDepth, m_pcRightOutputDepth, m_pcOutputDepth);374 375 xBackShiftPixels ( m_pcLeftInputImage, m_pcOutputDepth, m_pcLeftOutputImage, m_pcLeftFilled , false);376 xFillHoles ( m_pcLeftOutputImage, m_pcLeftFilled, m_pcLeftOutputImage, false);377 xCreateAlphaMap ( m_pcLeftFilled, m_pcLeftFilled, true );378 379 TRenFilter<REN_BIT_DEPTH>::mirrorHor( m_pcRightInputImage );380 xBackShiftPixels ( m_pcRightInputImage, m_pcOutputDepth, m_pcRightOutputImage, m_pcRightFilled , true );381 xFillHoles ( m_pcRightOutputImage, m_pcRightFilled, m_pcRightOutputImage, true);382 383 TRenFilter<REN_BIT_DEPTH>::mirrorHor( m_pcRightFilled );384 xCreateAlphaMap ( m_pcRightFilled, m_pcRightFilled, true );385 TRenFilter<REN_BIT_DEPTH>::mirrorHor( m_pcRightFilled );386 }387 388 xBlend(m_pcLeftOutputImage, m_pcRightOutputImage, m_pcLeftFilled, m_pcRightFilled, m_pcLeftOutputDepth, m_pcRightOutputDepth, m_pcOutputImage);389 xConvertOutputData( m_pcOutputImage, &cOutputImage , false );390 391 xPostProcessImage ( &cOutputImage, &cOutputImage);392 xCutMargin( &cOutputImage );393 };394 395 396 Void TRenTop::xPreProcessDepth( PelImage* pcInImage, PelImage* pcOutImage )397 {398 if ( m_iPreProcMode == eRenPreProNone )399 return;400 401 PelImage* pcTemp;402 403 if (pcInImage == pcOutImage)404 {405 pcTemp = pcOutImage->create();406 }407 else408 {409 pcTemp = pcOutImage;410 }411 412 pcTemp->assign(pcInImage);413 414 switch ( m_iPreProcMode )415 {416 case eRenPreProBinom:417 TRenFilter<REN_BIT_DEPTH>::binominal(pcOutImage, pcTemp, m_iPreFilterSize);418 break;419 case eRenPreProNone:420 break;421 default:422 assert(0);423 break;424 }425 426 if (pcInImage == pcOutImage)427 {428 pcOutImage->setData(pcTemp, true);429 delete pcTemp;430 };431 432 }433 434 Void TRenTop::xShiftPlanePixelsLinInt( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes )435 {436 Int iWidth = apcInputPlanes[0]->getWidth();437 Int iHeight = apcInputPlanes[0]->getHeight();438 439 Int iInputStride = apcInputPlanes [0]->getStride();440 Int iOutputStride = apcOutputPlanes[0]->getStride();441 442 Int iFilledStride = pcFilledPlane->getStride();443 Int iDepthStride = pcDepthPlane ->getStride();444 445 pcFilledPlane->assign(REN_IS_HOLE);446 447 Pel** apcInputData = new Pel*[ uiNumberOfPlanes ];448 Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ];449 450 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)451 {452 apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData();453 apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData();454 assert( iWidth == apcInputPlanes [uiCurPlane]->getWidth() && iWidth == apcOutputPlanes[uiCurPlane]->getWidth() );455 assert( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight());456 assert( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride());457 }458 459 Pel* pcDepthData = pcDepthPlane ->getPlaneData();460 Pel* pcFilledData = pcFilledPlane->getPlaneData();461 462 for(Int iPosY = 0; iPosY < iHeight; iPosY++)463 {464 Int iPrevShiftedPos = -1;465 Int iShiftedPos = -1;466 467 for(Int iPosX = 0; iPosX < iWidth; iPosX ++ )468 {469 Bool bExtrapolate = false;470 471 // compute disparity and shift472 iShiftedPos = ( iPosX << m_iRelShiftLUTPrec ) - m_aiShiftLUTCur[RemoveBitIncrement( pcDepthData[iPosX])];473 474 if (iPosX == 0)475 {476 // in first iteration only get dLeftPos477 iPrevShiftedPos = iShiftedPos;478 continue;479 };480 481 Int iDeltaPos = iShiftedPos - iPrevShiftedPos;482 483 if ( iDeltaPos <= 0 || (iDeltaPos > (2 << m_iRelShiftLUTPrec)))484 {485 // skip Interpolation if pixel is shifted forwards (gap) or if pixel is shifted backwards (foreground object)486 bExtrapolate = true;487 };488 489 Int iInterPolPos;490 if (!bExtrapolate)491 { // Interpolate between j1 and j2492 for (iInterPolPos = ( iPrevShiftedPos + (1 << m_iRelShiftLUTPrec) - 1 ) >> m_iRelShiftLUTPrec ; iInterPolPos <= (iShiftedPos >> m_iRelShiftLUTPrec); iInterPolPos++)493 {494 if ( (iInterPolPos >= iWidth) || (iInterPolPos < (Int) 0))495 {496 // skip Interpolation if Interpolation position is outside frame497 continue;498 };499 500 // Interpolate501 Int iDeltaCurPos = (iInterPolPos << m_iRelShiftLUTPrec) - iPrevShiftedPos;502 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)503 {504 Pel cVal = (( apcInputData[uiCurPlane][iPosX - 1] * iDeltaPos + ( apcInputData[uiCurPlane][iPosX] - apcInputData[uiCurPlane][iPosX - 1] ) * iDeltaCurPos ) / iDeltaPos );505 apcOutputData[uiCurPlane][iInterPolPos] = cVal;506 }507 508 pcFilledData[iInterPolPos] = REN_IS_FILLED;509 }510 }511 else512 { // Extrapolate right from dLeftPos and left from dRightPos513 Int iShiftedPosCeiled = (( iPrevShiftedPos + (1 << m_iRelShiftLUTPrec) - 1) >> m_iRelShiftLUTPrec ) << m_iRelShiftLUTPrec;514 if ( (iPrevShiftedPos + (m_iRelShiftLUTPrec >> 1) ) > iShiftedPosCeiled )515 {516 iInterPolPos = iShiftedPosCeiled >> m_iRelShiftLUTPrec;517 518 if ( (iInterPolPos >= iWidth) || (iInterPolPos < (Int) 0))519 {520 // skip Interpolation if Interpolation position is outside frame521 iPrevShiftedPos = iShiftedPos;522 continue;523 };524 525 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)526 {527 apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX - 1];528 }529 530 pcFilledData[iInterPolPos] = REN_IS_FILLED;531 }532 533 Int iPrevShiftedPosFloor = (iShiftedPos >> m_iRelShiftLUTPrec) << m_iRelShiftLUTPrec;534 if (iShiftedPos - (m_iRelShiftLUTPrec > 1) < iPrevShiftedPosFloor )535 {536 iInterPolPos = iPrevShiftedPosFloor >> m_iRelShiftLUTPrec;537 538 if ( (iInterPolPos >= iWidth) || (iInterPolPos < (Int) 0))539 {540 // skip Interpolation if Interpolation position is outside frame541 iPrevShiftedPos = iShiftedPos;542 continue;543 };544 545 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)546 {547 apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX ];548 }549 550 pcFilledData[iInterPolPos] = REN_IS_FILLED;551 }552 }553 iPrevShiftedPos = iShiftedPos;554 }555 556 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)557 {558 apcOutputData[uiCurPlane] += iOutputStride;559 apcInputData [uiCurPlane] += iInputStride;560 }561 pcFilledData += iFilledStride;562 pcDepthData += iDepthStride;563 }564 delete[] apcInputData;565 delete[] apcOutputData;566 };567 568 569 Void TRenTop::xShiftPlanePixelsLinReal( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes )570 {571 Int iWidth = apcInputPlanes[0]->getWidth();572 Int iHeight = apcInputPlanes[0]->getHeight();573 574 Int iInputStride = apcInputPlanes [0]->getStride();575 Int iOutputStride = apcOutputPlanes[0]->getStride();576 577 Int iFilledStride = pcFilledPlane->getStride();578 Int iDepthStride = pcDepthPlane ->getStride();579 580 pcFilledPlane->assign( REN_IS_HOLE );581 582 Pel** apcInputData = new Pel*[ uiNumberOfPlanes ];583 Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ];584 585 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)586 {587 apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData();588 apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData();589 assert( iWidth == apcInputPlanes [uiCurPlane]->getWidth() && iWidth == apcOutputPlanes[uiCurPlane]->getWidth() );590 assert( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight());591 assert( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride());592 }593 594 Pel* pcDepthData = pcDepthPlane ->getPlaneData();595 Pel* pcFilledData = pcFilledPlane->getPlaneData();596 597 ///// FEM Stuff /////598 const UInt cuiMaxPlaneNum = 6; AOT( uiNumberOfPlanes > cuiMaxPlaneNum );599 IntImagePlane* apcDiffPlane[ cuiMaxPlaneNum ];600 Int* ppiDiffPlanes[ cuiMaxPlaneNum ];601 Int iDiffStride = 0;602 603 if ( m_iInterpolationMode == eRenIntFEM )604 {605 AOT( uiNumberOfPlanes > cuiMaxPlaneNum );606 for ( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++ )607 {608 apcDiffPlane[uiCurPlane] = new IntImagePlane( iWidth, iHeight, apcInputPlanes[uiCurPlane]->getPad());609 TRenFilter<REN_BIT_DEPTH>::diffHorSym(apcInputPlanes[uiCurPlane] , apcDiffPlane[uiCurPlane]);610 ppiDiffPlanes[uiCurPlane] = apcDiffPlane[uiCurPlane]->getPlaneData();611 }612 iDiffStride = apcDiffPlane[0]->getStride();613 }614 ///// FEM Stuff End /////615 616 for(Int iPosY = 0; iPosY < iHeight; iPosY++)617 {618 Double dShiftedPos = 0;619 Double dPrevShiftedPos = 0;620 621 for(Int iPosX = 0; iPosX < iWidth; iPosX ++ )622 {623 Bool bExtrapolate = false;624 625 // compute disparity and shift626 assert( RemoveBitIncrement(pcDepthData[iPosX]) >= 0 && RemoveBitIncrement(pcDepthData[iPosX]) <= 256 );627 dPrevShiftedPos = (Double) iPosX - m_adShiftLUTCur[ RemoveBitIncrement(pcDepthData[iPosX])];628 629 if (iPosX == 0)630 {631 // in first iteration only get dLeftPos632 dShiftedPos = dPrevShiftedPos;633 continue;634 };635 636 Double dDeltaPos = dPrevShiftedPos - dShiftedPos;637 638 if ((dDeltaPos <= 0) || ( dDeltaPos > 2 ))639 {640 // skip Interpolation if pixel is shifted backwards (foreground object) or if pixel is shifted forwards (gap)641 bExtrapolate = true;642 };643 644 Int iInterPolPos;645 if (!bExtrapolate)646 { // Interpolate between j1 and j2647 for (iInterPolPos = (Int) ceil(dShiftedPos); iInterPolPos <= floor(dPrevShiftedPos); iInterPolPos++)648 {649 if ( (iInterPolPos >= (Int) iWidth) || (iInterPolPos < (Int) 0 ))650 {651 // skip Interpolation if Interpolation position is outside frame652 continue;653 };654 655 // Interpolate656 Pel cVal;657 if ( m_iInterpolationMode == eRenIntFEM ) //FEM Interpolation658 {659 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)660 {661 cVal = TRenFilter<REN_BIT_DEPTH>::interpCHSpline(iInterPolPos, dShiftedPos, dPrevShiftedPos, apcInputData[uiCurPlane][iPosX - 1], ppiDiffPlanes[uiCurPlane][iPosX - 1], apcInputData[uiCurPlane][iPosX], ppiDiffPlanes[uiCurPlane][iPosX] );662 apcOutputData[uiCurPlane][iInterPolPos] = cVal;663 }664 }665 else666 {667 Double dDeltaJ = (Double) iInterPolPos - dShiftedPos;668 669 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)670 {671 cVal = (UChar) ( (Double) apcInputData[uiCurPlane][iPosX - 1] + ( (Double) apcInputData[uiCurPlane][iPosX] - (Double) apcInputData[uiCurPlane][iPosX - 1] ) / dDeltaPos * dDeltaJ + 0.5);672 apcOutputData[uiCurPlane][iInterPolPos] = cVal;673 }674 };675 676 pcFilledData[iInterPolPos] = REN_IS_FILLED;677 }678 }679 else680 { // Extrapolate right from dLeftPos and left from dRightPos681 if (dShiftedPos + 0.5 > ceil(dShiftedPos))682 {683 iInterPolPos = (Int) ceil(dShiftedPos);684 685 if ( (iInterPolPos >= (Int) iWidth) || (iInterPolPos < (Int) 0))686 {687 // skip Interpolation if Interpolation position is outside frame688 dShiftedPos = dPrevShiftedPos;689 continue;690 };691 692 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)693 {694 apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX - 1];695 }696 697 pcFilledData[iInterPolPos] = REN_IS_FILLED;698 }699 700 if (dPrevShiftedPos - 0.5 < floor(dPrevShiftedPos))701 {702 iInterPolPos = (Int) floor(dPrevShiftedPos);703 704 if ( (iInterPolPos >= (Int) iWidth) || (iInterPolPos < (Int) 0))705 {706 // skip Interpolation if Interpolation position is outside frame707 dShiftedPos = dPrevShiftedPos;708 continue;709 };710 711 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)712 {713 apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX ];714 }715 716 pcFilledData[iInterPolPos] = REN_IS_FILLED;717 }718 }719 dShiftedPos = dPrevShiftedPos;720 }721 722 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)723 {724 apcOutputData[uiCurPlane] += iOutputStride;725 apcInputData [uiCurPlane] += iInputStride;726 727 if (m_iInterpolationMode == eRenIntFEM)728 {729 ppiDiffPlanes[ uiCurPlane ] += iDiffStride;730 }731 }732 733 pcFilledData += iFilledStride;734 pcDepthData += iDepthStride;735 }736 737 if (m_iInterpolationMode == eRenIntFEM)738 {739 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)740 {741 delete apcDiffPlane[uiCurPlane];742 }743 }744 745 delete[] apcInputData;746 delete[] apcOutputData;747 }748 749 750 Void TRenTop::xShiftPlanePixels( PelImagePlane** apcInPlane, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutPlane, PelImagePlane* pcPlaneFilled, UInt uiNumberOfPlanes )751 {752 switch ( m_iInterpolationMode)753 {754 case eRenIntFullPel:755 xShiftPlanePixelsFullPel( apcInPlane, pcDepthPlane, apcOutPlane, pcPlaneFilled, uiNumberOfPlanes);756 break;757 case eRenIntFEM:758 case eRenIntLinReal:759 xShiftPlanePixelsLinReal( apcInPlane, pcDepthPlane, apcOutPlane, pcPlaneFilled, uiNumberOfPlanes);760 break;761 case eRenIntLinInt:762 xShiftPlanePixelsLinInt ( apcInPlane, pcDepthPlane, apcOutPlane, pcPlaneFilled, uiNumberOfPlanes);763 break;764 case eRenInt8Tap:765 xShiftPlanePixels8Tap ( apcInPlane, pcDepthPlane, apcOutPlane, pcPlaneFilled, uiNumberOfPlanes );766 break;767 default:768 AOF( false );769 }770 }771 772 773 Void TRenTop::xShiftPlanePixelsFullPel( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes )774 {775 Int iWidth = apcInputPlanes[0]->getWidth();776 Int iHeight = apcInputPlanes[0]->getHeight();777 778 Int iInputStride = apcInputPlanes [0]->getStride();779 Int iOutputStride = apcOutputPlanes[0]->getStride();780 781 Int iFilledStride = pcFilledPlane->getStride();782 Int iDepthStride = pcDepthPlane ->getStride();783 784 pcFilledPlane->assign(REN_IS_HOLE);785 786 Pel** apcInputData = new Pel*[ uiNumberOfPlanes ];787 Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ];788 789 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)790 {791 apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData();792 apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData();793 assert( iWidth == apcInputPlanes [uiCurPlane]->getWidth() && iWidth == apcOutputPlanes[uiCurPlane]->getWidth() );794 assert( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight());795 assert( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride());796 }797 798 Pel* pcDepthData = pcDepthPlane ->getPlaneData();799 Pel* pcFilledData = pcFilledPlane->getPlaneData();800 801 for(Int iPosY = 0; iPosY < iHeight; iPosY++)802 {803 Int iPrevShiftedPos = -1;804 805 for(Int iPosX = 0; iPosX < iWidth; iPosX++)806 {807 assert( RemoveBitIncrement(pcDepthData[iPosX]) >= 0 && RemoveBitIncrement(pcDepthData[iPosX]) <= 256 );808 Int iShiftedPos = iPosX - m_aiShiftLUTCur[ RemoveBitIncrement(pcDepthData[iPosX])] ;809 if (iShiftedPos < iWidth && iShiftedPos >= 0)810 {811 Int iDiff = iShiftedPos - iPrevShiftedPos;812 if (( iDiff <= 2) && (iDiff > 0) )813 {814 for (Int iCurPos = iPrevShiftedPos+1; iCurPos <= iShiftedPos; iCurPos++)815 {816 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)817 {818 apcOutputData[uiCurPlane][iCurPos] = apcInputData[uiCurPlane][iPosX]; // Only small gaps, therefor not necessary NN819 }820 pcFilledData[iCurPos] = REN_IS_FILLED;821 }822 }823 else824 {825 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)826 {827 apcOutputData[uiCurPlane][iShiftedPos] = apcInputData[uiCurPlane][iPosX];828 }829 pcFilledData[iShiftedPos] = REN_IS_FILLED;830 }831 iPrevShiftedPos = iShiftedPos;832 }833 }834 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)835 {836 apcOutputData[uiCurPlane] += iOutputStride;837 apcInputData [uiCurPlane] += iInputStride;838 }839 pcFilledData += iFilledStride;840 pcDepthData += iDepthStride;841 }842 843 delete[] apcInputData;844 delete[] apcOutputData;845 }846 847 Void TRenTop::xBackShiftPlanePixels( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes )848 {849 Int iOutputWidth = apcOutputPlanes[0]->getWidth();850 Int iInputWidth = apcInputPlanes [0]->getWidth();851 Int iHeight = apcInputPlanes [0]->getHeight();852 853 Int iInputStride = apcInputPlanes [0]->getStride();854 Int iOutputStride = apcOutputPlanes[0]->getStride();855 856 Int iFilledStride = pcFilledPlane->getStride();857 Int iDepthStride = pcDepthPlane ->getStride();858 859 Pel** apcInputData = new Pel*[ uiNumberOfPlanes ];860 Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ];861 862 Int iStep = (1 << m_iRelShiftLUTPrec);863 864 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)865 {866 apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData();867 apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData();868 AOF( iInputWidth == apcInputPlanes [uiCurPlane]->getWidth() && iOutputWidth == apcOutputPlanes[uiCurPlane]->getWidth() );869 AOF( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight());870 AOF( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride());871 AOF( iInputWidth == iOutputWidth * iStep );872 }873 874 Pel* pcDepthData = pcDepthPlane ->getPlaneData();875 Pel* pcFilledData = pcFilledPlane->getPlaneData();876 877 878 for(Int iPosY = 0; iPosY < iHeight; iPosY++)879 {880 for(Int iPosX = 0; iPosX < iOutputWidth; iPosX ++)881 {882 Int iBackShiftedPos = (iPosX << m_iRelShiftLUTPrec) - m_aiShiftLUTCur[ RemoveBitIncrement( pcDepthData[iPosX] )];883 if( ( pcFilledData[iPosX] == REN_IS_FILLED ) && (iBackShiftedPos >= 0 ) && ( iBackShiftedPos < iInputWidth ) )884 {885 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)886 {887 apcOutputData[uiCurPlane][iPosX] = apcInputData[uiCurPlane][iBackShiftedPos];888 }889 }890 else891 {892 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)893 {894 apcOutputData[uiCurPlane][iPosX] = 0;895 }896 pcFilledData[iPosX] = REN_IS_HOLE;897 }898 }899 900 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)901 {902 apcOutputData[uiCurPlane] += iOutputStride;903 apcInputData [uiCurPlane] += iInputStride;904 }905 pcFilledData += iFilledStride;906 pcDepthData += iDepthStride;907 }908 909 delete[] apcInputData;910 delete[] apcOutputData;911 }912 913 Void TRenTop::xShiftPlanePixels8Tap( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes )914 {915 Bool bRenderDepth = (apcInputPlanes[0] == pcDepthPlane);916 917 Int iOutputWidth = apcOutputPlanes[0]->getWidth();918 Int iInputWidth = apcInputPlanes [0]->getWidth();919 Int iHeight = apcInputPlanes [0]->getHeight();920 921 Int iInputStride = apcInputPlanes [0]->getStride();922 Int iOutputStride = apcOutputPlanes[0]->getStride();923 924 Int iFilledStride = pcFilledPlane->getStride();925 Int iDepthStride = pcDepthPlane ->getStride();926 927 Int iStep = (1 << m_iRelShiftLUTPrec);928 929 pcFilledPlane->assign(REN_IS_HOLE);930 931 Pel** apcInputData = new Pel*[ uiNumberOfPlanes ];932 Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ];933 934 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)935 {936 apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData();937 apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData();938 AOF( iInputWidth == apcInputPlanes [uiCurPlane]->getWidth() && iOutputWidth == apcOutputPlanes[uiCurPlane]->getWidth() );939 AOF( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight());940 AOF( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride());941 AOF( iInputWidth == iOutputWidth * iStep );942 }943 944 Pel* pcDepthData = pcDepthPlane ->getPlaneData();945 Pel* pcFilledData = pcFilledPlane->getPlaneData();946 947 for(Int iPosY = 0; iPosY < iHeight; iPosY++)948 {949 Int iPrevShiftedPos = -1;950 Int iShiftedPos = -1;951 952 for(Int iPosX = 0; iPosX < iInputWidth; iPosX += iStep )953 {954 // compute disparity and shift955 iShiftedPos = iPosX - m_aiShiftLUTCur[RemoveBitIncrement(pcDepthData[iPosX])];956 957 if ( iPosX == 0 )958 {959 // in first iteration only get dLeftPos960 iPrevShiftedPos = iShiftedPos;961 continue;962 };963 964 Int iDeltaPos = iShiftedPos - iPrevShiftedPos;965 966 Bool bDisocclusion = ( iDeltaPos > (2 << m_iRelShiftLUTPrec) );967 Bool bOcclusion = ( iDeltaPos <= 0 );968 969 Int iInterPolPos;970 if ( !bDisocclusion && !bOcclusion )971 { // Interpolate between previous shifted pos and shifted pos972 for (iInterPolPos = xCeil( iPrevShiftedPos ); iInterPolPos <= xCeil (iShiftedPos ) -1 ; iInterPolPos++)973 {974 if ( (iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth))975 {976 // skip Interpolation if Interpolation position is outside frame977 continue;978 };979 980 // Interpolate981 Int iDeltaCurPos = (iInterPolPos << m_iRelShiftLUTPrec) - iPrevShiftedPos;982 983 AOF( (iDeltaCurPos <= iDeltaPos) && ( iDeltaCurPos >= 0));984 AOF( iDeltaPos <= (2 << m_iRelShiftLUTPrec) );985 AOF( m_aaiSubPelShift[iDeltaPos][iDeltaCurPos] != 0xdeaddead);986 987 Int iSourcePos;988 989 if ( bRenderDepth )990 {991 iSourcePos = iPosX - iStep; // Render depth with Full Pel accuracy to avoid ringing at sharp depth edges;992 }993 else994 {995 iSourcePos = iPosX + m_aaiSubPelShift[iDeltaPos][iDeltaCurPos]; // GT: = iPosX - iStep + ( iStep * iDeltaCurPos + ( iDeltaPos >> 1) ) / iDeltaPos;996 }997 998 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)999 {1000 apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iSourcePos];1001 }1002 1003 pcFilledData[ iInterPolPos] = REN_IS_FILLED;1004 }1005 }1006 else1007 {1008 // Fill Disocclusion Edge1009 1010 if ( bDisocclusion )1011 {1012 Int iPrevShiftedPosCeiled = xCeil(iPrevShiftedPos) << m_iRelShiftLUTPrec;1013 iInterPolPos = iPrevShiftedPosCeiled >> m_iRelShiftLUTPrec;1014 1015 if ((iPrevShiftedPos + (iStep >> 1) ) > iPrevShiftedPosCeiled )1016 {1017 if ( !((iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth)))1018 {1019 1020 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1021 {1022 apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX - iStep];1023 }1024 pcFilledData[iInterPolPos] = REN_IS_FILLED;1025 1026 }1027 iInterPolPos++;1028 }1029 1030 // Fill Disocclusion1031 if ( m_bInstantHoleFilling )1032 {1033 for ( ; iInterPolPos <= xCeil (iShiftedPos ) -1 ; iInterPolPos++)1034 {1035 if ( ( iInterPolPos >= 0 ) && ( iInterPolPos < iOutputWidth ) )1036 {1037 if( pcFilledData[iInterPolPos] == REN_IS_HOLE )1038 {1039 Int iNextPos = std::min(iInputWidth-1,iPosX + iStep);1040 Int iPosXBG = ( std::abs( pcDepthData[iNextPos] - pcDepthData[iPosX] ) > 5 ) ? iPosX : iNextPos;1041 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1042 {1043 apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosXBG];1044 }1045 }1046 else1047 {1048 pcFilledData[iInterPolPos] = REN_IS_HOLE + 1;1049 }1050 }1051 }1052 }1053 }1054 1055 //// Last sample next to occlusion1056 Int iShiftedPosFloor = ( iShiftedPos >> m_iRelShiftLUTPrec ) << m_iRelShiftLUTPrec;1057 if ( bOcclusion && (iShiftedPos - (iStep >> 1) < iShiftedPosFloor) )1058 {1059 iInterPolPos = iShiftedPosFloor >> m_iRelShiftLUTPrec;1060 if ( !((iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth)))1061 {1062 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1063 {1064 apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX ];1065 }1066 1067 pcFilledData[iInterPolPos] = REN_IS_FILLED;1068 }1069 }1070 }1071 iPrevShiftedPos = iShiftedPos;1072 }1073 1074 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1075 {1076 apcOutputData[uiCurPlane] += iOutputStride;1077 apcInputData [uiCurPlane] += iInputStride;1078 }1079 pcFilledData += iFilledStride;1080 pcDepthData += iDepthStride;1081 }1082 delete[] apcInputData;1083 delete[] apcOutputData;1084 };1085 1086 Void TRenTop::xShiftPixels(PelImage* pcInImage, PelImage* pcDepth, PelImage* pcOutImage, PelImage* pcFilledImage, Bool bShiftFromLeft )1087 {1088 PelImage* pcTemp = 0;1089 1090 if (pcInImage == pcOutImage)1091 {1092 pcTemp = pcOutImage->create();1093 }1094 else1095 {1096 pcTemp = pcOutImage;1097 }1098 1099 Double ** ppdShiftLUT = bShiftFromLeft ? m_ppdShiftLUTLeft : m_ppdShiftLUTRightMirror;1100 Int ** ppiShiftLUT = bShiftFromLeft ? m_ppiShiftLUTLeft : m_ppiShiftLUTRightMirror;1101 1102 UInt uiNumFullPlanes = pcInImage->getNumberOfFullPlanes();1103 UInt uiNumQuatPlanes = pcInImage->getNumberOfQuaterPlanes();1104 1105 assert( uiNumFullPlanes == pcOutImage->getNumberOfFullPlanes () );1106 assert( uiNumQuatPlanes == pcOutImage->getNumberOfQuaterPlanes() );1107 1108 m_aiShiftLUTCur = ppiShiftLUT[ 0 ];1109 m_adShiftLUTCur = ppdShiftLUT[ 0 ];1110 1111 xShiftPlanePixels( pcInImage->getPlanes(), pcDepth->getPlane(0), pcOutImage->getPlanes(), pcFilledImage->getPlane(0), uiNumFullPlanes );1112 1113 if (uiNumQuatPlanes > 0)1114 {1115 assert( pcDepth->getNumberOfPlanes() > 1 && pcFilledImage->getNumberOfPlanes() > 1);1116 m_aiShiftLUTCur = ppiShiftLUT[ 1 ];1117 m_adShiftLUTCur = ppdShiftLUT[ 1 ];1118 xShiftPlanePixels( pcInImage->getPlanes()+uiNumFullPlanes,pcDepth->getPlane(1), pcOutImage->getPlanes() + uiNumFullPlanes, pcFilledImage->getPlane(1), uiNumQuatPlanes );1119 }1120 1121 if (pcInImage == pcOutImage)1122 {1123 pcOutImage->assign(pcTemp);1124 delete pcTemp;1125 };1126 };1127 1128 Void TRenTop::xBackShiftPixels(PelImage* pcInImage, PelImage* pcDepth, PelImage* pcOutImage, PelImage* pcFilledImage, Bool bShiftFromLeft )1129 {1130 PelImage* pcTemp = 0;1131 1132 if (pcInImage == pcOutImage)1133 {1134 pcTemp = pcOutImage->create();1135 }1136 else1137 {1138 pcTemp = pcOutImage;1139 }1140 1141 Double ** ppdShiftLUT = bShiftFromLeft ? m_ppdShiftLUTLeft : m_ppdShiftLUTRight;1142 Int ** ppiShiftLUT = bShiftFromLeft ? m_ppiShiftLUTLeft : m_ppiShiftLUTRight;1143 1144 UInt uiNumFullPlanes = pcInImage->getNumberOfFullPlanes();1145 UInt uiNumQuatPlanes = pcInImage->getNumberOfQuaterPlanes();1146 1147 assert( uiNumFullPlanes == pcOutImage->getNumberOfFullPlanes () );1148 assert( uiNumQuatPlanes == pcOutImage->getNumberOfQuaterPlanes() );1149 1150 m_aiShiftLUTCur = ppiShiftLUT[ 0 ];1151 m_adShiftLUTCur = ppdShiftLUT[ 0 ];1152 1153 xBackShiftPlanePixels( pcInImage->getPlanes(), pcDepth->getPlane(0), pcOutImage->getPlanes(), pcFilledImage->getPlane(0), uiNumFullPlanes );1154 1155 if (uiNumQuatPlanes > 0)1156 {1157 assert( pcDepth->getNumberOfPlanes() > 1 && pcFilledImage->getNumberOfPlanes() > 1);1158 m_aiShiftLUTCur = ppiShiftLUT[ 1 ];1159 m_adShiftLUTCur = ppdShiftLUT[ 1 ];1160 xBackShiftPlanePixels( pcInImage->getPlanes()+uiNumFullPlanes,pcDepth->getPlane(1), pcOutImage->getPlanes() + uiNumFullPlanes, pcFilledImage->getPlane(1), uiNumQuatPlanes );1161 }1162 1163 if (pcInImage == pcOutImage)1164 {1165 pcOutImage->assign(pcTemp);1166 delete pcTemp;1167 };1168 };1169 1170 Void TRenTop::xFillHoles(PelImage* pcInImage, PelImage* pcFilled, PelImage* pcOutImage, Bool bRenderFromLeft )1171 {1172 if (pcInImage != pcOutImage)1173 {1174 pcOutImage->assign(pcInImage);1175 }1176 1177 switch (m_iHoleFillingMode)1178 {1179 case eRenHFNone:1180 break;1181 case eRenHFLWBackExt:1182 xFillLWBackExt( pcInImage, pcFilled, pcOutImage, bRenderFromLeft);1183 break;1184 default:1185 break;1186 }1187 };1188 1189 Void TRenTop::xFillLWBackExt( PelImage* pcInImage, PelImage* pcFilledImage, PelImage* pcOutImage, Bool bRenderFromLeft )1190 {1191 UInt uiNumFullPlanes = pcInImage->getNumberOfFullPlanes();1192 UInt uiNumQuatPlanes = pcInImage->getNumberOfQuaterPlanes();1193 1194 assert( uiNumFullPlanes == pcOutImage->getNumberOfFullPlanes () );1195 assert( uiNumQuatPlanes == pcOutImage->getNumberOfQuaterPlanes() );1196 1197 xFillPlaneHoles( pcInImage->getPlanes(), pcFilledImage->getPlane(0), pcOutImage->getPlanes(), uiNumFullPlanes, bRenderFromLeft );1198 1199 if (uiNumQuatPlanes > 0)1200 {1201 assert( pcFilledImage->getNumberOfPlanes() > 1);1202 xFillPlaneHoles( pcInImage->getPlanes()+uiNumFullPlanes, pcFilledImage->getPlane(1), pcOutImage->getPlanes() + uiNumFullPlanes, uiNumQuatPlanes, bRenderFromLeft );1203 }1204 };1205 1206 Void TRenTop::xCreateAlphaMap(PelImage* pcFilledImage, PelImage* pcAlphaMapImage, Bool bRenderFromLeft )1207 {1208 UInt uiNumFullPlanes = pcFilledImage ->getNumberOfFullPlanes();1209 UInt uiNumQuatPlanes = pcFilledImage->getNumberOfQuaterPlanes();1210 1211 AOF( uiNumFullPlanes == pcAlphaMapImage->getNumberOfFullPlanes () );1212 AOF( uiNumQuatPlanes == pcAlphaMapImage->getNumberOfQuaterPlanes() );1213 1214 xCreateAlphaMapPlane( pcFilledImage->getPlanes(), pcAlphaMapImage->getPlanes(), uiNumFullPlanes, bRenderFromLeft );1215 1216 if (uiNumQuatPlanes > 0)1217 {1218 AOF( pcFilledImage->getNumberOfPlanes() > 1);1219 xCreateAlphaMapPlane( pcFilledImage->getPlanes()+ uiNumFullPlanes, pcAlphaMapImage->getPlanes()+uiNumFullPlanes, uiNumQuatPlanes, bRenderFromLeft );1220 }1221 };1222 1223 Void TRenTop::xCreateAlphaMapPlane(PelImagePlane** apcFilledPlanes, PelImagePlane** apcAlphaPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft)1224 {1225 Int iWidth = apcFilledPlanes [0]->getWidth();1226 Int iHeight = apcFilledPlanes [0]->getHeight();1227 1228 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1229 {1230 AOF( iWidth == apcFilledPlanes [uiCurPlane]->getWidth() && iWidth == apcAlphaPlanes[uiCurPlane]->getWidth() );1231 AOF( iHeight == apcFilledPlanes [uiCurPlane]->getHeight() && iHeight == apcAlphaPlanes[uiCurPlane]->getHeight());1232 }1233 1234 Int iBlendWidth = m_iBlendHoleMargin;1235 Int iMaxBlendLevel;1236 1237 if (!m_bBlendUseDistWeight )1238 {1239 iMaxBlendLevel = ( 1 << REN_VDWEIGHT_PREC ) ;1240 1241 if ( m_iBlendMode == 0)1242 {1243 iMaxBlendLevel >>= 1;1244 }1245 }1246 else1247 {1248 if ( m_iBlendMode == 0)1249 {1250 iMaxBlendLevel = bRenderFromLeft ? (1 << REN_VDWEIGHT_PREC) - m_iBlendDistWeight : m_iBlendDistWeight;1251 }1252 else1253 {1254 iMaxBlendLevel = ( 1 << REN_VDWEIGHT_PREC );1255 }1256 }1257 1258 Int iWeightStep = (iBlendWidth > 0) ? ( iMaxBlendLevel + (iBlendWidth >> 1) ) / iBlendWidth : 0;1259 1260 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1261 {1262 Int iFilledStride = apcFilledPlanes [uiCurPlane]->getStride();1263 Int iAlphaStride = apcAlphaPlanes [uiCurPlane]->getStride();1264 1265 Pel* pcFilledData = apcFilledPlanes [uiCurPlane]->getPlaneData();1266 Pel* pcAlphaData = apcAlphaPlanes [uiCurPlane]->getPlaneData();1267 1268 for(Int iYPos = 0; iYPos < iHeight; iYPos++)1269 {1270 for(Int iXPos = 0 ; iXPos < iWidth; iXPos++ )1271 {1272 if (pcFilledData[iXPos] == REN_IS_HOLE)1273 {1274 while( (pcFilledData[iXPos] == REN_IS_HOLE) && (iXPos < iWidth) )1275 {1276 pcAlphaData[iXPos] = REN_IS_HOLE;1277 iXPos++;1278 }1279 1280 if ( iXPos >= iWidth )1281 continue;1282 1283 Int iWeight = 0;1284 Int iLastFillPos = iXPos + iBlendWidth;1285 1286 while( (pcFilledData[iXPos] != REN_IS_HOLE) && (iXPos < iWidth) && (iXPos < iLastFillPos) )1287 {1288 AOF( iWeight <= (1 << REN_VDWEIGHT_PREC) );1289 pcAlphaData[iXPos] = (iWeight == 0) ? 1 : iWeight;1290 iWeight += iWeightStep;1291 iXPos++;1292 }1293 }1294 else1295 {1296 pcAlphaData[iXPos] = pcFilledData[iXPos];1297 }1298 }1299 pcAlphaData += iAlphaStride;1300 pcFilledData += iFilledStride;1301 }1302 }1303 }1304 1305 Void TRenTop::xRemBoundaryNoise(PelImage* pcInImage, PelImage* pcFilledImage, PelImage* pcOutImage, Bool bRenderFromLeft )1306 {1307 if (pcInImage != pcOutImage)1308 {1309 pcOutImage->assign(pcInImage);1310 }1311 1312 UInt uiNumFullPlanes = pcInImage->getNumberOfFullPlanes();1313 UInt uiNumQuatPlanes = pcInImage->getNumberOfQuaterPlanes();1314 1315 AOF( uiNumFullPlanes == pcOutImage->getNumberOfFullPlanes () );1316 AOF( uiNumQuatPlanes == pcOutImage->getNumberOfQuaterPlanes() );1317 1318 xRemBoundaryNoisePlane( pcInImage->getPlanes(), pcFilledImage->getPlane(0), pcOutImage->getPlanes(), uiNumFullPlanes, bRenderFromLeft );1319 1320 if (uiNumQuatPlanes > 0)1321 {1322 AOF( pcFilledImage->getNumberOfPlanes() > 1);1323 xRemBoundaryNoisePlane( pcInImage->getPlanes()+uiNumFullPlanes, pcFilledImage->getPlane(1), pcOutImage->getPlanes() + uiNumFullPlanes, uiNumQuatPlanes, bRenderFromLeft );1324 }1325 };1326 1327 Void TRenTop::xRemBoundaryNoisePlane(PelImagePlane** apcInputPlanes, PelImagePlane* pcFilledPlane, PelImagePlane** apcOutputPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft)1328 {1329 Int iWidth = apcOutputPlanes[0]->getWidth();1330 Int iHeight = apcInputPlanes [0]->getHeight();1331 1332 Int iInputStride = apcInputPlanes [0]->getStride();1333 Int iOutputStride = apcOutputPlanes[0]->getStride();1334 1335 Int iFilledStride = pcFilledPlane->getStride();1336 1337 Pel** apcInputData = new Pel*[ uiNumberOfPlanes ];1338 Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ];1339 Pel* pcFilledData = pcFilledPlane->getPlaneData();1340 1341 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1342 {1343 apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData();1344 apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData();1345 AOF( iWidth == apcInputPlanes [uiCurPlane]->getWidth() && iWidth == apcOutputPlanes[uiCurPlane]->getWidth() );1346 AOF( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight());1347 AOF( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride());1348 }1349 1350 Int iRemovalWidth = m_iBlendHoleMargin;1351 AOT(iRemovalWidth > 6); // GT: insufficent padding1352 1353 for(Int iYPos = 0; iYPos < iHeight; iYPos++)1354 {1355 for(Int iXPos = iWidth-1; iXPos >= 0; iXPos-- )1356 {1357 if (pcFilledData[iXPos] == REN_IS_HOLE)1358 {1359 Int iSourcePos = iXPos + 1;1360 1361 // Get New Value1362 while( (pcFilledData[iSourcePos] != REN_IS_HOLE) && ( iSourcePos < iWidth) && ( iSourcePos < iXPos + iRemovalWidth ) ) iSourcePos++;1363 1364 if (iSourcePos == iWidth || pcFilledData[iSourcePos] != REN_IS_HOLE )1365 iSourcePos--;1366 1367 Int iXPosRem = iSourcePos - 1;1368 1369 // Remove1370 while( iXPosRem > iXPos)1371 {1372 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1373 {1374 apcOutputData[uiCurPlane][iXPosRem] = apcInputData[uiCurPlane][iSourcePos];1375 }1376 1377 iXPosRem--;1378 }1379 1380 // Skip Hole1381 while( (pcFilledData[iXPos] == REN_IS_HOLE) && ( iXPos > 0) ) iXPos--;1382 }1383 }1384 1385 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1386 {1387 apcOutputData[uiCurPlane] += iOutputStride;1388 apcInputData [uiCurPlane] += iInputStride;1389 }1390 pcFilledData += iFilledStride;1391 }1392 delete[] apcInputData;1393 delete[] apcOutputData;1394 }1395 1396 Void TRenTop::xFillPlaneHoles(PelImagePlane** apcInputPlanes, PelImagePlane* pcFilledPlane, PelImagePlane** apcOutputPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft)1397 {1398 Int iWidth = apcOutputPlanes[0]->getWidth();1399 Int iHeight = apcInputPlanes [0]->getHeight();1400 1401 Int iInputStride = apcInputPlanes [0]->getStride();1402 Int iOutputStride = apcOutputPlanes[0]->getStride();1403 1404 Int iFilledStride = pcFilledPlane->getStride();1405 1406 Pel** apcInputData = new Pel*[ uiNumberOfPlanes ];1407 Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ];1408 Pel* pcFilledData = pcFilledPlane->getPlaneData();1409 1410 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1411 {1412 apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData();1413 apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData();1414 AOF( iWidth == apcInputPlanes [uiCurPlane]->getWidth() && iWidth == apcOutputPlanes[uiCurPlane]->getWidth() );1415 AOF( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight());1416 AOF( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride());1417 }1418 1419 for(Int iYPos = 0; iYPos < iHeight; iYPos++)1420 {1421 if ( !m_bInstantHoleFilling )1422 {1423 for(Int iXPos = 0 ; iXPos < iWidth; iXPos++ )1424 {1425 if (pcFilledData[iXPos] == REN_IS_HOLE)1426 {1427 Int iSourcePos;1428 Int iLastFillPos;1429 1430 Int iXPosSearch = iXPos;1431 while( (pcFilledData[iXPosSearch] == REN_IS_HOLE) && (iXPosSearch < iWidth) ) iXPosSearch++;1432 1433 if ( iXPosSearch >= iWidth )1434 {1435 continue;1436 }1437 else1438 {1439 iSourcePos = iXPosSearch;1440 iLastFillPos = iXPosSearch-1;1441 }1442 1443 while( iXPos <= iLastFillPos)1444 {1445 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1446 {1447 apcOutputData[uiCurPlane][iXPos] = apcInputData[uiCurPlane][iSourcePos];1448 }1449 iXPos++;1450 }1451 }1452 }1453 }1454 1455 // Fill Right Gap1456 Int iXPosSearch = iWidth -1;1457 while( (pcFilledData[iXPosSearch] == REN_IS_HOLE) && (iXPosSearch >= 0) ) iXPosSearch--;1458 if ( iXPosSearch < 0) iXPosSearch++;1459 1460 Int iSourcePos = iXPosSearch;1461 1462 for( Int iXPos = iSourcePos + 1; iXPos < iWidth; iXPos++)1463 {1464 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1465 {1466 apcOutputData[uiCurPlane][iXPos] = apcInputData[uiCurPlane][iSourcePos];1467 }1468 }1469 1470 // Fill Left Gap1471 iXPosSearch = 0;1472 while( (pcFilledData[iXPosSearch] == REN_IS_HOLE) && (iXPosSearch < iWidth) ) iXPosSearch++;1473 if ( iXPosSearch >= iWidth) iXPosSearch--;1474 1475 iSourcePos = iXPosSearch;1476 1477 for( Int iXPos = iSourcePos - 1; iXPos >= 0; iXPos--)1478 {1479 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1480 {1481 apcOutputData[uiCurPlane][iXPos] = apcInputData[uiCurPlane][iSourcePos];1482 }1483 }1484 1485 // Go to next line1486 for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++)1487 {1488 apcOutputData[uiCurPlane] += iOutputStride;1489 apcInputData [uiCurPlane] += iInputStride;1490 }1491 pcFilledData += iFilledStride;1492 }1493 delete[] apcInputData;1494 delete[] apcOutputData;1495 }1496 1497 Void TRenTop::xPostProcessImage(PelImage* pcInImage, PelImage* pcOutImage)1498 {1499 if ( m_iPostProcMode == eRenPostProNone )1500 return;1501 1502 PelImage* pcTemp;1503 1504 if (pcInImage == pcOutImage)1505 {1506 pcTemp = pcOutImage->create();1507 }1508 else1509 {1510 pcTemp = pcOutImage;1511 }1512 1513 pcTemp->assign(pcInImage);1514 1515 switch ( m_iPostProcMode )1516 {1517 case eRenPostProMed:1518 TRenFilter<REN_BIT_DEPTH>::lineMedian3(pcTemp);1519 break;1520 case eRenPostProNone:1521 break;1522 default:1523 assert(0);1524 }1525 1526 if (pcInImage == pcOutImage)1527 {1528 pcOutImage->assign(pcTemp);1529 delete pcTemp;1530 };1531 }1532 1533 1534 Void TRenTop::xCutPlaneMargin( PelImagePlane* pcImagePlane, Pel cFill, UInt uiScale )1535 {1536 UInt uiWidth = pcImagePlane->getWidth();1537 UInt uiHeight = pcImagePlane->getHeight();1538 1539 UInt uiStride = pcImagePlane->getStride();1540 Pel* pcPlaneData = pcImagePlane->getPlaneData();1541 1542 UInt uiCutLeft = m_auiCut[0] / uiScale;1543 UInt uiCutRight = uiWidth - m_auiCut[1] / uiScale;1544 1545 for(UInt uiYPos = 0; uiYPos < uiHeight; uiYPos++)1546 {1547 for(UInt uiXPos = 0; uiXPos < (UInt) uiWidth ; uiXPos++)1548 {1549 if ( ( uiXPos < uiCutLeft ) || ( uiXPos >= uiCutRight ) )1550 {1551 pcPlaneData[uiXPos ] = cFill;1552 }1553 }1554 pcPlaneData += uiStride;1555 }1556 };1557 1558 Void TRenTop::xCutMargin( PelImage* pcInputImage )1559 {1560 if ( ( m_auiCut[0] == 0 ) && ( m_auiCut[1] == 0 ) )1561 {1562 return;1563 };1564 1565 UInt uiCurPlane = 0;1566 for (; uiCurPlane < pcInputImage->getNumberOfFullPlanes(); uiCurPlane++ )1567 {1568 xCutPlaneMargin( pcInputImage->getPlane(uiCurPlane), (Pel) 0 , 1 );1569 }1570 1571 for (; uiCurPlane < pcInputImage->getNumberOfPlanes(); uiCurPlane++ )1572 {1573 xCutPlaneMargin( pcInputImage->getPlane(uiCurPlane), (Pel) 128 , 2 );1574 }1575 1576 };1577 1578 1579 Void TRenTop::xEnhSimilarity( PelImage* pcLeftImage, PelImage* pcRightImage, PelImage* pcFilledLeft, PelImage* pcFilledRight )1580 {1581 if (m_iSimEnhBaseView == 0)1582 return;1583 1584 UInt uiNumFullPlanes = pcLeftImage->getNumberOfFullPlanes();1585 UInt uiNumQuatPlanes = pcLeftImage->getNumberOfQuaterPlanes();1586 1587 if (uiNumQuatPlanes > 0)1588 {1589 assert( pcFilledLeft ->getNumberOfPlanes() > 1);1590 assert( pcFilledRight->getNumberOfPlanes() > 1);1591 };1592 1593 xEnhSimilarityPlane ( pcLeftImage->getPlanes() , pcRightImage->getPlanes() , pcFilledLeft->getPlane(0), pcFilledRight->getPlane(0), uiNumFullPlanes);1594 if (uiNumQuatPlanes > 0)1595 {1596 xEnhSimilarityPlane ( pcLeftImage->getPlanes()+uiNumFullPlanes, pcRightImage->getPlanes()+uiNumFullPlanes, pcFilledLeft->getPlane(1), pcFilledRight->getPlane(1), uiNumQuatPlanes);1597 }1598 }1599 1600 Void TRenTop::xEnhSimilarityPlane ( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, UInt uiNumberOfPlanes )1601 {1602 AOT( m_iSimEnhBaseView != 1 && m_iSimEnhBaseView != 2 );1603 Int iWidth = (*apcRightPlane)->getWidth ();1604 Int iHeight = (*apcRightPlane)->getHeight();1605 1606 Int* aiHistLeft = new Int[ ((Int64)1 ) << REN_BIT_DEPTH ];1607 Int* aiHistRight = new Int[ ((Int64)1 ) << REN_BIT_DEPTH ];1608 Pel* aiConvLUT = new Pel[ ((Int64)1 ) << REN_BIT_DEPTH ];1609 1610 for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++ )1611 {1612 for (Int iCurVal = 0 ; iCurVal < ( 1 << REN_BIT_DEPTH ); iCurVal++)1613 {1614 aiHistLeft [iCurVal] = 0;1615 aiHistRight[iCurVal] = 0;1616 }1617 1618 Pel* pcFilledRightData = pcFilledRightPlane ->getPlaneData();1619 Pel* pcRightImageData = (*apcRightPlane ) ->getPlaneData();1620 1621 Pel* pcFilledLeftData = pcFilledLeftPlane ->getPlaneData();1622 Pel* pcLeftImageData = (*apcLeftPlane) ->getPlaneData();1623 1624 1625 1626 for (UInt uiYPos = 0; uiYPos < iHeight; uiYPos++ )1627 {1628 for (UInt uiXPos = 0; uiXPos < iWidth; uiXPos++ )1629 {1630 if ( pcFilledLeftData[uiXPos] == REN_IS_FILLED && pcFilledRightData[uiXPos] == REN_IS_FILLED )1631 {1632 aiHistLeft [pcLeftImageData [uiXPos] ]++;1633 aiHistRight[pcRightImageData [uiXPos] ]++;1634 }1635 }1636 1637 1638 pcFilledRightData += pcFilledRightPlane ->getStride();1639 pcRightImageData += (*apcRightPlane) ->getStride();1640 1641 pcFilledLeftData += pcFilledLeftPlane ->getStride();1642 pcLeftImageData += (*apcLeftPlane) ->getStride();1643 }1644 1645 Int iCumSumChange = 0;1646 Int iCumSumBase = 0;1647 Int iCurBaseVal = 0;1648 Int iCurChangeVal = 0;1649 1650 Int* aiHistChange = (m_iSimEnhBaseView == 2 ) ? aiHistLeft : aiHistRight;1651 Int* aiHistBase = (m_iSimEnhBaseView == 2 ) ? aiHistRight : aiHistLeft ;1652 1653 iCumSumChange += aiHistChange[iCurChangeVal];1654 iCumSumBase += aiHistBase [iCurBaseVal] ;1655 1656 Int iCheckSumLeft = 0;1657 Int iCheckSumRight = 0;1658 1659 for (Int iCurVal = 0 ; iCurVal < ( 1 << REN_BIT_DEPTH ); iCurVal++)1660 {1661 iCheckSumLeft += aiHistLeft [iCurVal];1662 iCheckSumRight += aiHistRight[iCurVal];1663 }1664 1665 1666 while( iCurChangeVal < ( 1 << REN_BIT_DEPTH ) )1667 {1668 if ( iCumSumBase == iCumSumChange )1669 {1670 aiConvLUT[iCurChangeVal] = std::min( iCurBaseVal, ( 1 << REN_BIT_DEPTH ) - 1 );1671 iCurBaseVal ++;1672 iCurChangeVal++;1673 iCumSumChange += aiHistChange[iCurChangeVal];1674 if (iCurBaseVal < ( 1 << REN_BIT_DEPTH ) )1675 {1676 iCumSumBase += aiHistBase [iCurBaseVal] ;1677 }1678 }1679 else if ( iCumSumBase < iCumSumChange )1680 {1681 iCurBaseVal++;1682 if (iCurBaseVal < ( 1 << REN_BIT_DEPTH ) )1683 {1684 iCumSumBase += aiHistBase [iCurBaseVal] ;1685 }1686 }1687 else if ( iCumSumBase > iCumSumChange)1688 {1689 aiConvLUT[iCurChangeVal] = std::min(iCurBaseVal, ( 1 << REN_BIT_DEPTH )-1);1690 iCurChangeVal++;1691 iCumSumChange += aiHistChange [iCurChangeVal] ;1692 }1693 }1694 1695 Pel* pcChangeImageData = ( ( m_iSimEnhBaseView == 2 ) ? (*apcLeftPlane) : (*apcRightPlane) )->getPlaneData();1696 Int iChangeImageStride = ( ( m_iSimEnhBaseView == 2 ) ? (*apcLeftPlane) : (*apcRightPlane) )->getStride ();1697 1698 for (UInt uiYPos = 0; uiYPos < iHeight; uiYPos++ )1699 {1700 for (UInt uiXPos = 0; uiXPos < iWidth; uiXPos++ )1701 {1702 pcChangeImageData [uiXPos] = aiConvLUT[ pcChangeImageData[uiXPos]];1703 }1704 pcChangeImageData += iChangeImageStride;1705 }1706 1707 apcRightPlane ++;1708 apcLeftPlane ++;1709 1710 }1711 1712 delete[] aiHistLeft ;1713 delete[] aiHistRight;1714 delete[] aiConvLUT ;1715 }1716 1717 1718 Void TRenTop::xBlend( PelImage* pcLeftImage, PelImage* pcRightImage, PelImage* pcFilledLeft, PelImage* pcFilledRight, PelImage* pcLeftDepth, PelImage* pcRightDepth, PelImage* pcOutputImage )1719 {1720 UInt uiNumFullPlanes = pcLeftImage->getNumberOfFullPlanes();1721 UInt uiNumQuatPlanes = pcLeftImage->getNumberOfQuaterPlanes();1722 1723 assert( uiNumFullPlanes == pcRightImage->getNumberOfFullPlanes () && uiNumFullPlanes == pcOutputImage->getNumberOfFullPlanes ());1724 assert( uiNumQuatPlanes == pcRightImage->getNumberOfQuaterPlanes() && uiNumQuatPlanes == pcOutputImage->getNumberOfQuaterPlanes ());1725 1726 if (uiNumQuatPlanes > 0)1727 {1728 assert( pcLeftDepth ->getNumberOfPlanes() > 1 || pcFilledLeft ->getNumberOfPlanes() > 1);1729 assert( pcRightDepth->getNumberOfPlanes() > 1 || pcFilledRight->getNumberOfPlanes() > 1);1730 };1731 1732 switch (m_iBlendMode)1733 {1734 case eRenBlendAverg:1735 case eRenBlendDepthFirst:1736 xBlendPlanesAvg( pcLeftImage->getPlanes() , pcRightImage->getPlanes() , pcFilledLeft->getPlane(0), pcFilledRight->getPlane(0), pcLeftDepth->getPlane(0), pcRightDepth->getPlane(0), pcOutputImage->getPlanes(), uiNumFullPlanes);1737 if (uiNumQuatPlanes > 0)1738 {1739 xBlendPlanesAvg( pcLeftImage->getPlanes()+uiNumFullPlanes, pcRightImage->getPlanes()+uiNumFullPlanes, pcFilledLeft->getPlane(1), pcFilledRight->getPlane(1), pcLeftDepth->getPlane(1), pcRightDepth->getPlane(1), pcOutputImage->getPlanes()+uiNumFullPlanes, uiNumQuatPlanes);1740 }1741 break;1742 case eRenBlendLeft:1743 case eRenBlendRight:1744 xBlendPlanesOneView( pcLeftImage->getPlanes() , pcRightImage->getPlanes() , pcFilledLeft->getPlane(0), pcFilledRight->getPlane(0), pcLeftDepth->getPlane(0), pcRightDepth->getPlane(0), pcOutputImage->getPlanes(), uiNumFullPlanes);1745 if (uiNumQuatPlanes > 0)1746 {1747 xBlendPlanesOneView( pcLeftImage->getPlanes()+uiNumFullPlanes, pcRightImage->getPlanes()+uiNumFullPlanes, pcFilledLeft->getPlane(1), pcFilledRight->getPlane(1), pcLeftDepth->getPlane(1), pcRightDepth->getPlane(1), pcOutputImage->getPlanes()+uiNumFullPlanes, uiNumQuatPlanes);1748 }1749 break;1750 }1751 }1752 1753 Void TRenTop::xBlendPlanesOneView( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, PelImagePlane* pcLeftDepthPlane, PelImagePlane* pcRightDepthPlane, PelImagePlane** apcOutputImagePlane, UInt uiNumberOfPlanes )1754 {1755 for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++ )1756 {1757 Pel* pcFilledRightData = pcFilledRightPlane ->getPlaneData();1758 Pel* pcRightImageData = (*apcRightPlane ) ->getPlaneData();1759 Pel* pcRightDepthData = pcRightDepthPlane ->getPlaneData();1760 1761 Pel* pcFilledLeftData = pcFilledLeftPlane ->getPlaneData();1762 Pel* pcLeftImageData = (*apcLeftPlane) ->getPlaneData();1763 Pel* pcLeftDepthData = pcLeftDepthPlane ->getPlaneData();1764 Pel* pcOutputData = (*apcOutputImagePlane)->getPlaneData();1765 1766 for (UInt uiYPos = 0; uiYPos < (*apcOutputImagePlane)->getHeight(); uiYPos++ )1767 {1768 for (UInt uiXPos = 0; uiXPos < (*apcOutputImagePlane)->getWidth(); uiXPos++ )1769 {1770 if (m_iBlendMode == eRenBlendLeft )1771 {1772 if ( pcFilledLeftData[uiXPos] == REN_IS_FILLED || pcFilledRightData[uiXPos] == REN_IS_HOLE )1773 {1774 pcOutputData[uiXPos] = pcLeftImageData[uiXPos];1775 }1776 else if ( pcFilledLeftData[uiXPos] == REN_IS_HOLE )1777 {1778 pcOutputData[uiXPos] = pcRightImageData[uiXPos];1779 }1780 else1781 {1782 pcOutputData[uiXPos] = pcRightImageData[uiXPos] + (Pel) ( ( (Int) ( pcLeftImageData[uiXPos] - pcRightImageData[uiXPos] ) * pcFilledLeftData[uiXPos] + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC );1783 }1784 }1785 else if ( m_iBlendMode == eRenBlendRight )1786 {1787 if ( pcFilledRightData[uiXPos] == REN_IS_FILLED || pcFilledLeftData[uiXPos] == REN_IS_HOLE )1788 {1789 pcOutputData[uiXPos] = pcRightImageData[uiXPos];1790 }1791 else if ( pcFilledRightData[uiXPos] == REN_IS_HOLE )1792 {1793 pcOutputData[uiXPos] = pcLeftImageData[uiXPos];1794 }1795 else1796 {1797 pcOutputData[uiXPos] = pcLeftImageData[uiXPos] + (Pel) ( ( (Int) ( pcRightImageData[uiXPos] - pcLeftImageData[uiXPos] ) * pcFilledRightData[uiXPos] + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC );1798 }1799 }1800 else1801 {1802 AOT(true);1803 }1804 }1805 1806 pcFilledRightData += pcFilledRightPlane ->getStride();1807 pcRightImageData += (*apcRightPlane) ->getStride();1808 pcRightDepthData += pcRightDepthPlane ->getStride();1809 1810 pcFilledLeftData += pcFilledLeftPlane ->getStride();1811 pcLeftImageData += (*apcLeftPlane) ->getStride();1812 pcLeftDepthData += pcLeftDepthPlane ->getStride();1813 pcOutputData += (*apcOutputImagePlane)->getStride();1814 }1815 1816 apcRightPlane ++;1817 apcLeftPlane ++;1818 apcOutputImagePlane++;1819 }1820 }1821 1822 Void TRenTop::xBlendPlanesAvg( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, PelImagePlane* pcLeftDepthPlane, PelImagePlane* pcRightDepthPlane, PelImagePlane** apcOutputImagePlane, UInt uiNumberOfPlanes )1823 {1824 for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++ )1825 {1826 Pel* pcFilledRightData = pcFilledRightPlane ->getPlaneData();1827 Pel* pcRightVideoData = (*apcRightPlane ) ->getPlaneData();1828 Pel* pcRightDepthData = pcRightDepthPlane ->getPlaneData();1829 1830 Pel* pcFilledLeftData = pcFilledLeftPlane ->getPlaneData();1831 Pel* pcLeftVideoData = (*apcLeftPlane) ->getPlaneData();1832 Pel* pcLeftDepthData = pcLeftDepthPlane ->getPlaneData();1833 1834 Pel* pcOutputData = (*apcOutputImagePlane)->getPlaneData();1835 1836 for (UInt uiYPos = 0; uiYPos < (*apcOutputImagePlane)->getHeight(); uiYPos++ )1837 {1838 for (UInt uiXPos = 0; uiXPos < (*apcOutputImagePlane)->getWidth(); uiXPos++ )1839 {1840 if ( (pcFilledRightData[uiXPos] != REN_IS_HOLE ) && ( pcFilledLeftData[uiXPos] != REN_IS_HOLE) )1841 {1842 Int iDepthDifference = m_piInvZLUTLeft[RemoveBitIncrement(pcLeftDepthData[uiXPos])] - m_piInvZLUTRight[RemoveBitIncrement(pcRightDepthData[uiXPos])];1843 1844 if ( abs ( iDepthDifference ) <= m_iBlendZThres )1845 {1846 if ((pcFilledRightData[uiXPos] == REN_IS_FILLED) && ( pcFilledLeftData[uiXPos] != REN_IS_FILLED))1847 {1848 pcOutputData[uiXPos] = pcRightVideoData[uiXPos] + (Pel) ( ( (Int) ( pcLeftVideoData[uiXPos] - pcRightVideoData[uiXPos] ) * (pcFilledLeftData[uiXPos]) + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC );1849 }1850 else if ((pcFilledRightData[uiXPos] != REN_IS_FILLED) && ( pcFilledLeftData[uiXPos] == REN_IS_FILLED))1851 {1852 pcOutputData[uiXPos] = pcLeftVideoData[uiXPos] + (Pel) ( ( (Int) ( pcRightVideoData[uiXPos] - pcLeftVideoData[uiXPos] ) * (pcFilledRightData[uiXPos]) + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC );1853 }1854 else1855 {1856 pcOutputData[uiXPos] = pcLeftVideoData[uiXPos] + (Pel) ( ( (Int) ( pcRightVideoData[uiXPos] - pcLeftVideoData[uiXPos] ) * m_iBlendDistWeight + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC );1857 }1858 1859 }1860 else if ( iDepthDifference < 0 )1861 {1862 pcOutputData[uiXPos] = pcRightVideoData[uiXPos];1863 }1864 else1865 {1866 pcOutputData[uiXPos] = pcLeftVideoData[uiXPos];1867 }1868 }1869 else if ( (pcFilledRightData[uiXPos] == REN_IS_HOLE) && (pcFilledLeftData[uiXPos] == REN_IS_HOLE))1870 {1871 pcOutputData[uiXPos] = m_piInvZLUTLeft[RemoveBitIncrement( pcLeftDepthData[uiXPos])] < m_piInvZLUTRight[RemoveBitIncrement(pcRightDepthData[uiXPos])] ? pcLeftVideoData[uiXPos] : pcRightVideoData[uiXPos];1872 }1873 else1874 {1875 pcOutputData[uiXPos] = (pcFilledLeftData[uiXPos] == REN_IS_HOLE) ? pcRightVideoData[uiXPos] : pcLeftVideoData[uiXPos];1876 }1877 }1878 1879 pcFilledRightData += pcFilledRightPlane ->getStride();1880 pcRightVideoData += (*apcRightPlane) ->getStride();1881 pcRightDepthData += pcRightDepthPlane ->getStride();1882 1883 pcFilledLeftData += pcFilledLeftPlane ->getStride();1884 pcLeftVideoData += (*apcLeftPlane) ->getStride();1885 pcLeftDepthData += pcLeftDepthPlane ->getStride();1886 pcOutputData += (*apcOutputImagePlane)->getStride();1887 };1888 1889 apcRightPlane ++;1890 apcLeftPlane ++;1891 apcOutputImagePlane++;1892 }1893 }1894 1895 // Temporal Filter from Zhejiang University: (a little different from m16041: Temporal Improvement Method in View Synthesis)1896 Void TRenTop::temporalFilterVSRS( TComPicYuv* pcPicYuvVideoCur, TComPicYuv* pcPicYuvDepthCur, TComPicYuv* pcPicYuvVideoLast, TComPicYuv* pcPicYuvDepthLast, Bool bFirstFrame )1897 {1898 Int iSADThres = 100 ; //threshold of sad in 4*4 block motion detection1899 1900 Int iWidth = m_auiInputResolution[0];1901 Int iHeight = m_auiInputResolution[1];1902 1903 //internal variables1904 Int* piFlagMoving = m_aiBlkMoving + 2;1905 1906 Int iVideoCurStride = pcPicYuvVideoCur ->getStride( COMPONENT_Y );1907 Int iVideoLastStride = pcPicYuvVideoLast->getStride( COMPONENT_Y );1908 Int iDepthCurStride = pcPicYuvDepthCur ->getStride( COMPONENT_Y );1909 Int iDepthLastStride = pcPicYuvDepthLast->getStride( COMPONENT_Y );1910 1911 Pel* pcVideoCurData = pcPicYuvVideoCur ->getAddr( COMPONENT_Y );1912 Pel* pcVideoLastData = pcPicYuvVideoLast->getAddr( COMPONENT_Y );1913 Pel* pcDepthCurData = pcPicYuvDepthCur ->getAddr( COMPONENT_Y );1914 Pel* pcDepthLastData = pcPicYuvDepthLast->getAddr( COMPONENT_Y );1915 1916 Pel* pcVideoCurDataFrm = pcVideoCurData ;1917 Pel* pcVideoLastDataFrm = pcVideoLastData;1918 Pel* pcDepthCurDataFrm = pcDepthCurData ;1919 Pel* pcDepthLastDataFrm = pcDepthLastData;1920 1921 1922 if( !bFirstFrame ) // first frame need not the weighting, but need to prepare the data1923 {1924 for ( Int iPosY = 0; iPosY < (iHeight >> 2); iPosY++)1925 {1926 //motion detection by SAD1927 for ( Int iPosX = 0; iPosX < (iWidth >> 2); iPosX++)1928 {1929 Int iSAD = 0;1930 1931 Pel* pcVideoCurDataBlk = pcVideoCurDataFrm + (iPosX << 2);1932 Pel* pcVideoLastDataBlk = pcVideoLastDataFrm + (iPosX << 2);1933 1934 //GT: Check difference of block compared to last frame1935 for( Int iCurPosY = 0; iCurPosY < 4; iCurPosY++)1936 {1937 for( Int iCurPosX = 0; iCurPosX < 4; iCurPosX++)1938 {1939 iSAD += abs( pcVideoLastDataBlk[iCurPosX] - pcVideoCurDataBlk[iCurPosX] ); //SAD1940 }1941 pcVideoLastDataBlk += iVideoLastStride;1942 pcVideoCurDataBlk += iVideoCurStride;1943 }1944 1945 piFlagMoving[iPosX] = ( iSAD < iSADThres ) ? 0 : 1;1946 }1947 1948 //temporal weighting according to motion detection result -- do a line1949 for ( Int iPosX = 0; iPosX < (iWidth >> 2); iPosX++)1950 {1951 //5 block1952 Int iSumMoving = piFlagMoving[iPosX-2] + piFlagMoving[iPosX-1] + piFlagMoving[iPosX] + piFlagMoving[iPosX+1] + piFlagMoving[iPosX+2];1953 1954 if( iSumMoving == 0 ) // if not moving1955 {1956 Pel* pcDepthCurDataBlk = pcDepthCurDataFrm + (iPosX << 2);1957 Pel* pcDepthLastDataBlk = pcDepthLastDataFrm + (iPosX << 2);1958 1959 for( Int iCurPosY = 0; iCurPosY < 4; iCurPosY++)1960 {1961 for( Int iCurPosX = 0; iCurPosX < 4; iCurPosX++)1962 { //Weight: 0.751963 Int iFilt = (( (pcDepthLastDataBlk[iCurPosX] << 1 ) + pcDepthLastDataBlk[iCurPosX] + pcDepthCurDataBlk[iCurPosX] + 2 ) >> 2 );1964 assert( (iFilt >= 0) && (iFilt < ( 1 << REN_BIT_DEPTH ) ) );1965 pcDepthCurDataBlk[iCurPosX] = pcDepthLastDataBlk[iCurPosX];1966 pcDepthCurDataBlk[iCurPosX] = iFilt;1967 }1968 1969 pcDepthCurDataBlk += iDepthCurStride;1970 pcDepthLastDataBlk += iDepthLastStride;1971 }1972 }1973 }1974 1975 pcDepthCurDataFrm += ( iDepthCurStride << 2);1976 pcDepthLastDataFrm += ( iDepthLastStride << 2);1977 pcVideoCurDataFrm += ( iVideoCurStride << 2);1978 pcVideoLastDataFrm += ( iVideoLastStride << 2);1979 }1980 }1981 pcPicYuvVideoCur->copyToPic( pcPicYuvVideoLast );1982 pcPicYuvDepthCur->copyToPic( pcPicYuvDepthLast );1983 }1984 1985 TRenTop::TRenTop()1986 {1987 m_auiInputResolution[0] = 0;1988 m_auiInputResolution[1] = 0;1989 1990 // Sub Pel Rendering1991 m_iLog2SamplingFactor = 0;1992 1993 // ColorPlaneHandling1994 m_bUVUp = true;1995 1996 1997 //PreProcessing1998 m_iPreProcMode = eRenPreProNone;1999 m_iPreFilterSize = 2;2000 2001 // Interpolation2002 m_iInterpolationMode = eRenIntFullPel;2003 2004 // Sim Enhancement2005 m_iSimEnhBaseView = 0;2006 2007 // Blending2008 m_iBlendMode = eRenBlendAverg;2009 m_iBlendZThresPerc = -1;2010 m_bBlendUseDistWeight = false;2011 m_iBlendHoleMargin = -1;2012 2013 m_iBlendZThres = -1;2014 m_iBlendDistWeight = -1;2015 2016 // Hole Filling2017 m_iHoleFillingMode = eRenHFLWBackExt;2018 m_bInstantHoleFilling = false;2019 2020 // PostProcessing2021 m_iPostProcMode = eRenPostProNone;2022 2023 // Cut2024 m_auiCut[0] = 0;2025 m_auiCut[1] = 0;2026 2027 // Data2028 m_uiSampledWidth = -1;2029 2030 // LUTs2031 m_ppdShiftLUTLeft = 0;2032 m_ppdShiftLUTRight = 0;2033 2034 m_ppdShiftLUTRightMirror = new Double*[2];2035 m_ppdShiftLUTRightMirror[0] = new Double [257];2036 m_ppdShiftLUTRightMirror[1] = new Double [257];2037 2038 m_adShiftLUTCur = 0;2039 2040 m_ppiShiftLUTLeft = 0;2041 m_ppiShiftLUTRight = 0;2042 m_ppiShiftLUTRightMirror = new Int*[2];2043 m_ppiShiftLUTRightMirror[0] = new Int[257];2044 m_ppiShiftLUTRightMirror[1] = new Int[257];2045 2046 m_aiShiftLUTCur = 0;2047 m_piInvZLUTLeft = new Int[257];2048 m_piInvZLUTRight = new Int[257];2049 2050 // Buffers2051 m_pcLeftInputImage = 0;2052 m_pcLeftInputDepth = 0;2053 m_pcLeftOutputImage = 0;2054 m_pcLeftOutputDepth = 0;2055 m_pcLeftFilled = 0;2056 2057 m_pcRightInputImage = 0;2058 m_pcRightInputDepth = 0;2059 m_pcRightOutputImage = 0;2060 m_pcRightOutputDepth = 0;2061 m_pcRightFilled = 0;2062 2063 m_pcOutputImage = 0;2064 m_pcOutputDepth = 0;2065 2066 //Extrapolation2067 m_pcInputImage = 0;2068 m_pcInputDepth = 0;2069 m_pcFilled = 0;2070 2071 // SubPel2072 m_aaiSubPelShift = 0;2073 2074 // Temp2075 m_pcTempImage = 0;2076 2077 //Temporal Filter2078 m_aiBlkMoving = 0;2079 }2080 2081 2082 Void TRenTop::init(UInt uiImageWidth,2083 UInt uiImageHeight,2084 Bool bExtrapolate,2085 UInt uiLog2SamplingFactor,2086 Int iShiftLUTPrec,2087 Bool bUVUp,2088 Int iPreProcMode,2089 Int iPreFilterKernelSize,2090 Int iBlendMode,2091 Int iBlendZThresPerc,2092 Bool bBlendUseDistWeight,2093 Int iBlendHoleMargin,2094 Int iInterpolationMode,2095 Int iHoleFillingMode,2096 Int iPostProcMode,2097 Int iUsedPelMapMarExt2098 )2099 2100 {2101 // Shift LUT Prec2102 m_iRelShiftLUTPrec = iShiftLUTPrec - (Int) uiLog2SamplingFactor;2103 2104 // Sub Pel Rendering2105 m_iLog2SamplingFactor = uiLog2SamplingFactor;2106 2107 // Extrapolation ?2108 m_bExtrapolate = bExtrapolate;2109 2110 // ColorPlaneHandling2111 m_bUVUp = bUVUp;2112 2113 //PreProcessing2114 m_iPreProcMode = iPreProcMode;2115 m_iPreFilterSize = iPreFilterKernelSize;2116 2117 // Interpolation2118 m_iInterpolationMode = iInterpolationMode;2119 2120 //Blending2121 m_iBlendMode = iBlendMode;2122 m_iBlendZThresPerc = iBlendZThresPerc;2123 m_bBlendUseDistWeight = bBlendUseDistWeight;2124 m_iBlendHoleMargin = iBlendHoleMargin;2125 2126 // Hole Filling2127 m_iHoleFillingMode = iHoleFillingMode;2128 2129 m_bInstantHoleFilling = (m_iInterpolationMode == eRenInt8Tap ) && (m_iHoleFillingMode != 0 );2130 2131 // PostProcessing2132 m_iPostProcMode = iPostProcMode;2133 2134 // Used pel map2135 m_iUsedPelMapMarExt = iUsedPelMapMarExt;2136 2137 // Cut2138 m_auiCut[0] = 0;2139 m_auiCut[1] = 0;2140 2141 m_auiInputResolution[0] = uiImageWidth;2142 m_auiInputResolution[1] = uiImageHeight;2143 2144 if ( m_bExtrapolate )2145 {2146 PelImage* pcDump = 0;2147 xGetDataPointers( m_pcInputImage, m_pcOutputImage, m_pcInputDepth, pcDump, m_pcFilled, false );2148 }2149 else2150 {2151 xGetDataPointers(m_pcLeftInputImage, m_pcLeftOutputImage, m_pcLeftInputDepth, m_pcLeftOutputDepth, m_pcLeftFilled, true);2152 xGetDataPointers(m_pcRightInputImage, m_pcRightOutputImage, m_pcRightInputDepth, m_pcRightOutputDepth, m_pcRightFilled, true);2153 xGetDataPointerOutputImage(m_pcOutputImage, m_pcOutputDepth );2154 }2155 2156 m_pcTempImage = new PelImage( m_auiInputResolution[0],m_auiInputResolution[1],1,2);2157 2158 // SubPelShiftLUT2159 if (iInterpolationMode == eRenInt8Tap)2160 {2161 // SubPel Shift LUT2162 Int iNumEntries = (1 << ( m_iRelShiftLUTPrec + 1) ) + 1 ;2163 m_aaiSubPelShift = new Int*[ iNumEntries ];2164 for (UInt uiEntry = 0; uiEntry < iNumEntries; uiEntry++)2165 {2166 m_aaiSubPelShift[uiEntry] = new Int[ iNumEntries ];2167 }2168 2169 TRenFilter<REN_BIT_DEPTH>::setSubPelShiftLUT(m_iRelShiftLUTPrec, m_aaiSubPelShift, -1);2170 }2171 2172 // Zheijang temporal filter2173 m_aiBlkMoving = new Int[ ( m_auiInputResolution[0] >> 2 ) + 4 ];2174 m_aiBlkMoving[0] = 0;2175 m_aiBlkMoving[1] = 0;2176 m_aiBlkMoving[ ( m_auiInputResolution[0] >> 2 ) + 2 ] = 0;2177 m_aiBlkMoving[ ( m_auiInputResolution[0] >> 2 ) + 3 ] = 0;2178 }2179 2180 2181 TRenTop::~TRenTop()2182 {2183 if ( m_ppdShiftLUTRightMirror != NULL )2184 {2185 delete[] m_ppdShiftLUTRightMirror[0];2186 delete[] m_ppdShiftLUTRightMirror[1];2187 delete[] m_ppdShiftLUTRightMirror;2188 };2189 2190 if ( m_ppiShiftLUTRightMirror != NULL )2191 {2192 delete[] m_ppiShiftLUTRightMirror[0];2193 delete[] m_ppiShiftLUTRightMirror[1];2194 delete[] m_ppiShiftLUTRightMirror;2195 };2196 2197 if (m_piInvZLUTLeft != NULL ) delete[] m_piInvZLUTLeft ;2198 if (m_piInvZLUTLeft != NULL ) delete[] m_piInvZLUTRight ;2199 2200 if (m_pcLeftInputImage != NULL ) delete m_pcLeftInputImage ;2201 if (m_pcLeftInputDepth != NULL ) delete m_pcLeftInputDepth ;2202 if (m_pcLeftOutputImage != NULL ) delete m_pcLeftOutputImage ;2203 if (m_pcLeftOutputDepth != NULL ) delete m_pcLeftOutputDepth ;2204 if (m_pcLeftFilled != NULL ) delete m_pcLeftFilled ;2205 2206 if (m_pcRightInputImage != NULL ) delete m_pcRightInputImage ;2207 if (m_pcRightInputDepth != NULL ) delete m_pcRightInputDepth ;2208 if (m_pcRightOutputImage != NULL ) delete m_pcRightOutputImage;2209 if (m_pcRightOutputDepth != NULL ) delete m_pcRightOutputDepth;2210 if (m_pcRightFilled != NULL ) delete m_pcRightFilled ;2211 2212 if (m_pcOutputImage != NULL ) delete m_pcOutputImage ;2213 if (m_pcOutputDepth != NULL ) delete m_pcOutputDepth ;2214 2215 if (m_pcInputImage != NULL ) delete m_pcInputImage ;2216 if (m_pcInputDepth != NULL ) delete m_pcInputDepth ;2217 if (m_pcFilled != NULL ) delete m_pcFilled ;2218 2219 if (m_pcTempImage != NULL ) delete m_pcTempImage ;2220 2221 // SubPel LUT2222 if ( m_aaiSubPelShift != NULL)2223 {2224 Int iNumEntries = (1 << ( m_iRelShiftLUTPrec + 1) ) + 1;2225 for (UInt uiEntry = 0; uiEntry < iNumEntries; uiEntry++)2226 {2227 delete[] m_aaiSubPelShift[uiEntry];2228 }2229 delete[] m_aaiSubPelShift;2230 }2231 2232 // Zheijang temporal filter2233 if(m_aiBlkMoving != NULL ) delete[] m_aiBlkMoving;2234 }2235 #endif // NH_3D2236 -
branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenTop.h
r1386 r1390 39 39 #include "../TLibCommon/TComPicYuv.h" 40 40 41 #if NH_3D_VSO42 #include <list>43 #include <vector>44 45 using namespace std;46 47 class TRenTop48 {49 // ENUM Modes50 51 52 // Interpolation Modes53 54 enum { eRenIntFullPel = 0, eRenIntLinInt = 1, eRenIntLinReal = 2, eRenIntFEM = 3, eRenInt8Tap = 4 };55 56 // HoleFilling57 enum { eRenHFNone = 0, eRenHFLWBackExt = 1};58 59 // Pre-Processing60 enum { eRenPreProNone = 0, eRenPreProBinom = 1};61 62 // Post-Processing63 enum { eRenPostProNone = 0, eRenPostProMed = 1};64 65 // Merging66 enum { eRenBlendAverg = 0, eRenBlendLeft = 1, eRenBlendRight = 2, eRenBlendDepthFirst = 5 };67 68 public:69 TRenTop();70 ~TRenTop();71 72 // Init73 Void init ( UInt uiImageWitdh,74 UInt uiImageHeight,75 Bool bExtrapolate,76 UInt uiLog2SamplingFactor,77 Int iLUTPrec,78 Bool bUVUp,79 Int iPreProcMode,80 Int iPreFilterKernelSize,81 Int iBlendMode,82 Int iBlendZThresPerc,83 Bool bBlendUseDistWeight,84 Int iBlendHoleMargin,85 Int iInterpolationMode,86 Int iHoleFillingMode,87 Int iPostProcMode,88 Int iUsedPelMapMarExt );89 90 Void setShiftLUTs ( Double** ppdShiftLUTLeft,91 Int** ppiShiftLUTLeft,92 Int** ppiBaseShiftLUTLeft,93 Double** ppdShiftLUTRight,94 Int** ppiShiftLUTRight,95 Int** ppiBaseShiftLUTRight,96 Int iRelDistLeft );97 98 // View Synthesis99 Void extrapolateView ( TComPicYuv* pcPicYuvVideo,100 TComPicYuv* pcPicYuvDepth,101 TComPicYuv* pcPicYuvSynthOut,102 Bool bRenderFromLeft );103 104 Void interpolateView ( TComPicYuv* pcPicYuvVideoLeft,105 TComPicYuv* pcPicYuvDepthLeft,106 TComPicYuv* pcPicYuvVideoRight,107 TComPicYuv* pcPicYuvDepthRight,108 TComPicYuv* pcPicYuvSynthOut,109 Int iBlendMode,110 Int iSimEnhBaseView );111 // Tools112 Void getUsedSamplesMap ( TComPicYuv* pcPicYuvDepth,113 TComPicYuv* pcUsedSampleMap,114 Bool bRenderFromLeft );115 116 // Zhejiang Temporal Improvement117 Void temporalFilterVSRS( TComPicYuv* pcPicYuvVideoCur,118 TComPicYuv* pcPicYuvDepthCur,119 TComPicYuv* pcPicYuvVideoLast,120 TComPicYuv* pcPicYuvDepthLast,121 Bool bFirstFrame );122 123 private:124 // Depth PreProcessing125 Void xPreProcessDepth(PelImage* pcInImage, PelImage* pcOutImage);126 127 // Pixel Shifting128 Void xShiftPixels ( PelImage* pcInImage, PelImage* pcDepth , PelImage* pcOutImage , PelImage* pcFilledImage, Bool bShiftFromLeft );129 Void xShiftPlanePixels ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcPlaneFilled, UInt uiNumberOfPlanes);130 Void xShiftPlanePixelsLinReal ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcPlaneFilled, UInt uiNumberOfPlanes);131 Void xShiftPlanePixelsFullPel ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcPlaneFilled, UInt uiNumberOfPlanes);132 Void xShiftPlanePixelsLinInt ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes);133 Void xShiftPlanePixels8Tap ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes);134 135 Void xBackShiftPixels ( PelImage* pcInImage, PelImage* pcDepth , PelImage* pcOutImage, PelImage* pcFilledImage, Bool bShiftFromLeft );136 Void xBackShiftPlanePixels ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes );137 138 Int xCeil ( Int iVal ) { return (( iVal + ( (1 << m_iRelShiftLUTPrec) - 1 ) ) >> m_iRelShiftLUTPrec); }139 140 // Hole Filling141 Void xFillHoles ( PelImage* pcInImage, PelImage* pcFilled, PelImage* pcOutImage , Bool bRenderFromLeft );142 Void xFillLWBackExt ( PelImage* pcInImage, PelImage* pcFilled, PelImage* pcOutImage , Bool bRenderFromLeft );143 Void xFillPlaneHoles ( PelImagePlane** apcInputPlanes, PelImagePlane* pcPlaneFilled, PelImagePlane** apcOutputPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft );144 145 // Alpha Map Creation146 Void xCreateAlphaMap (PelImage* pcFilledImage, PelImage* pcAlphaMapImage, Bool bRenderFromLeft );147 Void xCreateAlphaMapPlane (PelImagePlane** apcFilledPlanes, PelImagePlane** apcAlphaPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft);148 149 // BoundaryNoiseErosion150 Void xRemBoundaryNoise ( PelImage* pcInImage, PelImage* pcFilled, PelImage* pcOutImage , Bool bRenderFromLeft );151 Void xRemBoundaryNoisePlane ( PelImagePlane** apcInputPlanes, PelImagePlane* pcPlaneFilled, PelImagePlane** apcOutputPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft );152 153 // Similarity Enhancement154 Void xEnhSimilarity ( PelImage* pcLeftImage, PelImage* pcRightImage, PelImage* pcFilledLeft, PelImage* pcFilledRight );155 Void xEnhSimilarityPlane ( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, UInt uNumPlanes );156 157 // View Blending158 Void xBlend ( PelImage* pcLeftImage, PelImage* pcRightImage, PelImage* pcFilledLeft, PelImage* pcFilledRight, PelImage* pcLeftDepth, PelImage* pcRightDepth, PelImage* pcOutputImage);159 Void xBlendPlanesAvg ( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, PelImagePlane* pcLeftDepthPlane, PelImagePlane* pcRightDepthPlane, PelImagePlane** apcOutputImagePlane, UInt uNumPlanes );160 Void xBlendPlanesOneView ( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, PelImagePlane* pcLeftDepthPlane, PelImagePlane* pcRightDepthPlane, PelImagePlane** apcOutputImagePlane, UInt uNumPlanes );161 162 // PostProcessing163 Void xCutMargin ( PelImage* pcInputImage );164 Void xCutPlaneMargin ( PelImagePlane* pcImagePlane, Pel cFill, UInt uiScale);165 Void xPostProcessImage ( PelImage* pcInImage, PelImage* pCOutImage);166 167 // Input Output Data Conversion168 Void xConvertInputData ( PelImage* pcOrgInputImage, PelImage* pcOrgInputDepth, PelImage* pcConvInputImage, PelImage* pcConvInputDepth, Bool bMirror);169 Void xConvertOutputData ( PelImage* pOrgOutputImage, PelImage* pConvOutputImage, Bool bMirror);170 171 Void xGetDataPointers ( PelImage*& rpcInputImage, PelImage*& rpcOutputImage, PelImage*& rpcInputDepth, PelImage*& rpcOutputDepth, PelImage*& rpcFilled, Bool bRenderDepth );172 Void xGetDataPointerOutputImage( PelImage*& rpcOutputImage, PelImage*& rpcOutputDepth );173 174 Void xConvertInputVideo ( PelImage* pcOrgInputImage, PelImage* pcConvInputImage);175 Void xConvertInputDepth ( PelImage* pcOrgInputImage, PelImage* pcConvInputImage);176 177 178 // Data179 UInt m_uiSampledWidth; // Width after UPsampling180 181 // Resolution of input view182 UInt m_auiInputResolution[2];183 184 // Extrapolation185 Bool m_bExtrapolate;186 187 // Input Conversion188 Int m_iLog2SamplingFactor;189 Bool m_bUVUp;190 191 // PreProcessing192 Int m_iPreProcMode; //0: none, 1: binominal193 Int m_iPreFilterSize; // Half size194 195 // Similarity Enhancement196 Int m_iSimEnhBaseView; // 0: none, 1: left, 2: right197 198 // Blending199 Int m_iBlendMode; // 0: average;200 Int m_iBlendZThresPerc; // in percent of total depth201 Bool m_bBlendUseDistWeight; // use weighting depending on viewing distance202 Int m_iBlendHoleMargin; // blending margin next to holes203 204 Int m_iBlendZThres; // absoluteInt m_iBlendWeight;205 Int m_iBlendDistWeight; // Weight for view distance depending blending206 207 // Interpolation208 Int m_iInterpolationMode; //0: none; 1: Linear (Double), 2: FEM (Double)209 210 // Hole Filling211 Int m_iHoleFillingMode; //0: none; 1: LW Background extension212 Int m_bInstantHoleFilling; // perform hole filling while pixel shifting ( only supported for interpolation mode 4 )213 214 // Post Processing215 Int m_iPostProcMode; //0: none; 1: Median216 217 // Precision in LUT218 Int m_iRelShiftLUTPrec;219 220 // Cut221 UInt m_auiCut[2];222 223 // Look up tables Shift224 Double** m_ppdShiftLUTLeft;225 Double** m_ppdShiftLUTRight;226 Double** m_ppdShiftLUTRightMirror; // For rendering the mirrored view227 Double* m_adShiftLUTCur;228 229 Int** m_ppiShiftLUTLeft;230 Int** m_ppiShiftLUTRight;231 Int** m_ppiShiftLUTRightMirror; // For rendering the mirrored view232 Int* m_aiShiftLUTCur;233 234 // Look up tables Z235 Int* m_piInvZLUTLeft; // Look up table entry is proportional to Z236 Int* m_piInvZLUTRight;237 238 // Look up tables sub pel shift239 Int** m_aaiSubPelShift;240 241 // Zhejiang Temporal Improvement242 Int* m_aiBlkMoving;243 244 // Used pel map generation245 Int m_iUsedPelMapMarExt;246 247 // Buffers248 249 // Interpolation250 PelImage* m_pcLeftInputImage ;251 PelImage* m_pcLeftInputDepth ;252 PelImage* m_pcLeftOutputImage ;253 PelImage* m_pcLeftOutputDepth ;254 PelImage* m_pcLeftFilled ;255 PelImage* m_pcRightInputImage ;256 PelImage* m_pcRightInputDepth ;257 PelImage* m_pcRightOutputImage;258 PelImage* m_pcRightOutputDepth;259 PelImage* m_pcRightFilled ;260 PelImage* m_pcOutputImage ;261 PelImage* m_pcOutputDepth ;262 263 // Extrapolation264 PelImage* m_pcInputImage ;265 PelImage* m_pcInputDepth ;266 PelImage* m_pcFilled ;267 268 //Temp269 PelImage* m_pcTempImage ;270 };271 272 #endif // NH_3D273 41 #endif //__TRENTOP__
Note: See TracChangeset for help on using the changeset viewer.