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