[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 | |
---|
| 34 | #ifndef __TRENTOP__ |
---|
| 35 | #define __TRENTOP__ |
---|
| 36 | |
---|
| 37 | #include "TRenImage.h" |
---|
| 38 | #include "../TLibCommon/CommonDef.h" |
---|
| 39 | #include "../TLibCommon/TComPicYuv.h" |
---|
| 40 | #include <list> |
---|
| 41 | #include <vector> |
---|
| 42 | |
---|
| 43 | using namespace std; |
---|
| 44 | |
---|
| 45 | class TRenTop |
---|
| 46 | { |
---|
| 47 | // ENUM Modes |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | // Interpolation Modes |
---|
| 51 | |
---|
[166] | 52 | #if NTT_SUBPEL |
---|
| 53 | enum { eRenIntFullPel = 0, eRenIntLinInt = 1, eRenIntLinReal = 2, eRenIntFEM = 3, eRenInt8Tap = 4, eRenInt8Tap2 = 5 }; |
---|
| 54 | #else |
---|
[2] | 55 | enum { eRenIntFullPel = 0, eRenIntLinInt = 1, eRenIntLinReal = 2, eRenIntFEM = 3, eRenInt8Tap = 4 }; |
---|
[166] | 56 | #endif |
---|
[2] | 57 | |
---|
| 58 | // HoleFilling |
---|
| 59 | enum { eRenHFNone = 0, eRenHFLWBackExt = 1}; |
---|
| 60 | |
---|
| 61 | // Pre-Processing |
---|
| 62 | enum { eRenPreProNone = 0, eRenPreProBinom = 1}; |
---|
| 63 | |
---|
| 64 | // Post-Processing |
---|
| 65 | enum { eRenPostProNone = 0, eRenPostProMed = 1}; |
---|
| 66 | |
---|
| 67 | // Merging |
---|
| 68 | enum { eRenBlendAverg = 0, eRenBlendLeft = 1, eRenBlendRight = 2, eRenBlendDepthFirst = 5 }; |
---|
| 69 | |
---|
| 70 | public: |
---|
| 71 | TRenTop(); |
---|
| 72 | ~TRenTop(); |
---|
| 73 | |
---|
| 74 | // Init |
---|
| 75 | Void init ( UInt uiImageWitdh, |
---|
| 76 | UInt uiImageHeight, |
---|
| 77 | Bool bExtrapolate, |
---|
| 78 | UInt uiLog2SamplingFactor, |
---|
| 79 | Int iLUTPrec, |
---|
| 80 | Bool bUVUp, |
---|
| 81 | Int iPreProcMode, |
---|
| 82 | Int iPreFilterKernelSize, |
---|
| 83 | Int iBlendMode, |
---|
| 84 | Int iBlendZThresPerc, |
---|
| 85 | Bool bBlendUseDistWeight, |
---|
| 86 | Int iBlendHoleMargin, |
---|
| 87 | Int iInterpolationMode, |
---|
| 88 | Int iHoleFillingMode, |
---|
| 89 | Int iPostProcMode, |
---|
| 90 | Int iUsedPelMapMarExt ); |
---|
| 91 | |
---|
| 92 | Void setShiftLUTs ( Double** ppdShiftLUTLeft, |
---|
| 93 | Int** ppiShiftLUTLeft, |
---|
| 94 | Int** ppiBaseShiftLUTLeft, |
---|
| 95 | Double** ppdShiftLUTRight, |
---|
| 96 | Int** ppiShiftLUTRight, |
---|
| 97 | Int** ppiBaseShiftLUTRight, |
---|
| 98 | Int iRelDistLeft ); |
---|
[166] | 99 | #if NTT_SUBPEL |
---|
| 100 | Void setFposLUTs ( Int** ppiFposLUTLeft, Int** ppiFposLUTRight ); |
---|
| 101 | Void setInterpolationMode ( Int iMode ) { m_iInterpolationMode = iMode; } |
---|
| 102 | #endif |
---|
[2] | 103 | |
---|
| 104 | // View Synthesis |
---|
| 105 | Void extrapolateView ( TComPicYuv* pcPicYuvVideo, |
---|
| 106 | TComPicYuv* pcPicYuvDepth, |
---|
| 107 | TComPicYuv* pcPicYuvSynthOut, |
---|
| 108 | Bool bRenderFromLeft ); |
---|
| 109 | |
---|
[166] | 110 | #if VSP_N |
---|
| 111 | Void extrapolateAvailabilityView ( TComPicYuv* pcPicYuvVideo, |
---|
| 112 | TComPicYuv* pcPicYuvDepth, |
---|
| 113 | TComPicYuv* pcPicYuvSynthOut, |
---|
| 114 | TComPicYuv* pcPicYuvAvailOut, |
---|
| 115 | Bool bRenderFromLeft ); |
---|
| 116 | #endif |
---|
| 117 | |
---|
[2] | 118 | Void interpolateView ( TComPicYuv* pcPicYuvVideoLeft, |
---|
| 119 | TComPicYuv* pcPicYuvDepthLeft, |
---|
| 120 | TComPicYuv* pcPicYuvVideoRight, |
---|
| 121 | TComPicYuv* pcPicYuvDepthRight, |
---|
| 122 | TComPicYuv* pcPicYuvSynthOut, |
---|
| 123 | Int iBlendMode, |
---|
| 124 | Int iSimEnhBaseView ); |
---|
| 125 | // Tools |
---|
| 126 | Void getUsedSamplesMap ( TComPicYuv* pcPicYuvDepth, |
---|
| 127 | TComPicYuv* pcUsedSampleMap, |
---|
| 128 | Bool bRenderFromLeft ); |
---|
| 129 | |
---|
| 130 | // Zhejiang Temporal Improvement |
---|
| 131 | Void temporalFilterVSRS( TComPicYuv* pcPicYuvVideoCur, |
---|
| 132 | TComPicYuv* pcPicYuvDepthCur, |
---|
| 133 | TComPicYuv* pcPicYuvVideoLast, |
---|
| 134 | TComPicYuv* pcPicYuvDepthLast, |
---|
| 135 | Bool bFirstFrame ); |
---|
| 136 | |
---|
| 137 | private: |
---|
| 138 | // Depth PreProcessing |
---|
| 139 | Void xPreProcessDepth(PelImage* pcInImage, PelImage* pcOutImage); |
---|
| 140 | |
---|
| 141 | // Pixel Shifting |
---|
| 142 | Void xShiftPixels ( PelImage* pcInImage, PelImage* pcDepth , PelImage* pcOutImage , PelImage* pcFilledImage, Bool bShiftFromLeft ); |
---|
| 143 | Void xShiftPlanePixels ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcPlaneFilled, UInt uiNumberOfPlanes); |
---|
| 144 | Void xShiftPlanePixelsLinReal ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcPlaneFilled, UInt uiNumberOfPlanes); |
---|
| 145 | Void xShiftPlanePixelsFullPel ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcPlaneFilled, UInt uiNumberOfPlanes); |
---|
| 146 | Void xShiftPlanePixelsLinInt ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes); |
---|
| 147 | Void xShiftPlanePixels8Tap ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes); |
---|
| 148 | |
---|
| 149 | Void xBackShiftPixels ( PelImage* pcInImage, PelImage* pcDepth , PelImage* pcOutImage, PelImage* pcFilledImage, Bool bShiftFromLeft ); |
---|
| 150 | Void xBackShiftPlanePixels ( PelImagePlane** apcInputPlanes, PelImagePlane* pcDepthPlane, PelImagePlane** apcOutputPlanes, PelImagePlane* pcFilledPlane, UInt uiNumberOfPlanes ); |
---|
| 151 | |
---|
| 152 | Int xCeil ( Int iVal ) { return (( iVal + ( (1 << m_iRelShiftLUTPrec) - 1 ) ) >> m_iRelShiftLUTPrec); } |
---|
| 153 | |
---|
| 154 | // Hole Filling |
---|
| 155 | Void xFillHoles ( PelImage* pcInImage, PelImage* pcFilled, PelImage* pcOutImage , Bool bRenderFromLeft ); |
---|
| 156 | Void xFillLWBackExt ( PelImage* pcInImage, PelImage* pcFilled, PelImage* pcOutImage , Bool bRenderFromLeft ); |
---|
| 157 | Void xFillPlaneHoles ( PelImagePlane** apcInputPlanes, PelImagePlane* pcPlaneFilled, PelImagePlane** apcOutputPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft ); |
---|
| 158 | |
---|
| 159 | // Alpha Map Creation |
---|
| 160 | Void xCreateAlphaMap (PelImage* pcFilledImage, PelImage* pcAlphaMapImage, Bool bRenderFromLeft ); |
---|
| 161 | Void xCreateAlphaMapPlane (PelImagePlane** apcFilledPlanes, PelImagePlane** apcAlphaPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft); |
---|
| 162 | |
---|
| 163 | // BoundaryNoiseErosion |
---|
| 164 | Void xRemBoundaryNoise ( PelImage* pcInImage, PelImage* pcFilled, PelImage* pcOutImage , Bool bRenderFromLeft ); |
---|
| 165 | Void xRemBoundaryNoisePlane ( PelImagePlane** apcInputPlanes, PelImagePlane* pcPlaneFilled, PelImagePlane** apcOutputPlanes, UInt uiNumberOfPlanes, Bool bRenderFromLeft ); |
---|
| 166 | |
---|
| 167 | // Similarity Enhancement |
---|
| 168 | Void xEnhSimilarity ( PelImage* pcLeftImage, PelImage* pcRightImage, PelImage* pcFilledLeft, PelImage* pcFilledRight ); |
---|
| 169 | Void xEnhSimilarityPlane ( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, UInt uNumPlanes ); |
---|
| 170 | |
---|
| 171 | // View Blending |
---|
| 172 | Void xBlend ( PelImage* pcLeftImage, PelImage* pcRightImage, PelImage* pcFilledLeft, PelImage* pcFilledRight, PelImage* pcLeftDepth, PelImage* pcRightDepth, PelImage* pcOutputImage); |
---|
| 173 | Void xBlendPlanesAvg ( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, PelImagePlane* pcLeftDepthPlane, PelImagePlane* pcRightDepthPlane, PelImagePlane** apcOutputImagePlane, UInt uNumPlanes ); |
---|
| 174 | Void xBlendPlanesOneView ( PelImagePlane** apcLeftPlane, PelImagePlane** apcRightPlane, PelImagePlane* pcFilledLeftPlane, PelImagePlane* pcFilledRightPlane, PelImagePlane* pcLeftDepthPlane, PelImagePlane* pcRightDepthPlane, PelImagePlane** apcOutputImagePlane, UInt uNumPlanes ); |
---|
| 175 | |
---|
| 176 | // PostProcessing |
---|
| 177 | Void xCutMargin ( PelImage* pcInputImage ); |
---|
| 178 | Void xCutPlaneMargin ( PelImagePlane* pcImagePlane, Pel cFill, UInt uiScale); |
---|
| 179 | Void xPostProcessImage ( PelImage* pcInImage, PelImage* pCOutImage); |
---|
| 180 | |
---|
| 181 | // Input Output Data Conversion |
---|
| 182 | Void xConvertInputData ( PelImage* pcOrgInputImage, PelImage* pcOrgInputDepth, PelImage* pcConvInputImage, PelImage* pcConvInputDepth, Bool bMirror); |
---|
| 183 | Void xConvertOutputData ( PelImage* pOrgOutputImage, PelImage* pConvOutputImage, Bool bMirror); |
---|
[166] | 184 | #if VSP_N |
---|
| 185 | Void xConvertOutputDataPlane0 ( PelImage* pOrgOutputImage, PelImage* pConvOutputImage, Bool bMirror); |
---|
| 186 | #endif |
---|
| 187 | #if NTT_SUBPEL |
---|
| 188 | Void xConvertInputDataSubpel ( PelImage* pcOrgInputImage, PelImage* pcOrgInputDepth, PelImage* pcConvInputImage, PelImage* pcConvInputDepth, Bool bMirror); |
---|
| 189 | Void xConvertInputVideoSubpel ( PelImage* pcOrgInputImage, PelImage* pcConvInputImage, PelImage* pcInputDepth, Bool bMirror ); |
---|
| 190 | Void xConvertInputDepthSubpel ( PelImage* pcOrgInputImage, PelImage* pcConvInputImage); |
---|
| 191 | #endif |
---|
[2] | 192 | |
---|
| 193 | Void xGetDataPointers ( PelImage*& rpcInputImage, PelImage*& rpcOutputImage, PelImage*& rpcInputDepth, PelImage*& rpcOutputDepth, PelImage*& rpcFilled, Bool bRenderDepth ); |
---|
| 194 | Void xGetDataPointerOutputImage( PelImage*& rpcOutputImage, PelImage*& rpcOutputDepth ); |
---|
| 195 | |
---|
| 196 | Void xConvertInputVideo ( PelImage* pcOrgInputImage, PelImage* pcConvInputImage); |
---|
| 197 | Void xConvertInputDepth ( PelImage* pcOrgInputImage, PelImage* pcConvInputImage); |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | // Data |
---|
| 201 | UInt m_uiSampledWidth; // Width after UPsampling |
---|
| 202 | |
---|
| 203 | // Resolution of input view |
---|
| 204 | UInt m_auiInputResolution[2]; |
---|
| 205 | |
---|
| 206 | // Extrapolation |
---|
| 207 | Bool m_bExtrapolate; |
---|
| 208 | |
---|
| 209 | // Input Conversion |
---|
| 210 | Int m_iLog2SamplingFactor; |
---|
| 211 | Bool m_bUVUp; |
---|
| 212 | |
---|
| 213 | // PreProcessing |
---|
| 214 | Int m_iPreProcMode; //0: none, 1: binominal |
---|
| 215 | Int m_iPreFilterSize; // Half size |
---|
| 216 | |
---|
| 217 | // Similarity Enhancement |
---|
| 218 | Int m_iSimEnhBaseView; // 0: none, 1: left, 2: right |
---|
| 219 | |
---|
| 220 | // Blending |
---|
| 221 | Int m_iBlendMode; // 0: average; |
---|
| 222 | Int m_iBlendZThresPerc; // in percent of total depth |
---|
| 223 | Bool m_bBlendUseDistWeight; // use weighting depending on viewing distance |
---|
| 224 | Int m_iBlendHoleMargin; // blending margin next to holes |
---|
| 225 | |
---|
| 226 | Int m_iBlendZThres; // absoluteInt m_iBlendWeight; |
---|
| 227 | Int m_iBlendDistWeight; // Weight for view distance depending blending |
---|
| 228 | |
---|
| 229 | // Interpolation |
---|
| 230 | Int m_iInterpolationMode; //0: none; 1: Linear (Double), 2: FEM (Double) |
---|
| 231 | |
---|
| 232 | // Hole Filling |
---|
| 233 | Int m_iHoleFillingMode; //0: none; 1: LW Background extension |
---|
| 234 | Int m_bInstantHoleFilling; // perform hole filling while pixel shifting ( only supported for interpolation mode 4 ) |
---|
| 235 | |
---|
| 236 | // Post Processing |
---|
| 237 | Int m_iPostProcMode; //0: none; 1: Median |
---|
| 238 | |
---|
| 239 | // Precision in LUT |
---|
| 240 | Int m_iRelShiftLUTPrec; |
---|
| 241 | |
---|
[5] | 242 | // Cut |
---|
[2] | 243 | UInt m_auiCut[2]; |
---|
| 244 | |
---|
| 245 | // Look up tables Shift |
---|
| 246 | Double** m_ppdShiftLUTLeft; |
---|
| 247 | Double** m_ppdShiftLUTRight; |
---|
| 248 | Double** m_ppdShiftLUTRightMirror; // For rendering the mirrored view |
---|
| 249 | Double* m_adShiftLUTCur; |
---|
| 250 | |
---|
| 251 | Int** m_ppiShiftLUTLeft; |
---|
| 252 | Int** m_ppiShiftLUTRight; |
---|
| 253 | Int** m_ppiShiftLUTRightMirror; // For rendering the mirrored view |
---|
| 254 | Int* m_aiShiftLUTCur; |
---|
[166] | 255 | #if NTT_SUBPEL |
---|
| 256 | Int** m_ppiFposLUTLeft; |
---|
| 257 | Int** m_ppiFposLUTRight; |
---|
| 258 | Int** m_ppiFposLUTRightMirror; // For rendering the mirrored view |
---|
| 259 | #endif |
---|
[2] | 260 | |
---|
| 261 | // Look up tables Z |
---|
| 262 | Int* m_piInvZLUTLeft; // Look up table entry is proportional to Z |
---|
| 263 | Int* m_piInvZLUTRight; |
---|
| 264 | |
---|
| 265 | // Look up tables sub pel shift |
---|
| 266 | Int** m_aaiSubPelShift; |
---|
| 267 | |
---|
| 268 | // Zhejiang Temporal Improvement |
---|
| 269 | Int* m_aiBlkMoving; |
---|
| 270 | |
---|
| 271 | // Used pel map generation |
---|
| 272 | Int m_iUsedPelMapMarExt; |
---|
| 273 | |
---|
| 274 | // Buffers |
---|
| 275 | |
---|
| 276 | // Interpolation |
---|
| 277 | PelImage* m_pcLeftInputImage ; |
---|
| 278 | PelImage* m_pcLeftInputDepth ; |
---|
| 279 | PelImage* m_pcLeftOutputImage ; |
---|
| 280 | PelImage* m_pcLeftOutputDepth ; |
---|
| 281 | PelImage* m_pcLeftFilled ; |
---|
| 282 | PelImage* m_pcRightInputImage ; |
---|
| 283 | PelImage* m_pcRightInputDepth ; |
---|
| 284 | PelImage* m_pcRightOutputImage; |
---|
| 285 | PelImage* m_pcRightOutputDepth; |
---|
| 286 | PelImage* m_pcRightFilled ; |
---|
| 287 | PelImage* m_pcOutputImage ; |
---|
| 288 | PelImage* m_pcOutputDepth ; |
---|
| 289 | |
---|
| 290 | // Extrapolation |
---|
| 291 | PelImage* m_pcInputImage ; |
---|
| 292 | PelImage* m_pcInputDepth ; |
---|
| 293 | PelImage* m_pcFilled ; |
---|
| 294 | |
---|
| 295 | //Temp |
---|
| 296 | PelImage* m_pcTempImage ; |
---|
| 297 | }; |
---|
| 298 | |
---|
| 299 | #endif //__TRENTOP__ |
---|