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