[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2011, ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
[2] | 33 | |
---|
[5] | 34 | |
---|
[2] | 35 | #include "TRenImage.h" |
---|
| 36 | #include "TRenTop.h" |
---|
| 37 | |
---|
| 38 | #include "TRenFilter.h" |
---|
| 39 | #include <iostream> |
---|
| 40 | #include <math.h> |
---|
| 41 | #include "../TLibCommon/CommonDef.h" |
---|
| 42 | |
---|
| 43 | Void TRenTop::xGetDataPointers( PelImage*& rpcInputImage, PelImage*& rpcOutputImage, PelImage*& rpcInputDepth, PelImage*& rpcOutputDepth, PelImage*& rpcFilled, Bool bRenderDepth ) |
---|
| 44 | { |
---|
| 45 | UInt uiWidth = m_auiInputResolution[0] << m_iLog2SamplingFactor; |
---|
| 46 | |
---|
| 47 | UInt uiSubPelWidth = uiWidth; |
---|
| 48 | |
---|
| 49 | if ( m_iInterpolationMode == eRenInt8Tap ) |
---|
| 50 | { |
---|
| 51 | uiSubPelWidth <<= m_iRelShiftLUTPrec; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | UInt uiHeight = m_auiInputResolution[1]; |
---|
| 55 | |
---|
| 56 | if ( m_bUVUp ) |
---|
| 57 | { |
---|
| 58 | rpcInputDepth = new PelImage(uiSubPelWidth, uiHeight,1,0); |
---|
| 59 | rpcInputImage = new PelImage(uiSubPelWidth, uiHeight,3,0); |
---|
| 60 | rpcOutputImage = new PelImage(uiWidth, uiHeight,3,0); |
---|
| 61 | rpcOutputDepth = bRenderDepth ? new PelImage(uiWidth, uiHeight,1,0) : 0; |
---|
| 62 | rpcFilled = new PelImage(uiWidth, uiHeight,1,0); |
---|
| 63 | } |
---|
| 64 | else |
---|
| 65 | { |
---|
| 66 | rpcInputDepth = new PelImage(uiSubPelWidth, uiHeight,1,1); |
---|
| 67 | rpcInputImage = new PelImage(uiSubPelWidth, uiHeight,1,2); |
---|
| 68 | rpcOutputImage = new PelImage(uiWidth, uiHeight,1,2); |
---|
| 69 | rpcOutputDepth = bRenderDepth ? new PelImage(uiWidth, uiHeight,1,1) : 0; |
---|
| 70 | rpcFilled = new PelImage(uiWidth, uiHeight,1,1); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | Void TRenTop::xGetDataPointerOutputImage( PelImage*& rpcOutputImage, PelImage*& rpcOutputDepth ) |
---|
| 76 | { |
---|
| 77 | |
---|
| 78 | UInt uiWidth = m_auiInputResolution[0] << m_iLog2SamplingFactor; |
---|
| 79 | UInt uiHeight = m_auiInputResolution[1]; |
---|
| 80 | |
---|
| 81 | if ( m_bUVUp ) |
---|
| 82 | { |
---|
| 83 | rpcOutputImage = new PelImage(uiWidth, uiHeight,3,0); |
---|
| 84 | rpcOutputDepth = (m_iBlendMode == eRenBlendDepthFirst ) ? new PelImage(uiWidth, uiHeight,1,0) : NULL; |
---|
| 85 | } |
---|
| 86 | else |
---|
| 87 | { |
---|
| 88 | rpcOutputImage = new PelImage(uiWidth, uiHeight,1,2); |
---|
| 89 | rpcOutputDepth = (m_iBlendMode == eRenBlendDepthFirst ) ? new PelImage(uiWidth, uiHeight,1,1) : NULL; |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | Void TRenTop::xConvertInputVideo( PelImage* pcOrgInputImage, PelImage* pcConvInputImage) |
---|
| 94 | { |
---|
| 95 | TRenImagePlane<Pel>* pcOrgPlane ; |
---|
| 96 | TRenImagePlane<Pel>* pcConvPlane; |
---|
| 97 | |
---|
| 98 | Int iLog2SamplingFactor = m_iLog2SamplingFactor; |
---|
| 99 | |
---|
| 100 | if ( m_iInterpolationMode == eRenInt8Tap) |
---|
| 101 | { |
---|
| 102 | iLog2SamplingFactor += m_iRelShiftLUTPrec; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | AOT( iLog2SamplingFactor > 2); |
---|
| 106 | |
---|
| 107 | for (UInt uiPlane = 0; uiPlane < 3; uiPlane++) |
---|
| 108 | { |
---|
| 109 | pcOrgPlane = pcOrgInputImage ->getPlane(uiPlane); |
---|
| 110 | pcConvPlane = pcConvInputImage->getPlane(uiPlane); |
---|
| 111 | |
---|
| 112 | if (uiPlane == 0) |
---|
| 113 | { |
---|
| 114 | TRenFilter::sampleHorUp ( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride()); |
---|
| 115 | } |
---|
| 116 | else |
---|
| 117 | { |
---|
| 118 | if ( m_bUVUp ) |
---|
| 119 | { |
---|
| 120 | TRenFilter::sampleCUpHorUp( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride()); |
---|
| 121 | } |
---|
| 122 | else |
---|
| 123 | { |
---|
| 124 | TRenFilter::sampleCHorUp ( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride()); |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | Void TRenTop::xConvertInputDepth( PelImage* pcOrgInputImage, PelImage* pcConvInputImage) |
---|
| 131 | { |
---|
| 132 | PelImagePlane* pcOrgPlane ; |
---|
| 133 | PelImagePlane* pcConvPlane; |
---|
| 134 | |
---|
| 135 | // Full Plane |
---|
| 136 | pcOrgPlane = pcOrgInputImage ->getPlane(0); |
---|
| 137 | pcConvPlane = pcConvInputImage->getPlane(0); |
---|
| 138 | |
---|
| 139 | Int iLog2SamplingFactor = m_iLog2SamplingFactor; |
---|
| 140 | |
---|
| 141 | if ( m_iInterpolationMode == eRenInt8Tap) |
---|
| 142 | { |
---|
| 143 | iLog2SamplingFactor += m_iRelShiftLUTPrec; |
---|
| 144 | } |
---|
| 145 | AOT( iLog2SamplingFactor > 2); |
---|
| 146 | |
---|
| 147 | TRenFilter::sampleHorUp(iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride()); |
---|
| 148 | |
---|
| 149 | if ( !m_bUVUp ) //GT: depth down |
---|
| 150 | { |
---|
| 151 | // Quarter Plane |
---|
| 152 | PelImagePlane* pcTempPlane = new PelImagePlane(pcOrgInputImage->getPlane(0)->getWidth(), ( pcOrgInputImage->getPlane(0)->getHeight() >> 1), REN_LUMA_MARGIN ); |
---|
| 153 | |
---|
| 154 | TRenFilter::sampleVerDown2Tap13(pcOrgInputImage->getPlane(0), pcTempPlane, 12); |
---|
| 155 | pcConvPlane = pcConvInputImage->getPlane(1); |
---|
| 156 | |
---|
| 157 | if ( iLog2SamplingFactor == 0 ) |
---|
| 158 | { |
---|
| 159 | TRenFilter::sampleHorDown2Tap13(pcTempPlane, pcConvPlane, 0 ); |
---|
| 160 | } |
---|
| 161 | else |
---|
| 162 | { |
---|
| 163 | TRenFilter::sampleHorUp ( iLog2SamplingFactor - 1, pcTempPlane->getPlaneData(), pcTempPlane->getStride(), pcTempPlane->getWidth(), pcTempPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride()); |
---|
| 164 | } |
---|
| 165 | delete pcTempPlane; |
---|
| 166 | } |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | Void TRenTop::xConvertInputData( PelImage* pcOrgInputImage, PelImage* pcOrgInputDepth, PelImage* pcConvInputImage, PelImage* pcConvInputDepth, Bool bMirror ) |
---|
| 170 | { |
---|
| 171 | //ToDo: remove unnecessary copying |
---|
| 172 | if ( bMirror ) |
---|
| 173 | { |
---|
| 174 | m_pcTempImage->assign( pcOrgInputImage ); |
---|
| 175 | TRenFilter::mirrorHor( m_pcTempImage ); |
---|
| 176 | m_pcTempImage->extendMargin(); |
---|
| 177 | xConvertInputVideo( m_pcTempImage, pcConvInputImage ); |
---|
| 178 | |
---|
| 179 | m_pcTempImage->getPlane(0)->assign( pcOrgInputDepth->getPlane(0) ); |
---|
| 180 | TRenFilter::mirrorHor( m_pcTempImage->getPlane(0) ); |
---|
| 181 | m_pcTempImage->getPlane(0)->extendMargin(); |
---|
| 182 | xConvertInputDepth( m_pcTempImage, pcConvInputDepth ); |
---|
| 183 | } |
---|
| 184 | else |
---|
| 185 | { |
---|
| 186 | m_pcTempImage->assign( pcOrgInputImage ); |
---|
| 187 | m_pcTempImage->extendMargin(); |
---|
| 188 | xConvertInputVideo( m_pcTempImage, pcConvInputImage ); |
---|
| 189 | |
---|
| 190 | m_pcTempImage->getPlane(0)->assign( pcOrgInputDepth->getPlane(0) ); |
---|
| 191 | m_pcTempImage->getPlane(0)->extendMargin(); |
---|
| 192 | xConvertInputDepth( m_pcTempImage, pcConvInputDepth ); |
---|
| 193 | } |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | Void TRenTop::xConvertOutputData( PelImage* pcOrgOutputImage, PelImage* pcConvOutputImage, Bool bMirror ) |
---|
| 198 | { |
---|
| 199 | Int iLog2SamplingFactor = m_iLog2SamplingFactor; |
---|
| 200 | |
---|
| 201 | for ( UInt uiPlane = 0; uiPlane < 3; uiPlane++) |
---|
| 202 | { |
---|
| 203 | PelImagePlane* pcOrgPlane = pcOrgOutputImage ->getPlane(uiPlane); |
---|
| 204 | PelImagePlane* pcConvPlane = pcConvOutputImage->getPlane(uiPlane); |
---|
| 205 | |
---|
| 206 | pcOrgPlane->extendMargin(); |
---|
| 207 | |
---|
| 208 | if ( uiPlane == 0 ) |
---|
| 209 | { |
---|
| 210 | TRenFilter::sampleHorDown( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride()); |
---|
| 211 | } |
---|
| 212 | else |
---|
| 213 | { |
---|
| 214 | if ( m_bUVUp ) |
---|
| 215 | { |
---|
| 216 | TRenFilter::sampleCDownHorDown( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride()); |
---|
| 217 | } |
---|
| 218 | else |
---|
| 219 | { |
---|
| 220 | TRenFilter::sampleCHorDown ( iLog2SamplingFactor, pcOrgPlane->getPlaneData(), pcOrgPlane->getStride(), pcOrgPlane->getWidth(), pcOrgPlane->getHeight(), pcConvPlane->getPlaneData(), pcConvPlane->getStride()); |
---|
| 221 | } |
---|
| 222 | } |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | if ( bMirror ) |
---|
| 226 | { |
---|
| 227 | TRenFilter::mirrorHor( pcConvOutputImage ); |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | Void TRenTop::setShiftLUTs( Double** ppdShiftLUTLeft, Int** ppiShiftLUTLeft, Int** ppiBaseShiftLUTLeft, Double** ppdShiftLUTRight, Int** ppiShiftLUTRight, Int** ppiBaseShiftLUTRight, Int iRelDistToLeft ) |
---|
| 233 | { |
---|
| 234 | m_ppdShiftLUTLeft = ppdShiftLUTLeft; |
---|
| 235 | m_ppdShiftLUTRight = ppdShiftLUTRight; |
---|
| 236 | |
---|
| 237 | m_ppiShiftLUTLeft = ppiShiftLUTLeft; |
---|
| 238 | m_ppiShiftLUTRight = ppiShiftLUTRight; |
---|
| 239 | |
---|
| 240 | if ( m_ppdShiftLUTRight != NULL && m_ppiShiftLUTRight != NULL ) |
---|
| 241 | { |
---|
| 242 | for( UInt uiPlane = 0; uiPlane < 2; uiPlane++) |
---|
| 243 | { |
---|
| 244 | for (UInt uiDepthValue = 0; uiDepthValue <= 256; uiDepthValue++) |
---|
| 245 | { |
---|
| 246 | m_ppdShiftLUTRightMirror[uiPlane][uiDepthValue] = - m_ppdShiftLUTRight[uiPlane][uiDepthValue]; |
---|
| 247 | m_ppiShiftLUTRightMirror[uiPlane][uiDepthValue] = - m_ppiShiftLUTRight[uiPlane][uiDepthValue]; |
---|
| 248 | } |
---|
| 249 | } |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | if ( !m_bExtrapolate ) |
---|
| 253 | { |
---|
| 254 | TRenFilter::setupZLUT( m_bBlendUseDistWeight, m_iBlendZThresPerc, iRelDistToLeft, ppiBaseShiftLUTLeft, ppiBaseShiftLUTRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight); |
---|
| 255 | } |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | Void TRenTop::extrapolateView( TComPicYuv* pcPicYuvVideo, TComPicYuv* pcPicYuvDepth, TComPicYuv* pcPicYuvSynthOut, Bool bRenderFromLeft ) |
---|
| 259 | { |
---|
| 260 | AOF( m_bExtrapolate ); |
---|
| 261 | AOF( bRenderFromLeft ? m_ppiShiftLUTLeft || m_ppdShiftLUTLeft : m_ppiShiftLUTRight || m_ppdShiftLUTRight ); |
---|
| 262 | AOF( m_auiInputResolution[0] == pcPicYuvVideo->getWidth ()); |
---|
| 263 | AOF( m_auiInputResolution[1] == pcPicYuvVideo->getHeight()); |
---|
| 264 | |
---|
| 265 | PelImage cInputImage ( pcPicYuvVideo ); |
---|
| 266 | PelImage cInputDepth ( pcPicYuvDepth , true); |
---|
| 267 | PelImage cOutputImage( pcPicYuvSynthOut ); |
---|
| 268 | |
---|
| 269 | m_pcOutputImage->init(); |
---|
| 270 | m_pcFilled ->assign(REN_IS_HOLE); |
---|
| 271 | |
---|
| 272 | xPreProcessDepth ( &cInputDepth, &cInputDepth); |
---|
| 273 | xConvertInputData( &cInputImage, &cInputDepth, m_pcInputImage, m_pcInputDepth, !bRenderFromLeft ); |
---|
| 274 | xShiftPixels(m_pcInputImage, m_pcInputDepth, m_pcOutputImage, m_pcFilled, bRenderFromLeft); |
---|
| 275 | xRemBoundaryNoise ( m_pcOutputImage, m_pcFilled, m_pcOutputImage, bRenderFromLeft); // Erode |
---|
| 276 | xFillHoles ( m_pcOutputImage, m_pcFilled, m_pcOutputImage, bRenderFromLeft); |
---|
| 277 | xConvertOutputData( m_pcOutputImage, &cOutputImage, !bRenderFromLeft ); |
---|
| 278 | xPostProcessImage (&cOutputImage, &cOutputImage); |
---|
| 279 | xCutMargin ( &cOutputImage ); |
---|
| 280 | }; |
---|
| 281 | |
---|
| 282 | Void TRenTop::getUsedSamplesMap( TComPicYuv* pcPicYuvDepth, TComPicYuv* pcUsedSampleMap, Bool bRenderFromLeft ) |
---|
| 283 | { |
---|
| 284 | AOF( bRenderFromLeft ? m_ppiShiftLUTLeft && m_ppdShiftLUTLeft : m_ppiShiftLUTRight && m_ppdShiftLUTRight ); |
---|
| 285 | AOF(m_auiInputResolution[0] == pcPicYuvDepth->getWidth ()); |
---|
| 286 | AOF(m_auiInputResolution[1] == pcPicYuvDepth->getHeight()); |
---|
| 287 | |
---|
| 288 | PelImage cInputDepth ( pcPicYuvDepth , true); |
---|
| 289 | PelImage cOutputImage( pcUsedSampleMap ); |
---|
| 290 | PelImage cInputImage ( m_auiInputResolution[0], m_auiInputResolution[1], 1, 2 ); |
---|
| 291 | cInputImage.assign(0); |
---|
| 292 | |
---|
| 293 | m_pcFilled ->assign(REN_IS_HOLE); |
---|
| 294 | xConvertInputData( &cInputImage, &cInputDepth, m_pcInputImage, m_pcInputDepth, !bRenderFromLeft ); |
---|
| 295 | xShiftPixels (m_pcInputImage, m_pcInputDepth, m_pcOutputImage, m_pcFilled, bRenderFromLeft); |
---|
| 296 | |
---|
| 297 | xCreateAlphaMap ( m_pcFilled, m_pcFilled, bRenderFromLeft ); |
---|
| 298 | |
---|
| 299 | if ( !bRenderFromLeft ) |
---|
| 300 | { |
---|
| 301 | TRenFilter::mirrorHor( m_pcFilled ); |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | TRenFilter::filledToUsedPelMap( m_pcFilled, &cOutputImage, m_iUsedPelMapMarExt ); |
---|
| 305 | }; |
---|
| 306 | |
---|
| 307 | |
---|
| 308 | Void TRenTop::interpolateView( TComPicYuv* pcPicYuvVideoLeft, TComPicYuv* pcPicYuvDepthLeft, TComPicYuv* pcPicYuvVideoRight, TComPicYuv* pcPicYuvDepthRight, TComPicYuv* pcPicYuvSynthOut, Int iBlendMode, Int iSimEnhBaseView ) |
---|
| 309 | { |
---|
| 310 | assert( !m_bExtrapolate ); |
---|
| 311 | assert( m_auiInputResolution[0] == pcPicYuvVideoLeft ->getWidth () ); |
---|
| 312 | assert( m_auiInputResolution[1] == pcPicYuvVideoRight->getHeight() ); |
---|
| 313 | |
---|
| 314 | AOT( iBlendMode == 3); |
---|
| 315 | m_iBlendMode = iBlendMode; |
---|
| 316 | m_iSimEnhBaseView = iSimEnhBaseView; |
---|
| 317 | |
---|
| 318 | PelImage cLeftInputImage ( pcPicYuvVideoLeft ); |
---|
| 319 | PelImage cLeftInputDepth ( pcPicYuvDepthLeft, true ); |
---|
| 320 | PelImage cRightInputImage ( pcPicYuvVideoRight ); |
---|
| 321 | PelImage cRightInputDepth ( pcPicYuvDepthRight , true ); |
---|
| 322 | PelImage cOutputImage ( pcPicYuvSynthOut ); |
---|
| 323 | |
---|
| 324 | m_pcLeftOutputImage ->init(); |
---|
| 325 | m_pcRightOutputImage->init(); |
---|
| 326 | m_pcOutputImage ->init(); |
---|
| 327 | |
---|
| 328 | if ( m_iBlendMode == eRenBlendDepthFirst ) |
---|
| 329 | { |
---|
| 330 | m_pcOutputDepth->init(); |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | m_pcLeftFilled ->assign(REN_IS_HOLE); |
---|
| 334 | m_pcRightFilled->assign(REN_IS_HOLE); |
---|
| 335 | |
---|
| 336 | xPreProcessDepth(&cLeftInputDepth , &cLeftInputDepth ); |
---|
| 337 | xPreProcessDepth(&cRightInputDepth, &cRightInputDepth); |
---|
| 338 | |
---|
| 339 | xConvertInputData( &cLeftInputImage, &cLeftInputDepth, m_pcLeftInputImage, m_pcLeftInputDepth ,false ); |
---|
| 340 | xConvertInputData( &cRightInputImage, &cRightInputDepth, m_pcRightInputImage, m_pcRightInputDepth ,true ); |
---|
| 341 | |
---|
| 342 | // Render from Left View to Right view |
---|
| 343 | if ( m_iBlendMode != eRenBlendDepthFirst ) |
---|
| 344 | { |
---|
| 345 | xShiftPixels(m_pcLeftInputImage, m_pcLeftInputDepth, m_pcLeftOutputImage, m_pcLeftFilled, true ); |
---|
| 346 | xFillHoles (m_pcLeftOutputImage, m_pcLeftFilled, m_pcLeftOutputImage, true ); |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | xShiftPixels(m_pcLeftInputDepth, m_pcLeftInputDepth, m_pcLeftOutputDepth, m_pcLeftFilled, true ); |
---|
| 350 | xFillHoles ( m_pcLeftOutputDepth, m_pcLeftFilled, m_pcLeftOutputDepth, true); |
---|
| 351 | xCreateAlphaMap( m_pcLeftFilled, m_pcLeftFilled, true ); |
---|
| 352 | |
---|
| 353 | // Render from Right View to Left view |
---|
| 354 | if ( m_iBlendMode != eRenBlendDepthFirst ) |
---|
| 355 | { |
---|
| 356 | xShiftPixels(m_pcRightInputImage , m_pcRightInputDepth, m_pcRightOutputImage, m_pcRightFilled, false ); |
---|
| 357 | xFillHoles (m_pcRightOutputImage, m_pcRightFilled, m_pcRightOutputImage, false); |
---|
| 358 | } |
---|
| 359 | |
---|
| 360 | xShiftPixels(m_pcRightInputDepth, m_pcRightInputDepth, m_pcRightOutputDepth, m_pcRightFilled, false); |
---|
| 361 | xFillHoles ( m_pcRightOutputDepth, m_pcRightFilled, m_pcRightOutputDepth, false); |
---|
| 362 | xCreateAlphaMap( m_pcRightFilled, m_pcRightFilled, false ); |
---|
| 363 | |
---|
| 364 | TRenFilter::mirrorHor( m_pcRightOutputImage ); |
---|
| 365 | TRenFilter::mirrorHor( m_pcRightOutputDepth ); |
---|
| 366 | TRenFilter::mirrorHor( m_pcRightFilled ); |
---|
| 367 | |
---|
| 368 | xEnhSimilarity( m_pcLeftOutputImage, m_pcRightOutputImage, m_pcLeftFilled, m_pcRightFilled ); |
---|
| 369 | |
---|
| 370 | if ( m_iBlendMode == eRenBlendDepthFirst ) |
---|
| 371 | { |
---|
| 372 | xBlend ( m_pcLeftOutputDepth, m_pcRightOutputDepth, m_pcLeftFilled, m_pcRightFilled, m_pcLeftOutputDepth, m_pcRightOutputDepth, m_pcOutputDepth); |
---|
| 373 | |
---|
| 374 | xBackShiftPixels ( m_pcLeftInputImage, m_pcOutputDepth, m_pcLeftOutputImage, m_pcLeftFilled , false); |
---|
| 375 | xFillHoles ( m_pcLeftOutputImage, m_pcLeftFilled, m_pcLeftOutputImage, false); |
---|
| 376 | xCreateAlphaMap ( m_pcLeftFilled, m_pcLeftFilled, true ); |
---|
| 377 | |
---|
| 378 | TRenFilter::mirrorHor( m_pcRightInputImage ); |
---|
| 379 | xBackShiftPixels ( m_pcRightInputImage, m_pcOutputDepth, m_pcRightOutputImage, m_pcRightFilled , true ); |
---|
| 380 | xFillHoles ( m_pcRightOutputImage, m_pcRightFilled, m_pcRightOutputImage, true); |
---|
| 381 | |
---|
| 382 | TRenFilter::mirrorHor( m_pcRightFilled ); |
---|
| 383 | xCreateAlphaMap ( m_pcRightFilled, m_pcRightFilled, true ); |
---|
| 384 | TRenFilter::mirrorHor( m_pcRightFilled ); |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | xBlend(m_pcLeftOutputImage, m_pcRightOutputImage, m_pcLeftFilled, m_pcRightFilled, m_pcLeftOutputDepth, m_pcRightOutputDepth, m_pcOutputImage); |
---|
| 388 | |
---|
| 389 | xConvertOutputData( m_pcOutputImage, &cOutputImage , false ); |
---|
| 390 | xPostProcessImage ( &cOutputImage, &cOutputImage); |
---|
| 391 | xCutMargin( &cOutputImage ); |
---|
| 392 | }; |
---|
| 393 | |
---|
| 394 | |
---|
| 395 | Void TRenTop::xPreProcessDepth( PelImage* pcInImage, PelImage* pcOutImage ) |
---|
| 396 | { |
---|
| 397 | if ( m_iPreProcMode == eRenPreProNone ) |
---|
| 398 | return; |
---|
| 399 | |
---|
| 400 | PelImage* pcTemp; |
---|
| 401 | |
---|
| 402 | if (pcInImage == pcOutImage) |
---|
| 403 | { |
---|
| 404 | pcTemp = pcOutImage->create(); |
---|
| 405 | } |
---|
| 406 | else |
---|
| 407 | { |
---|
| 408 | pcTemp = pcOutImage; |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | pcTemp->assign(pcInImage); |
---|
| 412 | |
---|
| 413 | switch ( m_iPreProcMode ) |
---|
| 414 | { |
---|
| 415 | case eRenPreProBinom: |
---|
| 416 | TRenFilter::binominal(pcOutImage, pcTemp, m_iPreFilterSize); |
---|
| 417 | break; |
---|
| 418 | case eRenPreProNone: |
---|
| 419 | break; |
---|
| 420 | default: |
---|
| 421 | assert(0); |
---|
| 422 | break; |
---|
| 423 | } |
---|
| 424 | |
---|
| 425 | if (pcInImage == pcOutImage) |
---|
| 426 | { |
---|
| 427 | pcOutImage->setData(pcTemp, true); |
---|
| 428 | delete pcTemp; |
---|
| 429 | }; |
---|
| 430 | |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | Void TRenTop::xShiftPlanePixelsLinInt( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes ) |
---|
| 434 | { |
---|
| 435 | Int iWidth = apcInputPlanes[0]->getWidth(); |
---|
| 436 | Int iHeight = apcInputPlanes[0]->getHeight(); |
---|
| 437 | |
---|
| 438 | Int iInputStride = apcInputPlanes [0]->getStride(); |
---|
| 439 | Int iOutputStride = apcOutputPlanes[0]->getStride(); |
---|
| 440 | |
---|
| 441 | Int iFilledStride = pcFilledPlane->getStride(); |
---|
| 442 | Int iDepthStride = pcDepthPlane ->getStride(); |
---|
| 443 | |
---|
| 444 | pcFilledPlane->assign(REN_IS_HOLE); |
---|
| 445 | |
---|
| 446 | Pel** apcInputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 447 | Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 448 | |
---|
| 449 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 450 | { |
---|
| 451 | apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData(); |
---|
| 452 | apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData(); |
---|
| 453 | assert( iWidth == apcInputPlanes [uiCurPlane]->getWidth() && iWidth == apcOutputPlanes[uiCurPlane]->getWidth() ); |
---|
| 454 | assert( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight()); |
---|
| 455 | assert( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride()); |
---|
| 456 | } |
---|
| 457 | |
---|
| 458 | Pel* pcDepthData = pcDepthPlane ->getPlaneData(); |
---|
| 459 | Pel* pcFilledData = pcFilledPlane->getPlaneData(); |
---|
| 460 | |
---|
| 461 | for(Int iPosY = 0; iPosY < iHeight; iPosY++) |
---|
| 462 | { |
---|
| 463 | Int iPrevShiftedPos = -1; |
---|
| 464 | Int iShiftedPos = -1; |
---|
| 465 | |
---|
| 466 | for(Int iPosX = 0; iPosX < iWidth; iPosX ++ ) |
---|
| 467 | { |
---|
| 468 | Bool bExtrapolate = false; |
---|
| 469 | |
---|
| 470 | // compute disparity and shift |
---|
| 471 | iShiftedPos = ( iPosX << m_iRelShiftLUTPrec ) - m_aiShiftLUTCur[RemoveBitIncrement( pcDepthData[iPosX])]; |
---|
| 472 | |
---|
| 473 | if (iPosX == 0) |
---|
| 474 | { |
---|
| 475 | // in first iteration only get dLeftPos |
---|
| 476 | iPrevShiftedPos = iShiftedPos; |
---|
| 477 | continue; |
---|
| 478 | }; |
---|
| 479 | |
---|
| 480 | Int iDeltaPos = iShiftedPos - iPrevShiftedPos; |
---|
| 481 | |
---|
| 482 | if ( iDeltaPos <= 0 || (iDeltaPos > (2 << m_iRelShiftLUTPrec))) |
---|
| 483 | { |
---|
| 484 | // skip Interpolation if pixel is shifted forwards (gap) or if pixel is shifted backwards (foreground object) |
---|
| 485 | bExtrapolate = true; |
---|
| 486 | }; |
---|
| 487 | |
---|
| 488 | Int iInterPolPos; |
---|
| 489 | if (!bExtrapolate) |
---|
| 490 | { // Interpolate between j1 and j2 |
---|
| 491 | for (iInterPolPos = ( iPrevShiftedPos + (1 << m_iRelShiftLUTPrec) - 1 ) >> m_iRelShiftLUTPrec ; iInterPolPos <= (iShiftedPos >> m_iRelShiftLUTPrec); iInterPolPos++) |
---|
| 492 | { |
---|
| 493 | if ( (iInterPolPos >= iWidth) || (iInterPolPos < (Int) 0)) |
---|
| 494 | { |
---|
| 495 | // skip Interpolation if Interpolation position is outside frame |
---|
| 496 | continue; |
---|
| 497 | }; |
---|
| 498 | |
---|
| 499 | // Interpolate |
---|
| 500 | Int iDeltaCurPos = (iInterPolPos << m_iRelShiftLUTPrec) - iPrevShiftedPos; |
---|
| 501 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 502 | { |
---|
| 503 | Pel cVal = (( apcInputData[uiCurPlane][iPosX - 1] * iDeltaPos + ( apcInputData[uiCurPlane][iPosX] - apcInputData[uiCurPlane][iPosX - 1] ) * iDeltaCurPos ) / iDeltaPos ); |
---|
| 504 | apcOutputData[uiCurPlane][iInterPolPos] = cVal; |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | pcFilledData[iInterPolPos] = REN_IS_FILLED; |
---|
| 508 | } |
---|
| 509 | } |
---|
| 510 | else |
---|
| 511 | { // Extrapolate right from dLeftPos and left from dRightPos |
---|
| 512 | Int iShiftedPosCeiled = (( iPrevShiftedPos + (1 << m_iRelShiftLUTPrec) - 1) >> m_iRelShiftLUTPrec ) << m_iRelShiftLUTPrec; |
---|
| 513 | if ( (iPrevShiftedPos + (m_iRelShiftLUTPrec >> 1) ) > iShiftedPosCeiled ) |
---|
| 514 | { |
---|
| 515 | iInterPolPos = iShiftedPosCeiled >> m_iRelShiftLUTPrec; |
---|
| 516 | |
---|
| 517 | if ( (iInterPolPos >= iWidth) || (iInterPolPos < (Int) 0)) |
---|
| 518 | { |
---|
| 519 | // skip Interpolation if Interpolation position is outside frame |
---|
| 520 | iPrevShiftedPos = iShiftedPos; |
---|
| 521 | continue; |
---|
| 522 | }; |
---|
| 523 | |
---|
| 524 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 525 | { |
---|
| 526 | apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX - 1]; |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | pcFilledData[iInterPolPos] = REN_IS_FILLED; |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | Int iPrevShiftedPosFloor = (iShiftedPos >> m_iRelShiftLUTPrec) << m_iRelShiftLUTPrec; |
---|
| 533 | if (iShiftedPos - (m_iRelShiftLUTPrec > 1) < iPrevShiftedPosFloor ) |
---|
| 534 | { |
---|
| 535 | iInterPolPos = iPrevShiftedPosFloor >> m_iRelShiftLUTPrec; |
---|
| 536 | |
---|
| 537 | if ( (iInterPolPos >= iWidth) || (iInterPolPos < (Int) 0)) |
---|
| 538 | { |
---|
| 539 | // skip Interpolation if Interpolation position is outside frame |
---|
| 540 | iPrevShiftedPos = iShiftedPos; |
---|
| 541 | continue; |
---|
| 542 | }; |
---|
| 543 | |
---|
| 544 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 545 | { |
---|
| 546 | apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX ]; |
---|
| 547 | } |
---|
| 548 | |
---|
| 549 | pcFilledData[iInterPolPos] = REN_IS_FILLED; |
---|
| 550 | } |
---|
| 551 | } |
---|
| 552 | iPrevShiftedPos = iShiftedPos; |
---|
| 553 | } |
---|
| 554 | |
---|
| 555 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 556 | { |
---|
| 557 | apcOutputData[uiCurPlane] += iOutputStride; |
---|
| 558 | apcInputData [uiCurPlane] += iInputStride; |
---|
| 559 | } |
---|
| 560 | pcFilledData += iFilledStride; |
---|
| 561 | pcDepthData += iDepthStride; |
---|
| 562 | } |
---|
| 563 | delete[] apcInputData; |
---|
| 564 | delete[] apcOutputData; |
---|
| 565 | }; |
---|
| 566 | |
---|
| 567 | |
---|
| 568 | Void TRenTop::xShiftPlanePixelsLinReal( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes ) |
---|
| 569 | { |
---|
| 570 | Int iWidth = apcInputPlanes[0]->getWidth(); |
---|
| 571 | Int iHeight = apcInputPlanes[0]->getHeight(); |
---|
| 572 | |
---|
| 573 | Int iInputStride = apcInputPlanes [0]->getStride(); |
---|
| 574 | Int iOutputStride = apcOutputPlanes[0]->getStride(); |
---|
| 575 | |
---|
| 576 | Int iFilledStride = pcFilledPlane->getStride(); |
---|
| 577 | Int iDepthStride = pcDepthPlane ->getStride(); |
---|
| 578 | |
---|
| 579 | pcFilledPlane->assign( REN_IS_HOLE ); |
---|
| 580 | |
---|
| 581 | Pel** apcInputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 582 | Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 583 | |
---|
| 584 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 585 | { |
---|
| 586 | apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData(); |
---|
| 587 | apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData(); |
---|
| 588 | assert( iWidth == apcInputPlanes [uiCurPlane]->getWidth() && iWidth == apcOutputPlanes[uiCurPlane]->getWidth() ); |
---|
| 589 | assert( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight()); |
---|
| 590 | assert( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride()); |
---|
| 591 | } |
---|
| 592 | |
---|
| 593 | Pel* pcDepthData = pcDepthPlane ->getPlaneData(); |
---|
| 594 | Pel* pcFilledData = pcFilledPlane->getPlaneData(); |
---|
| 595 | |
---|
| 596 | ///// FEM Stuff ///// |
---|
| 597 | const UInt cuiMaxPlaneNum = 6; AOT( uiNumberOfPlanes > cuiMaxPlaneNum ); |
---|
| 598 | IntImagePlane* apcDiffPlane[ cuiMaxPlaneNum ]; |
---|
| 599 | Int* ppiDiffPlanes[ cuiMaxPlaneNum ]; |
---|
| 600 | Int iDiffStride = 0; |
---|
| 601 | |
---|
| 602 | if ( m_iInterpolationMode == eRenIntFEM ) |
---|
| 603 | { |
---|
| 604 | AOT( uiNumberOfPlanes > cuiMaxPlaneNum ); |
---|
| 605 | for ( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++ ) |
---|
| 606 | { |
---|
| 607 | apcDiffPlane[uiCurPlane] = new IntImagePlane( iWidth, iHeight, apcInputPlanes[uiCurPlane]->getPad()); |
---|
| 608 | TRenFilter::diffHorSym(apcInputPlanes[uiCurPlane] , apcDiffPlane[uiCurPlane]); |
---|
| 609 | ppiDiffPlanes[uiCurPlane] = apcDiffPlane[uiCurPlane]->getPlaneData(); |
---|
| 610 | } |
---|
| 611 | iDiffStride = apcDiffPlane[0]->getStride(); |
---|
| 612 | } |
---|
| 613 | ///// FEM Stuff End ///// |
---|
| 614 | |
---|
| 615 | for(Int iPosY = 0; iPosY < iHeight; iPosY++) |
---|
| 616 | { |
---|
| 617 | Double dShiftedPos = 0; |
---|
| 618 | Double dPrevShiftedPos = 0; |
---|
| 619 | |
---|
| 620 | for(Int iPosX = 0; iPosX < iWidth; iPosX ++ ) |
---|
| 621 | { |
---|
| 622 | Bool bExtrapolate = false; |
---|
| 623 | |
---|
| 624 | // compute disparity and shift |
---|
| 625 | assert( RemoveBitIncrement(pcDepthData[iPosX]) >= 0 && RemoveBitIncrement(pcDepthData[iPosX]) <= 256 ); |
---|
| 626 | dPrevShiftedPos = (Double) iPosX - m_adShiftLUTCur[ RemoveBitIncrement(pcDepthData[iPosX])]; |
---|
| 627 | |
---|
| 628 | if (iPosX == 0) |
---|
| 629 | { |
---|
| 630 | // in first iteration only get dLeftPos |
---|
| 631 | dShiftedPos = dPrevShiftedPos; |
---|
| 632 | continue; |
---|
| 633 | }; |
---|
| 634 | |
---|
| 635 | Double dDeltaPos = dPrevShiftedPos - dShiftedPos; |
---|
| 636 | |
---|
| 637 | if ((dDeltaPos <= 0) || ( dDeltaPos > 2 )) |
---|
| 638 | { |
---|
| 639 | // skip Interpolation if pixel is shifted backwards (foreground object) or if pixel is shifted forwards (gap) |
---|
| 640 | bExtrapolate = true; |
---|
| 641 | }; |
---|
| 642 | |
---|
| 643 | Int iInterPolPos; |
---|
| 644 | if (!bExtrapolate) |
---|
| 645 | { // Interpolate between j1 and j2 |
---|
| 646 | for (iInterPolPos = (Int) ceil(dShiftedPos); iInterPolPos <= floor(dPrevShiftedPos); iInterPolPos++) |
---|
| 647 | { |
---|
| 648 | if ( (iInterPolPos >= (Int) iWidth) || (iInterPolPos < (Int) 0 )) |
---|
| 649 | { |
---|
| 650 | // skip Interpolation if Interpolation position is outside frame |
---|
| 651 | continue; |
---|
| 652 | }; |
---|
| 653 | |
---|
| 654 | // Interpolate |
---|
| 655 | Pel cVal; |
---|
| 656 | if ( m_iInterpolationMode == eRenIntFEM ) //FEM Interpolation |
---|
| 657 | { |
---|
| 658 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 659 | { |
---|
| 660 | cVal = TRenFilter::interpCHSpline(iInterPolPos, dShiftedPos, dPrevShiftedPos, apcInputData[uiCurPlane][iPosX - 1], ppiDiffPlanes[uiCurPlane][iPosX - 1], apcInputData[uiCurPlane][iPosX], ppiDiffPlanes[uiCurPlane][iPosX] ); |
---|
| 661 | apcOutputData[uiCurPlane][iInterPolPos] = cVal; |
---|
| 662 | } |
---|
| 663 | } |
---|
| 664 | else |
---|
| 665 | { |
---|
| 666 | Double dDeltaJ = (Double) iInterPolPos - dShiftedPos; |
---|
| 667 | |
---|
| 668 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 669 | { |
---|
| 670 | cVal = (UChar) ( (Double) apcInputData[uiCurPlane][iPosX - 1] + ( (Double) apcInputData[uiCurPlane][iPosX] - (Double) apcInputData[uiCurPlane][iPosX - 1] ) / dDeltaPos * dDeltaJ + 0.5); |
---|
| 671 | apcOutputData[uiCurPlane][iInterPolPos] = cVal; |
---|
| 672 | } |
---|
| 673 | }; |
---|
| 674 | |
---|
| 675 | pcFilledData[iInterPolPos] = REN_IS_FILLED; |
---|
| 676 | } |
---|
| 677 | } |
---|
| 678 | else |
---|
| 679 | { // Extrapolate right from dLeftPos and left from dRightPos |
---|
| 680 | if (dShiftedPos + 0.5 > ceil(dShiftedPos)) |
---|
| 681 | { |
---|
| 682 | iInterPolPos = (Int) ceil(dShiftedPos); |
---|
| 683 | |
---|
| 684 | if ( (iInterPolPos >= (Int) iWidth) || (iInterPolPos < (Int) 0)) |
---|
| 685 | { |
---|
| 686 | // skip Interpolation if Interpolation position is outside frame |
---|
| 687 | dShiftedPos = dPrevShiftedPos; |
---|
| 688 | continue; |
---|
| 689 | }; |
---|
| 690 | |
---|
| 691 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 692 | { |
---|
| 693 | apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX - 1]; |
---|
| 694 | } |
---|
| 695 | |
---|
| 696 | pcFilledData[iInterPolPos] = REN_IS_FILLED; |
---|
| 697 | } |
---|
| 698 | |
---|
| 699 | if (dPrevShiftedPos - 0.5 < floor(dPrevShiftedPos)) |
---|
| 700 | { |
---|
| 701 | iInterPolPos = (Int) floor(dPrevShiftedPos); |
---|
| 702 | |
---|
| 703 | if ( (iInterPolPos >= (Int) iWidth) || (iInterPolPos < (Int) 0)) |
---|
| 704 | { |
---|
| 705 | // skip Interpolation if Interpolation position is outside frame |
---|
| 706 | dShiftedPos = dPrevShiftedPos; |
---|
| 707 | continue; |
---|
| 708 | }; |
---|
| 709 | |
---|
| 710 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 711 | { |
---|
| 712 | apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX ]; |
---|
| 713 | } |
---|
| 714 | |
---|
| 715 | pcFilledData[iInterPolPos] = REN_IS_FILLED; |
---|
| 716 | } |
---|
| 717 | } |
---|
| 718 | dShiftedPos = dPrevShiftedPos; |
---|
| 719 | } |
---|
| 720 | |
---|
| 721 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 722 | { |
---|
| 723 | apcOutputData[uiCurPlane] += iOutputStride; |
---|
| 724 | apcInputData [uiCurPlane] += iInputStride; |
---|
| 725 | |
---|
| 726 | if (m_iInterpolationMode == eRenIntFEM) |
---|
| 727 | { |
---|
| 728 | ppiDiffPlanes[ uiCurPlane ] += iDiffStride; |
---|
| 729 | } |
---|
| 730 | } |
---|
| 731 | |
---|
| 732 | pcFilledData += iFilledStride; |
---|
| 733 | pcDepthData += iDepthStride; |
---|
| 734 | } |
---|
| 735 | |
---|
| 736 | if (m_iInterpolationMode == eRenIntFEM) |
---|
| 737 | { |
---|
| 738 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 739 | { |
---|
| 740 | delete apcDiffPlane[uiCurPlane]; |
---|
| 741 | } |
---|
| 742 | } |
---|
| 743 | |
---|
| 744 | delete[] apcInputData; |
---|
| 745 | delete[] apcOutputData; |
---|
| 746 | } |
---|
| 747 | |
---|
| 748 | |
---|
| 749 | Void TRenTop::xShiftPlanePixels( PelImagePlane** apcInPlane, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutPlane, PelImagePlane* pcPlaneFilled, UInt uiNumberOfPlanes ) |
---|
| 750 | { |
---|
| 751 | switch ( m_iInterpolationMode) |
---|
| 752 | { |
---|
| 753 | case eRenIntFullPel: |
---|
| 754 | xShiftPlanePixelsFullPel( apcInPlane, pcDepthPlane, apcOutPlane, pcPlaneFilled, uiNumberOfPlanes); |
---|
| 755 | break; |
---|
| 756 | case eRenIntFEM: |
---|
| 757 | case eRenIntLinReal: |
---|
| 758 | xShiftPlanePixelsLinReal( apcInPlane, pcDepthPlane, apcOutPlane, pcPlaneFilled, uiNumberOfPlanes); |
---|
| 759 | break; |
---|
| 760 | case eRenIntLinInt: |
---|
| 761 | xShiftPlanePixelsLinInt ( apcInPlane, pcDepthPlane, apcOutPlane, pcPlaneFilled, uiNumberOfPlanes); |
---|
| 762 | break; |
---|
| 763 | case eRenInt8Tap: |
---|
| 764 | xShiftPlanePixels8Tap ( apcInPlane, pcDepthPlane, apcOutPlane, pcPlaneFilled, uiNumberOfPlanes ); |
---|
| 765 | break; |
---|
| 766 | default: |
---|
| 767 | AOF( false ); |
---|
| 768 | } |
---|
| 769 | } |
---|
| 770 | |
---|
| 771 | |
---|
| 772 | Void TRenTop::xShiftPlanePixelsFullPel( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes ) |
---|
| 773 | { |
---|
| 774 | Int iWidth = apcInputPlanes[0]->getWidth(); |
---|
| 775 | Int iHeight = apcInputPlanes[0]->getHeight(); |
---|
| 776 | |
---|
| 777 | Int iInputStride = apcInputPlanes [0]->getStride(); |
---|
| 778 | Int iOutputStride = apcOutputPlanes[0]->getStride(); |
---|
| 779 | |
---|
| 780 | Int iFilledStride = pcFilledPlane->getStride(); |
---|
| 781 | Int iDepthStride = pcDepthPlane ->getStride(); |
---|
| 782 | |
---|
| 783 | pcFilledPlane->assign(REN_IS_HOLE); |
---|
| 784 | |
---|
| 785 | Pel** apcInputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 786 | Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 787 | |
---|
| 788 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 789 | { |
---|
| 790 | apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData(); |
---|
| 791 | apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData(); |
---|
| 792 | assert( iWidth == apcInputPlanes [uiCurPlane]->getWidth() && iWidth == apcOutputPlanes[uiCurPlane]->getWidth() ); |
---|
| 793 | assert( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight()); |
---|
| 794 | assert( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride()); |
---|
| 795 | } |
---|
| 796 | |
---|
| 797 | Pel* pcDepthData = pcDepthPlane ->getPlaneData(); |
---|
| 798 | Pel* pcFilledData = pcFilledPlane->getPlaneData(); |
---|
| 799 | |
---|
| 800 | for(Int iPosY = 0; iPosY < iHeight; iPosY++) |
---|
| 801 | { |
---|
| 802 | Int iPrevShiftedPos = -1; |
---|
| 803 | |
---|
| 804 | for(Int iPosX = 0; iPosX < iWidth; iPosX++) |
---|
| 805 | { |
---|
| 806 | assert( RemoveBitIncrement(pcDepthData[iPosX]) >= 0 && RemoveBitIncrement(pcDepthData[iPosX]) <= 256 ); |
---|
| 807 | Int iShiftedPos = iPosX - m_aiShiftLUTCur[ RemoveBitIncrement(pcDepthData[iPosX])] ; |
---|
| 808 | if (iShiftedPos < iWidth && iShiftedPos >= 0) |
---|
| 809 | { |
---|
| 810 | Int iDiff = iShiftedPos - iPrevShiftedPos; |
---|
| 811 | if (( iDiff <= 2) && (iDiff > 0) ) |
---|
| 812 | { |
---|
| 813 | for (Int iCurPos = iPrevShiftedPos+1; iCurPos <= iShiftedPos; iCurPos++) |
---|
| 814 | { |
---|
| 815 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 816 | { |
---|
| 817 | apcOutputData[uiCurPlane][iCurPos] = apcInputData[uiCurPlane][iPosX]; // Only small gaps, therefor not necessary NN |
---|
| 818 | } |
---|
| 819 | pcFilledData[iCurPos] = REN_IS_FILLED; |
---|
| 820 | } |
---|
| 821 | } |
---|
| 822 | else |
---|
| 823 | { |
---|
| 824 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 825 | { |
---|
| 826 | apcOutputData[uiCurPlane][iShiftedPos] = apcInputData[uiCurPlane][iPosX]; |
---|
| 827 | } |
---|
| 828 | pcFilledData[iShiftedPos] = REN_IS_FILLED; |
---|
| 829 | } |
---|
| 830 | iPrevShiftedPos = iShiftedPos; |
---|
| 831 | } |
---|
| 832 | } |
---|
| 833 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 834 | { |
---|
| 835 | apcOutputData[uiCurPlane] += iOutputStride; |
---|
| 836 | apcInputData [uiCurPlane] += iInputStride; |
---|
| 837 | } |
---|
| 838 | pcFilledData += iFilledStride; |
---|
| 839 | pcDepthData += iDepthStride; |
---|
| 840 | } |
---|
| 841 | |
---|
| 842 | delete[] apcInputData; |
---|
| 843 | delete[] apcOutputData; |
---|
| 844 | } |
---|
| 845 | |
---|
| 846 | Void TRenTop::xBackShiftPlanePixels( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes ) |
---|
| 847 | { |
---|
| 848 | Int iOutputWidth = apcOutputPlanes[0]->getWidth(); |
---|
| 849 | Int iInputWidth = apcInputPlanes [0]->getWidth(); |
---|
| 850 | Int iHeight = apcInputPlanes [0]->getHeight(); |
---|
| 851 | |
---|
| 852 | Int iInputStride = apcInputPlanes [0]->getStride(); |
---|
| 853 | Int iOutputStride = apcOutputPlanes[0]->getStride(); |
---|
| 854 | |
---|
| 855 | Int iFilledStride = pcFilledPlane->getStride(); |
---|
| 856 | Int iDepthStride = pcDepthPlane ->getStride(); |
---|
| 857 | |
---|
| 858 | Pel** apcInputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 859 | Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 860 | |
---|
| 861 | Int iStep = (1 << m_iRelShiftLUTPrec); |
---|
| 862 | |
---|
| 863 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 864 | { |
---|
| 865 | apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData(); |
---|
| 866 | apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData(); |
---|
| 867 | AOF( iInputWidth == apcInputPlanes [uiCurPlane]->getWidth() && iOutputWidth == apcOutputPlanes[uiCurPlane]->getWidth() ); |
---|
| 868 | AOF( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight()); |
---|
| 869 | AOF( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride()); |
---|
| 870 | AOF( iInputWidth == iOutputWidth * iStep ); |
---|
| 871 | } |
---|
| 872 | |
---|
| 873 | Pel* pcDepthData = pcDepthPlane ->getPlaneData(); |
---|
| 874 | Pel* pcFilledData = pcFilledPlane->getPlaneData(); |
---|
| 875 | |
---|
| 876 | |
---|
| 877 | for(Int iPosY = 0; iPosY < iHeight; iPosY++) |
---|
| 878 | { |
---|
| 879 | for(Int iPosX = 0; iPosX < iOutputWidth; iPosX ++) |
---|
| 880 | { |
---|
| 881 | Int iBackShiftedPos = (iPosX << m_iRelShiftLUTPrec) - m_aiShiftLUTCur[ RemoveBitIncrement( pcDepthData[iPosX] )]; |
---|
| 882 | if( ( pcFilledData[iPosX] == REN_IS_FILLED ) && (iBackShiftedPos >= 0 ) && ( iBackShiftedPos < iInputWidth ) ) |
---|
| 883 | { |
---|
| 884 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 885 | { |
---|
| 886 | apcOutputData[uiCurPlane][iPosX] = apcInputData[uiCurPlane][iBackShiftedPos]; |
---|
| 887 | } |
---|
| 888 | } |
---|
| 889 | else |
---|
| 890 | { |
---|
| 891 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 892 | { |
---|
| 893 | apcOutputData[uiCurPlane][iPosX] = 0; |
---|
| 894 | } |
---|
| 895 | pcFilledData[iPosX] = REN_IS_HOLE; |
---|
| 896 | } |
---|
| 897 | } |
---|
| 898 | |
---|
| 899 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 900 | { |
---|
| 901 | apcOutputData[uiCurPlane] += iOutputStride; |
---|
| 902 | apcInputData [uiCurPlane] += iInputStride; |
---|
| 903 | } |
---|
| 904 | pcFilledData += iFilledStride; |
---|
| 905 | pcDepthData += iDepthStride; |
---|
| 906 | } |
---|
| 907 | |
---|
| 908 | delete[] apcInputData; |
---|
| 909 | delete[] apcOutputData; |
---|
| 910 | } |
---|
| 911 | |
---|
| 912 | Void TRenTop::xShiftPlanePixels8Tap( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes ) |
---|
| 913 | { |
---|
| 914 | Bool bRenderDepth = (apcInputPlanes[0] == pcDepthPlane); |
---|
| 915 | |
---|
| 916 | Int iOutputWidth = apcOutputPlanes[0]->getWidth(); |
---|
| 917 | Int iInputWidth = apcInputPlanes [0]->getWidth(); |
---|
| 918 | Int iHeight = apcInputPlanes [0]->getHeight(); |
---|
| 919 | |
---|
| 920 | Int iInputStride = apcInputPlanes [0]->getStride(); |
---|
| 921 | Int iOutputStride = apcOutputPlanes[0]->getStride(); |
---|
| 922 | |
---|
| 923 | Int iFilledStride = pcFilledPlane->getStride(); |
---|
| 924 | Int iDepthStride = pcDepthPlane ->getStride(); |
---|
| 925 | |
---|
| 926 | Int iStep = (1 << m_iRelShiftLUTPrec); |
---|
| 927 | |
---|
| 928 | pcFilledPlane->assign(REN_IS_HOLE); |
---|
| 929 | |
---|
| 930 | Pel** apcInputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 931 | Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 932 | |
---|
| 933 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 934 | { |
---|
| 935 | apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData(); |
---|
| 936 | apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData(); |
---|
| 937 | AOF( iInputWidth == apcInputPlanes [uiCurPlane]->getWidth() && iOutputWidth == apcOutputPlanes[uiCurPlane]->getWidth() ); |
---|
| 938 | AOF( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight()); |
---|
| 939 | AOF( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride()); |
---|
| 940 | AOF( iInputWidth == iOutputWidth * iStep ); |
---|
| 941 | } |
---|
| 942 | |
---|
| 943 | Pel* pcDepthData = pcDepthPlane ->getPlaneData(); |
---|
| 944 | Pel* pcFilledData = pcFilledPlane->getPlaneData(); |
---|
| 945 | |
---|
| 946 | for(Int iPosY = 0; iPosY < iHeight; iPosY++) |
---|
| 947 | { |
---|
| 948 | Int iPrevShiftedPos = -1; |
---|
| 949 | Int iShiftedPos = -1; |
---|
| 950 | |
---|
| 951 | for(Int iPosX = 0; iPosX < iInputWidth; iPosX += iStep ) |
---|
| 952 | { |
---|
| 953 | // compute disparity and shift |
---|
| 954 | iShiftedPos = iPosX - m_aiShiftLUTCur[RemoveBitIncrement(pcDepthData[iPosX])]; |
---|
| 955 | |
---|
| 956 | if ( iPosX == 0 ) |
---|
| 957 | { |
---|
| 958 | // in first iteration only get dLeftPos |
---|
| 959 | iPrevShiftedPos = iShiftedPos; |
---|
| 960 | continue; |
---|
| 961 | }; |
---|
| 962 | |
---|
| 963 | Int iDeltaPos = iShiftedPos - iPrevShiftedPos; |
---|
| 964 | |
---|
| 965 | Bool bDisocclusion = ( iDeltaPos > (2 << m_iRelShiftLUTPrec) ); |
---|
| 966 | Bool bOcclusion = ( iDeltaPos <= 0 ); |
---|
| 967 | |
---|
| 968 | Int iInterPolPos; |
---|
| 969 | if ( !bDisocclusion && !bOcclusion ) |
---|
| 970 | { // Interpolate between previous shifted pos and shifted pos |
---|
| 971 | for (iInterPolPos = xCeil( iPrevShiftedPos ); iInterPolPos <= xCeil (iShiftedPos ) -1 ; iInterPolPos++) |
---|
| 972 | { |
---|
| 973 | if ( (iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth)) |
---|
| 974 | { |
---|
| 975 | // skip Interpolation if Interpolation position is outside frame |
---|
| 976 | continue; |
---|
| 977 | }; |
---|
| 978 | |
---|
| 979 | // Interpolate |
---|
| 980 | Int iDeltaCurPos = (iInterPolPos << m_iRelShiftLUTPrec) - iPrevShiftedPos; |
---|
| 981 | |
---|
| 982 | AOF( (iDeltaCurPos <= iDeltaPos) && ( iDeltaCurPos >= 0)); |
---|
| 983 | AOF( iDeltaPos <= (2 << m_iRelShiftLUTPrec) ); |
---|
| 984 | AOF( m_aaiSubPelShift[iDeltaPos][iDeltaCurPos] != 0xdeaddead); |
---|
| 985 | |
---|
| 986 | Int iSourcePos; |
---|
| 987 | |
---|
| 988 | if ( bRenderDepth ) |
---|
| 989 | { |
---|
| 990 | iSourcePos = iPosX - iStep; // Render depth with Full Pel accuracy to avoid ringing at sharp depth edges; |
---|
| 991 | } |
---|
| 992 | else |
---|
| 993 | { |
---|
| 994 | iSourcePos = iPosX + m_aaiSubPelShift[iDeltaPos][iDeltaCurPos]; // GT: = iPosX - iStep + ( iStep * iDeltaCurPos + ( iDeltaPos >> 1) ) / iDeltaPos; |
---|
| 995 | } |
---|
| 996 | |
---|
| 997 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 998 | { |
---|
| 999 | apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iSourcePos]; |
---|
| 1000 | } |
---|
| 1001 | |
---|
| 1002 | pcFilledData[ iInterPolPos] = REN_IS_FILLED; |
---|
| 1003 | } |
---|
| 1004 | } |
---|
| 1005 | else |
---|
| 1006 | { |
---|
| 1007 | // Fill Disocclusion Edge |
---|
| 1008 | |
---|
| 1009 | if ( bDisocclusion ) |
---|
| 1010 | { |
---|
| 1011 | Int iPrevShiftedPosCeiled = xCeil(iPrevShiftedPos) << m_iRelShiftLUTPrec; |
---|
| 1012 | iInterPolPos = iPrevShiftedPosCeiled >> m_iRelShiftLUTPrec; |
---|
| 1013 | |
---|
| 1014 | if ((iPrevShiftedPos + (iStep >> 1) ) > iPrevShiftedPosCeiled ) |
---|
| 1015 | { |
---|
| 1016 | if ( (iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth)) |
---|
| 1017 | { |
---|
| 1018 | // skip Interpolation if Interpolation position is outside frame |
---|
| 1019 | iPrevShiftedPos = iShiftedPos; |
---|
| 1020 | continue; |
---|
| 1021 | }; |
---|
| 1022 | |
---|
| 1023 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1024 | { |
---|
| 1025 | apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX - iStep]; |
---|
| 1026 | } |
---|
| 1027 | pcFilledData[iInterPolPos] = REN_IS_FILLED; |
---|
| 1028 | iInterPolPos++; |
---|
| 1029 | } |
---|
| 1030 | |
---|
| 1031 | // Fill Disocclusion |
---|
| 1032 | if ( m_bInstantHoleFilling ) |
---|
| 1033 | { |
---|
| 1034 | for ( ; iInterPolPos <= xCeil (iShiftedPos ) -1 ; iInterPolPos++) |
---|
| 1035 | { |
---|
| 1036 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1037 | { |
---|
| 1038 | if ( ( iInterPolPos >= 0 ) && ( iInterPolPos < iOutputWidth ) ) |
---|
| 1039 | { |
---|
| 1040 | apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX]; |
---|
| 1041 | } |
---|
| 1042 | |
---|
| 1043 | } |
---|
| 1044 | } |
---|
| 1045 | } |
---|
| 1046 | } |
---|
| 1047 | |
---|
| 1048 | //// Last sample next to occlusion |
---|
| 1049 | Int iShiftedPosFloor = ( iShiftedPos >> m_iRelShiftLUTPrec ) << m_iRelShiftLUTPrec; |
---|
| 1050 | if ( bOcclusion && (iShiftedPos - (iStep >> 1) < iShiftedPosFloor) ) |
---|
| 1051 | { |
---|
| 1052 | iInterPolPos = iShiftedPosFloor >> m_iRelShiftLUTPrec; |
---|
| 1053 | if ( (iInterPolPos < (Int) 0) || (iInterPolPos >= iOutputWidth)) |
---|
| 1054 | { |
---|
| 1055 | // skip Interpolation if Interpolation position is outside frame |
---|
| 1056 | iPrevShiftedPos = iShiftedPos; |
---|
| 1057 | continue; |
---|
| 1058 | }; |
---|
| 1059 | |
---|
| 1060 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1061 | { |
---|
| 1062 | apcOutputData[uiCurPlane][iInterPolPos] = apcInputData[uiCurPlane][iPosX ]; |
---|
| 1063 | } |
---|
| 1064 | |
---|
| 1065 | pcFilledData[iInterPolPos] = REN_IS_FILLED; |
---|
| 1066 | } |
---|
| 1067 | } |
---|
| 1068 | iPrevShiftedPos = iShiftedPos; |
---|
| 1069 | } |
---|
| 1070 | |
---|
| 1071 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1072 | { |
---|
| 1073 | apcOutputData[uiCurPlane] += iOutputStride; |
---|
| 1074 | apcInputData [uiCurPlane] += iInputStride; |
---|
| 1075 | } |
---|
| 1076 | pcFilledData += iFilledStride; |
---|
| 1077 | pcDepthData += iDepthStride; |
---|
| 1078 | } |
---|
| 1079 | delete[] apcInputData; |
---|
| 1080 | delete[] apcOutputData; |
---|
| 1081 | }; |
---|
| 1082 | |
---|
| 1083 | Void TRenTop::xShiftPixels(PelImage* pcInImage, PelImage* pcDepth, PelImage* pcOutImage, PelImage* pcFilledImage, Bool bShiftFromLeft ) |
---|
| 1084 | { |
---|
| 1085 | PelImage* pcTemp = 0; |
---|
| 1086 | |
---|
| 1087 | if (pcInImage == pcOutImage) |
---|
| 1088 | { |
---|
| 1089 | pcTemp = pcOutImage->create(); |
---|
| 1090 | } |
---|
| 1091 | else |
---|
| 1092 | { |
---|
| 1093 | pcTemp = pcOutImage; |
---|
| 1094 | } |
---|
| 1095 | |
---|
| 1096 | Double ** ppdShiftLUT = bShiftFromLeft ? m_ppdShiftLUTLeft : m_ppdShiftLUTRightMirror; |
---|
| 1097 | Int ** ppiShiftLUT = bShiftFromLeft ? m_ppiShiftLUTLeft : m_ppiShiftLUTRightMirror; |
---|
| 1098 | |
---|
| 1099 | UInt uiNumFullPlanes = pcInImage->getNumberOfFullPlanes(); |
---|
| 1100 | UInt uiNumQuatPlanes = pcInImage->getNumberOfQuaterPlanes(); |
---|
| 1101 | |
---|
| 1102 | assert( uiNumFullPlanes == pcOutImage->getNumberOfFullPlanes () ); |
---|
| 1103 | assert( uiNumQuatPlanes == pcOutImage->getNumberOfQuaterPlanes() ); |
---|
| 1104 | |
---|
| 1105 | m_aiShiftLUTCur = ppiShiftLUT[ 0 ]; |
---|
| 1106 | m_adShiftLUTCur = ppdShiftLUT[ 0 ]; |
---|
| 1107 | |
---|
| 1108 | xShiftPlanePixels( pcInImage->getPlanes(), pcDepth->getPlane(0), pcOutImage->getPlanes(), pcFilledImage->getPlane(0), uiNumFullPlanes ); |
---|
| 1109 | |
---|
| 1110 | if (uiNumQuatPlanes > 0) |
---|
| 1111 | { |
---|
| 1112 | assert( pcDepth->getNumberOfPlanes() > 1 && pcFilledImage->getNumberOfPlanes() > 1); |
---|
| 1113 | m_aiShiftLUTCur = ppiShiftLUT[ 1 ]; |
---|
| 1114 | m_adShiftLUTCur = ppdShiftLUT[ 1 ]; |
---|
| 1115 | xShiftPlanePixels( pcInImage->getPlanes()+uiNumFullPlanes,pcDepth->getPlane(1), pcOutImage->getPlanes() + uiNumFullPlanes, pcFilledImage->getPlane(1), uiNumQuatPlanes ); |
---|
| 1116 | } |
---|
| 1117 | |
---|
| 1118 | if (pcInImage == pcOutImage) |
---|
| 1119 | { |
---|
| 1120 | pcOutImage->assign(pcTemp); |
---|
| 1121 | delete pcTemp; |
---|
| 1122 | }; |
---|
| 1123 | }; |
---|
| 1124 | |
---|
| 1125 | Void TRenTop::xBackShiftPixels(PelImage* pcInImage, PelImage* pcDepth, PelImage* pcOutImage, PelImage* pcFilledImage, Bool bShiftFromLeft ) |
---|
| 1126 | { |
---|
| 1127 | PelImage* pcTemp = 0; |
---|
| 1128 | |
---|
| 1129 | if (pcInImage == pcOutImage) |
---|
| 1130 | { |
---|
| 1131 | pcTemp = pcOutImage->create(); |
---|
| 1132 | } |
---|
| 1133 | else |
---|
| 1134 | { |
---|
| 1135 | pcTemp = pcOutImage; |
---|
| 1136 | } |
---|
| 1137 | |
---|
| 1138 | Double ** ppdShiftLUT = bShiftFromLeft ? m_ppdShiftLUTLeft : m_ppdShiftLUTRight; |
---|
| 1139 | Int ** ppiShiftLUT = bShiftFromLeft ? m_ppiShiftLUTLeft : m_ppiShiftLUTRight; |
---|
| 1140 | |
---|
| 1141 | UInt uiNumFullPlanes = pcInImage->getNumberOfFullPlanes(); |
---|
| 1142 | UInt uiNumQuatPlanes = pcInImage->getNumberOfQuaterPlanes(); |
---|
| 1143 | |
---|
| 1144 | assert( uiNumFullPlanes == pcOutImage->getNumberOfFullPlanes () ); |
---|
| 1145 | assert( uiNumQuatPlanes == pcOutImage->getNumberOfQuaterPlanes() ); |
---|
| 1146 | |
---|
| 1147 | m_aiShiftLUTCur = ppiShiftLUT[ 0 ]; |
---|
| 1148 | m_adShiftLUTCur = ppdShiftLUT[ 0 ]; |
---|
| 1149 | |
---|
| 1150 | xBackShiftPlanePixels( pcInImage->getPlanes(), pcDepth->getPlane(0), pcOutImage->getPlanes(), pcFilledImage->getPlane(0), uiNumFullPlanes ); |
---|
| 1151 | |
---|
| 1152 | if (uiNumQuatPlanes > 0) |
---|
| 1153 | { |
---|
| 1154 | assert( pcDepth->getNumberOfPlanes() > 1 && pcFilledImage->getNumberOfPlanes() > 1); |
---|
| 1155 | m_aiShiftLUTCur = ppiShiftLUT[ 1 ]; |
---|
| 1156 | m_adShiftLUTCur = ppdShiftLUT[ 1 ]; |
---|
| 1157 | xBackShiftPlanePixels( pcInImage->getPlanes()+uiNumFullPlanes,pcDepth->getPlane(1), pcOutImage->getPlanes() + uiNumFullPlanes, pcFilledImage->getPlane(1), uiNumQuatPlanes ); |
---|
| 1158 | } |
---|
| 1159 | |
---|
| 1160 | if (pcInImage == pcOutImage) |
---|
| 1161 | { |
---|
| 1162 | pcOutImage->assign(pcTemp); |
---|
| 1163 | delete pcTemp; |
---|
| 1164 | }; |
---|
| 1165 | }; |
---|
| 1166 | |
---|
| 1167 | Void TRenTop::xFillHoles(PelImage* pcInImage, PelImage* pcFilled, PelImage* pcOutImage, Bool bRenderFromLeft ) |
---|
| 1168 | { |
---|
| 1169 | if (pcInImage != pcOutImage) |
---|
| 1170 | { |
---|
| 1171 | pcOutImage->assign(pcInImage); |
---|
| 1172 | } |
---|
| 1173 | |
---|
| 1174 | switch (m_iHoleFillingMode) |
---|
| 1175 | { |
---|
| 1176 | case eRenHFNone: |
---|
| 1177 | break; |
---|
| 1178 | case eRenHFLWBackExt: |
---|
| 1179 | xFillLWBackExt( pcInImage, pcFilled, pcOutImage, bRenderFromLeft); |
---|
| 1180 | break; |
---|
| 1181 | default: |
---|
| 1182 | break; |
---|
| 1183 | } |
---|
| 1184 | }; |
---|
| 1185 | |
---|
| 1186 | Void TRenTop::xFillLWBackExt( PelImage* pcInImage, PelImage* pcFilledImage, PelImage* pcOutImage, Bool bRenderFromLeft ) |
---|
| 1187 | { |
---|
| 1188 | UInt uiNumFullPlanes = pcInImage->getNumberOfFullPlanes(); |
---|
| 1189 | UInt uiNumQuatPlanes = pcInImage->getNumberOfQuaterPlanes(); |
---|
| 1190 | |
---|
| 1191 | assert( uiNumFullPlanes == pcOutImage->getNumberOfFullPlanes () ); |
---|
| 1192 | assert( uiNumQuatPlanes == pcOutImage->getNumberOfQuaterPlanes() ); |
---|
| 1193 | |
---|
| 1194 | xFillPlaneHoles( pcInImage->getPlanes(), pcFilledImage->getPlane(0), pcOutImage->getPlanes(), uiNumFullPlanes, bRenderFromLeft ); |
---|
| 1195 | |
---|
| 1196 | if (uiNumQuatPlanes > 0) |
---|
| 1197 | { |
---|
| 1198 | assert( pcFilledImage->getNumberOfPlanes() > 1); |
---|
| 1199 | xFillPlaneHoles( pcInImage->getPlanes()+uiNumFullPlanes, pcFilledImage->getPlane(1), pcOutImage->getPlanes() + uiNumFullPlanes, uiNumQuatPlanes, bRenderFromLeft ); |
---|
| 1200 | } |
---|
| 1201 | }; |
---|
| 1202 | |
---|
| 1203 | Void TRenTop::xCreateAlphaMap(PelImage* pcFilledImage, PelImage* pcAlphaMapImage, Bool bRenderFromLeft ) |
---|
| 1204 | { |
---|
| 1205 | UInt uiNumFullPlanes = pcFilledImage ->getNumberOfFullPlanes(); |
---|
| 1206 | UInt uiNumQuatPlanes = pcFilledImage->getNumberOfQuaterPlanes(); |
---|
| 1207 | |
---|
| 1208 | AOF( uiNumFullPlanes == pcAlphaMapImage->getNumberOfFullPlanes () ); |
---|
| 1209 | AOF( uiNumQuatPlanes == pcAlphaMapImage->getNumberOfQuaterPlanes() ); |
---|
| 1210 | |
---|
| 1211 | xCreateAlphaMapPlane( pcFilledImage->getPlanes(), pcAlphaMapImage->getPlanes(), uiNumFullPlanes, bRenderFromLeft ); |
---|
| 1212 | |
---|
| 1213 | if (uiNumQuatPlanes > 0) |
---|
| 1214 | { |
---|
| 1215 | AOF( pcFilledImage->getNumberOfPlanes() > 1); |
---|
| 1216 | xCreateAlphaMapPlane( pcFilledImage->getPlanes()+ uiNumFullPlanes, pcAlphaMapImage->getPlanes()+uiNumFullPlanes, uiNumQuatPlanes, bRenderFromLeft ); |
---|
| 1217 | } |
---|
| 1218 | }; |
---|
| 1219 | |
---|
| 1220 | Void TRenTop::xCreateAlphaMapPlane(PelImagePlane** apcFilledPlanes, PelImagePlane** apcAlphaPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft) |
---|
| 1221 | { |
---|
| 1222 | Int iWidth = apcFilledPlanes [0]->getWidth(); |
---|
| 1223 | Int iHeight = apcFilledPlanes [0]->getHeight(); |
---|
| 1224 | |
---|
| 1225 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1226 | { |
---|
| 1227 | AOF( iWidth == apcFilledPlanes [uiCurPlane]->getWidth() && iWidth == apcAlphaPlanes[uiCurPlane]->getWidth() ); |
---|
| 1228 | AOF( iHeight == apcFilledPlanes [uiCurPlane]->getHeight() && iHeight == apcAlphaPlanes[uiCurPlane]->getHeight()); |
---|
| 1229 | } |
---|
| 1230 | |
---|
| 1231 | Int iBlendWidth = m_iBlendHoleMargin; |
---|
| 1232 | Int iMaxBlendLevel; |
---|
| 1233 | |
---|
| 1234 | if (!m_bBlendUseDistWeight ) |
---|
| 1235 | { |
---|
| 1236 | iMaxBlendLevel = ( 1 << REN_VDWEIGHT_PREC ) ; |
---|
| 1237 | |
---|
| 1238 | if ( m_iBlendMode == 0) |
---|
| 1239 | { |
---|
| 1240 | iMaxBlendLevel >>= 1; |
---|
| 1241 | } |
---|
| 1242 | } |
---|
| 1243 | else |
---|
| 1244 | { |
---|
| 1245 | if ( m_iBlendMode == 0) |
---|
| 1246 | { |
---|
| 1247 | iMaxBlendLevel = bRenderFromLeft ? (1 << REN_VDWEIGHT_PREC) - m_iBlendDistWeight : m_iBlendDistWeight; |
---|
| 1248 | } |
---|
| 1249 | else |
---|
| 1250 | { |
---|
| 1251 | iMaxBlendLevel = ( 1 << REN_VDWEIGHT_PREC ); |
---|
| 1252 | } |
---|
| 1253 | } |
---|
| 1254 | |
---|
| 1255 | Int iWeightStep = (iBlendWidth > 0) ? ( iMaxBlendLevel + (iBlendWidth >> 1) ) / iBlendWidth : 0; |
---|
| 1256 | |
---|
| 1257 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1258 | { |
---|
| 1259 | Int iFilledStride = apcFilledPlanes [uiCurPlane]->getStride(); |
---|
| 1260 | Int iAlphaStride = apcAlphaPlanes [uiCurPlane]->getStride(); |
---|
| 1261 | |
---|
| 1262 | Pel* pcFilledData = apcFilledPlanes [uiCurPlane]->getPlaneData(); |
---|
| 1263 | Pel* pcAlphaData = apcAlphaPlanes [uiCurPlane]->getPlaneData(); |
---|
| 1264 | |
---|
| 1265 | for(Int iYPos = 0; iYPos < iHeight; iYPos++) |
---|
| 1266 | { |
---|
| 1267 | for(Int iXPos = 0 ; iXPos < iWidth; iXPos++ ) |
---|
| 1268 | { |
---|
| 1269 | if (pcFilledData[iXPos] == REN_IS_HOLE) |
---|
| 1270 | { |
---|
| 1271 | while( (pcFilledData[iXPos] == REN_IS_HOLE) && (iXPos < iWidth) ) |
---|
| 1272 | { |
---|
| 1273 | pcAlphaData[iXPos] = REN_IS_HOLE; |
---|
| 1274 | iXPos++; |
---|
| 1275 | } |
---|
| 1276 | |
---|
| 1277 | if ( iXPos >= iWidth ) |
---|
| 1278 | continue; |
---|
| 1279 | |
---|
| 1280 | Int iWeight = 0; |
---|
| 1281 | Int iLastFillPos = iXPos + iBlendWidth; |
---|
| 1282 | |
---|
| 1283 | while( (pcFilledData[iXPos] != REN_IS_HOLE) && (iXPos < iWidth) && (iXPos < iLastFillPos) ) |
---|
| 1284 | { |
---|
| 1285 | AOF( iWeight <= (1 << REN_VDWEIGHT_PREC) ); |
---|
| 1286 | pcAlphaData[iXPos] = (iWeight == 0) ? 1 : iWeight; |
---|
| 1287 | iWeight += iWeightStep; |
---|
| 1288 | iXPos++; |
---|
| 1289 | } |
---|
| 1290 | } |
---|
| 1291 | else |
---|
| 1292 | { |
---|
| 1293 | pcAlphaData[iXPos] = REN_IS_FILLED; |
---|
| 1294 | } |
---|
| 1295 | } |
---|
| 1296 | pcAlphaData += iAlphaStride; |
---|
| 1297 | pcFilledData += iFilledStride; |
---|
| 1298 | } |
---|
| 1299 | } |
---|
| 1300 | } |
---|
| 1301 | |
---|
| 1302 | Void TRenTop::xRemBoundaryNoise(PelImage* pcInImage, PelImage* pcFilledImage, PelImage* pcOutImage, Bool bRenderFromLeft ) |
---|
| 1303 | { |
---|
| 1304 | if (pcInImage != pcOutImage) |
---|
| 1305 | { |
---|
| 1306 | pcOutImage->assign(pcInImage); |
---|
| 1307 | } |
---|
| 1308 | |
---|
| 1309 | UInt uiNumFullPlanes = pcInImage->getNumberOfFullPlanes(); |
---|
| 1310 | UInt uiNumQuatPlanes = pcInImage->getNumberOfQuaterPlanes(); |
---|
| 1311 | |
---|
| 1312 | AOF( uiNumFullPlanes == pcOutImage->getNumberOfFullPlanes () ); |
---|
| 1313 | AOF( uiNumQuatPlanes == pcOutImage->getNumberOfQuaterPlanes() ); |
---|
| 1314 | |
---|
| 1315 | xRemBoundaryNoisePlane( pcInImage->getPlanes(), pcFilledImage->getPlane(0), pcOutImage->getPlanes(), uiNumFullPlanes, bRenderFromLeft ); |
---|
| 1316 | |
---|
| 1317 | if (uiNumQuatPlanes > 0) |
---|
| 1318 | { |
---|
| 1319 | AOF( pcFilledImage->getNumberOfPlanes() > 1); |
---|
| 1320 | xRemBoundaryNoisePlane( pcInImage->getPlanes()+uiNumFullPlanes, pcFilledImage->getPlane(1), pcOutImage->getPlanes() + uiNumFullPlanes, uiNumQuatPlanes, bRenderFromLeft ); |
---|
| 1321 | } |
---|
| 1322 | }; |
---|
| 1323 | |
---|
| 1324 | Void TRenTop::xRemBoundaryNoisePlane(PelImagePlane** apcInputPlanes, PelImagePlane* pcFilledPlane, PelImagePlane** apcOutputPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft) |
---|
| 1325 | { |
---|
| 1326 | Int iWidth = apcOutputPlanes[0]->getWidth(); |
---|
| 1327 | Int iHeight = apcInputPlanes [0]->getHeight(); |
---|
| 1328 | |
---|
| 1329 | Int iInputStride = apcInputPlanes [0]->getStride(); |
---|
| 1330 | Int iOutputStride = apcOutputPlanes[0]->getStride(); |
---|
| 1331 | |
---|
| 1332 | Int iFilledStride = pcFilledPlane->getStride(); |
---|
| 1333 | |
---|
| 1334 | Pel** apcInputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 1335 | Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 1336 | Pel* pcFilledData = pcFilledPlane->getPlaneData(); |
---|
| 1337 | |
---|
| 1338 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1339 | { |
---|
| 1340 | apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData(); |
---|
| 1341 | apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData(); |
---|
| 1342 | AOF( iWidth == apcInputPlanes [uiCurPlane]->getWidth() && iWidth == apcOutputPlanes[uiCurPlane]->getWidth() ); |
---|
| 1343 | AOF( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight()); |
---|
| 1344 | AOF( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride()); |
---|
| 1345 | } |
---|
| 1346 | |
---|
| 1347 | Int iRemovalWidth = m_iBlendHoleMargin; |
---|
| 1348 | AOT(iRemovalWidth > 6); // GT: insufficent padding |
---|
| 1349 | |
---|
| 1350 | for(Int iYPos = 0; iYPos < iHeight; iYPos++) |
---|
| 1351 | { |
---|
| 1352 | for(Int iXPos = iWidth-1; iXPos >= 0; iXPos-- ) |
---|
| 1353 | { |
---|
| 1354 | if (pcFilledData[iXPos] == REN_IS_HOLE) |
---|
| 1355 | { |
---|
| 1356 | Int iSourcePos = iXPos + 1; |
---|
| 1357 | |
---|
| 1358 | // Get New Value |
---|
| 1359 | while( (pcFilledData[iSourcePos] != REN_IS_HOLE) && ( iSourcePos < iWidth) && ( iSourcePos < iXPos + iRemovalWidth ) ) iSourcePos++; |
---|
| 1360 | |
---|
| 1361 | if (iSourcePos == iWidth || pcFilledData[iSourcePos] != REN_IS_HOLE ) |
---|
| 1362 | iSourcePos--; |
---|
| 1363 | |
---|
| 1364 | Int iXPosRem = iSourcePos - 1; |
---|
| 1365 | |
---|
| 1366 | // Remove |
---|
| 1367 | while( iXPosRem > iXPos) |
---|
| 1368 | { |
---|
| 1369 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1370 | { |
---|
| 1371 | apcOutputData[uiCurPlane][iXPosRem] = apcInputData[uiCurPlane][iSourcePos]; |
---|
| 1372 | } |
---|
| 1373 | |
---|
| 1374 | iXPosRem--; |
---|
| 1375 | } |
---|
| 1376 | |
---|
| 1377 | // Skip Hole |
---|
| 1378 | while( (pcFilledData[iXPos] == REN_IS_HOLE) && ( iXPos > 0) ) iXPos--; |
---|
| 1379 | } |
---|
| 1380 | } |
---|
| 1381 | |
---|
| 1382 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1383 | { |
---|
| 1384 | apcOutputData[uiCurPlane] += iOutputStride; |
---|
| 1385 | apcInputData [uiCurPlane] += iInputStride; |
---|
| 1386 | } |
---|
| 1387 | pcFilledData += iFilledStride; |
---|
| 1388 | } |
---|
| 1389 | delete[] apcInputData; |
---|
| 1390 | delete[] apcOutputData; |
---|
| 1391 | } |
---|
| 1392 | |
---|
| 1393 | Void TRenTop::xFillPlaneHoles(PelImagePlane** apcInputPlanes, PelImagePlane* pcFilledPlane, PelImagePlane** apcOutputPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft) |
---|
| 1394 | { |
---|
| 1395 | Int iWidth = apcOutputPlanes[0]->getWidth(); |
---|
| 1396 | Int iHeight = apcInputPlanes [0]->getHeight(); |
---|
| 1397 | |
---|
| 1398 | Int iInputStride = apcInputPlanes [0]->getStride(); |
---|
| 1399 | Int iOutputStride = apcOutputPlanes[0]->getStride(); |
---|
| 1400 | |
---|
| 1401 | Int iFilledStride = pcFilledPlane->getStride(); |
---|
| 1402 | |
---|
| 1403 | Pel** apcInputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 1404 | Pel** apcOutputData = new Pel*[ uiNumberOfPlanes ]; |
---|
| 1405 | Pel* pcFilledData = pcFilledPlane->getPlaneData(); |
---|
| 1406 | |
---|
| 1407 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1408 | { |
---|
| 1409 | apcInputData [uiCurPlane] = apcInputPlanes [uiCurPlane]->getPlaneData(); |
---|
| 1410 | apcOutputData [uiCurPlane] = apcOutputPlanes[uiCurPlane]->getPlaneData(); |
---|
| 1411 | AOF( iWidth == apcInputPlanes [uiCurPlane]->getWidth() && iWidth == apcOutputPlanes[uiCurPlane]->getWidth() ); |
---|
| 1412 | AOF( iHeight == apcInputPlanes [uiCurPlane]->getHeight() && iHeight == apcOutputPlanes[uiCurPlane]->getHeight()); |
---|
| 1413 | AOF( iInputStride == apcInputPlanes [uiCurPlane]->getStride() && iOutputStride == apcOutputPlanes[uiCurPlane]->getStride()); |
---|
| 1414 | } |
---|
| 1415 | |
---|
| 1416 | for(Int iYPos = 0; iYPos < iHeight; iYPos++) |
---|
| 1417 | { |
---|
| 1418 | if ( !m_bInstantHoleFilling ) |
---|
| 1419 | { |
---|
| 1420 | for(Int iXPos = 0 ; iXPos < iWidth; iXPos++ ) |
---|
| 1421 | { |
---|
| 1422 | if (pcFilledData[iXPos] == REN_IS_HOLE) |
---|
| 1423 | { |
---|
| 1424 | Int iSourcePos; |
---|
| 1425 | Int iLastFillPos; |
---|
| 1426 | |
---|
| 1427 | Int iXPosSearch = iXPos; |
---|
| 1428 | while( (pcFilledData[iXPosSearch] == REN_IS_HOLE) && (iXPosSearch < iWidth) ) iXPosSearch++; |
---|
| 1429 | |
---|
| 1430 | if ( iXPosSearch >= iWidth ) |
---|
| 1431 | { |
---|
| 1432 | continue; |
---|
| 1433 | } |
---|
| 1434 | else |
---|
| 1435 | { |
---|
| 1436 | iSourcePos = iXPosSearch; |
---|
| 1437 | iLastFillPos = iXPosSearch-1; |
---|
| 1438 | } |
---|
| 1439 | |
---|
| 1440 | while( iXPos <= iLastFillPos) |
---|
| 1441 | { |
---|
| 1442 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1443 | { |
---|
| 1444 | apcOutputData[uiCurPlane][iXPos] = apcInputData[uiCurPlane][iSourcePos]; |
---|
| 1445 | } |
---|
| 1446 | iXPos++; |
---|
| 1447 | } |
---|
| 1448 | } |
---|
| 1449 | } |
---|
| 1450 | } |
---|
| 1451 | |
---|
| 1452 | // Fill Right Gap |
---|
| 1453 | Int iXPosSearch = iWidth -1; |
---|
| 1454 | while( (pcFilledData[iXPosSearch] == REN_IS_HOLE) && (iXPosSearch >= 0) ) iXPosSearch--; |
---|
| 1455 | if ( iXPosSearch < 0) iXPosSearch++; |
---|
| 1456 | |
---|
| 1457 | Int iSourcePos = iXPosSearch; |
---|
| 1458 | |
---|
| 1459 | for( Int iXPos = iSourcePos + 1; iXPos < iWidth; iXPos++) |
---|
| 1460 | { |
---|
| 1461 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1462 | { |
---|
| 1463 | apcOutputData[uiCurPlane][iXPos] = apcInputData[uiCurPlane][iSourcePos]; |
---|
| 1464 | } |
---|
| 1465 | } |
---|
| 1466 | |
---|
| 1467 | // Fill Left Gap |
---|
| 1468 | iXPosSearch = 0; |
---|
| 1469 | while( (pcFilledData[iXPosSearch] == REN_IS_HOLE) && (iXPosSearch < iWidth) ) iXPosSearch++; |
---|
| 1470 | if ( iXPosSearch >= iWidth) iXPosSearch--; |
---|
| 1471 | |
---|
| 1472 | iSourcePos = iXPosSearch; |
---|
| 1473 | |
---|
| 1474 | for( Int iXPos = iSourcePos - 1; iXPos >= 0; iXPos--) |
---|
| 1475 | { |
---|
| 1476 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1477 | { |
---|
| 1478 | apcOutputData[uiCurPlane][iXPos] = apcInputData[uiCurPlane][iSourcePos]; |
---|
| 1479 | } |
---|
| 1480 | } |
---|
| 1481 | |
---|
| 1482 | // Go to next line |
---|
| 1483 | for( UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++) |
---|
| 1484 | { |
---|
| 1485 | apcOutputData[uiCurPlane] += iOutputStride; |
---|
| 1486 | apcInputData [uiCurPlane] += iInputStride; |
---|
| 1487 | } |
---|
| 1488 | pcFilledData += iFilledStride; |
---|
| 1489 | } |
---|
| 1490 | delete[] apcInputData; |
---|
| 1491 | delete[] apcOutputData; |
---|
| 1492 | } |
---|
| 1493 | |
---|
| 1494 | Void TRenTop::xPostProcessImage(PelImage* pcInImage, PelImage* pcOutImage) |
---|
| 1495 | { |
---|
| 1496 | if ( m_iPostProcMode == eRenPostProNone ) |
---|
| 1497 | return; |
---|
| 1498 | |
---|
| 1499 | PelImage* pcTemp; |
---|
| 1500 | |
---|
| 1501 | if (pcInImage == pcOutImage) |
---|
| 1502 | { |
---|
| 1503 | pcTemp = pcOutImage->create(); |
---|
| 1504 | } |
---|
| 1505 | else |
---|
| 1506 | { |
---|
| 1507 | pcTemp = pcOutImage; |
---|
| 1508 | } |
---|
| 1509 | |
---|
| 1510 | pcTemp->assign(pcInImage); |
---|
| 1511 | |
---|
| 1512 | switch ( m_iPostProcMode ) |
---|
| 1513 | { |
---|
| 1514 | case eRenPostProMed: |
---|
| 1515 | TRenFilter::lineMedian3(pcTemp); |
---|
| 1516 | break; |
---|
| 1517 | case eRenPostProNone: |
---|
| 1518 | break; |
---|
| 1519 | default: |
---|
| 1520 | assert(0); |
---|
| 1521 | } |
---|
| 1522 | |
---|
| 1523 | if (pcInImage == pcOutImage) |
---|
| 1524 | { |
---|
| 1525 | pcOutImage->assign(pcTemp); |
---|
| 1526 | delete pcTemp; |
---|
| 1527 | }; |
---|
| 1528 | } |
---|
| 1529 | |
---|
| 1530 | |
---|
| 1531 | Void TRenTop::xCutPlaneMargin( PelImagePlane* pcImagePlane, Pel cFill, UInt uiScale ) |
---|
| 1532 | { |
---|
| 1533 | UInt uiWidth = pcImagePlane->getWidth(); |
---|
| 1534 | UInt uiHeight = pcImagePlane->getHeight(); |
---|
| 1535 | |
---|
| 1536 | UInt uiStride = pcImagePlane->getStride(); |
---|
| 1537 | Pel* pcPlaneData = pcImagePlane->getPlaneData(); |
---|
| 1538 | |
---|
| 1539 | UInt uiCutLeft = m_auiCut[0] / uiScale; |
---|
| 1540 | UInt uiCutRight = uiWidth - m_auiCut[1] / uiScale; |
---|
| 1541 | |
---|
| 1542 | for(UInt uiYPos = 0; uiYPos < uiHeight; uiYPos++) |
---|
| 1543 | { |
---|
| 1544 | for(UInt uiXPos = 0; uiXPos < (UInt) uiWidth ; uiXPos++) |
---|
| 1545 | { |
---|
| 1546 | if ( ( uiXPos < uiCutLeft ) || ( uiXPos >= uiCutRight ) ) |
---|
| 1547 | { |
---|
| 1548 | pcPlaneData[uiXPos ] = cFill; |
---|
| 1549 | } |
---|
| 1550 | } |
---|
| 1551 | pcPlaneData += uiStride; |
---|
| 1552 | } |
---|
| 1553 | }; |
---|
| 1554 | |
---|
| 1555 | Void TRenTop::xCutMargin( PelImage* pcInputImage ) |
---|
| 1556 | { |
---|
| 1557 | if ( ( m_auiCut[0] == 0 ) && ( m_auiCut[1] == 0 ) ) |
---|
| 1558 | { |
---|
| 1559 | return; |
---|
| 1560 | }; |
---|
| 1561 | |
---|
| 1562 | UInt uiCurPlane = 0; |
---|
| 1563 | for (; uiCurPlane < pcInputImage->getNumberOfFullPlanes(); uiCurPlane++ ) |
---|
| 1564 | { |
---|
| 1565 | xCutPlaneMargin( pcInputImage->getPlane(uiCurPlane), (Pel) 0 , 1 ); |
---|
| 1566 | } |
---|
| 1567 | |
---|
| 1568 | for (; uiCurPlane < pcInputImage->getNumberOfPlanes(); uiCurPlane++ ) |
---|
| 1569 | { |
---|
| 1570 | xCutPlaneMargin( pcInputImage->getPlane(uiCurPlane), (Pel) 128 , 2 ); |
---|
| 1571 | } |
---|
| 1572 | |
---|
| 1573 | }; |
---|
| 1574 | |
---|
| 1575 | |
---|
| 1576 | Void TRenTop::xEnhSimilarity( PelImage* pcLeftImage, PelImage* pcRightImage, PelImage* pcFilledLeft, PelImage* pcFilledRight ) |
---|
| 1577 | { |
---|
| 1578 | if (m_iSimEnhBaseView == 0) |
---|
| 1579 | return; |
---|
| 1580 | |
---|
| 1581 | UInt uiNumFullPlanes = pcLeftImage->getNumberOfFullPlanes(); |
---|
| 1582 | UInt uiNumQuatPlanes = pcLeftImage->getNumberOfQuaterPlanes(); |
---|
| 1583 | |
---|
| 1584 | if (uiNumQuatPlanes > 0) |
---|
| 1585 | { |
---|
| 1586 | assert( pcFilledLeft ->getNumberOfPlanes() > 1); |
---|
| 1587 | assert( pcFilledRight->getNumberOfPlanes() > 1); |
---|
| 1588 | }; |
---|
| 1589 | |
---|
| 1590 | xEnhSimilarityPlane ( pcLeftImage->getPlanes() , pcRightImage->getPlanes() , pcFilledLeft->getPlane(0), pcFilledRight->getPlane(0), uiNumFullPlanes); |
---|
| 1591 | if (uiNumQuatPlanes > 0) |
---|
| 1592 | { |
---|
| 1593 | xEnhSimilarityPlane ( pcLeftImage->getPlanes()+uiNumFullPlanes, pcRightImage->getPlanes()+uiNumFullPlanes, pcFilledLeft->getPlane(1), pcFilledRight->getPlane(1), uiNumQuatPlanes); |
---|
| 1594 | } |
---|
| 1595 | } |
---|
| 1596 | |
---|
| 1597 | Void TRenTop::xEnhSimilarityPlane ( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, UInt uiNumberOfPlanes ) |
---|
| 1598 | { |
---|
| 1599 | AOT( m_iSimEnhBaseView != 1 && m_iSimEnhBaseView != 2 ); |
---|
| 1600 | Int iWidth = (*apcRightPlane)->getWidth (); |
---|
| 1601 | Int iHeight = (*apcRightPlane)->getHeight(); |
---|
| 1602 | |
---|
| 1603 | Int* aiHistLeft = new Int[ g_uiIBDI_MAX + 1 ]; |
---|
| 1604 | Int* aiHistRight = new Int[ g_uiIBDI_MAX + 1 ]; |
---|
| 1605 | Pel* aiConvLUT = new Pel[ g_uiIBDI_MAX + 1 ]; |
---|
| 1606 | |
---|
| 1607 | for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++ ) |
---|
| 1608 | { |
---|
| 1609 | for (Int iCurVal = 0 ; iCurVal <= g_uiIBDI_MAX; iCurVal++) |
---|
| 1610 | { |
---|
| 1611 | aiHistLeft [iCurVal] = 0; |
---|
| 1612 | aiHistRight[iCurVal] = 0; |
---|
| 1613 | } |
---|
| 1614 | |
---|
| 1615 | Pel* pcFilledRightData = pcFilledRightPlane ->getPlaneData(); |
---|
| 1616 | Pel* pcRightImageData = (*apcRightPlane ) ->getPlaneData(); |
---|
| 1617 | |
---|
| 1618 | Pel* pcFilledLeftData = pcFilledLeftPlane ->getPlaneData(); |
---|
| 1619 | Pel* pcLeftImageData = (*apcLeftPlane) ->getPlaneData(); |
---|
| 1620 | |
---|
[5] | 1621 | |
---|
[2] | 1622 | |
---|
| 1623 | for (UInt uiYPos = 0; uiYPos < iHeight; uiYPos++ ) |
---|
| 1624 | { |
---|
| 1625 | for (UInt uiXPos = 0; uiXPos < iWidth; uiXPos++ ) |
---|
| 1626 | { |
---|
| 1627 | if ( pcFilledLeftData[uiXPos] == REN_IS_FILLED && pcFilledRightData[uiXPos] == REN_IS_FILLED ) |
---|
| 1628 | { |
---|
| 1629 | aiHistLeft [pcLeftImageData [uiXPos] ]++; |
---|
| 1630 | aiHistRight[pcRightImageData [uiXPos] ]++; |
---|
| 1631 | } |
---|
| 1632 | } |
---|
| 1633 | |
---|
| 1634 | |
---|
| 1635 | pcFilledRightData += pcFilledRightPlane ->getStride(); |
---|
| 1636 | pcRightImageData += (*apcRightPlane) ->getStride(); |
---|
| 1637 | |
---|
| 1638 | pcFilledLeftData += pcFilledLeftPlane ->getStride(); |
---|
| 1639 | pcLeftImageData += (*apcLeftPlane) ->getStride(); |
---|
| 1640 | } |
---|
| 1641 | |
---|
| 1642 | Int iCumSumChange = 0; |
---|
| 1643 | Int iCumSumBase = 0; |
---|
| 1644 | Int iCurBaseVal = 0; |
---|
| 1645 | Int iCurChangeVal = 0; |
---|
| 1646 | |
---|
| 1647 | Int* aiHistChange = (m_iSimEnhBaseView == 2 ) ? aiHistLeft : aiHistRight; |
---|
| 1648 | Int* aiHistBase = (m_iSimEnhBaseView == 2 ) ? aiHistRight : aiHistLeft ; |
---|
| 1649 | |
---|
| 1650 | iCumSumChange += aiHistChange[iCurChangeVal]; |
---|
| 1651 | iCumSumBase += aiHistBase [iCurBaseVal] ; |
---|
| 1652 | |
---|
| 1653 | Int iCheckSumLeft = 0; |
---|
| 1654 | Int iCheckSumRight = 0; |
---|
| 1655 | |
---|
| 1656 | for (Int iCurVal = 0 ; iCurVal <= g_uiIBDI_MAX; iCurVal++) |
---|
| 1657 | { |
---|
| 1658 | iCheckSumLeft += aiHistLeft [iCurVal]; |
---|
| 1659 | iCheckSumRight += aiHistRight[iCurVal]; |
---|
| 1660 | } |
---|
| 1661 | |
---|
| 1662 | |
---|
| 1663 | while( iCurChangeVal <= g_uiIBDI_MAX ) |
---|
| 1664 | { |
---|
| 1665 | if ( iCumSumBase == iCumSumChange ) |
---|
| 1666 | { |
---|
| 1667 | aiConvLUT[iCurChangeVal] = Min(iCurBaseVal, g_uiIBDI_MAX); |
---|
| 1668 | iCurBaseVal ++; |
---|
| 1669 | iCurChangeVal++; |
---|
| 1670 | iCumSumChange += aiHistChange[iCurChangeVal]; |
---|
| 1671 | if (iCurBaseVal <= g_uiIBDI_MAX ) |
---|
| 1672 | { |
---|
| 1673 | iCumSumBase += aiHistBase [iCurBaseVal] ; |
---|
| 1674 | } |
---|
| 1675 | } |
---|
| 1676 | else if ( iCumSumBase < iCumSumChange ) |
---|
| 1677 | { |
---|
| 1678 | iCurBaseVal++; |
---|
| 1679 | if (iCurBaseVal <= g_uiIBDI_MAX ) |
---|
| 1680 | { |
---|
| 1681 | iCumSumBase += aiHistBase [iCurBaseVal] ; |
---|
| 1682 | } |
---|
| 1683 | } |
---|
| 1684 | else if ( iCumSumBase > iCumSumChange) |
---|
| 1685 | { |
---|
| 1686 | aiConvLUT[iCurChangeVal] = Min(iCurBaseVal, g_uiIBDI_MAX); |
---|
| 1687 | iCurChangeVal++; |
---|
| 1688 | iCumSumChange += aiHistChange [iCurChangeVal] ; |
---|
| 1689 | } |
---|
| 1690 | } |
---|
| 1691 | |
---|
| 1692 | Pel* pcChangeImageData = ( ( m_iSimEnhBaseView == 2 ) ? (*apcLeftPlane) : (*apcRightPlane) )->getPlaneData(); |
---|
| 1693 | Int iChangeImageStride = ( ( m_iSimEnhBaseView == 2 ) ? (*apcLeftPlane) : (*apcRightPlane) )->getStride (); |
---|
| 1694 | |
---|
| 1695 | for (UInt uiYPos = 0; uiYPos < iHeight; uiYPos++ ) |
---|
| 1696 | { |
---|
| 1697 | for (UInt uiXPos = 0; uiXPos < iWidth; uiXPos++ ) |
---|
| 1698 | { |
---|
| 1699 | pcChangeImageData [uiXPos] = aiConvLUT[ pcChangeImageData[uiXPos]]; |
---|
| 1700 | } |
---|
| 1701 | pcChangeImageData += iChangeImageStride; |
---|
| 1702 | } |
---|
| 1703 | |
---|
| 1704 | apcRightPlane ++; |
---|
| 1705 | apcLeftPlane ++; |
---|
| 1706 | |
---|
| 1707 | } |
---|
| 1708 | |
---|
| 1709 | delete[] aiHistLeft ; |
---|
| 1710 | delete[] aiHistRight; |
---|
| 1711 | delete[] aiConvLUT ; |
---|
| 1712 | } |
---|
| 1713 | |
---|
| 1714 | |
---|
| 1715 | Void TRenTop::xBlend( PelImage* pcLeftImage, PelImage* pcRightImage, PelImage* pcFilledLeft, PelImage* pcFilledRight, PelImage* pcLeftDepth, PelImage* pcRightDepth, PelImage* pcOutputImage ) |
---|
| 1716 | { |
---|
| 1717 | UInt uiNumFullPlanes = pcLeftImage->getNumberOfFullPlanes(); |
---|
| 1718 | UInt uiNumQuatPlanes = pcLeftImage->getNumberOfQuaterPlanes(); |
---|
| 1719 | |
---|
| 1720 | assert( uiNumFullPlanes == pcRightImage->getNumberOfFullPlanes () && uiNumFullPlanes == pcOutputImage->getNumberOfFullPlanes ()); |
---|
| 1721 | assert( uiNumQuatPlanes == pcRightImage->getNumberOfQuaterPlanes() && uiNumQuatPlanes == pcOutputImage->getNumberOfQuaterPlanes ()); |
---|
| 1722 | |
---|
| 1723 | if (uiNumQuatPlanes > 0) |
---|
| 1724 | { |
---|
| 1725 | assert( pcLeftDepth ->getNumberOfPlanes() > 1 || pcFilledLeft ->getNumberOfPlanes() > 1); |
---|
| 1726 | assert( pcRightDepth->getNumberOfPlanes() > 1 || pcFilledRight->getNumberOfPlanes() > 1); |
---|
| 1727 | }; |
---|
| 1728 | |
---|
| 1729 | switch (m_iBlendMode) |
---|
| 1730 | { |
---|
| 1731 | case eRenBlendAverg: |
---|
| 1732 | case eRenBlendDepthFirst: |
---|
| 1733 | xBlendPlanesAvg( pcLeftImage->getPlanes() , pcRightImage->getPlanes() , pcFilledLeft->getPlane(0), pcFilledRight->getPlane(0), pcLeftDepth->getPlane(0), pcRightDepth->getPlane(0), pcOutputImage->getPlanes(), uiNumFullPlanes); |
---|
| 1734 | if (uiNumQuatPlanes > 0) |
---|
| 1735 | { |
---|
| 1736 | xBlendPlanesAvg( pcLeftImage->getPlanes()+uiNumFullPlanes, pcRightImage->getPlanes()+uiNumFullPlanes, pcFilledLeft->getPlane(1), pcFilledRight->getPlane(1), pcLeftDepth->getPlane(1), pcRightDepth->getPlane(1), pcOutputImage->getPlanes()+uiNumFullPlanes, uiNumQuatPlanes); |
---|
| 1737 | } |
---|
| 1738 | break; |
---|
| 1739 | case eRenBlendLeft: |
---|
| 1740 | case eRenBlendRight: |
---|
| 1741 | xBlendPlanesOneView( pcLeftImage->getPlanes() , pcRightImage->getPlanes() , pcFilledLeft->getPlane(0), pcFilledRight->getPlane(0), pcLeftDepth->getPlane(0), pcRightDepth->getPlane(0), pcOutputImage->getPlanes(), uiNumFullPlanes); |
---|
| 1742 | if (uiNumQuatPlanes > 0) |
---|
| 1743 | { |
---|
| 1744 | xBlendPlanesOneView( pcLeftImage->getPlanes()+uiNumFullPlanes, pcRightImage->getPlanes()+uiNumFullPlanes, pcFilledLeft->getPlane(1), pcFilledRight->getPlane(1), pcLeftDepth->getPlane(1), pcRightDepth->getPlane(1), pcOutputImage->getPlanes()+uiNumFullPlanes, uiNumQuatPlanes); |
---|
| 1745 | } |
---|
| 1746 | break; |
---|
| 1747 | } |
---|
| 1748 | } |
---|
| 1749 | |
---|
| 1750 | Void TRenTop::xBlendPlanesOneView( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, PelImagePlane* pcLeftDepthPlane, PelImagePlane* pcRightDepthPlane, PelImagePlane** apcOutputImagePlane, UInt uiNumberOfPlanes ) |
---|
| 1751 | { |
---|
| 1752 | for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++ ) |
---|
| 1753 | { |
---|
| 1754 | Pel* pcFilledRightData = pcFilledRightPlane ->getPlaneData(); |
---|
| 1755 | Pel* pcRightImageData = (*apcRightPlane ) ->getPlaneData(); |
---|
| 1756 | Pel* pcRightDepthData = pcRightDepthPlane ->getPlaneData(); |
---|
| 1757 | |
---|
| 1758 | Pel* pcFilledLeftData = pcFilledLeftPlane ->getPlaneData(); |
---|
| 1759 | Pel* pcLeftImageData = (*apcLeftPlane) ->getPlaneData(); |
---|
| 1760 | Pel* pcLeftDepthData = pcLeftDepthPlane ->getPlaneData(); |
---|
| 1761 | Pel* pcOutputData = (*apcOutputImagePlane)->getPlaneData(); |
---|
| 1762 | |
---|
| 1763 | for (UInt uiYPos = 0; uiYPos < (*apcOutputImagePlane)->getHeight(); uiYPos++ ) |
---|
| 1764 | { |
---|
| 1765 | for (UInt uiXPos = 0; uiXPos < (*apcOutputImagePlane)->getWidth(); uiXPos++ ) |
---|
| 1766 | { |
---|
| 1767 | if (m_iBlendMode == eRenBlendLeft ) |
---|
| 1768 | { |
---|
| 1769 | if ( pcFilledLeftData[uiXPos] == REN_IS_FILLED || pcFilledRightData[uiXPos] == REN_IS_HOLE ) |
---|
| 1770 | { |
---|
| 1771 | pcOutputData[uiXPos] = pcLeftImageData[uiXPos]; |
---|
| 1772 | } |
---|
| 1773 | else if ( pcFilledLeftData[uiXPos] == REN_IS_HOLE ) |
---|
| 1774 | { |
---|
| 1775 | pcOutputData[uiXPos] = pcRightImageData[uiXPos]; |
---|
| 1776 | } |
---|
| 1777 | else |
---|
| 1778 | { |
---|
| 1779 | pcOutputData[uiXPos] = pcRightImageData[uiXPos] + (Pel) ( ( (Int) ( pcLeftImageData[uiXPos] - pcRightImageData[uiXPos] ) * pcFilledLeftData[uiXPos] + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC ); |
---|
| 1780 | } |
---|
| 1781 | } |
---|
| 1782 | else if ( m_iBlendMode == eRenBlendRight ) |
---|
| 1783 | { |
---|
| 1784 | if ( pcFilledRightData[uiXPos] == REN_IS_FILLED || pcFilledLeftData[uiXPos] == REN_IS_HOLE ) |
---|
| 1785 | { |
---|
| 1786 | pcOutputData[uiXPos] = pcRightImageData[uiXPos]; |
---|
| 1787 | } |
---|
| 1788 | else if ( pcFilledRightData[uiXPos] == REN_IS_HOLE ) |
---|
| 1789 | { |
---|
| 1790 | pcOutputData[uiXPos] = pcLeftImageData[uiXPos]; |
---|
| 1791 | } |
---|
| 1792 | else |
---|
| 1793 | { |
---|
| 1794 | pcOutputData[uiXPos] = pcLeftImageData[uiXPos] + (Pel) ( ( (Int) ( pcRightImageData[uiXPos] - pcLeftImageData[uiXPos] ) * pcFilledRightData[uiXPos] + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC ); |
---|
| 1795 | } |
---|
| 1796 | } |
---|
| 1797 | else |
---|
| 1798 | { |
---|
| 1799 | AOT(true); |
---|
| 1800 | } |
---|
| 1801 | } |
---|
| 1802 | |
---|
| 1803 | pcFilledRightData += pcFilledRightPlane ->getStride(); |
---|
| 1804 | pcRightImageData += (*apcRightPlane) ->getStride(); |
---|
| 1805 | pcRightDepthData += pcRightDepthPlane ->getStride(); |
---|
| 1806 | |
---|
| 1807 | pcFilledLeftData += pcFilledLeftPlane ->getStride(); |
---|
| 1808 | pcLeftImageData += (*apcLeftPlane) ->getStride(); |
---|
| 1809 | pcLeftDepthData += pcLeftDepthPlane ->getStride(); |
---|
| 1810 | pcOutputData += (*apcOutputImagePlane)->getStride(); |
---|
| 1811 | } |
---|
| 1812 | |
---|
| 1813 | apcRightPlane ++; |
---|
| 1814 | apcLeftPlane ++; |
---|
| 1815 | apcOutputImagePlane++; |
---|
| 1816 | } |
---|
| 1817 | } |
---|
| 1818 | |
---|
| 1819 | Void TRenTop::xBlendPlanesAvg( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, PelImagePlane* pcLeftDepthPlane, PelImagePlane* pcRightDepthPlane, PelImagePlane** apcOutputImagePlane, UInt uiNumberOfPlanes ) |
---|
| 1820 | { |
---|
| 1821 | for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfPlanes; uiCurPlane++ ) |
---|
| 1822 | { |
---|
| 1823 | Pel* pcFilledRightData = pcFilledRightPlane ->getPlaneData(); |
---|
| 1824 | Pel* pcRightVideoData = (*apcRightPlane ) ->getPlaneData(); |
---|
| 1825 | Pel* pcRightDepthData = pcRightDepthPlane ->getPlaneData(); |
---|
| 1826 | |
---|
| 1827 | Pel* pcFilledLeftData = pcFilledLeftPlane ->getPlaneData(); |
---|
| 1828 | Pel* pcLeftVideoData = (*apcLeftPlane) ->getPlaneData(); |
---|
| 1829 | Pel* pcLeftDepthData = pcLeftDepthPlane ->getPlaneData(); |
---|
| 1830 | |
---|
| 1831 | Pel* pcOutputData = (*apcOutputImagePlane)->getPlaneData(); |
---|
| 1832 | |
---|
| 1833 | for (UInt uiYPos = 0; uiYPos < (*apcOutputImagePlane)->getHeight(); uiYPos++ ) |
---|
| 1834 | { |
---|
| 1835 | for (UInt uiXPos = 0; uiXPos < (*apcOutputImagePlane)->getWidth(); uiXPos++ ) |
---|
| 1836 | { |
---|
| 1837 | if ( (pcFilledRightData[uiXPos] != REN_IS_HOLE ) && ( pcFilledLeftData[uiXPos] != REN_IS_HOLE) ) |
---|
| 1838 | { |
---|
| 1839 | Int iDepthDifference = m_piInvZLUTLeft[RemoveBitIncrement(pcLeftDepthData[uiXPos])] - m_piInvZLUTRight[RemoveBitIncrement(pcRightDepthData[uiXPos])]; |
---|
| 1840 | |
---|
| 1841 | if ( abs ( iDepthDifference ) <= m_iBlendZThres ) |
---|
| 1842 | { |
---|
| 1843 | if ((pcFilledRightData[uiXPos] == REN_IS_FILLED) && ( pcFilledLeftData[uiXPos] != REN_IS_FILLED)) |
---|
| 1844 | { |
---|
| 1845 | pcOutputData[uiXPos] = pcRightVideoData[uiXPos] + (Pel) ( ( (Int) ( pcLeftVideoData[uiXPos] - pcRightVideoData[uiXPos] ) * (pcFilledLeftData[uiXPos]) + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC ); |
---|
| 1846 | } |
---|
| 1847 | else if ((pcFilledRightData[uiXPos] != REN_IS_FILLED) && ( pcFilledLeftData[uiXPos] == REN_IS_FILLED)) |
---|
| 1848 | { |
---|
| 1849 | pcOutputData[uiXPos] = pcLeftVideoData[uiXPos] + (Pel) ( ( (Int) ( pcRightVideoData[uiXPos] - pcLeftVideoData[uiXPos] ) * (pcFilledRightData[uiXPos]) + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC ); |
---|
| 1850 | } |
---|
| 1851 | else |
---|
| 1852 | { |
---|
| 1853 | pcOutputData[uiXPos] = pcLeftVideoData[uiXPos] + (Pel) ( ( (Int) ( pcRightVideoData[uiXPos] - pcLeftVideoData[uiXPos] ) * m_iBlendDistWeight + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC ); |
---|
| 1854 | } |
---|
| 1855 | |
---|
| 1856 | } |
---|
| 1857 | else if ( iDepthDifference < 0 ) |
---|
| 1858 | { |
---|
| 1859 | pcOutputData[uiXPos] = pcRightVideoData[uiXPos]; |
---|
| 1860 | } |
---|
| 1861 | else |
---|
| 1862 | { |
---|
| 1863 | pcOutputData[uiXPos] = pcLeftVideoData[uiXPos]; |
---|
| 1864 | } |
---|
| 1865 | } |
---|
| 1866 | else if ( (pcFilledRightData[uiXPos] == REN_IS_HOLE) && (pcFilledLeftData[uiXPos] == REN_IS_HOLE)) |
---|
| 1867 | { |
---|
| 1868 | pcOutputData[uiXPos] = m_piInvZLUTLeft[RemoveBitIncrement( pcLeftDepthData[uiXPos])] < m_piInvZLUTRight[RemoveBitIncrement(pcRightDepthData[uiXPos])] ? pcLeftVideoData[uiXPos] : pcRightVideoData[uiXPos]; |
---|
| 1869 | } |
---|
| 1870 | else |
---|
| 1871 | { |
---|
| 1872 | pcOutputData[uiXPos] = (pcFilledLeftData[uiXPos] == REN_IS_HOLE) ? pcRightVideoData[uiXPos] : pcLeftVideoData[uiXPos]; |
---|
| 1873 | } |
---|
| 1874 | } |
---|
| 1875 | |
---|
| 1876 | pcFilledRightData += pcFilledRightPlane ->getStride(); |
---|
| 1877 | pcRightVideoData += (*apcRightPlane) ->getStride(); |
---|
| 1878 | pcRightDepthData += pcRightDepthPlane ->getStride(); |
---|
| 1879 | |
---|
| 1880 | pcFilledLeftData += pcFilledLeftPlane ->getStride(); |
---|
| 1881 | pcLeftVideoData += (*apcLeftPlane) ->getStride(); |
---|
| 1882 | pcLeftDepthData += pcLeftDepthPlane ->getStride(); |
---|
| 1883 | pcOutputData += (*apcOutputImagePlane)->getStride(); |
---|
| 1884 | }; |
---|
| 1885 | |
---|
| 1886 | apcRightPlane ++; |
---|
| 1887 | apcLeftPlane ++; |
---|
| 1888 | apcOutputImagePlane++; |
---|
| 1889 | } |
---|
| 1890 | } |
---|
| 1891 | |
---|
| 1892 | // Temporal Filter from Zhejiang University: (a little different from m16041: Temporal Improvement Method in View Synthesis) |
---|
| 1893 | Void TRenTop::temporalFilterVSRS( TComPicYuv* pcPicYuvVideoCur, TComPicYuv* pcPicYuvDepthCur, TComPicYuv* pcPicYuvVideoLast, TComPicYuv* pcPicYuvDepthLast, Bool bFirstFrame ) |
---|
| 1894 | { |
---|
| 1895 | Int iSADThres = 100 ; //threshold of sad in 4*4 block motion detection |
---|
| 1896 | |
---|
| 1897 | Int iWidth = m_auiInputResolution[0]; |
---|
| 1898 | Int iHeight = m_auiInputResolution[1]; |
---|
| 1899 | |
---|
| 1900 | //internal variables |
---|
| 1901 | Int* piFlagMoving = m_aiBlkMoving + 2; |
---|
| 1902 | |
---|
| 1903 | Int iVideoCurStride = pcPicYuvVideoCur ->getStride(); |
---|
| 1904 | Int iVideoLastStride = pcPicYuvVideoLast->getStride(); |
---|
| 1905 | Int iDepthCurStride = pcPicYuvDepthCur ->getStride(); |
---|
| 1906 | Int iDepthLastStride = pcPicYuvDepthLast->getStride(); |
---|
| 1907 | |
---|
| 1908 | Pel* pcVideoCurData = pcPicYuvVideoCur ->getLumaAddr(); |
---|
| 1909 | Pel* pcVideoLastData = pcPicYuvVideoLast->getLumaAddr(); |
---|
| 1910 | Pel* pcDepthCurData = pcPicYuvDepthCur ->getLumaAddr(); |
---|
| 1911 | Pel* pcDepthLastData = pcPicYuvDepthLast->getLumaAddr(); |
---|
| 1912 | |
---|
| 1913 | Pel* pcVideoCurDataFrm = pcVideoCurData ; |
---|
| 1914 | Pel* pcVideoLastDataFrm = pcVideoLastData; |
---|
| 1915 | Pel* pcDepthCurDataFrm = pcDepthCurData ; |
---|
| 1916 | Pel* pcDepthLastDataFrm = pcDepthLastData; |
---|
| 1917 | |
---|
| 1918 | |
---|
| 1919 | if( !bFirstFrame ) // first frame need not the weighting, but need to prepare the data |
---|
| 1920 | { |
---|
| 1921 | for ( Int iPosY = 0; iPosY < (iHeight >> 2); iPosY++) |
---|
| 1922 | { |
---|
| 1923 | //motion detection by SAD |
---|
| 1924 | for ( Int iPosX = 0; iPosX < (iWidth >> 2); iPosX++) |
---|
| 1925 | { |
---|
| 1926 | Int iSAD = 0; |
---|
| 1927 | |
---|
| 1928 | Pel* pcVideoCurDataBlk = pcVideoCurDataFrm + (iPosX << 2); |
---|
| 1929 | Pel* pcVideoLastDataBlk = pcVideoLastDataFrm + (iPosX << 2); |
---|
| 1930 | |
---|
| 1931 | //GT: Check difference of block compared to last frame |
---|
| 1932 | for( Int iCurPosY = 0; iCurPosY < 4; iCurPosY++) |
---|
| 1933 | { |
---|
| 1934 | for( Int iCurPosX = 0; iCurPosX < 4; iCurPosX++) |
---|
| 1935 | { |
---|
| 1936 | iSAD += abs( pcVideoLastDataBlk[iCurPosX] - pcVideoCurDataBlk[iCurPosX] ); //SAD |
---|
| 1937 | } |
---|
| 1938 | pcVideoLastDataBlk += iVideoLastStride; |
---|
| 1939 | pcVideoCurDataBlk += iVideoCurStride; |
---|
| 1940 | } |
---|
| 1941 | |
---|
| 1942 | piFlagMoving[iPosX] = ( iSAD < iSADThres ) ? 0 : 1; |
---|
| 1943 | } |
---|
| 1944 | |
---|
| 1945 | //temporal weighting according to motion detection result -- do a line |
---|
| 1946 | for ( Int iPosX = 0; iPosX < (iWidth >> 2); iPosX++) |
---|
| 1947 | { |
---|
| 1948 | //5 block |
---|
| 1949 | Int iSumMoving = piFlagMoving[iPosX-2] + piFlagMoving[iPosX-1] + piFlagMoving[iPosX] + piFlagMoving[iPosX+1] + piFlagMoving[iPosX+2]; |
---|
| 1950 | |
---|
| 1951 | if( iSumMoving == 0 ) // if not moving |
---|
| 1952 | { |
---|
| 1953 | Pel* pcDepthCurDataBlk = pcDepthCurDataFrm + (iPosX << 2); |
---|
| 1954 | Pel* pcDepthLastDataBlk = pcDepthLastDataFrm + (iPosX << 2); |
---|
| 1955 | |
---|
| 1956 | for( Int iCurPosY = 0; iCurPosY < 4; iCurPosY++) |
---|
| 1957 | { |
---|
| 1958 | for( Int iCurPosX = 0; iCurPosX < 4; iCurPosX++) |
---|
| 1959 | { //Weight: 0.75 |
---|
| 1960 | Int iFilt = (( (pcDepthLastDataBlk[iCurPosX] << 1 ) + pcDepthLastDataBlk[iCurPosX] + pcDepthCurDataBlk[iCurPosX] + 2 ) >> 2 ); |
---|
| 1961 | assert( (iFilt >= 0) && (iFilt <= g_uiIBDI_MAX) ); |
---|
| 1962 | pcDepthCurDataBlk[iCurPosX] = pcDepthLastDataBlk[iCurPosX]; |
---|
| 1963 | pcDepthCurDataBlk[iCurPosX] = iFilt; |
---|
| 1964 | } |
---|
| 1965 | |
---|
| 1966 | pcDepthCurDataBlk += iDepthCurStride; |
---|
| 1967 | pcDepthLastDataBlk += iDepthLastStride; |
---|
| 1968 | } |
---|
| 1969 | } |
---|
| 1970 | } |
---|
| 1971 | |
---|
| 1972 | pcDepthCurDataFrm += ( iDepthCurStride << 2); |
---|
| 1973 | pcDepthLastDataFrm += ( iDepthLastStride << 2); |
---|
| 1974 | pcVideoCurDataFrm += ( iVideoCurStride << 2); |
---|
| 1975 | pcVideoLastDataFrm += ( iVideoLastStride << 2); |
---|
| 1976 | } |
---|
| 1977 | } |
---|
| 1978 | pcPicYuvVideoCur->copyToPic( pcPicYuvVideoLast ); |
---|
| 1979 | pcPicYuvDepthCur->copyToPic( pcPicYuvDepthLast ); |
---|
| 1980 | } |
---|
| 1981 | |
---|
| 1982 | TRenTop::TRenTop() |
---|
| 1983 | { |
---|
| 1984 | m_auiInputResolution[0] = 0; |
---|
| 1985 | m_auiInputResolution[1] = 0; |
---|
| 1986 | |
---|
| 1987 | // Sub Pel Rendering |
---|
| 1988 | m_iLog2SamplingFactor = 0; |
---|
| 1989 | |
---|
| 1990 | // ColorPlaneHandling |
---|
| 1991 | m_bUVUp = true; |
---|
| 1992 | |
---|
| 1993 | |
---|
| 1994 | //PreProcessing |
---|
| 1995 | m_iPreProcMode = eRenPreProNone; |
---|
| 1996 | m_iPreFilterSize = 2; |
---|
| 1997 | |
---|
| 1998 | // Interpolation |
---|
| 1999 | m_iInterpolationMode = eRenIntFullPel; |
---|
| 2000 | |
---|
| 2001 | // Sim Enhancement |
---|
| 2002 | m_iSimEnhBaseView = 0; |
---|
| 2003 | |
---|
| 2004 | // Blending |
---|
| 2005 | m_iBlendMode = eRenBlendAverg; |
---|
| 2006 | m_iBlendZThresPerc = -1; |
---|
| 2007 | m_bBlendUseDistWeight = false; |
---|
| 2008 | m_iBlendHoleMargin = -1; |
---|
| 2009 | |
---|
| 2010 | m_iBlendZThres = -1; |
---|
| 2011 | m_iBlendDistWeight = -1; |
---|
| 2012 | |
---|
| 2013 | // Hole Filling |
---|
| 2014 | m_iHoleFillingMode = eRenHFLWBackExt; |
---|
| 2015 | m_bInstantHoleFilling = false; |
---|
| 2016 | |
---|
| 2017 | // PostProcessing |
---|
| 2018 | m_iPostProcMode = eRenPostProNone; |
---|
| 2019 | |
---|
| 2020 | // Cut |
---|
| 2021 | m_auiCut[0] = 0; |
---|
| 2022 | m_auiCut[1] = 0; |
---|
| 2023 | |
---|
| 2024 | // Data |
---|
| 2025 | m_uiSampledWidth = -1; |
---|
| 2026 | |
---|
| 2027 | // LUTs |
---|
| 2028 | m_ppdShiftLUTLeft = 0; |
---|
| 2029 | m_ppdShiftLUTRight = 0; |
---|
| 2030 | |
---|
| 2031 | m_ppdShiftLUTRightMirror = new Double*[2]; |
---|
| 2032 | m_ppdShiftLUTRightMirror[0] = new Double [257]; |
---|
| 2033 | m_ppdShiftLUTRightMirror[1] = new Double [257]; |
---|
| 2034 | |
---|
| 2035 | m_adShiftLUTCur = 0; |
---|
| 2036 | |
---|
| 2037 | m_ppiShiftLUTLeft = 0; |
---|
| 2038 | m_ppiShiftLUTRight = 0; |
---|
| 2039 | m_ppiShiftLUTRightMirror = new Int*[2]; |
---|
| 2040 | m_ppiShiftLUTRightMirror[0] = new Int[257]; |
---|
| 2041 | m_ppiShiftLUTRightMirror[1] = new Int[257]; |
---|
| 2042 | |
---|
| 2043 | m_aiShiftLUTCur = 0; |
---|
| 2044 | m_piInvZLUTLeft = new Int[257]; |
---|
| 2045 | m_piInvZLUTRight = new Int[257]; |
---|
| 2046 | |
---|
| 2047 | // Buffers |
---|
| 2048 | m_pcLeftInputImage = 0; |
---|
| 2049 | m_pcLeftInputDepth = 0; |
---|
| 2050 | m_pcLeftOutputImage = 0; |
---|
| 2051 | m_pcLeftOutputDepth = 0; |
---|
| 2052 | m_pcLeftFilled = 0; |
---|
| 2053 | |
---|
| 2054 | m_pcRightInputImage = 0; |
---|
| 2055 | m_pcRightInputDepth = 0; |
---|
| 2056 | m_pcRightOutputImage = 0; |
---|
| 2057 | m_pcRightOutputDepth = 0; |
---|
| 2058 | m_pcRightFilled = 0; |
---|
| 2059 | |
---|
| 2060 | m_pcOutputImage = 0; |
---|
| 2061 | m_pcOutputDepth = 0; |
---|
| 2062 | |
---|
| 2063 | //Extrapolation |
---|
| 2064 | m_pcInputImage = 0; |
---|
| 2065 | m_pcInputDepth = 0; |
---|
| 2066 | m_pcFilled = 0; |
---|
| 2067 | |
---|
| 2068 | // SubPel |
---|
| 2069 | m_aaiSubPelShift = 0; |
---|
| 2070 | |
---|
| 2071 | // Temp |
---|
| 2072 | m_pcTempImage = 0; |
---|
| 2073 | |
---|
| 2074 | //Temporal Filter |
---|
| 2075 | m_aiBlkMoving = 0; |
---|
| 2076 | } |
---|
| 2077 | |
---|
| 2078 | |
---|
| 2079 | Void TRenTop::init(UInt uiImageWidth, |
---|
| 2080 | UInt uiImageHeight, |
---|
| 2081 | Bool bExtrapolate, |
---|
| 2082 | UInt uiLog2SamplingFactor, |
---|
| 2083 | Int iShiftLUTPrec, |
---|
| 2084 | Bool bUVUp, |
---|
| 2085 | Int iPreProcMode, |
---|
| 2086 | Int iPreFilterKernelSize, |
---|
| 2087 | Int iBlendMode, |
---|
| 2088 | Int iBlendZThresPerc, |
---|
| 2089 | Bool bBlendUseDistWeight, |
---|
| 2090 | Int iBlendHoleMargin, |
---|
| 2091 | Int iInterpolationMode, |
---|
| 2092 | Int iHoleFillingMode, |
---|
| 2093 | Int iPostProcMode, |
---|
| 2094 | Int iUsedPelMapMarExt |
---|
| 2095 | ) |
---|
| 2096 | |
---|
| 2097 | { |
---|
| 2098 | // Shift LUT Prec |
---|
| 2099 | m_iRelShiftLUTPrec = iShiftLUTPrec - (Int) uiLog2SamplingFactor; |
---|
| 2100 | |
---|
| 2101 | // Sub Pel Rendering |
---|
| 2102 | m_iLog2SamplingFactor = uiLog2SamplingFactor; |
---|
| 2103 | |
---|
| 2104 | // Extrapolation ? |
---|
| 2105 | m_bExtrapolate = bExtrapolate; |
---|
| 2106 | |
---|
| 2107 | // ColorPlaneHandling |
---|
| 2108 | m_bUVUp = bUVUp; |
---|
| 2109 | |
---|
| 2110 | //PreProcessing |
---|
| 2111 | m_iPreProcMode = iPreProcMode; |
---|
| 2112 | m_iPreFilterSize = iPreFilterKernelSize; |
---|
| 2113 | |
---|
| 2114 | // Interpolation |
---|
| 2115 | m_iInterpolationMode = iInterpolationMode; |
---|
| 2116 | |
---|
| 2117 | //Blending |
---|
| 2118 | m_iBlendMode = iBlendMode; |
---|
| 2119 | m_iBlendZThresPerc = iBlendZThresPerc; |
---|
| 2120 | m_bBlendUseDistWeight = bBlendUseDistWeight; |
---|
| 2121 | m_iBlendHoleMargin = iBlendHoleMargin; |
---|
| 2122 | |
---|
| 2123 | // Hole Filling |
---|
| 2124 | m_iHoleFillingMode = iHoleFillingMode; |
---|
| 2125 | |
---|
| 2126 | m_bInstantHoleFilling = (m_iInterpolationMode == eRenInt8Tap ) && (m_iHoleFillingMode != 0 ); |
---|
| 2127 | |
---|
| 2128 | // PostProcessing |
---|
| 2129 | m_iPostProcMode = iPostProcMode; |
---|
| 2130 | |
---|
| 2131 | // Used pel map |
---|
| 2132 | m_iUsedPelMapMarExt = iUsedPelMapMarExt; |
---|
| 2133 | |
---|
| 2134 | // Cut |
---|
| 2135 | m_auiCut[0] = 0; |
---|
| 2136 | m_auiCut[1] = 0; |
---|
| 2137 | |
---|
| 2138 | m_auiInputResolution[0] = uiImageWidth; |
---|
| 2139 | m_auiInputResolution[1] = uiImageHeight; |
---|
| 2140 | |
---|
| 2141 | if ( m_bExtrapolate ) |
---|
| 2142 | { |
---|
| 2143 | PelImage* pcDump = 0; |
---|
| 2144 | xGetDataPointers( m_pcInputImage, m_pcOutputImage, m_pcInputDepth, pcDump, m_pcFilled, false ); |
---|
| 2145 | } |
---|
| 2146 | else |
---|
| 2147 | { |
---|
| 2148 | xGetDataPointers(m_pcLeftInputImage, m_pcLeftOutputImage, m_pcLeftInputDepth, m_pcLeftOutputDepth, m_pcLeftFilled, true); |
---|
| 2149 | xGetDataPointers(m_pcRightInputImage, m_pcRightOutputImage, m_pcRightInputDepth, m_pcRightOutputDepth, m_pcRightFilled, true); |
---|
| 2150 | xGetDataPointerOutputImage(m_pcOutputImage, m_pcOutputDepth ); |
---|
| 2151 | } |
---|
| 2152 | |
---|
| 2153 | m_pcTempImage = new PelImage( m_auiInputResolution[0],m_auiInputResolution[1],1,2); |
---|
| 2154 | |
---|
| 2155 | // SubPelShiftLUT |
---|
| 2156 | if (iInterpolationMode == eRenInt8Tap) |
---|
| 2157 | { |
---|
| 2158 | // SubPel Shift LUT |
---|
| 2159 | Int iNumEntries = (1 << ( m_iRelShiftLUTPrec + 1) ) + 1 ; |
---|
| 2160 | m_aaiSubPelShift = new Int*[ iNumEntries ]; |
---|
| 2161 | for (UInt uiEntry = 0; uiEntry < iNumEntries; uiEntry++) |
---|
| 2162 | { |
---|
| 2163 | m_aaiSubPelShift[uiEntry] = new Int[ iNumEntries ]; |
---|
| 2164 | } |
---|
| 2165 | |
---|
| 2166 | TRenFilter::setSubPelShiftLUT(m_iRelShiftLUTPrec, m_aaiSubPelShift, -1); |
---|
| 2167 | } |
---|
| 2168 | |
---|
| 2169 | // Zheijang temporal filter |
---|
| 2170 | m_aiBlkMoving = new Int[ ( m_auiInputResolution[0] >> 2 ) + 4 ]; |
---|
| 2171 | m_aiBlkMoving[0] = 0; |
---|
| 2172 | m_aiBlkMoving[1] = 0; |
---|
| 2173 | m_aiBlkMoving[ ( m_auiInputResolution[0] >> 2 ) + 2 ] = 0; |
---|
| 2174 | m_aiBlkMoving[ ( m_auiInputResolution[0] >> 2 ) + 3 ] = 0; |
---|
| 2175 | } |
---|
| 2176 | |
---|
| 2177 | |
---|
| 2178 | TRenTop::~TRenTop() |
---|
| 2179 | { |
---|
| 2180 | if ( m_ppdShiftLUTRightMirror != NULL ) |
---|
| 2181 | { |
---|
| 2182 | delete[] m_ppdShiftLUTRightMirror[0]; |
---|
| 2183 | delete[] m_ppdShiftLUTRightMirror[1]; |
---|
| 2184 | delete[] m_ppdShiftLUTRightMirror; |
---|
| 2185 | }; |
---|
| 2186 | |
---|
| 2187 | if ( m_ppiShiftLUTRightMirror != NULL ) |
---|
| 2188 | { |
---|
| 2189 | delete[] m_ppiShiftLUTRightMirror[0]; |
---|
| 2190 | delete[] m_ppiShiftLUTRightMirror[1]; |
---|
| 2191 | delete[] m_ppiShiftLUTRightMirror; |
---|
| 2192 | }; |
---|
| 2193 | |
---|
| 2194 | if (m_piInvZLUTLeft != NULL ) delete[] m_piInvZLUTLeft ; |
---|
| 2195 | if (m_piInvZLUTLeft != NULL ) delete[] m_piInvZLUTRight ; |
---|
| 2196 | |
---|
| 2197 | if (m_pcLeftInputImage != NULL ) delete m_pcLeftInputImage ; |
---|
| 2198 | if (m_pcLeftInputDepth != NULL ) delete m_pcLeftInputDepth ; |
---|
| 2199 | if (m_pcLeftOutputImage != NULL ) delete m_pcLeftOutputImage ; |
---|
| 2200 | if (m_pcLeftOutputDepth != NULL ) delete m_pcLeftOutputDepth ; |
---|
| 2201 | if (m_pcLeftFilled != NULL ) delete m_pcLeftFilled ; |
---|
| 2202 | |
---|
| 2203 | if (m_pcRightInputImage != NULL ) delete m_pcRightInputImage ; |
---|
| 2204 | if (m_pcRightInputDepth != NULL ) delete m_pcRightInputDepth ; |
---|
| 2205 | if (m_pcRightOutputImage != NULL ) delete m_pcRightOutputImage; |
---|
| 2206 | if (m_pcRightOutputDepth != NULL ) delete m_pcRightOutputDepth; |
---|
| 2207 | if (m_pcRightFilled != NULL ) delete m_pcRightFilled ; |
---|
| 2208 | |
---|
| 2209 | if (m_pcOutputImage != NULL ) delete m_pcOutputImage ; |
---|
| 2210 | if (m_pcOutputDepth != NULL ) delete m_pcOutputDepth ; |
---|
| 2211 | |
---|
| 2212 | if (m_pcInputImage != NULL ) delete m_pcInputImage ; |
---|
| 2213 | if (m_pcInputDepth != NULL ) delete m_pcInputDepth ; |
---|
| 2214 | if (m_pcFilled != NULL ) delete m_pcFilled ; |
---|
| 2215 | |
---|
| 2216 | if (m_pcTempImage != NULL ) delete m_pcTempImage ; |
---|
| 2217 | |
---|
| 2218 | // SubPel LUT |
---|
| 2219 | if ( m_aaiSubPelShift != NULL) |
---|
| 2220 | { |
---|
| 2221 | Int iNumEntries = (1 << ( m_iRelShiftLUTPrec + 1) ) + 1; |
---|
| 2222 | for (UInt uiEntry = 0; uiEntry < iNumEntries; uiEntry++) |
---|
| 2223 | { |
---|
| 2224 | delete[] m_aaiSubPelShift[uiEntry]; |
---|
| 2225 | } |
---|
| 2226 | delete[] m_aaiSubPelShift; |
---|
| 2227 | } |
---|
| 2228 | |
---|
| 2229 | // Zheijang temporal filter |
---|
| 2230 | if(m_aiBlkMoving != NULL ) delete[] m_aiBlkMoving; |
---|
| 2231 | } |
---|
| 2232 | |
---|