1 | |
---|
2 | #include "TRenImage.h" |
---|
3 | #include "TRenFilter.h" |
---|
4 | #include "TRenSingleModel.h" |
---|
5 | |
---|
6 | ////////////// TRENSINGLE MODEL /////////////// |
---|
7 | TRenSingleModel::TRenSingleModel() |
---|
8 | : m_iDistShift ( g_uiBitIncrement << 1 ) |
---|
9 | { |
---|
10 | m_iWidth = -1; |
---|
11 | m_iHeight = -1; |
---|
12 | m_iStride = -1; |
---|
13 | m_iMode = -1; |
---|
14 | m_iPad = 12; |
---|
15 | m_iGapTolerance = -1; |
---|
16 | m_bUseOrgRef = false; |
---|
17 | |
---|
18 | m_pcPicYuvRef = NULL; |
---|
19 | m_aapiRefVideoPel[0] = NULL; |
---|
20 | m_aapiRefVideoPel[1] = NULL; |
---|
21 | m_aapiRefVideoPel[2] = NULL; |
---|
22 | |
---|
23 | |
---|
24 | m_aiRefVideoStrides[0] = -1; |
---|
25 | m_aiRefVideoStrides[1] = -1; |
---|
26 | m_aiRefVideoStrides[2] = -1; |
---|
27 | |
---|
28 | for (UInt uiViewNum = 0 ; uiViewNum < 2; uiViewNum++) |
---|
29 | { |
---|
30 | // LUT |
---|
31 | m_appiShiftLut[uiViewNum] = NULL; |
---|
32 | m_ppiCurLUT = NULL; |
---|
33 | m_piInvZLUTLeft = NULL; |
---|
34 | m_piInvZLUTRight = NULL; |
---|
35 | |
---|
36 | // Cur Data |
---|
37 | m_apiBaseDepthPel [uiViewNum] = NULL; |
---|
38 | m_aiBaseDepthStrides [uiViewNum] = -1; |
---|
39 | |
---|
40 | // State Data |
---|
41 | m_apbOccluded [uiViewNum] = NULL; |
---|
42 | m_apiFilled [uiViewNum] = NULL; |
---|
43 | |
---|
44 | // Cur Data |
---|
45 | m_aapiBaseVideoPel [uiViewNum] = NULL; |
---|
46 | m_aaiBaseVideoStrides [uiViewNum] = NULL; |
---|
47 | }; |
---|
48 | |
---|
49 | m_piError = NULL; |
---|
50 | |
---|
51 | for (UInt uiViewNum = 0 ; uiViewNum < 3; uiViewNum++) |
---|
52 | { |
---|
53 | m_apiSynthDepthPel[uiViewNum] = NULL; |
---|
54 | for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++) |
---|
55 | { |
---|
56 | // Rendered Data |
---|
57 | m_aapiSynthVideoPel[uiViewNum][uiPlaneNum] = NULL; |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | TRenSingleModel::~TRenSingleModel() |
---|
63 | { |
---|
64 | if ( m_apbOccluded[0] ) delete[] m_apbOccluded[0]; |
---|
65 | if ( m_apbOccluded[1] ) delete[] m_apbOccluded[1]; |
---|
66 | |
---|
67 | if ( m_apiFilled [0] ) delete[] m_apiFilled [0]; |
---|
68 | if ( m_apiFilled [1] ) delete[] m_apiFilled [1]; |
---|
69 | |
---|
70 | if ( m_piError ) delete[] m_piError ; |
---|
71 | |
---|
72 | |
---|
73 | for (UInt uiViewNum = 0 ; uiViewNum < 3; uiViewNum++) |
---|
74 | { |
---|
75 | for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++) |
---|
76 | { |
---|
77 | if ( m_aapiSynthVideoPel[uiViewNum] && m_aapiSynthVideoPel[uiViewNum][uiPlaneNum] ) delete[] m_aapiSynthVideoPel[uiViewNum][uiPlaneNum]; |
---|
78 | } |
---|
79 | if ( m_apiSynthDepthPel[uiViewNum] ) delete[] m_apiSynthDepthPel[uiViewNum]; |
---|
80 | } |
---|
81 | |
---|
82 | delete[] (m_aapiRefVideoPel[0] - m_iPad * m_aiRefVideoStrides[0] - m_iPad ); |
---|
83 | delete[] (m_aapiRefVideoPel[1] - m_iPad * m_aiRefVideoStrides[1] - m_iPad ); |
---|
84 | delete[] (m_aapiRefVideoPel[2] - m_iPad * m_aiRefVideoStrides[2] - m_iPad ); |
---|
85 | |
---|
86 | if ( m_piInvZLUTLeft ) delete[] m_piInvZLUTLeft; |
---|
87 | if ( m_piInvZLUTRight ) delete[] m_piInvZLUTRight; |
---|
88 | } |
---|
89 | |
---|
90 | Void |
---|
91 | TRenSingleModel::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode ) |
---|
92 | { |
---|
93 | m_iBlendMode = iBlendMode; |
---|
94 | m_iMode = iMode; |
---|
95 | m_iWidth = iWidth; |
---|
96 | m_iHeight = iHeight; |
---|
97 | m_iStride = iWidth; |
---|
98 | |
---|
99 | m_iSampledWidth = m_iWidth << iShiftPrec; |
---|
100 | m_iSampledStride = m_iStride << iShiftPrec; |
---|
101 | |
---|
102 | m_iShiftPrec = iShiftPrec; |
---|
103 | m_aaiSubPelShiftL = aaaiSubPelShiftTable[0]; |
---|
104 | m_aaiSubPelShiftR = aaaiSubPelShiftTable[1]; |
---|
105 | |
---|
106 | if (m_iMode == 2) |
---|
107 | { |
---|
108 | m_piInvZLUTLeft = new Int[257]; |
---|
109 | m_piInvZLUTRight = new Int[257]; |
---|
110 | } |
---|
111 | |
---|
112 | m_iGapTolerance = ( 2 << iShiftPrec ); |
---|
113 | m_iHoleMargin = iHoleMargin; |
---|
114 | |
---|
115 | m_bUseOrgRef = bUseOrgRef; |
---|
116 | |
---|
117 | m_aiRefVideoStrides[0] = m_iStride + (m_iPad << 1); |
---|
118 | m_aiRefVideoStrides[1] = m_iStride + (m_iPad << 1); |
---|
119 | m_aiRefVideoStrides[2] = m_iStride + (m_iPad << 1); |
---|
120 | |
---|
121 | m_aapiRefVideoPel [0] = new Pel[ m_aiRefVideoStrides[0] * (m_iHeight + (m_iPad << 1))]; |
---|
122 | m_aapiRefVideoPel [1] = new Pel[ m_aiRefVideoStrides[1] * (m_iHeight + (m_iPad << 1))]; |
---|
123 | m_aapiRefVideoPel [2] = new Pel[ m_aiRefVideoStrides[2] * (m_iHeight + (m_iPad << 1))]; |
---|
124 | |
---|
125 | m_aapiRefVideoPel [0] += m_aiRefVideoStrides[0] * m_iPad + m_iPad; |
---|
126 | m_aapiRefVideoPel [1] += m_aiRefVideoStrides[1] * m_iPad + m_iPad; |
---|
127 | m_aapiRefVideoPel [2] += m_aiRefVideoStrides[2] * m_iPad + m_iPad; |
---|
128 | |
---|
129 | m_piError = new Int [m_iStride*m_iHeight]; |
---|
130 | |
---|
131 | // Create Buffers |
---|
132 | if ( (m_iMode == 0) || (m_iMode == 2 ) ) |
---|
133 | { |
---|
134 | m_apbOccluded [0] = new Bool[m_iStride*m_iHeight]; |
---|
135 | m_apiFilled [0] = new Pel [m_iStride*m_iHeight]; |
---|
136 | |
---|
137 | for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++) |
---|
138 | { |
---|
139 | m_aapiSynthVideoPel[0][uiPlaneNum] = new Pel[m_iStride*m_iHeight]; |
---|
140 | } |
---|
141 | } |
---|
142 | |
---|
143 | if ( (m_iMode == 1) || (m_iMode == 2 ) ) |
---|
144 | { |
---|
145 | m_apbOccluded [1] = new Bool[m_iStride*m_iHeight]; |
---|
146 | m_apiFilled [1] = new Pel [m_iStride*m_iHeight]; |
---|
147 | |
---|
148 | for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++) |
---|
149 | { |
---|
150 | m_aapiSynthVideoPel[1][uiPlaneNum] = new Pel[m_iStride*m_iHeight]; |
---|
151 | } |
---|
152 | } |
---|
153 | |
---|
154 | if ( m_iMode == 2 ) |
---|
155 | { |
---|
156 | m_apiSynthDepthPel[0] = new Pel[m_iStride*m_iHeight]; |
---|
157 | m_apiSynthDepthPel[1] = new Pel[m_iStride*m_iHeight]; |
---|
158 | m_apiSynthDepthPel[2] = new Pel[m_iStride*m_iHeight]; |
---|
159 | |
---|
160 | for (UInt uiPlaneNum = 0; uiPlaneNum < 3; uiPlaneNum++) |
---|
161 | { |
---|
162 | m_aapiSynthVideoPel[2][uiPlaneNum] = new Pel[m_iStride*m_iHeight]; |
---|
163 | } |
---|
164 | } |
---|
165 | } |
---|
166 | |
---|
167 | Void |
---|
168 | TRenSingleModel::setLRView( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride ) |
---|
169 | { |
---|
170 | AOF(( iViewPos == 0) || (iViewPos == 1) ); |
---|
171 | m_aapiBaseVideoPel [iViewPos] = apiCurVideoPel; |
---|
172 | m_aaiBaseVideoStrides [iViewPos] = aiCurVideoStride; |
---|
173 | m_apiBaseDepthPel [iViewPos] = piCurDepthPel; |
---|
174 | m_aiBaseDepthStrides [iViewPos] = iCurDepthStride; |
---|
175 | } |
---|
176 | |
---|
177 | Void |
---|
178 | TRenSingleModel::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, Bool bKeepReference ) |
---|
179 | { |
---|
180 | AOT( !m_bUseOrgRef && pcOrgVideo ); |
---|
181 | AOT( (ppiShiftLutLeft == NULL) && (m_iMode == 0 || m_iMode == 2) ); |
---|
182 | AOT( (ppiShiftLutRight == NULL) && (m_iMode == 1 || m_iMode == 2) ); |
---|
183 | AOT( pcOrgVideo != NULL && bKeepReference ); |
---|
184 | |
---|
185 | m_appiShiftLut[0] = ppiShiftLutLeft; |
---|
186 | m_appiShiftLut[1] = ppiShiftLutRight; |
---|
187 | |
---|
188 | // Copy Reference |
---|
189 | m_pcPicYuvRef = pcOrgVideo; |
---|
190 | |
---|
191 | if ( pcOrgVideo ) |
---|
192 | { |
---|
193 | TRenFilter::copy( pcOrgVideo->getLumaAddr(), pcOrgVideo->getStride() , m_iWidth, m_iHeight, m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]); |
---|
194 | TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCbAddr() , pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]); |
---|
195 | TRenFilter::sampleCUpHorUp(0, pcOrgVideo->getCrAddr() , pcOrgVideo->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]); |
---|
196 | } |
---|
197 | |
---|
198 | // Initial Rendering |
---|
199 | xSetInts( m_piError , m_iStride, m_iWidth, m_iHeight, 0 ); |
---|
200 | |
---|
201 | switch ( m_iMode ) |
---|
202 | { |
---|
203 | case 0: |
---|
204 | xInitView( VIEWPOS_LEFT ); |
---|
205 | xRenderL( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0], true ); |
---|
206 | break; |
---|
207 | case 1: |
---|
208 | xInitView( VIEWPOS_RIGHT ); |
---|
209 | xRenderR( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1], true ); |
---|
210 | break; |
---|
211 | case 2: |
---|
212 | TRenFilter::setupZLUT( true, 30, iDistToLeft, ppiBaseShiftLutLeft, ppiBaseShiftLutRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight ); |
---|
213 | xInitView( VIEWPOS_LEFT ); |
---|
214 | xInitView( VIEWPOS_RIGHT ); |
---|
215 | xInitView( VIEWPOS_MERGED ); |
---|
216 | xRenderL( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0], true ); |
---|
217 | xRenderR( 0, 0, m_iWidth, m_iHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1], true ); |
---|
218 | break; |
---|
219 | default: |
---|
220 | AOT(true); |
---|
221 | } |
---|
222 | |
---|
223 | // Get Rendered View as Reference |
---|
224 | if ( !pcOrgVideo && !bKeepReference ) |
---|
225 | { |
---|
226 | xSetInts ( m_piError , m_iStride, m_iWidth, m_iHeight, 0 ); |
---|
227 | TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][0], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]); |
---|
228 | TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][1], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]); |
---|
229 | TRenFilter::copy( m_aapiSynthVideoPel[m_iMode ][2], m_iStride, m_iWidth, m_iHeight , m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]); |
---|
230 | } |
---|
231 | } |
---|
232 | |
---|
233 | RMDist |
---|
234 | TRenSingleModel::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) |
---|
235 | { |
---|
236 | RMDist iSSE = 0; |
---|
237 | switch (iViewPos ) |
---|
238 | { |
---|
239 | case 0: |
---|
240 | iSSE = xRenderL( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, false ); |
---|
241 | break; |
---|
242 | case 1: |
---|
243 | iSSE = xRenderR( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, false ); |
---|
244 | break; |
---|
245 | default: |
---|
246 | assert(0); |
---|
247 | } |
---|
248 | return iSSE; |
---|
249 | } |
---|
250 | |
---|
251 | Void |
---|
252 | TRenSingleModel::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) |
---|
253 | { |
---|
254 | switch (iViewPos ) |
---|
255 | { |
---|
256 | case 0: |
---|
257 | xRenderL( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, true ); |
---|
258 | break; |
---|
259 | case 1: |
---|
260 | xRenderR( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, true ); |
---|
261 | break; |
---|
262 | default: |
---|
263 | assert(0); |
---|
264 | } |
---|
265 | } |
---|
266 | |
---|
267 | |
---|
268 | Void |
---|
269 | TRenSingleModel::getSynthView( Int iViewPos, Pel**& rppiRenVideoPel, Pel*& rpiRenDepthPel, Int& riStride ) |
---|
270 | { |
---|
271 | rppiRenVideoPel = m_aapiSynthVideoPel[iViewPos]; |
---|
272 | rpiRenDepthPel = m_apiSynthDepthPel [iViewPos]; |
---|
273 | riStride = m_iStride; |
---|
274 | } |
---|
275 | |
---|
276 | |
---|
277 | Void |
---|
278 | TRenSingleModel::getRefView( TComPicYuv*& rpcPicYuvRefView, Pel**& rppiRefVideoPel, Int*& raiStrides ) |
---|
279 | { |
---|
280 | rpcPicYuvRefView = m_pcPicYuvRef; |
---|
281 | rppiRefVideoPel = m_aapiRefVideoPel; |
---|
282 | raiStrides = m_aiRefVideoStrides; |
---|
283 | } |
---|
284 | |
---|
285 | |
---|
286 | RMDist |
---|
287 | TRenSingleModel::getDistVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) |
---|
288 | { |
---|
289 | AOF(false); |
---|
290 | return 0; |
---|
291 | } |
---|
292 | |
---|
293 | Void |
---|
294 | TRenSingleModel::setVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) |
---|
295 | { |
---|
296 | AOF(false); |
---|
297 | } |
---|
298 | |
---|
299 | |
---|
300 | |
---|
301 | __inline Void |
---|
302 | TRenSingleModel::xSetViewRow( Int iPosY ) |
---|
303 | { |
---|
304 | m_aapiBaseVideoPelRow [m_iCurViewPos][0] = m_aapiBaseVideoPel [m_iCurViewPos] [0] + m_aaiBaseVideoStrides [ m_iCurViewPos ][0] * iPosY; |
---|
305 | m_aapiBaseVideoPelRow [m_iCurViewPos][1] = m_aapiBaseVideoPel [m_iCurViewPos] [1] + m_aaiBaseVideoStrides [ m_iCurViewPos ][1] * iPosY; |
---|
306 | m_aapiBaseVideoPelRow [m_iCurViewPos][2] = m_aapiBaseVideoPel [m_iCurViewPos] [2] + m_aaiBaseVideoStrides [ m_iCurViewPos ][2] * iPosY; |
---|
307 | |
---|
308 | m_apiBaseDepthPelRow [m_iCurViewPos] = m_apiBaseDepthPel [m_iCurViewPos] + m_aiBaseDepthStrides [ m_iCurViewPos] * iPosY; |
---|
309 | m_apbOccludedRow [m_iCurViewPos] = m_apbOccluded [m_iCurViewPos] + m_iStride * iPosY; |
---|
310 | m_apiFilledRow [m_iCurViewPos] = m_apiFilled [m_iCurViewPos] + m_iStride * iPosY; |
---|
311 | m_apiErrorRow = m_piError + m_iStride * iPosY; |
---|
312 | |
---|
313 | m_aapiSynthVideoPelRow [m_iCurViewPos][0] = m_aapiSynthVideoPel [m_iCurViewPos] [0] + m_iStride * iPosY; |
---|
314 | m_aapiSynthVideoPelRow [m_iCurViewPos][1] = m_aapiSynthVideoPel [m_iCurViewPos] [1] + m_iStride * iPosY; |
---|
315 | m_aapiSynthVideoPelRow [m_iCurViewPos][2] = m_aapiSynthVideoPel [m_iCurViewPos] [2] + m_iStride * iPosY; |
---|
316 | |
---|
317 | m_aapiRefVideoPelRow [0] = m_aapiRefVideoPel [0] + m_aiRefVideoStrides [0] * iPosY; |
---|
318 | m_aapiRefVideoPelRow [1] = m_aapiRefVideoPel [1] + m_aiRefVideoStrides [1] * iPosY; |
---|
319 | m_aapiRefVideoPelRow [2] = m_aapiRefVideoPel [2] + m_aiRefVideoStrides [2] * iPosY; |
---|
320 | |
---|
321 | if (m_iMode == 2) |
---|
322 | { |
---|
323 | m_apiSynthDepthPelRow [m_iCurViewPos ] = m_apiSynthDepthPel [m_iCurViewPos] + m_iStride * iPosY; |
---|
324 | m_aapiSynthVideoPelRow[m_iOtherViewPos][0] = m_aapiSynthVideoPel [m_iOtherViewPos][0] + m_iStride * iPosY; |
---|
325 | m_aapiSynthVideoPelRow[m_iOtherViewPos][1] = m_aapiSynthVideoPel [m_iOtherViewPos][1] + m_iStride * iPosY; |
---|
326 | m_aapiSynthVideoPelRow[m_iOtherViewPos][2] = m_aapiSynthVideoPel [m_iOtherViewPos][2] + m_iStride * iPosY; |
---|
327 | |
---|
328 | m_apiFilledRow [m_iOtherViewPos] = m_apiFilled [m_iOtherViewPos] + m_iStride * iPosY; |
---|
329 | m_apiSynthDepthPelRow [m_iOtherViewPos] = m_apiSynthDepthPel [m_iOtherViewPos] + m_iStride * iPosY; |
---|
330 | |
---|
331 | m_aapiSynthVideoPelRow[2 ][0] = m_aapiSynthVideoPel[2] [0] + m_iStride * iPosY; |
---|
332 | m_aapiSynthVideoPelRow[2 ][1] = m_aapiSynthVideoPel[2] [1] + m_iStride * iPosY; |
---|
333 | m_aapiSynthVideoPelRow[2 ][2] = m_aapiSynthVideoPel[2] [2] + m_iStride * iPosY; |
---|
334 | } |
---|
335 | } |
---|
336 | |
---|
337 | __inline Void |
---|
338 | TRenSingleModel::xIncViewRow( ) |
---|
339 | { |
---|
340 | m_aapiBaseVideoPelRow [m_iCurViewPos][0] += m_aaiBaseVideoStrides [ m_iCurViewPos ][0]; |
---|
341 | m_aapiBaseVideoPelRow [m_iCurViewPos][1] += m_aaiBaseVideoStrides [ m_iCurViewPos ][1]; |
---|
342 | m_aapiBaseVideoPelRow [m_iCurViewPos][2] += m_aaiBaseVideoStrides [ m_iCurViewPos ][2]; |
---|
343 | |
---|
344 | m_apiBaseDepthPelRow [m_iCurViewPos] += m_aiBaseDepthStrides [ m_iCurViewPos] ; |
---|
345 | m_apbOccludedRow [m_iCurViewPos] += m_iStride ; |
---|
346 | m_apiFilledRow [m_iCurViewPos] += m_iStride ; |
---|
347 | m_apiErrorRow += m_iStride ; |
---|
348 | |
---|
349 | m_aapiSynthVideoPelRow [m_iCurViewPos][0] += m_iStride ; |
---|
350 | m_aapiSynthVideoPelRow [m_iCurViewPos][1] += m_iStride ; |
---|
351 | m_aapiSynthVideoPelRow [m_iCurViewPos][2] += m_iStride ; |
---|
352 | |
---|
353 | m_aapiRefVideoPelRow [0] += m_aiRefVideoStrides [0]; |
---|
354 | m_aapiRefVideoPelRow [1] += m_aiRefVideoStrides [1]; |
---|
355 | m_aapiRefVideoPelRow [2] += m_aiRefVideoStrides [2]; |
---|
356 | |
---|
357 | if (m_iMode == 2) |
---|
358 | { |
---|
359 | m_apiSynthDepthPelRow [m_iCurViewPos ] += m_iStride ; // This is correct! |
---|
360 | |
---|
361 | m_aapiSynthVideoPelRow[m_iOtherViewPos][0] += m_iStride ; |
---|
362 | m_aapiSynthVideoPelRow[m_iOtherViewPos][1] += m_iStride ; |
---|
363 | m_aapiSynthVideoPelRow[m_iOtherViewPos][2] += m_iStride ; |
---|
364 | |
---|
365 | m_apiFilledRow [m_iOtherViewPos] += m_iStride ; |
---|
366 | m_apiSynthDepthPelRow [m_iOtherViewPos] += m_iStride ; |
---|
367 | |
---|
368 | m_aapiSynthVideoPelRow[2 ][0] += m_iStride ; |
---|
369 | m_aapiSynthVideoPelRow[2 ][1] += m_iStride ; |
---|
370 | m_aapiSynthVideoPelRow[2 ][2] += m_iStride ; |
---|
371 | } |
---|
372 | } |
---|
373 | |
---|
374 | __inline RMDist |
---|
375 | TRenSingleModel::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bAdd ) |
---|
376 | { |
---|
377 | m_bSet = bAdd; |
---|
378 | m_iCurViewPos = 0; |
---|
379 | m_iOtherViewPos = 1; |
---|
380 | |
---|
381 | m_piNewDepthData = piNewData; |
---|
382 | m_iNewDataWidth = iWidth; |
---|
383 | m_iStartChangePosX = iStartPosX; |
---|
384 | |
---|
385 | if ((iWidth == 0) || (iHeight == 0)) |
---|
386 | return 0; |
---|
387 | |
---|
388 | //TODO: Specialize to left and right; setData and getDist |
---|
389 | |
---|
390 | // Get Data |
---|
391 | m_ppiCurLUT = m_appiShiftLut [m_iCurViewPos]; |
---|
392 | |
---|
393 | xSetViewRow ( iStartPosY); |
---|
394 | |
---|
395 | // Init Start |
---|
396 | RMDist iError = 0; |
---|
397 | Int iStartChangePos; |
---|
398 | |
---|
399 | iStartChangePos = m_iStartChangePosX; |
---|
400 | |
---|
401 | for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ ) |
---|
402 | { |
---|
403 | m_bInOcclusion = false; |
---|
404 | |
---|
405 | Int iLastSPos; |
---|
406 | Int iEndChangePos = m_iStartChangePosX + iWidth - 1; |
---|
407 | Int iPosXinNewData = iWidth - 1; |
---|
408 | Int iMinChangedSPos = m_iSampledWidth; |
---|
409 | |
---|
410 | if ( iEndChangePos == ( m_iWidth -1 )) // Special processing for rightmost depth sample |
---|
411 | { |
---|
412 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
---|
413 | Int iCurSPos = xShiftNewData(iEndChangePos, iPosXinNewData); |
---|
414 | m_iLastOccludedSPos = iCurSPos + 1; |
---|
415 | m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos ); |
---|
416 | xExtrapolateMarginL ( iCurSPos, iEndChangePos, iError ); |
---|
417 | iMinChangedSPos = Min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos], m_piNewDepthData[iPosXinNewData] )) ]); |
---|
418 | iLastSPos = iCurSPos; |
---|
419 | m_iLastDepth = m_iCurDepth; |
---|
420 | iPosXinNewData--; |
---|
421 | iEndChangePos--; |
---|
422 | } |
---|
423 | else |
---|
424 | { |
---|
425 | iLastSPos = xShift(iEndChangePos+1); |
---|
426 | m_iLastDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iEndChangePos+1]; |
---|
427 | xInitRenderPartL( iEndChangePos, iLastSPos ); |
---|
428 | } |
---|
429 | |
---|
430 | //// RENDER NEW DATA |
---|
431 | Int iCurPosX; |
---|
432 | for ( iCurPosX = iEndChangePos; iCurPosX >= iStartChangePos; iCurPosX-- ) |
---|
433 | { |
---|
434 | // Get minimal changed sample position |
---|
435 | iMinChangedSPos = Min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]); |
---|
436 | Int iCurSPos = xShiftNewData(iCurPosX,iPosXinNewData); |
---|
437 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
---|
438 | xRenderRangeL(iCurSPos, iLastSPos, iCurPosX, iError ); |
---|
439 | iLastSPos = iCurSPos; |
---|
440 | m_iLastDepth = m_iCurDepth; |
---|
441 | iPosXinNewData--; |
---|
442 | } |
---|
443 | |
---|
444 | //// RE-RENDER DATA LEFT TO NEW DATA |
---|
445 | while ( iCurPosX >= 0 ) |
---|
446 | { |
---|
447 | Int iCurSPos = xShift(iCurPosX); |
---|
448 | m_iCurDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX]; |
---|
449 | xRenderRangeL( iCurSPos, iLastSPos, iCurPosX, iError ); |
---|
450 | |
---|
451 | if ( iCurSPos < iMinChangedSPos ) |
---|
452 | { |
---|
453 | #if GERHARD_RM_HOLE_EXT |
---|
454 | if ( (iCurSPos > 0) && (m_apiFilledRow[m_iCurViewPos][ iCurSPos-1 ] != REN_IS_FILLED) || (iCurSPos > 1) && (m_apiFilledRow[m_iCurViewPos][ iCurSPos-2 ] != REN_IS_FILLED) ) |
---|
455 | { |
---|
456 | iMinChangedSPos = iMinChangedSPos - m_iHoleMargin - 2; |
---|
457 | } |
---|
458 | else |
---|
459 | { |
---|
460 | break; |
---|
461 | } |
---|
462 | #else |
---|
463 | break; |
---|
464 | #endif |
---|
465 | } |
---|
466 | iCurPosX--; |
---|
467 | iLastSPos = iCurSPos; |
---|
468 | m_iLastDepth = m_iCurDepth; |
---|
469 | } |
---|
470 | |
---|
471 | xIncViewRow(); |
---|
472 | m_piNewDepthData += iStride; |
---|
473 | } |
---|
474 | return iError; |
---|
475 | } |
---|
476 | |
---|
477 | |
---|
478 | __inline RMDist |
---|
479 | TRenSingleModel::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bAdd ) |
---|
480 | { |
---|
481 | m_bSet = bAdd; |
---|
482 | m_iCurViewPos = 1; |
---|
483 | m_iOtherViewPos = 0; |
---|
484 | |
---|
485 | m_piNewDepthData = piNewData; |
---|
486 | m_iNewDataWidth = iWidth; |
---|
487 | m_iStartChangePosX = iStartPosX; |
---|
488 | |
---|
489 | if ((iWidth == 0) || (iHeight == 0)) |
---|
490 | return 0; |
---|
491 | |
---|
492 | // Get Data |
---|
493 | m_ppiCurLUT = m_appiShiftLut [m_iCurViewPos]; |
---|
494 | |
---|
495 | xSetViewRow ( iStartPosY); |
---|
496 | |
---|
497 | // Init Start |
---|
498 | RMDist iError = 0; |
---|
499 | Int iEndChangePos; |
---|
500 | |
---|
501 | iEndChangePos = m_iStartChangePosX + iWidth - 1; |
---|
502 | |
---|
503 | |
---|
504 | for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ ) |
---|
505 | { |
---|
506 | m_bInOcclusion = false; |
---|
507 | |
---|
508 | Int iLastSPos; |
---|
509 | Int iStartChangePos = m_iStartChangePosX; |
---|
510 | Int iPosXinNewData = 0; |
---|
511 | Int iMaxChangedSPos = -1; |
---|
512 | |
---|
513 | if ( iStartChangePos == 0 ) // Special processing for leftmost depth sample |
---|
514 | { |
---|
515 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
---|
516 | Int iCurSPos = xShiftNewData(iStartChangePos, iPosXinNewData); |
---|
517 | m_iLastOccludedSPos = iCurSPos - 1; |
---|
518 | m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos ); |
---|
519 | xExtrapolateMarginR ( iCurSPos, iStartChangePos, iError ); |
---|
520 | iMaxChangedSPos = Max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos], m_piNewDepthData[iPosXinNewData] )) ]); |
---|
521 | iLastSPos = iCurSPos; |
---|
522 | m_iLastDepth = m_iCurDepth; |
---|
523 | iPosXinNewData++; |
---|
524 | iStartChangePos++; |
---|
525 | } |
---|
526 | else |
---|
527 | { |
---|
528 | iLastSPos = xShift(iStartChangePos-1); |
---|
529 | m_iLastDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iStartChangePos-1]; |
---|
530 | xInitRenderPartR( iStartChangePos, iLastSPos ); |
---|
531 | } |
---|
532 | |
---|
533 | //// RENDER NEW DATA |
---|
534 | Int iCurPosX; |
---|
535 | for ( iCurPosX = iStartChangePos; iCurPosX <= iEndChangePos; iCurPosX++ ) |
---|
536 | { |
---|
537 | // Get minimal changed sample position |
---|
538 | iMaxChangedSPos = Max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( Max(m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX], m_piNewDepthData[iPosXinNewData] )) ]); |
---|
539 | Int iCurSPos = xShiftNewData(iCurPosX,iPosXinNewData); |
---|
540 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
---|
541 | xRenderRangeR(iCurSPos, iLastSPos, iCurPosX, iError ); |
---|
542 | iLastSPos = iCurSPos; |
---|
543 | m_iLastDepth = m_iCurDepth; |
---|
544 | iPosXinNewData++; |
---|
545 | } |
---|
546 | |
---|
547 | //// RE-RENDER DATA LEFT TO NEW DATA |
---|
548 | while ( iCurPosX < m_iWidth ) |
---|
549 | { |
---|
550 | Int iCurSPos = xShift(iCurPosX); |
---|
551 | m_iCurDepth = m_apiBaseDepthPelRow[m_iCurViewPos][iCurPosX]; |
---|
552 | xRenderRangeR( iCurSPos, iLastSPos, iCurPosX, iError ); |
---|
553 | |
---|
554 | if ( iCurSPos > iMaxChangedSPos ) |
---|
555 | { |
---|
556 | #if GERHARD_RM_HOLE_EXT |
---|
557 | if ( (iCurSPos > 0) && (m_apiFilledRow[m_iCurViewPos][ iCurSPos-1 ] != REN_IS_FILLED) || (iCurSPos > 1) && (m_apiFilledRow[m_iCurViewPos][ iCurSPos-2 ] != REN_IS_FILLED) ) |
---|
558 | { |
---|
559 | iMaxChangedSPos = iMaxChangedSPos - m_iHoleMargin - 2; |
---|
560 | } |
---|
561 | else |
---|
562 | { |
---|
563 | break; |
---|
564 | } |
---|
565 | #else |
---|
566 | break; |
---|
567 | #endif |
---|
568 | } |
---|
569 | iCurPosX++; |
---|
570 | iLastSPos = iCurSPos; |
---|
571 | m_iLastDepth = m_iCurDepth; |
---|
572 | } |
---|
573 | xIncViewRow(); |
---|
574 | m_piNewDepthData += iStride; |
---|
575 | } |
---|
576 | return iError; |
---|
577 | } |
---|
578 | |
---|
579 | |
---|
580 | __inline Void |
---|
581 | TRenSingleModel::xInitRenderPartL( Int iEndChangePos, Int iLastSPos ) |
---|
582 | { |
---|
583 | // GET MINIMAL OCCLUDED SAMPLE POSITION |
---|
584 | Int iCurPosX = iEndChangePos; |
---|
585 | |
---|
586 | #if GERHARD_RM_HOLE_EXT |
---|
587 | Int iEndFillSPos = iLastSPos + m_iHoleMargin; |
---|
588 | while ( (iCurPosX + 1 < m_iWidth) && ( xShift(iCurPosX + 1) <= iEndFillSPos) && !(m_apbOccludedRow[m_iCurViewPos][ iCurPosX + 1] ) ) |
---|
589 | iCurPosX++; |
---|
590 | #endif |
---|
591 | |
---|
592 | if ( ( iCurPosX + 1 < m_iWidth ) && (m_apbOccludedRow[m_iCurViewPos][ iCurPosX + 1] ) ) |
---|
593 | { |
---|
594 | iCurPosX++; |
---|
595 | while ( (iCurPosX + 1 < m_iWidth) && (m_apbOccludedRow[m_iCurViewPos][ iCurPosX + 1] ) ) |
---|
596 | iCurPosX++; |
---|
597 | |
---|
598 | if ( iCurPosX + 1 < m_iWidth ) |
---|
599 | { |
---|
600 | iCurPosX++; |
---|
601 | m_iLastOccludedSPos = xShift(iCurPosX); |
---|
602 | } |
---|
603 | else |
---|
604 | { |
---|
605 | m_iLastOccludedSPos = xShift(iCurPosX) + 1; |
---|
606 | } |
---|
607 | |
---|
608 | m_iLastOccludedSPosFP = xRoundL( m_iLastOccludedSPos ); |
---|
609 | } |
---|
610 | else |
---|
611 | { |
---|
612 | m_iLastOccludedSPos = iLastSPos+1; |
---|
613 | m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos ); |
---|
614 | } |
---|
615 | |
---|
616 | m_bInOcclusion = iLastSPos >= m_iLastOccludedSPos; |
---|
617 | |
---|
618 | #if GERHARD_RM_HOLE_EXT |
---|
619 | // RE-RENDER if not filled |
---|
620 | if ( ( ( ( iLastSPos < m_iLastOccludedSPos) && ( m_apiFilledRow[m_iCurViewPos][ iLastSPos ] != REN_IS_FILLED ) ))) |
---|
621 | { |
---|
622 | xRemoveHoleExtL(iLastSPos, iEndChangePos+1, iError ); |
---|
623 | } |
---|
624 | #endif |
---|
625 | }; |
---|
626 | |
---|
627 | __inline Void |
---|
628 | TRenSingleModel::xInitRenderPartR( Int iStartChangePos, Int iLastSPos ) |
---|
629 | { |
---|
630 | // GET MINIMAL OCCLUDED SAMPLE POSITION |
---|
631 | Int iCurPosX = iStartChangePos; |
---|
632 | |
---|
633 | #if GERHARD_RM_HOLE_EXT |
---|
634 | Int iEndFillSPos = iLastSPos + m_iHoleMargin; |
---|
635 | while ( (iCurPosX + 1 < m_iWidth) && ( xShift(iCurPosX + 1) <= iEndFillSPos) && !(m_apbOccludedRow[m_iCurViewPos][ iCurPosX + 1] ) ) |
---|
636 | iCurPosX++; |
---|
637 | #endif |
---|
638 | |
---|
639 | if ( ( iCurPosX - 1 > -1 ) && (m_apbOccludedRow[m_iCurViewPos][ iCurPosX - 1] ) ) |
---|
640 | { |
---|
641 | iCurPosX--; |
---|
642 | while ( (iCurPosX - 1 > -1 ) && (m_apbOccludedRow[m_iCurViewPos][ iCurPosX - 1] ) ) |
---|
643 | iCurPosX--; |
---|
644 | |
---|
645 | if ( iCurPosX - 1 > -1 ) |
---|
646 | { |
---|
647 | iCurPosX--; |
---|
648 | m_iLastOccludedSPos = xShift(iCurPosX); |
---|
649 | } |
---|
650 | else |
---|
651 | { |
---|
652 | m_iLastOccludedSPos = xShift(iCurPosX) - 1; |
---|
653 | } |
---|
654 | #if GERHARD_RM_SPLAT |
---|
655 | m_iLastOccludedSPosFP = xRoundR( m_iLastOccludedSPos ); |
---|
656 | #else |
---|
657 | m_iLastOccludedSPosFP = xRangeLeftR( m_iLastOccludedSPos ); |
---|
658 | #endif |
---|
659 | } |
---|
660 | else |
---|
661 | { |
---|
662 | m_iLastOccludedSPos = iLastSPos-1; |
---|
663 | m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos ); |
---|
664 | } |
---|
665 | |
---|
666 | m_bInOcclusion = iLastSPos <= m_iLastOccludedSPos; |
---|
667 | |
---|
668 | #if GERHARD_RM_HOLE_EXT |
---|
669 | // RE-RENDER if not filled |
---|
670 | if ( ( ( ( iLastSPos < m_iLastOccludedSPos) && ( m_apiFilledRow[m_iCurViewPos][ iLastSPos ] != REN_IS_FILLED ) ))) |
---|
671 | { |
---|
672 | xRemoveHoleExtL(iLastSPos, iStartChangePos+1, iError ); |
---|
673 | } |
---|
674 | #endif |
---|
675 | }; |
---|
676 | |
---|
677 | |
---|
678 | __inline Void |
---|
679 | TRenSingleModel::xRenderShiftedRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
680 | { |
---|
681 | assert( iCurSPos <= iLastSPos ); |
---|
682 | //assert( iRightSPos < m_iWidth ); |
---|
683 | |
---|
684 | Int iDeltaSPos = iLastSPos - iCurSPos; |
---|
685 | if ( iDeltaSPos > m_iGapTolerance ) |
---|
686 | { |
---|
687 | xFillHoleL( iCurSPos, iLastSPos, iCurPos, riError ); |
---|
688 | } |
---|
689 | else |
---|
690 | { |
---|
691 | if (iLastSPos < 0 ) |
---|
692 | return; |
---|
693 | |
---|
694 | AOT( iDeltaSPos > m_iGapTolerance ); |
---|
695 | |
---|
696 | m_iThisDepth = m_iCurDepth; |
---|
697 | for (Int iFillSPos = Max(0, xRangeLeftL(iCurSPos) ); iFillSPos <= min(xRangeRightL( iLastSPos ) ,m_iLastOccludedSPosFP-1); iFillSPos++ ) |
---|
698 | { |
---|
699 | Int iDeltaCurSPos = (iFillSPos << m_iShiftPrec) - iCurSPos; |
---|
700 | |
---|
701 | AOT( iDeltaCurSPos > iDeltaSPos ); |
---|
702 | AOT( iDeltaCurSPos < 0 ); |
---|
703 | AOT( m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead); |
---|
704 | |
---|
705 | Int iSourcePos = (iCurPos << m_iShiftPrec) + m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos]; // GT: = iPosX - iStep + ( iStep * iDeltaCurPos + ( iDeltaPos >> 1) ) / iDeltaPos; |
---|
706 | xSetShiftedPel( iSourcePos, iFillSPos, REN_IS_FILLED, riError ); |
---|
707 | } |
---|
708 | }; |
---|
709 | } |
---|
710 | |
---|
711 | __inline Void |
---|
712 | TRenSingleModel::xRenderShiftedRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
713 | { |
---|
714 | assert( iCurSPos >= iLastSPos ); |
---|
715 | //assert( iRightSPos < m_iWidth ); |
---|
716 | |
---|
717 | Int iDeltaSPos = iCurSPos - iLastSPos; |
---|
718 | if ( iDeltaSPos > m_iGapTolerance ) |
---|
719 | { |
---|
720 | xFillHoleR( iCurSPos, iLastSPos, iCurPos, riError ); |
---|
721 | } |
---|
722 | else |
---|
723 | { |
---|
724 | if (iLastSPos > m_iSampledWidth - 1 ) |
---|
725 | return; |
---|
726 | |
---|
727 | m_iThisDepth = m_iCurDepth; |
---|
728 | AOT( iDeltaSPos > m_iGapTolerance ); |
---|
729 | for (Int iFillSPos = max(m_iLastOccludedSPosFP+1, xRangeLeftR(iLastSPos) ); iFillSPos <= min(xRangeRightR( iCurSPos ) ,m_iWidth -1); iFillSPos++ ) |
---|
730 | { |
---|
731 | Int iDeltaCurSPos = (iFillSPos << m_iShiftPrec) - iLastSPos; |
---|
732 | |
---|
733 | AOT( iDeltaCurSPos > iDeltaSPos ); |
---|
734 | AOT( iDeltaCurSPos < 0 ); |
---|
735 | AOT( m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead); |
---|
736 | |
---|
737 | Int iSourcePos = (iCurPos << m_iShiftPrec) + m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos]; // GT: = iPosX - iStep + ( iStep * iDeltaCurPos + ( iDeltaPos >> 1) ) / iDeltaPos; |
---|
738 | |
---|
739 | xSetShiftedPel( iSourcePos, iFillSPos, REN_IS_FILLED, riError ); |
---|
740 | } |
---|
741 | }; |
---|
742 | } |
---|
743 | |
---|
744 | |
---|
745 | |
---|
746 | __inline Void |
---|
747 | TRenSingleModel::xRenderRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
748 | { |
---|
749 | if ( !m_bInOcclusion ) |
---|
750 | { |
---|
751 | if ( iCurSPos >= iLastSPos ) |
---|
752 | { |
---|
753 | m_iLastOccludedSPos = iLastSPos; |
---|
754 | #if GERHARD_RM_SPLAT |
---|
755 | Int iRightSPosFP = xRoundL( iLastSPos ); |
---|
756 | if ( ( iRightSPosFP == xRangeRightL(iLastSPos)) && (iRightSPosFP >= 0) ) |
---|
757 | { |
---|
758 | m_iThisDepth = m_iLastDepth; |
---|
759 | xSetShiftedPel( (iCurPos+1) << m_iShiftPrec, iRightSPosFP, REN_IS_FILLED, riError ); |
---|
760 | } |
---|
761 | m_iLastOccludedSPosFP = iRightSPosFP; |
---|
762 | #else |
---|
763 | m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos ); |
---|
764 | #endif |
---|
765 | |
---|
766 | m_bInOcclusion = true; |
---|
767 | |
---|
768 | if ( m_bSet ) |
---|
769 | { |
---|
770 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true; |
---|
771 | } |
---|
772 | } |
---|
773 | else |
---|
774 | { |
---|
775 | if ( m_bSet ) |
---|
776 | { |
---|
777 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false; |
---|
778 | } |
---|
779 | |
---|
780 | xRenderShiftedRangeL(iCurSPos, iLastSPos, iCurPos, riError ); |
---|
781 | } |
---|
782 | } |
---|
783 | else |
---|
784 | { |
---|
785 | if ( iCurSPos < m_iLastOccludedSPos ) |
---|
786 | { |
---|
787 | m_bInOcclusion = false; |
---|
788 | if ( m_bSet ) |
---|
789 | { |
---|
790 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false; |
---|
791 | } |
---|
792 | |
---|
793 | xRenderShiftedRangeL(iCurSPos, iLastSPos, iCurPos, riError ); |
---|
794 | } |
---|
795 | else |
---|
796 | { |
---|
797 | if ( m_bSet ) |
---|
798 | { |
---|
799 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true; |
---|
800 | } |
---|
801 | } |
---|
802 | } |
---|
803 | } |
---|
804 | |
---|
805 | __inline Void |
---|
806 | TRenSingleModel::xRenderRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
807 | { |
---|
808 | // Find out if current sample is occluded |
---|
809 | if ( !m_bInOcclusion ) |
---|
810 | { |
---|
811 | if ( iCurSPos <= iLastSPos ) |
---|
812 | { |
---|
813 | m_iLastOccludedSPos = iLastSPos; |
---|
814 | |
---|
815 | #if GERHARD_RM_SPLAT |
---|
816 | Int iLeftSPosFP = xRoundR( iLastSPos ); |
---|
817 | if ( ( iLeftSPosFP == xRangeLeftR(iLastSPos)) && (iLeftSPosFP <= m_iWidth - 1) ) |
---|
818 | { |
---|
819 | m_iThisDepth = m_iLastDepth; |
---|
820 | xSetShiftedPel( (iCurPos-1) << m_iShiftPrec, iLeftSPosFP, REN_IS_FILLED, riError ); |
---|
821 | } |
---|
822 | m_iLastOccludedSPosFP = iLeftSPosFP; |
---|
823 | #endif |
---|
824 | |
---|
825 | m_bInOcclusion = true; |
---|
826 | |
---|
827 | if ( m_bSet ) |
---|
828 | { |
---|
829 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true; |
---|
830 | } |
---|
831 | } |
---|
832 | else |
---|
833 | { |
---|
834 | if ( m_bSet ) |
---|
835 | { |
---|
836 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false; |
---|
837 | } |
---|
838 | |
---|
839 | xRenderShiftedRangeR(iCurSPos, iLastSPos, iCurPos, riError ); |
---|
840 | } |
---|
841 | } |
---|
842 | else |
---|
843 | { |
---|
844 | if ( iCurSPos > m_iLastOccludedSPos ) |
---|
845 | { |
---|
846 | m_bInOcclusion = false; |
---|
847 | if ( m_bSet ) |
---|
848 | { |
---|
849 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = false; |
---|
850 | } |
---|
851 | |
---|
852 | xRenderShiftedRangeR(iCurSPos, iLastSPos, iCurPos, riError ); |
---|
853 | } |
---|
854 | else |
---|
855 | { |
---|
856 | if ( m_bSet ) |
---|
857 | { |
---|
858 | m_apbOccludedRow[m_iCurViewPos][ iCurPos ] = true; |
---|
859 | } |
---|
860 | } |
---|
861 | } |
---|
862 | } |
---|
863 | |
---|
864 | |
---|
865 | |
---|
866 | __inline Void |
---|
867 | TRenSingleModel::xFillHoleL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
868 | { |
---|
869 | if (iLastSPos < 0) |
---|
870 | return; |
---|
871 | |
---|
872 | Int iStartFillSPos = iCurSPos; |
---|
873 | Int iStartFillPos = iCurPos; |
---|
874 | Int iLastPos = iCurPos + 1; |
---|
875 | |
---|
876 | #if GERHARD_RM_HOLE_EXT |
---|
877 | Int iErrorCorrection = 0; |
---|
878 | Int iLastPosInNewData = iLastPos - m_iStartChangePosX; |
---|
879 | Int iEndFillSPos = iLastSPos + m_iHoleMargin; |
---|
880 | ////////// Go back hole margin width and correct error /////// |
---|
881 | while( ( (iLastPos+1) < m_iWidth) && (iLastSPos > iEndFillSPos) ) |
---|
882 | { |
---|
883 | iCurPos++; |
---|
884 | iLastPos++; |
---|
885 | iLastPosInNewData++; |
---|
886 | iCurSPos = iLastSPos; |
---|
887 | |
---|
888 | iLastSPos = xShift( iLastPos, iLastPosInNewData); |
---|
889 | |
---|
890 | if ( iLastSPos < 0 ) iLastSPos = 0; |
---|
891 | if ( iLastSPos >= m_iWidth ) iLastSPos = m_iWidth-1; |
---|
892 | |
---|
893 | Int iDiff = iLastSPos - iCurSPos; |
---|
894 | |
---|
895 | // Stop if other hole begins, or if position is occluded |
---|
896 | if (iDiff > 2 || iLastSPos >= Min( iEndFillSPos, m_iLastOccludedSPos ) || iCurSPos == 0) |
---|
897 | { |
---|
898 | iCurPos--; |
---|
899 | iLastPos--; |
---|
900 | iLastPosInNewData--; |
---|
901 | iLastSPos = iCurSPos; |
---|
902 | iCurSPos = xShift( iCurPos, iLastPosInNewData-1); |
---|
903 | break; |
---|
904 | } |
---|
905 | |
---|
906 | if ( !m_bSet ) |
---|
907 | { |
---|
908 | xRenderShiftedRangeL(iCurSPos, iLastSPos, iCurPos, iLastPos, iErrorCorrection ); |
---|
909 | } |
---|
910 | } |
---|
911 | |
---|
912 | riError -= iErrorCorrection; |
---|
913 | |
---|
914 | ////////// Fill enlarged hole /////// |
---|
915 | #endif |
---|
916 | |
---|
917 | Int iStartFillSPosFP = xRangeLeftL(iStartFillSPos); |
---|
918 | |
---|
919 | #if GERHARD_RM_SPLAT |
---|
920 | if (iStartFillSPosFP == xRoundL(iStartFillSPos)) |
---|
921 | { |
---|
922 | #endif |
---|
923 | if ((iStartFillSPosFP >= 0) && (iStartFillSPosFP < m_iLastOccludedSPosFP) ) |
---|
924 | { |
---|
925 | m_iThisDepth = m_iCurDepth; |
---|
926 | xSetShiftedPel ( iStartFillPos << m_iShiftPrec, iStartFillSPosFP, REN_IS_FILLED, riError ); |
---|
927 | } |
---|
928 | #if GERHARD_RM_SPLAT |
---|
929 | } |
---|
930 | else |
---|
931 | { |
---|
932 | iStartFillSPosFP--; |
---|
933 | } |
---|
934 | #endif |
---|
935 | |
---|
936 | m_iThisDepth = m_iLastDepth; |
---|
937 | for (Int iFillSPos = Max(iStartFillSPosFP+1,0); iFillSPos <= min(xRangeRightL( iLastSPos ), m_iLastOccludedSPosFP-1 ); iFillSPos++ ) |
---|
938 | { |
---|
939 | xSetShiftedPel( iLastPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError ); |
---|
940 | } |
---|
941 | } |
---|
942 | |
---|
943 | __inline Void |
---|
944 | TRenSingleModel::xFillHoleR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
945 | { |
---|
946 | if (iLastSPos < 0) |
---|
947 | return; |
---|
948 | |
---|
949 | Int iStartFillSPos = iCurSPos; |
---|
950 | Int iEndFillPos = iCurPos; |
---|
951 | Int iLastPos = iCurPos - 1; |
---|
952 | |
---|
953 | |
---|
954 | #if GERHARD_RM_HOLE_EXT |
---|
955 | Int iErrorCorrection = 0; |
---|
956 | Int iLPosInNewData = iLastPos - m_iStartChangePosX; |
---|
957 | Int iEndFillSPos = iLastSPos + m_iHoleMargin; |
---|
958 | ////////// Go back hole margin width and correct error /////// |
---|
959 | while( ( (iLastPos+1) < m_iWidth) && (iLastSPos > iEndFillSPos) ) |
---|
960 | { |
---|
961 | iCurPos++; |
---|
962 | iLastPos++; |
---|
963 | iLPosInNewData++; |
---|
964 | iCurSPos = iLastSPos; |
---|
965 | |
---|
966 | iLastSPos = xShift( iLastPos, iLPosInNewData); |
---|
967 | |
---|
968 | if ( iLastSPos < 0 ) iLastSPos = 0; |
---|
969 | if ( iLastSPos >= m_iWidth ) iLastSPos = m_iWidth-1; |
---|
970 | |
---|
971 | Int iDiff = iLastSPos - iCurSPos; |
---|
972 | |
---|
973 | // Stop if other hole begins, or if position is occluded |
---|
974 | if (iDiff > 2 || iLastSPos >= Min( iEndFillSPos, m_iLastOccludedSPos ) || iCurSPos == 0) |
---|
975 | { |
---|
976 | iCurPos--; |
---|
977 | iLastPos--; |
---|
978 | iLPosInNewData--; |
---|
979 | iLastSPos = iCurSPos; |
---|
980 | iCurSPos = xShift( iCurPos, iLPosInNewData-1); |
---|
981 | break; |
---|
982 | } |
---|
983 | |
---|
984 | if ( !m_bSet ) |
---|
985 | { |
---|
986 | xRenderShiftedRangeL(iCurSPos, iLastSPos, iCurPos, iLastPos, iErrorCorrection ); |
---|
987 | } |
---|
988 | } |
---|
989 | |
---|
990 | riError -= iErrorCorrection; |
---|
991 | |
---|
992 | ////////// Fill enlarged hole /////// |
---|
993 | #endif |
---|
994 | |
---|
995 | Int iStartFillSPosFP = xRangeRightR(iStartFillSPos); |
---|
996 | |
---|
997 | #if GERHARD_RM_SPLAT |
---|
998 | if (iStartFillSPosFP == xRoundR(iStartFillSPos)) |
---|
999 | { |
---|
1000 | #endif |
---|
1001 | if ((iStartFillSPosFP < m_iWidth) && (iStartFillSPosFP > m_iLastOccludedSPosFP) ) |
---|
1002 | { |
---|
1003 | m_iThisDepth = m_iCurDepth; |
---|
1004 | xSetShiftedPel( iEndFillPos << m_iShiftPrec, iStartFillSPosFP, REN_IS_FILLED, riError ); |
---|
1005 | } |
---|
1006 | #if GERHARD_RM_SPLAT |
---|
1007 | } |
---|
1008 | else |
---|
1009 | { |
---|
1010 | iStartFillSPosFP++; |
---|
1011 | } |
---|
1012 | #endif |
---|
1013 | |
---|
1014 | m_iThisDepth = m_iLastDepth; |
---|
1015 | for (Int iFillSPos = max(xRangeLeftR( iLastSPos ), m_iLastOccludedSPosFP+1); iFillSPos <= min(iStartFillSPosFP,m_iWidth)-1 ; iFillSPos++ ) |
---|
1016 | { |
---|
1017 | xSetShiftedPel( iLastPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError ); |
---|
1018 | } |
---|
1019 | } |
---|
1020 | |
---|
1021 | #if GERHARD_RM_HOLE_EXT |
---|
1022 | Void TRenSingleModel::xRemoveHoleExtL( Int iShiftedLeftPos, Int iLeftPos, Int& riError ) |
---|
1023 | { |
---|
1024 | if (iShiftedLeftPos < 0 || iShiftedLeftPos == (m_iWidth - 1) ) |
---|
1025 | return; |
---|
1026 | |
---|
1027 | Int iStartRemovePos = iLeftPos; |
---|
1028 | Int iEndRemoveSPos = iShiftedLeftPos + m_iHoleMargin; |
---|
1029 | Int iRightPos = iLeftPos + 1; |
---|
1030 | |
---|
1031 | Int iShiftedRightPos; |
---|
1032 | |
---|
1033 | ////////// Go back hole margin width /////// |
---|
1034 | while( iRightPos < m_iWidth ) |
---|
1035 | { |
---|
1036 | iShiftedRightPos = xShift(iRightPos); |
---|
1037 | |
---|
1038 | if ( iShiftedRightPos < 0 ) iShiftedRightPos = 0; |
---|
1039 | if ( iShiftedRightPos >= m_iWidth ) iShiftedRightPos = m_iWidth-1; |
---|
1040 | |
---|
1041 | Int iDiff = iShiftedRightPos - iShiftedLeftPos; |
---|
1042 | |
---|
1043 | // Stop if other hole begins, or if position is occluded |
---|
1044 | if ( iDiff > 2 || iShiftedRightPos >= m_iLastOccludedSPos ) |
---|
1045 | { |
---|
1046 | // Go back one |
---|
1047 | iShiftedRightPos = iShiftedLeftPos; |
---|
1048 | iRightPos--; |
---|
1049 | iLeftPos--; |
---|
1050 | iShiftedLeftPos = xShift(iLeftPos); |
---|
1051 | break; |
---|
1052 | } |
---|
1053 | |
---|
1054 | if ( (iShiftedRightPos > iEndRemoveSPos) ) |
---|
1055 | { |
---|
1056 | break; |
---|
1057 | } |
---|
1058 | |
---|
1059 | iShiftedLeftPos = iShiftedRightPos; |
---|
1060 | iLeftPos++; |
---|
1061 | iRightPos++; |
---|
1062 | } |
---|
1063 | |
---|
1064 | ////////// Remove Hole margin /////// |
---|
1065 | while( iLeftPos >= iStartRemovePos ) |
---|
1066 | { |
---|
1067 | xRenderShiftedRangeL(iShiftedLeftPos, iShiftedRightPos, iLeftPos, iRightPos, riError ); |
---|
1068 | iLeftPos--; |
---|
1069 | iRightPos--; |
---|
1070 | iShiftedRightPos = iShiftedLeftPos; |
---|
1071 | iShiftedLeftPos = xShift(iLeftPos); |
---|
1072 | } |
---|
1073 | } |
---|
1074 | #endif |
---|
1075 | |
---|
1076 | __inline Void |
---|
1077 | TRenSingleModel::xExtrapolateMarginL(Int iCurSPos, Int iCurPos, RMDist& riError ) |
---|
1078 | { |
---|
1079 | // if (iLeftSPos < 0 ) |
---|
1080 | // return; |
---|
1081 | |
---|
1082 | Int iSPosFullPel = Max(0,xRangeLeftL(iCurSPos)); |
---|
1083 | |
---|
1084 | m_iThisDepth = m_iCurDepth; |
---|
1085 | if (iSPosFullPel < m_iWidth) |
---|
1086 | { |
---|
1087 | xSetShiftedPel( iCurPos << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError ); |
---|
1088 | } |
---|
1089 | |
---|
1090 | for (Int iFillSPos = iSPosFullPel +1; iFillSPos < m_iWidth; iFillSPos++ ) |
---|
1091 | { |
---|
1092 | xSetShiftedPel( iCurPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError ); |
---|
1093 | } |
---|
1094 | } |
---|
1095 | |
---|
1096 | __inline Void |
---|
1097 | TRenSingleModel::xExtrapolateMarginR(Int iCurSPos, Int iCurPos, RMDist& riError ) |
---|
1098 | { |
---|
1099 | // if (iLeftSPos < 0 ) |
---|
1100 | // return; |
---|
1101 | |
---|
1102 | Int iSPosFullPel = Min(m_iWidth-1,xRangeRightR(iCurSPos)); |
---|
1103 | |
---|
1104 | m_iThisDepth = m_iCurDepth; |
---|
1105 | if (iSPosFullPel > -1) |
---|
1106 | { |
---|
1107 | xSetShiftedPel( iCurPos << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError ); |
---|
1108 | } |
---|
1109 | |
---|
1110 | for (Int iFillSPos = iSPosFullPel -1; iFillSPos > -1; iFillSPos-- ) |
---|
1111 | { |
---|
1112 | xSetShiftedPel( iCurPos << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError ); |
---|
1113 | } |
---|
1114 | } |
---|
1115 | |
---|
1116 | |
---|
1117 | __inline Int |
---|
1118 | TRenSingleModel::xShiftNewData( Int iPosX, Int iPosInNewData ) |
---|
1119 | { |
---|
1120 | AOT( iPosInNewData < 0 ); |
---|
1121 | AOF( iPosInNewData < m_iNewDataWidth ); |
---|
1122 | |
---|
1123 | return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_piNewDepthData[iPosInNewData] )]; |
---|
1124 | } |
---|
1125 | |
---|
1126 | __inline Int |
---|
1127 | TRenSingleModel::xShift( Int iPosX ) |
---|
1128 | { |
---|
1129 | AOT( iPosX < 0); |
---|
1130 | AOF( iPosX < m_iWidth); |
---|
1131 | return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RemoveBitIncrement( m_apiBaseDepthPelRow[m_iCurViewPos][iPosX] )]; |
---|
1132 | } |
---|
1133 | |
---|
1134 | |
---|
1135 | __inline Int |
---|
1136 | TRenSingleModel::xShift( Int iPos, Int iPosInNewData ) |
---|
1137 | { |
---|
1138 | if ( (iPosInNewData >= 0) && (iPosInNewData < m_iNewDataWidth) ) |
---|
1139 | { |
---|
1140 | return xShiftNewData(iPos ,iPosInNewData ); |
---|
1141 | } |
---|
1142 | else |
---|
1143 | { |
---|
1144 | return xShift(iPos); |
---|
1145 | } |
---|
1146 | } |
---|
1147 | |
---|
1148 | __inline Int |
---|
1149 | TRenSingleModel::xRangeLeftL( Int iPos ) |
---|
1150 | { |
---|
1151 | return ( iPos + (1 << m_iShiftPrec) - 1) >> m_iShiftPrec; |
---|
1152 | } |
---|
1153 | |
---|
1154 | |
---|
1155 | __inline Int |
---|
1156 | TRenSingleModel::xRangeLeftR( Int iPos ) |
---|
1157 | { |
---|
1158 | |
---|
1159 | return xRangeRightR( iPos ) + 1; |
---|
1160 | } |
---|
1161 | |
---|
1162 | |
---|
1163 | __inline Int |
---|
1164 | TRenSingleModel::xRangeRightL( Int iPos ) |
---|
1165 | { |
---|
1166 | return xRangeLeftL(iPos) - 1; |
---|
1167 | } |
---|
1168 | |
---|
1169 | __inline Int |
---|
1170 | TRenSingleModel::xRangeRightR( Int iPos ) |
---|
1171 | { |
---|
1172 | return iPos >> m_iShiftPrec; |
---|
1173 | } |
---|
1174 | |
---|
1175 | |
---|
1176 | __inline Int |
---|
1177 | TRenSingleModel::xRoundL( Int iPos ) |
---|
1178 | { |
---|
1179 | return (iPos + (( 1 << m_iShiftPrec ) >> 1 )) >> m_iShiftPrec; |
---|
1180 | } |
---|
1181 | |
---|
1182 | __inline Int |
---|
1183 | TRenSingleModel::xRoundR( Int iPos ) |
---|
1184 | { |
---|
1185 | return (m_iShiftPrec == 0) ? iPos : xRoundL(iPos - 1); |
---|
1186 | } |
---|
1187 | |
---|
1188 | |
---|
1189 | Void |
---|
1190 | TRenSingleModel::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal ) |
---|
1191 | { |
---|
1192 | for (Int iYPos = 0; iYPos < iHeight; iYPos++) |
---|
1193 | { |
---|
1194 | for (Int iXPos = 0; iXPos < iWidth; iXPos++) |
---|
1195 | { |
---|
1196 | piPelSource[iXPos] = iVal; |
---|
1197 | } |
---|
1198 | piPelSource += iSourceStride; |
---|
1199 | } |
---|
1200 | } |
---|
1201 | |
---|
1202 | Void |
---|
1203 | TRenSingleModel::xSetInts( Int* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal ) |
---|
1204 | { |
---|
1205 | for (Int iYPos = 0; iYPos < iHeight; iYPos++) |
---|
1206 | { |
---|
1207 | for (Int iXPos = 0; iXPos < iWidth; iXPos++) |
---|
1208 | { |
---|
1209 | piPelSource[iXPos] = iVal; |
---|
1210 | } |
---|
1211 | piPelSource += iSourceStride; |
---|
1212 | } |
---|
1213 | } |
---|
1214 | |
---|
1215 | |
---|
1216 | Void |
---|
1217 | TRenSingleModel::xSetBools( Bool* pbPelSource , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal ) |
---|
1218 | { |
---|
1219 | for (Int iYPos = 0; iYPos < iHeight; iYPos++) |
---|
1220 | { |
---|
1221 | for (Int iXPos = 0; iXPos < iWidth; iXPos++) |
---|
1222 | { |
---|
1223 | pbPelSource[iXPos] = bVal; |
---|
1224 | } |
---|
1225 | pbPelSource += iSourceStride; |
---|
1226 | } |
---|
1227 | } |
---|
1228 | |
---|
1229 | Void |
---|
1230 | TRenSingleModel::xInitView( Int iViewPos ) |
---|
1231 | { |
---|
1232 | AOT( iViewPos == VIEWPOS_MERGED && ( m_iMode == 0 || m_iMode == 1 ) ); |
---|
1233 | |
---|
1234 | xSetPels( m_aapiSynthVideoPel[iViewPos][0], m_iStride, m_iWidth, m_iHeight, 0 ); |
---|
1235 | xSetPels( m_aapiSynthVideoPel[iViewPos][1], m_iStride, m_iWidth, m_iHeight, 128 << g_uiBitIncrement ); |
---|
1236 | xSetPels( m_aapiSynthVideoPel[iViewPos][2], m_iStride, m_iWidth, m_iHeight, 128 << g_uiBitIncrement ); |
---|
1237 | |
---|
1238 | if ( iViewPos != VIEWPOS_MERGED) |
---|
1239 | { |
---|
1240 | xSetBools( m_apbOccluded [iViewPos], m_iStride, m_iWidth, m_iHeight, false ); |
---|
1241 | xSetPels ( m_apiFilled [iViewPos], m_iStride, m_iWidth, m_iHeight, REN_IS_HOLE); |
---|
1242 | if ( m_iMode == 2 ) |
---|
1243 | { |
---|
1244 | xSetPels( m_apiSynthDepthPel [iViewPos], m_iStride, m_iWidth, m_iHeight, 0); |
---|
1245 | } |
---|
1246 | } |
---|
1247 | } |
---|
1248 | |
---|
1249 | __inline Void |
---|
1250 | TRenSingleModel::xSetShiftedPel(Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError ) |
---|
1251 | { |
---|
1252 | AOT( iSourcePos < 0 ); |
---|
1253 | AOT( iSourcePos >= m_iSampledWidth ); |
---|
1254 | |
---|
1255 | AOT( iTargetSPos < 0 ); |
---|
1256 | AOT( iTargetSPos >= m_iWidth ); |
---|
1257 | // AOT( m_apiFilledRow[m_iViewPos][iTargetSPos] != REN_IS_HOLE); |
---|
1258 | |
---|
1259 | if ( m_iMode == 2) |
---|
1260 | { |
---|
1261 | xSetShiftedPelBlend(iSourcePos, iTargetSPos, iFilled, riError ); |
---|
1262 | return; |
---|
1263 | } |
---|
1264 | |
---|
1265 | if ( m_bSet ) |
---|
1266 | { |
---|
1267 | m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][0][iSourcePos]; |
---|
1268 | #if GERHARD_RM_COLOR_PLANES |
---|
1269 | m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][1][iSourcePos]; |
---|
1270 | m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][2][iSourcePos]; |
---|
1271 | #endif |
---|
1272 | m_apiFilledRow [m_iCurViewPos] [iTargetSPos] = iFilled; |
---|
1273 | Int iDiffY = m_aapiRefVideoPelRow [0][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos]; |
---|
1274 | #if GERHARD_RM_COLOR_PLANES |
---|
1275 | Int iDiffU = m_aapiRefVideoPelRow [1][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos]; |
---|
1276 | Int iDiffV = m_aapiRefVideoPelRow [2][iTargetSPos] - m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos]; |
---|
1277 | m_apiErrorRow [iTargetSPos] = xGetDist( iDiffY, iDiffU, iDiffV); |
---|
1278 | #else |
---|
1279 | m_apiErrorRow [iTargetSPos] = xGetDist(iDiffY); |
---|
1280 | #endif |
---|
1281 | } |
---|
1282 | else |
---|
1283 | { |
---|
1284 | Int iSDOld = m_apiErrorRow [iTargetSPos]; |
---|
1285 | Int iDiffY = m_aapiRefVideoPelRow [0][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][0][iSourcePos]; |
---|
1286 | #if GERHARD_RM_COLOR_PLANES |
---|
1287 | Int iDiffU = m_aapiRefVideoPelRow [1][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][1][iSourcePos]; |
---|
1288 | Int iDiffV = m_aapiRefVideoPelRow [2][iTargetSPos] - m_aapiBaseVideoPelRow [m_iCurViewPos][2][iSourcePos]; |
---|
1289 | riError += ( xGetDist(iDiffY,iDiffU,iDiffV) - iSDOld ); |
---|
1290 | #else |
---|
1291 | riError += ( xGetDist( iDiffY ) - iSDOld ); |
---|
1292 | #endif |
---|
1293 | } |
---|
1294 | } |
---|
1295 | |
---|
1296 | __inline Void |
---|
1297 | TRenSingleModel::xSetShiftedPelBlend( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError ) |
---|
1298 | { |
---|
1299 | AOT( iSourcePos < 0 ); |
---|
1300 | AOT( iSourcePos >= m_iSampledWidth ); |
---|
1301 | |
---|
1302 | AOT( iTargetSPos < 0 ); |
---|
1303 | AOT( iTargetSPos >= m_iWidth ); |
---|
1304 | // AOT( m_apiFilledRow[m_iViewPos][iTargetSPos] != REN_IS_HOLE); |
---|
1305 | |
---|
1306 | Pel piBlendedValueY; |
---|
1307 | #if GERHARD_RM_COLOR_PLANES |
---|
1308 | Pel piBlendedValueU; |
---|
1309 | Pel piBlendedValueV; |
---|
1310 | #endif |
---|
1311 | |
---|
1312 | |
---|
1313 | if (m_iCurViewPos == 0) |
---|
1314 | { |
---|
1315 | xGetBlendedValue ( |
---|
1316 | m_aapiBaseVideoPelRow [0][0][iSourcePos ] , |
---|
1317 | m_aapiSynthVideoPelRow [1][0][iTargetSPos] , |
---|
1318 | #if GERHARD_RM_COLOR_PLANES |
---|
1319 | m_aapiBaseVideoPelRow [0][1][iSourcePos ] , |
---|
1320 | m_aapiSynthVideoPelRow [1][1][iTargetSPos] , |
---|
1321 | m_aapiBaseVideoPelRow [0][2][iSourcePos ] , |
---|
1322 | m_aapiSynthVideoPelRow [1][2][iTargetSPos] , |
---|
1323 | #endif |
---|
1324 | m_piInvZLUTLeft [RemoveBitIncrement(m_iThisDepth) ], |
---|
1325 | m_piInvZLUTRight[RemoveBitIncrement(m_apiSynthDepthPelRow[1] [iTargetSPos])], |
---|
1326 | iFilled, |
---|
1327 | m_apiFilledRow [1] [iTargetSPos] , |
---|
1328 | piBlendedValueY |
---|
1329 | #if GERHARD_RM_COLOR_PLANES |
---|
1330 | , piBlendedValueU, |
---|
1331 | piBlendedValueV |
---|
1332 | #endif |
---|
1333 | ); |
---|
1334 | } |
---|
1335 | else |
---|
1336 | { |
---|
1337 | xGetBlendedValue ( |
---|
1338 | m_aapiSynthVideoPelRow [0][0][iTargetSPos], |
---|
1339 | m_aapiBaseVideoPelRow [1][0][iSourcePos ], |
---|
1340 | #if GERHARD_RM_COLOR_PLANES |
---|
1341 | m_aapiSynthVideoPelRow [0][1][iTargetSPos], |
---|
1342 | m_aapiBaseVideoPelRow [1][1][iSourcePos ], |
---|
1343 | m_aapiSynthVideoPelRow [0][2][iTargetSPos], |
---|
1344 | m_aapiBaseVideoPelRow [1][2][iSourcePos ], |
---|
1345 | #endif |
---|
1346 | m_piInvZLUTLeft [RemoveBitIncrement(m_apiSynthDepthPelRow[0] [iTargetSPos])], |
---|
1347 | m_piInvZLUTRight[RemoveBitIncrement(m_iThisDepth) ], |
---|
1348 | m_apiFilledRow [0] [iTargetSPos], |
---|
1349 | iFilled , |
---|
1350 | piBlendedValueY |
---|
1351 | #if GERHARD_RM_COLOR_PLANES |
---|
1352 | , piBlendedValueU, |
---|
1353 | piBlendedValueV |
---|
1354 | #endif |
---|
1355 | ); |
---|
1356 | } |
---|
1357 | |
---|
1358 | if ( m_bSet ) |
---|
1359 | { |
---|
1360 | m_apiSynthDepthPelRow [m_iCurViewPos] [iTargetSPos] = m_iThisDepth; |
---|
1361 | m_aapiSynthVideoPelRow[m_iCurViewPos][0][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][0][iSourcePos]; |
---|
1362 | m_aapiSynthVideoPelRow[2 ][0][iTargetSPos] = piBlendedValueY; |
---|
1363 | #if GERHARD_RM_COLOR_PLANES |
---|
1364 | m_aapiSynthVideoPelRow[m_iCurViewPos][1][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][1][iSourcePos]; |
---|
1365 | m_aapiSynthVideoPelRow[2 ][1][iTargetSPos] = piBlendedValueU; |
---|
1366 | m_aapiSynthVideoPelRow[m_iCurViewPos][2][iTargetSPos] = m_aapiBaseVideoPelRow[m_iCurViewPos][2][iSourcePos]; |
---|
1367 | m_aapiSynthVideoPelRow[2 ][2][iTargetSPos] = piBlendedValueV; |
---|
1368 | #endif |
---|
1369 | m_apiFilledRow [m_iCurViewPos] [iTargetSPos] = iFilled; |
---|
1370 | |
---|
1371 | Int iDiffY = m_aapiRefVideoPelRow [0][iTargetSPos] - piBlendedValueY; |
---|
1372 | #if GERHARD_RM_COLOR_PLANES |
---|
1373 | Int iDiffU = m_aapiRefVideoPelRow [1][iTargetSPos] - piBlendedValueU; |
---|
1374 | Int iDiffV = m_aapiRefVideoPelRow [2][iTargetSPos] - piBlendedValueV; |
---|
1375 | m_apiErrorRow [iTargetSPos] = xGetDist(iDiffY, iDiffU, iDiffV ); |
---|
1376 | #else |
---|
1377 | m_apiErrorRow [iTargetSPos] = xGetDist(iDiffY); |
---|
1378 | #endif |
---|
1379 | } |
---|
1380 | else |
---|
1381 | { |
---|
1382 | Int iSDOld = m_apiErrorRow [iTargetSPos]; |
---|
1383 | Int iDiffY = m_aapiRefVideoPelRow [0][iTargetSPos] - piBlendedValueY; |
---|
1384 | #if GERHARD_RM_COLOR_PLANES |
---|
1385 | Int iDiffU = m_aapiRefVideoPelRow [1][iTargetSPos] - piBlendedValueU; |
---|
1386 | Int iDiffV = m_aapiRefVideoPelRow [2][iTargetSPos] - piBlendedValueV; |
---|
1387 | riError += ( xGetDist( iDiffY, iDiffU, iDiffV ) - iSDOld ); |
---|
1388 | #else |
---|
1389 | riError += ( xGetDist( iDiffY )- iSDOld ); |
---|
1390 | #endif |
---|
1391 | } |
---|
1392 | } |
---|
1393 | |
---|
1394 | |
---|
1395 | __inline Int |
---|
1396 | TRenSingleModel::xGetDist( Int iDiffY, Int iDiffU, Int iDiffV ) |
---|
1397 | { |
---|
1398 | return ( ((iDiffY * iDiffY) >> m_iDistShift) |
---|
1399 | + ((( ((iDiffU * iDiffU) >> m_iDistShift) |
---|
1400 | +((iDiffV * iDiffV) >> m_iDistShift) |
---|
1401 | ) |
---|
1402 | ) >> 2 |
---|
1403 | ) |
---|
1404 | ); |
---|
1405 | } |
---|
1406 | |
---|
1407 | __inline Int |
---|
1408 | TRenSingleModel::xGetDist( Int iDiffY ) |
---|
1409 | { |
---|
1410 | return ((iDiffY * iDiffY) >> m_iDistShift); |
---|
1411 | } |
---|
1412 | |
---|
1413 | #if GERHARD_RM_COLOR_PLANES |
---|
1414 | __inline Void |
---|
1415 | TRenSingleModel::xGetBlendedValue( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV ) |
---|
1416 | #else |
---|
1417 | Void |
---|
1418 | TRenSingleModel::xGetBlendedValue( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY ) |
---|
1419 | #endif |
---|
1420 | { |
---|
1421 | if (m_iBlendMode != 0 ) |
---|
1422 | { |
---|
1423 | if (m_iBlendMode == 1 ) |
---|
1424 | { |
---|
1425 | xGetBlendedValueBM1( iYL, iYR, iUL, iUR, iVL, iVR, iDepthL, iDepthR, iFilledL, iFilledR, riY, riU, riV ); |
---|
1426 | } |
---|
1427 | else |
---|
1428 | { |
---|
1429 | xGetBlendedValueBM2( iYL, iYR, iUL, iUR, iVL, iVR, iDepthL, iDepthR, iFilledL, iFilledR, riY, riU, riV ); |
---|
1430 | } |
---|
1431 | return; |
---|
1432 | } |
---|
1433 | |
---|
1434 | if ( (iFilledL != REN_IS_HOLE ) && ( iFilledR != REN_IS_HOLE) ) |
---|
1435 | { |
---|
1436 | Int iDepthDifference = iDepthR - iDepthL; |
---|
1437 | |
---|
1438 | if ( abs ( iDepthDifference ) <= m_iBlendZThres ) |
---|
1439 | { |
---|
1440 | if ((iFilledL == REN_IS_FILLED) && ( iFilledR != REN_IS_FILLED)) |
---|
1441 | { |
---|
1442 | riY = xBlend( iYL, iYR, iFilledR >> 1 ); |
---|
1443 | #if GERHARD_RM_COLOR_PLANES |
---|
1444 | riU = xBlend( iUL, iUR, iFilledR >> 1 ); |
---|
1445 | riV = xBlend( iVL, iVR, iFilledR >> 1 ); |
---|
1446 | #endif |
---|
1447 | |
---|
1448 | } |
---|
1449 | else if ((iFilledL != REN_IS_FILLED) && ( iFilledR == REN_IS_FILLED)) |
---|
1450 | { |
---|
1451 | riY = xBlend( iYR, iYL, (iFilledL >> 1) ); |
---|
1452 | #if GERHARD_RM_COLOR_PLANES |
---|
1453 | riU = xBlend( iUR, iUL, (iFilledL >> 1) ); |
---|
1454 | riV = xBlend( iVR, iVL, (iFilledL >> 1) ); |
---|
1455 | #endif |
---|
1456 | } |
---|
1457 | else |
---|
1458 | { |
---|
1459 | riY = xBlend( iYR, iYL, m_iBlendDistWeight ); |
---|
1460 | #if GERHARD_RM_COLOR_PLANES |
---|
1461 | riU = xBlend( iUR, iUL, m_iBlendDistWeight ); |
---|
1462 | riV = xBlend( iVR, iVL, m_iBlendDistWeight ); |
---|
1463 | #endif |
---|
1464 | } |
---|
1465 | } |
---|
1466 | else if ( iDepthDifference < 0 ) |
---|
1467 | { |
---|
1468 | riY = iYL; |
---|
1469 | #if GERHARD_RM_COLOR_PLANES |
---|
1470 | riU = iUL; |
---|
1471 | riV = iVL; |
---|
1472 | #endif |
---|
1473 | } |
---|
1474 | else |
---|
1475 | { |
---|
1476 | riY = iYR; |
---|
1477 | #if GERHARD_RM_COLOR_PLANES |
---|
1478 | riU = iUR; |
---|
1479 | riV = iVR; |
---|
1480 | #endif |
---|
1481 | } |
---|
1482 | } |
---|
1483 | else if ( (iFilledL == REN_IS_HOLE) && (iFilledR == REN_IS_HOLE)) |
---|
1484 | { |
---|
1485 | if ( iDepthR < iDepthL ) |
---|
1486 | { |
---|
1487 | riY = iYR; |
---|
1488 | #if GERHARD_RM_COLOR_PLANES |
---|
1489 | riU = iUR; |
---|
1490 | riV = iVR; |
---|
1491 | #endif |
---|
1492 | } |
---|
1493 | else |
---|
1494 | { |
---|
1495 | riY = iYL; |
---|
1496 | #if GERHARD_RM_COLOR_PLANES |
---|
1497 | riU = iUL; |
---|
1498 | riV = iVL; |
---|
1499 | #endif |
---|
1500 | } |
---|
1501 | } |
---|
1502 | else |
---|
1503 | { |
---|
1504 | if (iFilledR == REN_IS_HOLE) |
---|
1505 | { |
---|
1506 | riY = iYL; |
---|
1507 | #if GERHARD_RM_COLOR_PLANES |
---|
1508 | riU = iUL; |
---|
1509 | riV = iVL; |
---|
1510 | #endif |
---|
1511 | } |
---|
1512 | else |
---|
1513 | { |
---|
1514 | riY = iYR; |
---|
1515 | #if GERHARD_RM_COLOR_PLANES |
---|
1516 | riU = iUR; |
---|
1517 | riV = iVR; |
---|
1518 | #endif |
---|
1519 | } |
---|
1520 | } |
---|
1521 | |
---|
1522 | } |
---|
1523 | |
---|
1524 | __inline Void |
---|
1525 | TRenSingleModel::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV ) |
---|
1526 | { |
---|
1527 | if ( iFilledL == REN_IS_FILLED || iFilledR == REN_IS_HOLE ) |
---|
1528 | { |
---|
1529 | riY = iYL; |
---|
1530 | #if GERHARD_RM_COLOR_PLANES |
---|
1531 | riU = iUL; |
---|
1532 | riV = iVL; |
---|
1533 | #endif |
---|
1534 | } |
---|
1535 | else if ( iFilledL == REN_IS_HOLE ) |
---|
1536 | { |
---|
1537 | riY = iYR; |
---|
1538 | #if GERHARD_RM_COLOR_PLANES |
---|
1539 | riU = iUR; |
---|
1540 | riV = iVR; |
---|
1541 | #endif |
---|
1542 | } |
---|
1543 | else |
---|
1544 | { |
---|
1545 | riY = xBlend( iYR, iYL, iFilledL ); |
---|
1546 | #if GERHARD_RM_COLOR_PLANES |
---|
1547 | riU = xBlend( iUR, iUL, iFilledL ); |
---|
1548 | riV = xBlend( iVR, iUL, iFilledL ); |
---|
1549 | #endif |
---|
1550 | } |
---|
1551 | } |
---|
1552 | |
---|
1553 | __inline Void |
---|
1554 | TRenSingleModel::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iUL, Pel iUR, Pel iVL, Pel iVR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY, Pel& riU, Pel&riV ) |
---|
1555 | { |
---|
1556 | if ( iFilledR == REN_IS_FILLED || iFilledL == REN_IS_HOLE ) |
---|
1557 | { |
---|
1558 | riY = iYR; |
---|
1559 | #if GERHARD_RM_COLOR_PLANES |
---|
1560 | riU = iUR; |
---|
1561 | riV = iVR; |
---|
1562 | #endif |
---|
1563 | } |
---|
1564 | else if ( iFilledR == REN_IS_HOLE ) |
---|
1565 | { |
---|
1566 | riY = iYL; |
---|
1567 | #if GERHARD_RM_COLOR_PLANES |
---|
1568 | riU = iUL; |
---|
1569 | riV = iVL; |
---|
1570 | #endif |
---|
1571 | } |
---|
1572 | else |
---|
1573 | { |
---|
1574 | riY = xBlend( iYL, iYR, iFilledR ); |
---|
1575 | #if GERHARD_RM_COLOR_PLANES |
---|
1576 | riU = xBlend( iUL, iUR, iFilledR ); |
---|
1577 | riV = xBlend( iVL, iUR, iFilledR ); |
---|
1578 | #endif |
---|
1579 | } |
---|
1580 | } |
---|
1581 | |
---|
1582 | |
---|
1583 | |
---|
1584 | __inline Pel |
---|
1585 | TRenSingleModel::xBlend( Pel pVal1, Pel pVal2, Int iWeightVal2 ) |
---|
1586 | { |
---|
1587 | return pVal1 + (Pel) ( ( (Int) ( pVal2 - pVal1) * iWeightVal2 + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC ); |
---|
1588 | } |
---|
1589 | |
---|
1590 | #if GERHARD_RM_DEBUG_MM |
---|
1591 | Bool |
---|
1592 | TRenSingleModel::compare( TRenSingleModel* pcRefModel ) |
---|
1593 | { |
---|
1594 | Bool bNoDirectStop = true; |
---|
1595 | Bool bEqual = true; |
---|
1596 | |
---|
1597 | for (Int iBaseView = 0; iBaseView < 2; iBaseView++ ) |
---|
1598 | { |
---|
1599 | for (Int iPosY = 0; iPosY < m_iHeight; iPosY++ ) //GT: change to 1 !!! for small tests |
---|
1600 | { |
---|
1601 | for (Int iPosX = 0; iPosX < m_iWidth; iPosX++ ) |
---|
1602 | { |
---|
1603 | if (( iBaseView == m_iMode ) || ( m_iMode == 2 )) |
---|
1604 | { |
---|
1605 | // MEV_RF( "imswitch", &mxAW(m_iWidth, m_iHeight, m_aiBaseDepthStrides[iBaseView], m_apiBaseDepthPel [iBaseView] ), &mxAW(m_iWidth, m_iHeight, pcRefModel->m_aiBaseDepthStrides[iBaseView], pcRefModel->m_apiBaseDepthPel [iBaseView] ), &mxAW("u" ), 0); |
---|
1606 | bEqual = bEqual && ( m_apiBaseDepthPel [iBaseView] [iPosX+iPosY* m_aiBaseDepthStrides[iBaseView]] == pcRefModel->m_apiBaseDepthPel [iBaseView] [iPosX+iPosY* pcRefModel->m_aiBaseDepthStrides[iBaseView] ] );AOF( bNoDirectStop || bEqual ); |
---|
1607 | bEqual = bEqual && ( m_apiFilled [iBaseView] [iPosX+iPosY* m_iStride] == pcRefModel->m_apiFilled [iBaseView] [iPosX+iPosY* m_iStride] ); AOF( bNoDirectStop || bEqual ); |
---|
1608 | bEqual = bEqual && ( m_piError [iPosX+iPosY* m_iStride] == pcRefModel->m_piError [iPosX+iPosY* m_iStride] ); AOF( bNoDirectStop || bEqual ); |
---|
1609 | bEqual = bEqual && ( m_apbOccluded [iBaseView] [iPosX+iPosY* m_iStride] == pcRefModel->m_apbOccluded [iBaseView] [iPosX+iPosY* m_iStride] ); AOF( bNoDirectStop || bEqual ); |
---|
1610 | bEqual = bEqual && ( m_aapiSynthVideoPel[iBaseView][0][iPosX+iPosY* m_iStride] == pcRefModel->m_aapiSynthVideoPel[iBaseView][0][iPosX+iPosY* m_iStride] ); AOF( bNoDirectStop || bEqual ); |
---|
1611 | bEqual = bEqual && ( m_aapiSynthVideoPel[iBaseView][0][iPosX+iPosY* m_iStride] >= 0 ); AOF( bNoDirectStop || bEqual ); |
---|
1612 | bEqual = bEqual && ( m_aapiSynthVideoPel[iBaseView][0][iPosX+iPosY* m_iStride] <= g_uiIBDI_MAX ); AOF( bNoDirectStop || bEqual ); |
---|
1613 | if (m_iMode == 2 ) |
---|
1614 | { |
---|
1615 | bEqual = bEqual && ( m_apiSynthDepthPel [iBaseView] [iPosX+iPosY* m_iStride] == pcRefModel->m_apiSynthDepthPel [iBaseView] [iPosX+iPosY* m_iStride] ); AOF( bNoDirectStop || bEqual ); |
---|
1616 | } |
---|
1617 | //if (!bEqual) |
---|
1618 | //{ |
---|
1619 | // std::cout << "Mismatch in PosX: " << iPosX << " PosY: " << iPosY << std::endl; |
---|
1620 | // AOF(false); |
---|
1621 | // exit(55); |
---|
1622 | //} |
---|
1623 | } |
---|
1624 | } |
---|
1625 | } |
---|
1626 | } |
---|
1627 | return bEqual; |
---|
1628 | } |
---|
1629 | |
---|
1630 | #endif |
---|