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 | #include "TRenImage.h" |
---|
35 | #include "TRenFilter.h" |
---|
36 | #include "TRenSingleModel.h" |
---|
37 | |
---|
38 | #if NH_3D_VSO |
---|
39 | |
---|
40 | ////////////// TRENSINGLE MODEL /////////////// |
---|
41 | template <BlenMod iBM, Bool bBitInc> |
---|
42 | TRenSingleModelC<iBM,bBitInc>::TRenSingleModelC() |
---|
43 | : m_iDistShift ( ( ENC_INTERNAL_BIT_DEPTH - REN_BIT_DEPTH) << 1 ) |
---|
44 | { |
---|
45 | m_iWidth = -1; |
---|
46 | m_iHeight = -1; |
---|
47 | m_iStride = -1; |
---|
48 | m_iUsedHeight = -1; |
---|
49 | m_iHorOffset = -1; |
---|
50 | m_iMode = -1; |
---|
51 | m_iPad = PICYUV_PAD; |
---|
52 | m_iGapTolerance = -1; |
---|
53 | m_bUseOrgRef = false; |
---|
54 | |
---|
55 | m_pcPicYuvRef = NULL; |
---|
56 | |
---|
57 | m_pcOutputSamples = NULL; |
---|
58 | m_pcOutputSamplesRow = NULL; |
---|
59 | m_iOutputSamplesStride = -1; |
---|
60 | |
---|
61 | m_ppiCurLUT = NULL; |
---|
62 | m_piInvZLUTLeft = NULL; |
---|
63 | m_piInvZLUTRight = NULL; |
---|
64 | |
---|
65 | m_aapiRefVideoPel[0] = NULL; |
---|
66 | m_aapiRefVideoPel[1] = NULL; |
---|
67 | m_aapiRefVideoPel[2] = NULL; |
---|
68 | |
---|
69 | m_aiRefVideoStrides[0] = -1; |
---|
70 | m_aiRefVideoStrides[1] = -1; |
---|
71 | m_aiRefVideoStrides[2] = -1; |
---|
72 | |
---|
73 | |
---|
74 | for (UInt uiViewNum = 0 ; uiViewNum < 2; uiViewNum++) |
---|
75 | { |
---|
76 | // LUT |
---|
77 | m_appiShiftLut[uiViewNum] = NULL; |
---|
78 | |
---|
79 | m_pcInputSamples[uiViewNum] = NULL; |
---|
80 | m_iInputSamplesStride = -1; |
---|
81 | |
---|
82 | m_ppiCurLUT = NULL; |
---|
83 | m_piInvZLUTLeft = NULL; |
---|
84 | m_piInvZLUTRight = NULL; |
---|
85 | } |
---|
86 | |
---|
87 | #if H_3D_VSO_EARLY_SKIP |
---|
88 | m_pbHorSkip = NULL; |
---|
89 | #endif |
---|
90 | } |
---|
91 | |
---|
92 | template <BlenMod iBM, Bool bBitInc> |
---|
93 | TRenSingleModelC<iBM,bBitInc>::~TRenSingleModelC() |
---|
94 | { |
---|
95 | #if H_3D_VSO_EARLY_SKIP |
---|
96 | if ( m_pbHorSkip ) |
---|
97 | { |
---|
98 | delete[] m_pbHorSkip; |
---|
99 | m_pbHorSkip = NULL; |
---|
100 | } |
---|
101 | #endif |
---|
102 | |
---|
103 | if ( m_pcInputSamples [0] ) delete[] m_pcInputSamples [0]; |
---|
104 | if ( m_pcInputSamples [1] ) delete[] m_pcInputSamples [1]; |
---|
105 | |
---|
106 | if ( m_pcOutputSamples ) delete[] m_pcOutputSamples ; |
---|
107 | |
---|
108 | if ( m_piInvZLUTLeft ) delete[] m_piInvZLUTLeft ; |
---|
109 | if ( m_piInvZLUTRight ) delete[] m_piInvZLUTRight; |
---|
110 | |
---|
111 | if ( m_aapiRefVideoPel[0] ) delete[] ( m_aapiRefVideoPel[0] - ( m_aiRefVideoStrides[0] * m_iPad + m_iPad ) ); |
---|
112 | if ( m_aapiRefVideoPel[1] ) delete[] ( m_aapiRefVideoPel[1] - ( m_aiRefVideoStrides[1] * m_iPad + m_iPad ) ); |
---|
113 | if ( m_aapiRefVideoPel[2] ) delete[] ( m_aapiRefVideoPel[2] - ( m_aiRefVideoStrides[2] * m_iPad + m_iPad ) ); |
---|
114 | } |
---|
115 | |
---|
116 | template <BlenMod iBM, Bool bBitInc> Void |
---|
117 | #if H_3D_VSO_EARLY_SKIP |
---|
118 | TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bEarlySkip ) |
---|
119 | #else |
---|
120 | TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode ) |
---|
121 | #endif |
---|
122 | |
---|
123 | { |
---|
124 | #if H_3D_VSO_EARLY_SKIP |
---|
125 | m_pbHorSkip = new Bool [MAX_CU_SIZE]; |
---|
126 | m_bEarlySkip = bEarlySkip; |
---|
127 | #endif |
---|
128 | |
---|
129 | AOF( iBlendMode == iBM ); |
---|
130 | |
---|
131 | m_iMode = iMode; |
---|
132 | |
---|
133 | m_iWidth = iWidth; |
---|
134 | m_iHeight = iHeight; |
---|
135 | m_iStride = iWidth; |
---|
136 | |
---|
137 | m_iSampledWidth = m_iWidth << iShiftPrec; |
---|
138 | m_iSampledStride = m_iStride << iShiftPrec; |
---|
139 | |
---|
140 | m_iShiftPrec = iShiftPrec; |
---|
141 | m_aaiSubPelShiftL = aaaiSubPelShiftTable[0]; |
---|
142 | m_aaiSubPelShiftR = aaaiSubPelShiftTable[1]; |
---|
143 | |
---|
144 | if (m_iMode == 2) |
---|
145 | { |
---|
146 | m_piInvZLUTLeft = new Int[257]; |
---|
147 | m_piInvZLUTRight = new Int[257]; |
---|
148 | } |
---|
149 | |
---|
150 | m_iGapTolerance = ( 2 << iShiftPrec ); |
---|
151 | m_iHoleMargin = iHoleMargin; |
---|
152 | |
---|
153 | m_bUseOrgRef = bUseOrgRef; |
---|
154 | |
---|
155 | m_aiRefVideoStrides[0] = m_iStride + (m_iPad << 1); |
---|
156 | m_aiRefVideoStrides[1] = m_iStride + (m_iPad << 1); |
---|
157 | m_aiRefVideoStrides[2] = m_iStride + (m_iPad << 1); |
---|
158 | |
---|
159 | m_aapiRefVideoPel [0] = new Pel[ m_aiRefVideoStrides[0] * (m_iHeight + (m_iPad << 1))]; |
---|
160 | m_aapiRefVideoPel [1] = new Pel[ m_aiRefVideoStrides[1] * (m_iHeight + (m_iPad << 1))]; |
---|
161 | m_aapiRefVideoPel [2] = new Pel[ m_aiRefVideoStrides[2] * (m_iHeight + (m_iPad << 1))]; |
---|
162 | |
---|
163 | m_aapiRefVideoPel [0] += m_aiRefVideoStrides[0] * m_iPad + m_iPad; |
---|
164 | m_aapiRefVideoPel [1] += m_aiRefVideoStrides[1] * m_iPad + m_iPad; |
---|
165 | m_aapiRefVideoPel [2] += m_aiRefVideoStrides[2] * m_iPad + m_iPad; |
---|
166 | |
---|
167 | m_iInputSamplesStride = m_iWidth+1; |
---|
168 | m_iOutputSamplesStride = m_iWidth; |
---|
169 | |
---|
170 | m_pcInputSamples[0] = new RenModelInPels[m_iInputSamplesStride*m_iHeight]; |
---|
171 | m_pcInputSamples[1] = new RenModelInPels[m_iInputSamplesStride*m_iHeight]; |
---|
172 | |
---|
173 | m_pcOutputSamples = new RenModelOutPels[m_iOutputSamplesStride*m_iHeight]; |
---|
174 | } |
---|
175 | |
---|
176 | template <BlenMod iBM, Bool bBitInc> Void |
---|
177 | TRenSingleModelC<iBM,bBitInc>::setLRView( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride ) |
---|
178 | { |
---|
179 | AOF(( iViewPos == 0) || (iViewPos == 1) ); |
---|
180 | |
---|
181 | RenModelInPels* pcCurInputSampleRow = m_pcInputSamples[iViewPos]; |
---|
182 | |
---|
183 | Pel* piDRow = piCurDepthPel; |
---|
184 | Pel* piYRow = apiCurVideoPel[0]; |
---|
185 | #if H_3D_VSO_COLOR_PLANES |
---|
186 | Pel* piURow = apiCurVideoPel[1]; |
---|
187 | Pel* piVRow = apiCurVideoPel[2]; |
---|
188 | #endif |
---|
189 | |
---|
190 | |
---|
191 | Int iOffsetX = ( iViewPos == VIEWPOS_RIGHT ) ? 1 : 0; |
---|
192 | |
---|
193 | for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ ) |
---|
194 | { |
---|
195 | if ( iViewPos == VIEWPOS_RIGHT ) |
---|
196 | { |
---|
197 | Int iSubPosX = (1 << m_iShiftPrec); |
---|
198 | pcCurInputSampleRow[0].aiY[iSubPosX] = piYRow[0]; |
---|
199 | #if H_3D_VSO_COLOR_PLANES |
---|
200 | pcCurInputSampleRow[0].aiU[iSubPosX] = piURow[0]; |
---|
201 | pcCurInputSampleRow[0].aiV[iSubPosX] = piVRow[0]; |
---|
202 | #endif |
---|
203 | } |
---|
204 | |
---|
205 | for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ ) |
---|
206 | { |
---|
207 | pcCurInputSampleRow[iPosX].iD = piDRow[iPosX]; |
---|
208 | |
---|
209 | for (Int iSubPosX = 0; iSubPosX < (1 << m_iShiftPrec)+1; iSubPosX++ ) |
---|
210 | { |
---|
211 | Int iShift = (iPosX << m_iShiftPrec) + iSubPosX; |
---|
212 | pcCurInputSampleRow[iPosX+iOffsetX].aiY[iSubPosX] = piYRow[iShift]; |
---|
213 | #if H_3D_VSO_COLOR_PLANES |
---|
214 | pcCurInputSampleRow[iPosX+iOffsetX].aiU[iSubPosX] = piURow[iShift]; |
---|
215 | pcCurInputSampleRow[iPosX+iOffsetX].aiV[iSubPosX] = piVRow[iShift]; |
---|
216 | #endif |
---|
217 | } |
---|
218 | } |
---|
219 | |
---|
220 | pcCurInputSampleRow += m_iInputSamplesStride; |
---|
221 | |
---|
222 | piDRow += iCurDepthStride; |
---|
223 | piYRow += aiCurVideoStride[0]; |
---|
224 | #if H_3D_VSO_COLOR_PLANES |
---|
225 | piURow += aiCurVideoStride[1]; |
---|
226 | piVRow += aiCurVideoStride[2]; |
---|
227 | #endif |
---|
228 | } |
---|
229 | |
---|
230 | |
---|
231 | m_aapiBaseVideoPel [iViewPos] = apiCurVideoPel; |
---|
232 | m_aaiBaseVideoStrides [iViewPos] = aiCurVideoStride; |
---|
233 | m_apiBaseDepthPel [iViewPos] = piCurDepthPel; |
---|
234 | m_aiBaseDepthStrides [iViewPos] = iCurDepthStride; |
---|
235 | |
---|
236 | } |
---|
237 | template <BlenMod iBM, Bool bBitInc> Void |
---|
238 | TRenSingleModelC<iBM,bBitInc>::setupPart ( UInt uiHorOffset, Int iUsedHeight ) |
---|
239 | { |
---|
240 | AOT( iUsedHeight > m_iHeight ); |
---|
241 | |
---|
242 | m_iUsedHeight = iUsedHeight; |
---|
243 | m_iHorOffset = (Int) uiHorOffset; |
---|
244 | } |
---|
245 | |
---|
246 | template <BlenMod iBM, Bool bBitInc> Void |
---|
247 | TRenSingleModelC<iBM,bBitInc>::setup( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, Bool bKeepReference ) |
---|
248 | { |
---|
249 | AOT( !m_bUseOrgRef && pcOrgVideo ); |
---|
250 | AOT( (ppiShiftLutLeft == NULL) && (m_iMode == 0 || m_iMode == 2) ); |
---|
251 | AOT( (ppiShiftLutRight == NULL) && (m_iMode == 1 || m_iMode == 2) ); |
---|
252 | |
---|
253 | m_appiShiftLut[0] = ppiShiftLutLeft; |
---|
254 | m_appiShiftLut[1] = ppiShiftLutRight; |
---|
255 | |
---|
256 | // Copy Reference |
---|
257 | m_pcPicYuvRef = pcOrgVideo; |
---|
258 | |
---|
259 | if ( pcOrgVideo && !bKeepReference ) |
---|
260 | { |
---|
261 | assert( pcOrgVideo->getChromaFormat() != CHROMA_420 ); |
---|
262 | |
---|
263 | TRenFilter<REN_BIT_DEPTH>::copy( pcOrgVideo->getAddr( COMPONENT_Y ) + m_iHorOffset * pcOrgVideo->getStride( COMPONENT_Y ), pcOrgVideo->getStride( COMPONENT_Y ), m_iWidth, m_iUsedHeight, m_aapiRefVideoPel[0], m_aiRefVideoStrides[0]); |
---|
264 | TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp(0, pcOrgVideo->getAddr( COMPONENT_Cb ) + (m_iHorOffset >> 1) * pcOrgVideo->getStride( COMPONENT_Cb ), pcOrgVideo->getStride( COMPONENT_Cb ), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]); |
---|
265 | TRenFilter<REN_BIT_DEPTH>::sampleCUpHorUp(0, pcOrgVideo->getAddr( COMPONENT_Cr ) + (m_iHorOffset >> 1) * pcOrgVideo->getStride( COMPONENT_Cr ), pcOrgVideo->getStride( COMPONENT_Cr ), m_iWidth >> 1, m_iUsedHeight >> 1, m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]); |
---|
266 | xSetStructRefView(); |
---|
267 | } |
---|
268 | |
---|
269 | // Initial Rendering |
---|
270 | xResetStructError(); |
---|
271 | xInitSampleStructs(); |
---|
272 | switch ( m_iMode ) |
---|
273 | { |
---|
274 | case 0: |
---|
275 | #if H_3D_VSO_EARLY_SKIP |
---|
276 | xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false ); |
---|
277 | #else |
---|
278 | xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] ); |
---|
279 | #endif |
---|
280 | break; |
---|
281 | case 1: |
---|
282 | #if H_3D_VSO_EARLY_SKIP |
---|
283 | xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false); |
---|
284 | #else |
---|
285 | xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] ); |
---|
286 | #endif |
---|
287 | break; |
---|
288 | case 2: |
---|
289 | TRenFilter<REN_BIT_DEPTH>::setupZLUT( true, 30, iDistToLeft, ppiBaseShiftLutLeft, ppiBaseShiftLutRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight ); |
---|
290 | #if H_3D_VSO_EARLY_SKIP |
---|
291 | xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false); |
---|
292 | xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false); |
---|
293 | #else |
---|
294 | xRenderL<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] ); |
---|
295 | xRenderR<true>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] ); |
---|
296 | #endif |
---|
297 | break; |
---|
298 | default: |
---|
299 | AOT(true); |
---|
300 | } |
---|
301 | |
---|
302 | // Get Rendered View as Reference |
---|
303 | if ( !pcOrgVideo && !bKeepReference ) |
---|
304 | { |
---|
305 | xResetStructError(); |
---|
306 | xSetStructSynthViewAsRefView(); |
---|
307 | } |
---|
308 | } |
---|
309 | |
---|
310 | template <BlenMod iBM, Bool bBitInc> Void |
---|
311 | #if H_3D_VSO_COLOR_PLANES |
---|
312 | TRenSingleModelC<iBM,bBitInc>::xGetSampleStrTextPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY, Pel RenModelOutPels::*& rpiSrcU, Pel RenModelOutPels::*& rpiSrcV ) |
---|
313 | #else |
---|
314 | TRenSingleModelC<iBM,bBitInc>::xGetSampleStrTextPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY ) |
---|
315 | #endif |
---|
316 | { |
---|
317 | switch ( iViewNum ) |
---|
318 | { |
---|
319 | case 0: |
---|
320 | rpiSrcY = &RenModelOutPels::iYLeft; |
---|
321 | #if H_3D_VSO_COLOR_PLANES |
---|
322 | rpiSrcU = &RenModelOutPels::iULeft; |
---|
323 | rpiSrcV = &RenModelOutPels::iVLeft; |
---|
324 | #endif |
---|
325 | break; |
---|
326 | case 1: |
---|
327 | rpiSrcY = &RenModelOutPels::iYRight; |
---|
328 | #if H_3D_VSO_COLOR_PLANES |
---|
329 | rpiSrcU = &RenModelOutPels::iURight; |
---|
330 | rpiSrcV = &RenModelOutPels::iVRight; |
---|
331 | #endif |
---|
332 | break; |
---|
333 | case 2: |
---|
334 | rpiSrcY = &RenModelOutPels::iYBlended; |
---|
335 | #if H_3D_VSO_COLOR_PLANES |
---|
336 | rpiSrcU = &RenModelOutPels::iUBlended; |
---|
337 | rpiSrcV = &RenModelOutPels::iVBlended; |
---|
338 | #endif |
---|
339 | break; |
---|
340 | } |
---|
341 | } |
---|
342 | |
---|
343 | |
---|
344 | template <BlenMod iBM, Bool bBitInc> Void |
---|
345 | TRenSingleModelC<iBM,bBitInc>::xGetSampleStrDepthPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcD ) |
---|
346 | { |
---|
347 | AOT(iViewNum != 0 && iViewNum != 1); |
---|
348 | rpiSrcD = (iViewNum == 1) ? &RenModelOutPels::iDRight : &RenModelOutPels::iDLeft; |
---|
349 | } |
---|
350 | |
---|
351 | |
---|
352 | template <BlenMod iBM, Bool bBitInc> Void |
---|
353 | TRenSingleModelC<iBM,bBitInc>::xSetStructRefView( ) |
---|
354 | { |
---|
355 | RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples; |
---|
356 | |
---|
357 | Pel* piYRow = m_aapiRefVideoPel[0]; |
---|
358 | #if H_3D_VSO_COLOR_PLANES |
---|
359 | Pel* piURow = m_aapiRefVideoPel[1]; |
---|
360 | Pel* piVRow = m_aapiRefVideoPel[2]; |
---|
361 | #endif |
---|
362 | |
---|
363 | for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ ) |
---|
364 | { |
---|
365 | for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ ) |
---|
366 | { |
---|
367 | pcCurOutSampleRow[iPosX].iYRef = piYRow[iPosX]; |
---|
368 | #if H_3D_VSO_COLOR_PLANES |
---|
369 | pcCurOutSampleRow[iPosX].iURef = piURow[iPosX]; |
---|
370 | pcCurOutSampleRow[iPosX].iVRef = piVRow[iPosX]; |
---|
371 | #endif |
---|
372 | } |
---|
373 | |
---|
374 | pcCurOutSampleRow += m_iOutputSamplesStride; |
---|
375 | |
---|
376 | piYRow += m_aiRefVideoStrides[0]; |
---|
377 | #if H_3D_VSO_COLOR_PLANES |
---|
378 | piURow += m_aiRefVideoStrides[1]; |
---|
379 | piVRow += m_aiRefVideoStrides[2]; |
---|
380 | #endif |
---|
381 | } |
---|
382 | } |
---|
383 | |
---|
384 | template <BlenMod iBM, Bool bBitInc> Void |
---|
385 | TRenSingleModelC<iBM,bBitInc>::xResetStructError( ) |
---|
386 | { |
---|
387 | RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples; |
---|
388 | |
---|
389 | for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ ) |
---|
390 | { |
---|
391 | for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ ) |
---|
392 | { |
---|
393 | pcCurOutSampleRow[iPosX].iError = 0; |
---|
394 | } |
---|
395 | pcCurOutSampleRow += m_iOutputSamplesStride; |
---|
396 | } |
---|
397 | } |
---|
398 | |
---|
399 | template <BlenMod iBM, Bool bBitInc> Void |
---|
400 | TRenSingleModelC<iBM,bBitInc>::xSetStructSynthViewAsRefView( ) |
---|
401 | { |
---|
402 | AOT( m_iMode < 0 || m_iMode > 2); |
---|
403 | |
---|
404 | RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples; |
---|
405 | |
---|
406 | Pel RenModelOutPels::* piSrcY = NULL; |
---|
407 | |
---|
408 | #if H_3D_VSO_COLOR_PLANES |
---|
409 | Pel RenModelOutPels::* piSrcU = NULL; |
---|
410 | Pel RenModelOutPels::* piSrcV = NULL; |
---|
411 | xGetSampleStrTextPtrs( m_iMode, piSrcY, piSrcU, piSrcV ); |
---|
412 | #else |
---|
413 | xGetSampleStrTextPtrs( m_iMode, piSrcY ); |
---|
414 | #endif |
---|
415 | |
---|
416 | for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ ) |
---|
417 | { |
---|
418 | for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ ) |
---|
419 | { |
---|
420 | pcCurOutSampleRow[iPosX].iYRef = pcCurOutSampleRow[iPosX].*piSrcY; |
---|
421 | #if H_3D_VSO_COLOR_PLANES |
---|
422 | pcCurOutSampleRow[iPosX].iURef = pcCurOutSampleRow[iPosX].*piSrcU; |
---|
423 | pcCurOutSampleRow[iPosX].iVRef = pcCurOutSampleRow[iPosX].*piSrcV; |
---|
424 | #endif |
---|
425 | } |
---|
426 | pcCurOutSampleRow += m_iOutputSamplesStride; |
---|
427 | } |
---|
428 | } |
---|
429 | |
---|
430 | template <BlenMod iBM, Bool bBitInc> Void |
---|
431 | TRenSingleModelC<iBM,bBitInc>::xInitSampleStructs() |
---|
432 | { |
---|
433 | RenModelOutPels* pcOutSampleRow = m_pcOutputSamples; |
---|
434 | RenModelInPels * pcLeftInSampleRow = m_pcInputSamples[0]; |
---|
435 | RenModelInPels * pcRightInSampleRow = m_pcInputSamples[1]; |
---|
436 | |
---|
437 | |
---|
438 | for (Int iPosY = 0; iPosY < m_iHeight; iPosY++) |
---|
439 | { |
---|
440 | for (Int iPosX = 0; iPosX < m_iWidth; iPosX++) |
---|
441 | { |
---|
442 | //// Output Samples |
---|
443 | pcOutSampleRow[iPosX].iFilledLeft = REN_IS_HOLE; |
---|
444 | pcOutSampleRow[iPosX].iFilledRight = REN_IS_HOLE; |
---|
445 | |
---|
446 | pcOutSampleRow[iPosX].iDLeft = 0; |
---|
447 | pcOutSampleRow[iPosX].iDRight = 0; |
---|
448 | pcOutSampleRow[iPosX].iDBlended = 0; |
---|
449 | |
---|
450 | // Y Planes |
---|
451 | pcOutSampleRow[iPosX].iYLeft = 0; |
---|
452 | pcOutSampleRow[iPosX].iYRight = 0; |
---|
453 | pcOutSampleRow[iPosX].iYBlended = 0; |
---|
454 | #if H_3D_VSO_COLOR_PLANES |
---|
455 | // U Planes |
---|
456 | pcOutSampleRow[iPosX].iULeft = 1 << (REN_BIT_DEPTH - 1); |
---|
457 | pcOutSampleRow[iPosX].iURight = 1 << (REN_BIT_DEPTH - 1); |
---|
458 | pcOutSampleRow[iPosX].iUBlended = 1 << (REN_BIT_DEPTH - 1); |
---|
459 | |
---|
460 | // V Planes |
---|
461 | pcOutSampleRow[iPosX].iVLeft = 1 << (REN_BIT_DEPTH - 1); |
---|
462 | pcOutSampleRow[iPosX].iVRight = 1 << (REN_BIT_DEPTH - 1); |
---|
463 | pcOutSampleRow[iPosX].iVBlended = 1 << (REN_BIT_DEPTH - 1); |
---|
464 | #endif |
---|
465 | //// Input Samples |
---|
466 | pcLeftInSampleRow [iPosX].bOccluded = false; |
---|
467 | pcRightInSampleRow[iPosX].bOccluded = false; |
---|
468 | } |
---|
469 | |
---|
470 | pcOutSampleRow += m_iOutputSamplesStride; |
---|
471 | pcLeftInSampleRow += m_iInputSamplesStride; |
---|
472 | pcRightInSampleRow += m_iInputSamplesStride; |
---|
473 | } |
---|
474 | } |
---|
475 | |
---|
476 | |
---|
477 | #if H_3D_VSO_EARLY_SKIP |
---|
478 | template <BlenMod iBM, Bool bBitInc> RMDist |
---|
479 | TRenSingleModelC<iBM,bBitInc>::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData , const Pel * piOrgData, Int iOrgStride ) |
---|
480 | #else |
---|
481 | template <BlenMod iBM, Bool bBitInc> RMDist |
---|
482 | TRenSingleModelC<iBM,bBitInc>::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData ) |
---|
483 | #endif |
---|
484 | { |
---|
485 | RMDist iSSE = 0; |
---|
486 | #if H_3D_VSO_EARLY_SKIP |
---|
487 | Bool bEarlySkip; |
---|
488 | #endif |
---|
489 | switch ( iViewPos ) |
---|
490 | { |
---|
491 | case 0: |
---|
492 | #if H_3D_VSO_EARLY_SKIP |
---|
493 | bEarlySkip = m_bEarlySkip ? xDetectEarlySkipL(iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, piOrgData, iOrgStride) : false; |
---|
494 | if( !bEarlySkip ) |
---|
495 | { |
---|
496 | iSSE = xRenderL<false>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,true ); |
---|
497 | } |
---|
498 | #else |
---|
499 | iSSE = xRenderL<false>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData ); |
---|
500 | #endif |
---|
501 | break; |
---|
502 | case 1: |
---|
503 | #if H_3D_VSO_EARLY_SKIP |
---|
504 | bEarlySkip = m_bEarlySkip ? xDetectEarlySkipR(iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, piOrgData, iOrgStride) : false; |
---|
505 | if( !bEarlySkip ) |
---|
506 | { |
---|
507 | iSSE = xRenderR<false>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,true ); |
---|
508 | } |
---|
509 | #else |
---|
510 | iSSE = xRenderR<false>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData ); |
---|
511 | #endif |
---|
512 | break; |
---|
513 | default: |
---|
514 | assert(0); |
---|
515 | } |
---|
516 | |
---|
517 | return iSSE; |
---|
518 | } |
---|
519 | #if H_3D_VSO_EARLY_SKIP |
---|
520 | template <BlenMod iBM, Bool bBitInc> Void |
---|
521 | TRenSingleModelC<iBM,bBitInc>::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride ) |
---|
522 | #else |
---|
523 | template <BlenMod iBM, Bool bBitInc> Void |
---|
524 | TRenSingleModelC<iBM,bBitInc>::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData ) |
---|
525 | #endif |
---|
526 | { |
---|
527 | #ifdef H_3D_VSO_EARLY_SKIP |
---|
528 | Bool bEarlySkip; |
---|
529 | #endif |
---|
530 | switch ( iViewPos ) |
---|
531 | { |
---|
532 | case 0: |
---|
533 | #if H_3D_VSO_EARLY_SKIP |
---|
534 | bEarlySkip = m_bEarlySkip ? xDetectEarlySkipL(iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, piOrgData,iOrgStride) : false; |
---|
535 | if( !bEarlySkip ) |
---|
536 | { |
---|
537 | xRenderL<true>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,true ); |
---|
538 | } |
---|
539 | #else |
---|
540 | xRenderL<true>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData ); |
---|
541 | #endif |
---|
542 | break; |
---|
543 | case 1: |
---|
544 | #if H_3D_VSO_EARLY_SKIP |
---|
545 | bEarlySkip = m_bEarlySkip ? xDetectEarlySkipR(iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData, piOrgData,iOrgStride) : false; |
---|
546 | if( !bEarlySkip ) |
---|
547 | { |
---|
548 | xRenderR<true>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData,true ); |
---|
549 | } |
---|
550 | #else |
---|
551 | xRenderR<true>( iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData ); |
---|
552 | #endif |
---|
553 | break; |
---|
554 | default: |
---|
555 | assert(0); |
---|
556 | } |
---|
557 | } |
---|
558 | |
---|
559 | template <BlenMod iBM, Bool bBitInc> Void |
---|
560 | TRenSingleModelC<iBM,bBitInc>::getSynthVideo( Int iViewPos, TComPicYuv* pcPicYuv ) |
---|
561 | { |
---|
562 | AOT( pcPicYuv->getWidth( COMPONENT_Y ) != m_iWidth ); |
---|
563 | AOT( pcPicYuv->getChromaFormat() != CHROMA_420 ); |
---|
564 | |
---|
565 | AOT( pcPicYuv->getHeight( COMPONENT_Y ) < m_iUsedHeight + m_iHorOffset ); |
---|
566 | |
---|
567 | #if H_3D_VSO_COLOR_PLANES |
---|
568 | Pel RenModelOutPels::* piText[3] = { NULL, NULL, NULL }; |
---|
569 | xGetSampleStrTextPtrs(iViewPos, piText[0], piText[1], piText[2]); |
---|
570 | |
---|
571 | // Temp image for chroma down sampling |
---|
572 | PelImage cTempImage( m_iWidth, m_iUsedHeight, 3, 0); |
---|
573 | |
---|
574 | Int aiStrides[3]; |
---|
575 | Pel* apiData [3]; |
---|
576 | |
---|
577 | cTempImage.getDataAndStrides( apiData, aiStrides ); |
---|
578 | |
---|
579 | for (UInt uiCurPlane = 0; uiCurPlane < 3; uiCurPlane++ ) |
---|
580 | { |
---|
581 | xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iUsedHeight); |
---|
582 | } |
---|
583 | xCopy2PicYuv( apiData, aiStrides, pcPicYuv ); |
---|
584 | #else |
---|
585 | Pel RenModelOutPels::* piY; |
---|
586 | xGetSampleStrTextPtrs(iViewPos, piY); |
---|
587 | xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piY, pcPicYuv->getLumaAddr() + m_iHorOffset * pcPicYuv->getStride(), pcPicYuv->getStride(), m_iWidth, m_iUsedHeight ); |
---|
588 | pcPicYuv->setChromaTo( 1 << (g_bitDepthC - 1) ); |
---|
589 | #endif |
---|
590 | } |
---|
591 | |
---|
592 | template <BlenMod iBM, Bool bBitInc> Void |
---|
593 | TRenSingleModelC<iBM,bBitInc>::getSynthDepth( Int iViewPos, TComPicYuv* pcPicYuv ) |
---|
594 | { |
---|
595 | AOT( iViewPos != 0 && iViewPos != 1); |
---|
596 | AOT( pcPicYuv->getWidth( COMPONENT_Y) != m_iWidth ); |
---|
597 | AOT( pcPicYuv->getChromaFormat( ) != CHROMA_420 ); |
---|
598 | AOT( pcPicYuv->getHeight( COMPONENT_Y ) < m_iUsedHeight + m_iHorOffset ); |
---|
599 | |
---|
600 | Pel RenModelOutPels::* piD = 0; |
---|
601 | xGetSampleStrDepthPtrs(iViewPos, piD); |
---|
602 | xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piD, pcPicYuv->getAddr( COMPONENT_Y ) + pcPicYuv->getStride( COMPONENT_Y ) * m_iHorOffset, pcPicYuv->getStride( COMPONENT_Y ), m_iWidth, m_iUsedHeight ); |
---|
603 | pcPicYuv->setChromaTo( 1 << (REN_BIT_DEPTH - 1) ); |
---|
604 | } |
---|
605 | |
---|
606 | |
---|
607 | template <BlenMod iBM, Bool bBitInc> Void |
---|
608 | TRenSingleModelC<iBM,bBitInc>::getRefVideo ( Int iViewPos, TComPicYuv* pcPicYuv ) |
---|
609 | { |
---|
610 | AOT( pcPicYuv->getChromaFormat( ) != CHROMA_420 ); |
---|
611 | AOT( pcPicYuv->getWidth( COMPONENT_Y ) != m_iWidth ); |
---|
612 | AOT( pcPicYuv->getHeight( COMPONENT_Y ) < m_iUsedHeight + m_iHorOffset); |
---|
613 | |
---|
614 | #if H_3D_VSO_COLOR_PLANES |
---|
615 | Pel RenModelOutPels::* piText[3]; |
---|
616 | piText[0] = &RenModelOutPels::iYRef; |
---|
617 | piText[1] = &RenModelOutPels::iURef; |
---|
618 | piText[2] = &RenModelOutPels::iVRef; |
---|
619 | |
---|
620 | // Temp image for chroma down sampling |
---|
621 | |
---|
622 | PelImage cTempImage( m_iWidth, m_iUsedHeight, 3, 0); |
---|
623 | Int aiStrides[3]; |
---|
624 | Pel* apiData [3]; |
---|
625 | |
---|
626 | cTempImage.getDataAndStrides( apiData, aiStrides ); |
---|
627 | |
---|
628 | for (UInt uiCurPlane = 0; uiCurPlane < 3; uiCurPlane++ ) |
---|
629 | { |
---|
630 | xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iUsedHeight); |
---|
631 | } |
---|
632 | |
---|
633 | xCopy2PicYuv( apiData, aiStrides, pcPicYuv ); |
---|
634 | #else |
---|
635 | xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, &RenModelOutPels::iYRef, pcPicYuv->getLumaAddr() * pcPicYuv->getStride() + m_iHorOffset, pcPicYuv->getStride(), m_iWidth, m_iUsedHeight ); |
---|
636 | pcPicYuv->setChromaTo( 1 << ( g_bitDepthC - 1 ) ); |
---|
637 | #endif |
---|
638 | } |
---|
639 | |
---|
640 | template <BlenMod iBM, Bool bBitInc> RMDist |
---|
641 | TRenSingleModelC<iBM,bBitInc>::getDistVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData ) |
---|
642 | { |
---|
643 | AOF(false); |
---|
644 | return 0; |
---|
645 | } |
---|
646 | |
---|
647 | template <BlenMod iBM, Bool bBitInc> Void |
---|
648 | TRenSingleModelC<iBM,bBitInc>::setVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData ) |
---|
649 | { |
---|
650 | AOF(false); |
---|
651 | } |
---|
652 | |
---|
653 | |
---|
654 | |
---|
655 | template <BlenMod iBM, Bool bBitInc> __inline Void |
---|
656 | TRenSingleModelC<iBM,bBitInc>::xSetViewRow( Int iPosY ) |
---|
657 | { |
---|
658 | m_pcInputSamplesRow[0] = m_pcInputSamples[0] + m_iInputSamplesStride * iPosY; |
---|
659 | m_pcInputSamplesRow[1] = m_pcInputSamples[1] + m_iInputSamplesStride * iPosY; |
---|
660 | m_pcOutputSamplesRow = m_pcOutputSamples + m_iOutputSamplesStride * iPosY; |
---|
661 | |
---|
662 | } |
---|
663 | |
---|
664 | template <BlenMod iBM, Bool bBitInc> __inline Void |
---|
665 | TRenSingleModelC<iBM,bBitInc>::xIncViewRow( ) |
---|
666 | { |
---|
667 | m_pcInputSamplesRow[0] += m_iInputSamplesStride ; |
---|
668 | m_pcInputSamplesRow[1] += m_iInputSamplesStride ; |
---|
669 | m_pcOutputSamplesRow += m_iOutputSamplesStride; |
---|
670 | } |
---|
671 | #if H_3D_VSO_EARLY_SKIP |
---|
672 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist |
---|
673 | TRenSingleModelC<iBM,bBitInc>::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast) |
---|
674 | #else |
---|
675 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist |
---|
676 | TRenSingleModelC<iBM,bBitInc>::xRenderL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData) |
---|
677 | #endif |
---|
678 | { |
---|
679 | const Int iCurViewPos = 0; |
---|
680 | const Int iOtherViewPos = 1; |
---|
681 | |
---|
682 | m_iCurViewPos = iCurViewPos ; |
---|
683 | m_iOtherViewPos = iOtherViewPos; |
---|
684 | |
---|
685 | m_piNewDepthData = piNewData; |
---|
686 | m_iNewDataWidth = iWidth; |
---|
687 | m_iStartChangePosX = iStartPosX; |
---|
688 | |
---|
689 | if ((iWidth == 0) || (iHeight == 0)) |
---|
690 | return 0; |
---|
691 | |
---|
692 | // Get Data |
---|
693 | m_ppiCurLUT = m_appiShiftLut [iCurViewPos]; |
---|
694 | xSetViewRow ( iStartPosY); |
---|
695 | |
---|
696 | // Init Start |
---|
697 | RMDist iError = 0; |
---|
698 | Int iStartChangePos; |
---|
699 | |
---|
700 | iStartChangePos = m_iStartChangePosX; |
---|
701 | |
---|
702 | for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ ) |
---|
703 | { |
---|
704 | #if H_3D_VSO_EARLY_SKIP |
---|
705 | if( m_bEarlySkip && bFast ) |
---|
706 | { |
---|
707 | if ( m_pbHorSkip[iPosY-iStartPosY] ) |
---|
708 | { |
---|
709 | xIncViewRow(); |
---|
710 | m_piNewDepthData += iStride; |
---|
711 | continue; |
---|
712 | } |
---|
713 | } |
---|
714 | #endif |
---|
715 | m_bInOcclusion = false; |
---|
716 | |
---|
717 | Int iLastSPos; |
---|
718 | Int iEndChangePos = m_iStartChangePosX + iWidth - 1; |
---|
719 | Int iPosXinNewData = iWidth - 1; |
---|
720 | Int iMinChangedSPos = m_iSampledWidth; |
---|
721 | |
---|
722 | if ( iEndChangePos == ( m_iWidth -1 )) // Special processing for rightmost depth sample |
---|
723 | { |
---|
724 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
---|
725 | Int iCurSPos = xShiftNewData(iEndChangePos, iPosXinNewData); |
---|
726 | m_iLastOccludedSPos = iCurSPos + 1; |
---|
727 | m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos ); |
---|
728 | xExtrapolateMarginL<bSet> ( iCurSPos, iEndChangePos, iError ); |
---|
729 | |
---|
730 | iMinChangedSPos = std::min( iMinChangedSPos, (iEndChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD, m_piNewDepthData[iPosXinNewData] )) ]); |
---|
731 | iLastSPos = iCurSPos; |
---|
732 | m_iLastDepth = m_iCurDepth; |
---|
733 | |
---|
734 | if ( bSet ) |
---|
735 | { |
---|
736 | m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD = m_piNewDepthData[iPosXinNewData]; |
---|
737 | } |
---|
738 | |
---|
739 | iPosXinNewData--; |
---|
740 | iEndChangePos--; |
---|
741 | } |
---|
742 | else |
---|
743 | { |
---|
744 | iLastSPos = xShift(iEndChangePos+1); |
---|
745 | m_iLastDepth = m_pcInputSamplesRow [iCurViewPos][iEndChangePos+1].iD; |
---|
746 | xInitRenderPartL( iEndChangePos, iLastSPos ); |
---|
747 | } |
---|
748 | |
---|
749 | //// RENDER NEW DATA |
---|
750 | Int iCurPosX; |
---|
751 | for ( iCurPosX = iEndChangePos; iCurPosX >= iStartChangePos; iCurPosX-- ) |
---|
752 | { |
---|
753 | // Get minimal changed sample position |
---|
754 | |
---|
755 | iMinChangedSPos = std::min( iMinChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD, m_piNewDepthData[iPosXinNewData] )) ]); |
---|
756 | Int iCurSPos = xShiftNewData(iCurPosX,iPosXinNewData); |
---|
757 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
---|
758 | xRenderRangeL<bSet>(iCurSPos, iLastSPos, iCurPosX, iError ); |
---|
759 | iLastSPos = iCurSPos; |
---|
760 | m_iLastDepth = m_iCurDepth; |
---|
761 | |
---|
762 | if ( bSet ) |
---|
763 | { |
---|
764 | m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData]; |
---|
765 | } |
---|
766 | |
---|
767 | iPosXinNewData--; |
---|
768 | } |
---|
769 | |
---|
770 | //// RE-RENDER DATA LEFT TO NEW DATA |
---|
771 | while ( iCurPosX >= 0 ) |
---|
772 | { |
---|
773 | Int iCurSPos = xShift(iCurPosX); |
---|
774 | |
---|
775 | m_iCurDepth = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD; |
---|
776 | xRenderRangeL<bSet>( iCurSPos, iLastSPos, iCurPosX, iError ); |
---|
777 | |
---|
778 | if ( iCurSPos < iMinChangedSPos ) |
---|
779 | { |
---|
780 | break; |
---|
781 | } |
---|
782 | |
---|
783 | iCurPosX--; |
---|
784 | iLastSPos = iCurSPos; |
---|
785 | m_iLastDepth = m_iCurDepth; |
---|
786 | } |
---|
787 | |
---|
788 | |
---|
789 | xIncViewRow(); |
---|
790 | m_piNewDepthData += iStride; |
---|
791 | } |
---|
792 | return iError; |
---|
793 | } |
---|
794 | |
---|
795 | #ifdef H_3D_VSO_EARLY_SKIP |
---|
796 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist |
---|
797 | TRenSingleModelC<iBM,bBitInc>::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData , Bool bFast) |
---|
798 | #else |
---|
799 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline RMDist |
---|
800 | TRenSingleModelC<iBM,bBitInc>::xRenderR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData ) |
---|
801 | #endif |
---|
802 | { |
---|
803 | |
---|
804 | const Int iCurViewPos = 1; |
---|
805 | const Int iOtherViewPos = 0; |
---|
806 | |
---|
807 | m_iCurViewPos = iCurViewPos; |
---|
808 | m_iOtherViewPos = iOtherViewPos; |
---|
809 | |
---|
810 | m_piNewDepthData = piNewData; |
---|
811 | m_iNewDataWidth = iWidth; |
---|
812 | m_iStartChangePosX = iStartPosX; |
---|
813 | |
---|
814 | if ((iWidth == 0) || (iHeight == 0)) |
---|
815 | return 0; |
---|
816 | |
---|
817 | // Get Data |
---|
818 | m_ppiCurLUT = m_appiShiftLut [iCurViewPos]; |
---|
819 | xSetViewRow ( iStartPosY); |
---|
820 | |
---|
821 | // Init Start |
---|
822 | RMDist iError = 0; |
---|
823 | Int iEndChangePos; |
---|
824 | |
---|
825 | iEndChangePos = m_iStartChangePosX + iWidth - 1; |
---|
826 | |
---|
827 | for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ ) |
---|
828 | { |
---|
829 | #if H_3D_VSO_EARLY_SKIP |
---|
830 | if( m_bEarlySkip && bFast ) |
---|
831 | { |
---|
832 | if ( m_pbHorSkip[iPosY-iStartPosY] ) |
---|
833 | { |
---|
834 | xIncViewRow(); |
---|
835 | m_piNewDepthData += iStride; |
---|
836 | continue; |
---|
837 | } |
---|
838 | } |
---|
839 | #endif |
---|
840 | m_bInOcclusion = false; |
---|
841 | |
---|
842 | Int iLastSPos; |
---|
843 | Int iStartChangePos = m_iStartChangePosX; |
---|
844 | Int iPosXinNewData = 0; |
---|
845 | Int iMaxChangedSPos = -1; |
---|
846 | |
---|
847 | if ( iStartChangePos == 0 ) // Special processing for leftmost depth sample |
---|
848 | { |
---|
849 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
---|
850 | Int iCurSPos = xShiftNewData(iStartChangePos, iPosXinNewData); |
---|
851 | m_iLastOccludedSPos = iCurSPos - 1; |
---|
852 | m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos ); |
---|
853 | xExtrapolateMarginR<bSet> ( iCurSPos, iStartChangePos, iError ); |
---|
854 | |
---|
855 | iMaxChangedSPos = std::max( iMaxChangedSPos, (iStartChangePos << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iStartChangePos].iD, m_piNewDepthData[iPosXinNewData] )) ]); |
---|
856 | iLastSPos = iCurSPos; |
---|
857 | m_iLastDepth = m_iCurDepth; |
---|
858 | if ( bSet ) |
---|
859 | { |
---|
860 | m_pcInputSamplesRow[iCurViewPos][iStartChangePos].iD = m_piNewDepthData[iPosXinNewData]; |
---|
861 | } |
---|
862 | |
---|
863 | |
---|
864 | iPosXinNewData++; |
---|
865 | iStartChangePos++; |
---|
866 | } |
---|
867 | else |
---|
868 | { |
---|
869 | iLastSPos = xShift(iStartChangePos-1); |
---|
870 | |
---|
871 | m_iLastDepth = m_pcInputSamplesRow[iCurViewPos][iStartChangePos-1].iD; |
---|
872 | xInitRenderPartR( iStartChangePos, iLastSPos ); |
---|
873 | } |
---|
874 | |
---|
875 | //// RENDER NEW DATA |
---|
876 | Int iCurPosX; |
---|
877 | for ( iCurPosX = iStartChangePos; iCurPosX <= iEndChangePos; iCurPosX++ ) |
---|
878 | { |
---|
879 | // Get minimal changed sample position |
---|
880 | |
---|
881 | iMaxChangedSPos = std::max( iMaxChangedSPos, (iCurPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( std::max(m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD, m_piNewDepthData[iPosXinNewData] )) ]); |
---|
882 | Int iCurSPos = xShiftNewData(iCurPosX,iPosXinNewData); |
---|
883 | m_iCurDepth = m_piNewDepthData[iPosXinNewData]; |
---|
884 | xRenderRangeR<bSet>(iCurSPos, iLastSPos, iCurPosX, iError ); |
---|
885 | iLastSPos = iCurSPos; |
---|
886 | m_iLastDepth = m_iCurDepth; |
---|
887 | |
---|
888 | if ( bSet ) |
---|
889 | { |
---|
890 | m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData]; |
---|
891 | } |
---|
892 | |
---|
893 | iPosXinNewData++; |
---|
894 | } |
---|
895 | |
---|
896 | //// RE-RENDER DATA LEFT TO NEW DATA |
---|
897 | while ( iCurPosX < m_iWidth ) |
---|
898 | { |
---|
899 | Int iCurSPos = xShift(iCurPosX); |
---|
900 | |
---|
901 | m_iCurDepth = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD; |
---|
902 | xRenderRangeR<bSet>( iCurSPos, iLastSPos, iCurPosX, iError ); |
---|
903 | |
---|
904 | if ( iCurSPos > iMaxChangedSPos ) |
---|
905 | { |
---|
906 | break; |
---|
907 | } |
---|
908 | iCurPosX++; |
---|
909 | iLastSPos = iCurSPos; |
---|
910 | m_iLastDepth = m_iCurDepth; |
---|
911 | } |
---|
912 | |
---|
913 | xIncViewRow(); |
---|
914 | m_piNewDepthData += iStride; |
---|
915 | } |
---|
916 | return iError; |
---|
917 | } |
---|
918 | |
---|
919 | |
---|
920 | template <BlenMod iBM, Bool bBitInc> __inline Void |
---|
921 | TRenSingleModelC<iBM,bBitInc>::xInitRenderPartL( Int iEndChangePos, Int iLastSPos ) |
---|
922 | { |
---|
923 | const Int iCurViewPos = 0; |
---|
924 | // GET MINIMAL OCCLUDED SAMPLE POSITION |
---|
925 | Int iCurPosX = iEndChangePos; |
---|
926 | |
---|
927 | |
---|
928 | if ( ( iCurPosX + 1 < m_iWidth ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX + 1].bOccluded ) ) |
---|
929 | { |
---|
930 | iCurPosX++; |
---|
931 | |
---|
932 | while ( (iCurPosX + 1 < m_iWidth) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX + 1].bOccluded ) ) |
---|
933 | |
---|
934 | iCurPosX++; |
---|
935 | |
---|
936 | if ( iCurPosX + 1 < m_iWidth ) |
---|
937 | { |
---|
938 | iCurPosX++; |
---|
939 | m_iLastOccludedSPos = xShift(iCurPosX); |
---|
940 | } |
---|
941 | else |
---|
942 | { |
---|
943 | m_iLastOccludedSPos = xShift(iCurPosX) + 1; |
---|
944 | } |
---|
945 | |
---|
946 | m_iLastOccludedSPosFP = xRoundL( m_iLastOccludedSPos ); |
---|
947 | } |
---|
948 | else |
---|
949 | { |
---|
950 | m_iLastOccludedSPos = iLastSPos+1; |
---|
951 | m_iLastOccludedSPosFP = xRangeLeftL( m_iLastOccludedSPos ); |
---|
952 | } |
---|
953 | |
---|
954 | m_bInOcclusion = iLastSPos >= m_iLastOccludedSPos; |
---|
955 | }; |
---|
956 | |
---|
957 | template <BlenMod iBM, Bool bBitInc> __inline Void |
---|
958 | TRenSingleModelC<iBM,bBitInc>::xInitRenderPartR( Int iStartChangePos, Int iLastSPos ) |
---|
959 | { |
---|
960 | const Int iCurViewPos = 1; |
---|
961 | // GET MINIMAL OCCLUDED SAMPLE POSITION |
---|
962 | Int iCurPosX = iStartChangePos; |
---|
963 | |
---|
964 | if ( ( iCurPosX - 1 > -1 ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX - 1].bOccluded ) ) |
---|
965 | { |
---|
966 | iCurPosX--; |
---|
967 | |
---|
968 | while ( (iCurPosX - 1 > -1 ) && (m_pcInputSamplesRow[iCurViewPos][ iCurPosX - 1].bOccluded ) ) |
---|
969 | iCurPosX--; |
---|
970 | |
---|
971 | if ( iCurPosX - 1 > -1 ) |
---|
972 | { |
---|
973 | iCurPosX--; |
---|
974 | m_iLastOccludedSPos = xShift(iCurPosX); |
---|
975 | } |
---|
976 | else |
---|
977 | { |
---|
978 | m_iLastOccludedSPos = xShift(iCurPosX) - 1; |
---|
979 | } |
---|
980 | m_iLastOccludedSPosFP = xRoundR( m_iLastOccludedSPos ); |
---|
981 | } |
---|
982 | else |
---|
983 | { |
---|
984 | m_iLastOccludedSPos = iLastSPos-1; |
---|
985 | m_iLastOccludedSPosFP = xRangeRightR( m_iLastOccludedSPos ); |
---|
986 | } |
---|
987 | |
---|
988 | m_bInOcclusion = iLastSPos <= m_iLastOccludedSPos; |
---|
989 | }; |
---|
990 | |
---|
991 | |
---|
992 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
993 | TRenSingleModelC<iBM,bBitInc>::xRenderShiftedRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
994 | { |
---|
995 | assert( iCurSPos <= iLastSPos ); |
---|
996 | //assert( iRightSPos < m_iWidth ); |
---|
997 | |
---|
998 | Int iDeltaSPos = iLastSPos - iCurSPos; |
---|
999 | if ( iDeltaSPos > m_iGapTolerance ) |
---|
1000 | { |
---|
1001 | xFillHoleL<bSet>( iCurSPos, iLastSPos, iCurPos, riError ); |
---|
1002 | } |
---|
1003 | else |
---|
1004 | { |
---|
1005 | if (iLastSPos < 0 ) |
---|
1006 | return; |
---|
1007 | |
---|
1008 | RM_AOT( iDeltaSPos > m_iGapTolerance ); |
---|
1009 | |
---|
1010 | m_iThisDepth = m_iCurDepth; |
---|
1011 | for (Int iFillSPos = std::max(0, xRangeLeftL(iCurSPos) ); iFillSPos <= min(xRangeRightL( iLastSPos ) ,m_iLastOccludedSPosFP-1); iFillSPos++ ) |
---|
1012 | { |
---|
1013 | Int iDeltaCurSPos = (iFillSPos << m_iShiftPrec) - iCurSPos; |
---|
1014 | |
---|
1015 | RM_AOT( iDeltaCurSPos > iDeltaSPos ); |
---|
1016 | RM_AOT( iDeltaCurSPos < 0 ); |
---|
1017 | RM_AOT( m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead); |
---|
1018 | |
---|
1019 | xSetShiftedPelL<bSet>( iCurPos, m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError ); |
---|
1020 | } |
---|
1021 | }; |
---|
1022 | } |
---|
1023 | |
---|
1024 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1025 | TRenSingleModelC<iBM,bBitInc>::xRenderShiftedRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
1026 | { |
---|
1027 | assert( iCurSPos >= iLastSPos ); |
---|
1028 | |
---|
1029 | Int iDeltaSPos = iCurSPos - iLastSPos; |
---|
1030 | if ( iDeltaSPos > m_iGapTolerance ) |
---|
1031 | { |
---|
1032 | xFillHoleR<bSet>( iCurSPos, iLastSPos, iCurPos, riError ); |
---|
1033 | } |
---|
1034 | else |
---|
1035 | { |
---|
1036 | if (iLastSPos > m_iSampledWidth - 1 ) |
---|
1037 | return; |
---|
1038 | |
---|
1039 | m_iThisDepth = m_iCurDepth; |
---|
1040 | RM_AOT( iDeltaSPos > m_iGapTolerance ); |
---|
1041 | for (Int iFillSPos = max(m_iLastOccludedSPosFP+1, xRangeLeftR(iLastSPos) ); iFillSPos <= min(xRangeRightR( iCurSPos ) ,m_iWidth -1); iFillSPos++ ) |
---|
1042 | { |
---|
1043 | Int iDeltaCurSPos = (iFillSPos << m_iShiftPrec) - iLastSPos; |
---|
1044 | |
---|
1045 | RM_AOT( iDeltaCurSPos > iDeltaSPos ); |
---|
1046 | RM_AOT( iDeltaCurSPos < 0 ); |
---|
1047 | RM_AOT( m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead); |
---|
1048 | |
---|
1049 | xSetShiftedPelR<bSet>( iCurPos, m_aaiSubPelShiftR[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError ); |
---|
1050 | } |
---|
1051 | }; |
---|
1052 | } |
---|
1053 | |
---|
1054 | |
---|
1055 | |
---|
1056 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1057 | TRenSingleModelC<iBM,bBitInc>::xRenderRangeL(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
1058 | { |
---|
1059 | const Int iCurViewPos = 0; |
---|
1060 | if ( !m_bInOcclusion ) |
---|
1061 | { |
---|
1062 | if ( iCurSPos >= iLastSPos ) |
---|
1063 | { |
---|
1064 | m_iLastOccludedSPos = iLastSPos; |
---|
1065 | |
---|
1066 | Int iRightSPosFP = xRoundL( iLastSPos ); |
---|
1067 | if ( ( iRightSPosFP == xRangeRightL(iLastSPos)) && (iRightSPosFP >= 0) ) |
---|
1068 | { |
---|
1069 | m_iThisDepth = m_iLastDepth; |
---|
1070 | |
---|
1071 | xSetShiftedPelL<bSet>( iCurPos+1, 0, iRightSPosFP, REN_IS_FILLED, riError ); |
---|
1072 | } |
---|
1073 | m_iLastOccludedSPosFP = iRightSPosFP; |
---|
1074 | |
---|
1075 | m_bInOcclusion = true; |
---|
1076 | |
---|
1077 | if ( bSet ) |
---|
1078 | { |
---|
1079 | m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true; |
---|
1080 | } |
---|
1081 | } |
---|
1082 | else |
---|
1083 | { |
---|
1084 | if ( bSet ) |
---|
1085 | { |
---|
1086 | m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false; |
---|
1087 | } |
---|
1088 | |
---|
1089 | xRenderShiftedRangeL<bSet>(iCurSPos, iLastSPos, iCurPos, riError ); |
---|
1090 | } |
---|
1091 | } |
---|
1092 | else |
---|
1093 | { |
---|
1094 | if ( iCurSPos < m_iLastOccludedSPos ) |
---|
1095 | { |
---|
1096 | m_bInOcclusion = false; |
---|
1097 | if ( bSet ) |
---|
1098 | { |
---|
1099 | m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false; |
---|
1100 | } |
---|
1101 | |
---|
1102 | xRenderShiftedRangeL<bSet>(iCurSPos, iLastSPos, iCurPos, riError ); |
---|
1103 | } |
---|
1104 | else |
---|
1105 | { |
---|
1106 | if ( bSet ) |
---|
1107 | { |
---|
1108 | m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true; |
---|
1109 | } |
---|
1110 | } |
---|
1111 | } |
---|
1112 | } |
---|
1113 | |
---|
1114 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1115 | TRenSingleModelC<iBM,bBitInc>::xRenderRangeR(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
1116 | { |
---|
1117 | const Int iCurViewPos = 1; |
---|
1118 | // Find out if current sample is occluded |
---|
1119 | if ( !m_bInOcclusion ) |
---|
1120 | { |
---|
1121 | if ( iCurSPos <= iLastSPos ) |
---|
1122 | { |
---|
1123 | m_iLastOccludedSPos = iLastSPos; |
---|
1124 | |
---|
1125 | Int iLeftSPosFP = xRoundR( iLastSPos ); |
---|
1126 | if ( ( iLeftSPosFP == xRangeLeftR(iLastSPos)) && (iLeftSPosFP <= m_iWidth - 1) ) |
---|
1127 | { |
---|
1128 | m_iThisDepth = m_iLastDepth; |
---|
1129 | xSetShiftedPelR<bSet>( iCurPos-1,1 << m_iShiftPrec , iLeftSPosFP, REN_IS_FILLED, riError ); |
---|
1130 | } |
---|
1131 | m_iLastOccludedSPosFP = iLeftSPosFP; |
---|
1132 | |
---|
1133 | m_bInOcclusion = true; |
---|
1134 | |
---|
1135 | if ( bSet ) |
---|
1136 | { |
---|
1137 | m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true; |
---|
1138 | } |
---|
1139 | } |
---|
1140 | else |
---|
1141 | { |
---|
1142 | if ( bSet ) |
---|
1143 | { |
---|
1144 | m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false; |
---|
1145 | } |
---|
1146 | |
---|
1147 | xRenderShiftedRangeR<bSet>(iCurSPos, iLastSPos, iCurPos, riError ); |
---|
1148 | } |
---|
1149 | } |
---|
1150 | else |
---|
1151 | { |
---|
1152 | if ( iCurSPos > m_iLastOccludedSPos ) |
---|
1153 | { |
---|
1154 | m_bInOcclusion = false; |
---|
1155 | if ( bSet ) |
---|
1156 | { |
---|
1157 | m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = false; |
---|
1158 | } |
---|
1159 | |
---|
1160 | xRenderShiftedRangeR<bSet>(iCurSPos, iLastSPos, iCurPos, riError ); |
---|
1161 | } |
---|
1162 | else |
---|
1163 | { |
---|
1164 | if ( bSet ) |
---|
1165 | { |
---|
1166 | m_pcInputSamplesRow[iCurViewPos][ iCurPos ].bOccluded = true; |
---|
1167 | } |
---|
1168 | } |
---|
1169 | } |
---|
1170 | } |
---|
1171 | |
---|
1172 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1173 | TRenSingleModelC<iBM,bBitInc>::xFillHoleL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
1174 | { |
---|
1175 | if (iLastSPos < 0) |
---|
1176 | return; |
---|
1177 | |
---|
1178 | Int iStartFillSPos = iCurSPos; |
---|
1179 | Int iStartFillPos = iCurPos; |
---|
1180 | Int iLastPos = iCurPos + 1; |
---|
1181 | |
---|
1182 | Int iStartFillSPosFP = xRangeLeftL(iStartFillSPos); |
---|
1183 | |
---|
1184 | if (iStartFillSPosFP == xRoundL(iStartFillSPos)) |
---|
1185 | { |
---|
1186 | if ((iStartFillSPosFP >= 0) && (iStartFillSPosFP < m_iLastOccludedSPosFP) ) |
---|
1187 | { |
---|
1188 | m_iThisDepth = m_iCurDepth; |
---|
1189 | xSetShiftedPelL<bSet> ( iStartFillPos, 0, iStartFillSPosFP, REN_IS_FILLED, riError ); |
---|
1190 | } |
---|
1191 | } |
---|
1192 | else |
---|
1193 | { |
---|
1194 | iStartFillSPosFP--; |
---|
1195 | } |
---|
1196 | |
---|
1197 | m_iThisDepth = m_iLastDepth; |
---|
1198 | for (Int iFillSPos = std::max(iStartFillSPosFP+1,0); iFillSPos <= min(xRangeRightL( iLastSPos ), m_iLastOccludedSPosFP-1 ); iFillSPos++ ) |
---|
1199 | { |
---|
1200 | xSetShiftedPelL<bSet>( iLastPos, 0, iFillSPos, REN_IS_HOLE, riError ); |
---|
1201 | } |
---|
1202 | } |
---|
1203 | |
---|
1204 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1205 | TRenSingleModelC<iBM,bBitInc>::xFillHoleR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError ) |
---|
1206 | { |
---|
1207 | if (iLastSPos < 0) |
---|
1208 | return; |
---|
1209 | |
---|
1210 | Int iStartFillSPos = iCurSPos; |
---|
1211 | Int iEndFillPos = iCurPos; |
---|
1212 | Int iLastPos = iCurPos - 1; |
---|
1213 | |
---|
1214 | Int iStartFillSPosFP = xRangeRightR(iStartFillSPos); |
---|
1215 | |
---|
1216 | if (iStartFillSPosFP == xRoundR(iStartFillSPos)) |
---|
1217 | { |
---|
1218 | if ((iStartFillSPosFP < m_iWidth) && (iStartFillSPosFP > m_iLastOccludedSPosFP) ) |
---|
1219 | { |
---|
1220 | m_iThisDepth = m_iCurDepth; |
---|
1221 | xSetShiftedPelR<bSet>( iEndFillPos, 1 << m_iShiftPrec , iStartFillSPosFP, REN_IS_FILLED, riError ); |
---|
1222 | } |
---|
1223 | } |
---|
1224 | else |
---|
1225 | { |
---|
1226 | iStartFillSPosFP++; |
---|
1227 | } |
---|
1228 | |
---|
1229 | m_iThisDepth = m_iLastDepth; |
---|
1230 | for (Int iFillSPos = max(xRangeLeftR( iLastSPos ), m_iLastOccludedSPosFP+1); iFillSPos <= min(iStartFillSPosFP,m_iWidth)-1 ; iFillSPos++ ) |
---|
1231 | { |
---|
1232 | xSetShiftedPelR<bSet>( iLastPos, 1 << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError ); |
---|
1233 | } |
---|
1234 | } |
---|
1235 | |
---|
1236 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1237 | TRenSingleModelC<iBM,bBitInc>::xExtrapolateMarginL(Int iCurSPos, Int iCurPos, RMDist& riError ) |
---|
1238 | { |
---|
1239 | // if (iLeftSPos < 0 ) |
---|
1240 | // return; |
---|
1241 | |
---|
1242 | Int iSPosFullPel = std::max(0,xRangeLeftL(iCurSPos)); |
---|
1243 | |
---|
1244 | m_iThisDepth = m_iCurDepth; |
---|
1245 | if (iSPosFullPel < m_iWidth) |
---|
1246 | { |
---|
1247 | xSetShiftedPelL<bSet>( iCurPos, 0, iSPosFullPel, REN_IS_FILLED, riError ); |
---|
1248 | } |
---|
1249 | |
---|
1250 | for (Int iFillSPos = iSPosFullPel +1; iFillSPos < m_iWidth; iFillSPos++ ) |
---|
1251 | { |
---|
1252 | xSetShiftedPelL<bSet>( iCurPos, 0, iFillSPos, REN_IS_HOLE, riError ); |
---|
1253 | } |
---|
1254 | } |
---|
1255 | |
---|
1256 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1257 | TRenSingleModelC<iBM,bBitInc>::xExtrapolateMarginR(Int iCurSPos, Int iCurPos, RMDist& riError ) |
---|
1258 | { |
---|
1259 | // if (iLeftSPos < 0 ) |
---|
1260 | // return; |
---|
1261 | |
---|
1262 | Int iSPosFullPel = std::min(m_iWidth-1,xRangeRightR(iCurSPos)); |
---|
1263 | |
---|
1264 | m_iThisDepth = m_iCurDepth; |
---|
1265 | if (iSPosFullPel > -1) |
---|
1266 | { |
---|
1267 | xSetShiftedPelR<bSet>( iCurPos, 1 << m_iShiftPrec, iSPosFullPel, REN_IS_FILLED, riError ); |
---|
1268 | } |
---|
1269 | |
---|
1270 | for (Int iFillSPos = iSPosFullPel -1; iFillSPos > -1; iFillSPos-- ) |
---|
1271 | { |
---|
1272 | xSetShiftedPelR<bSet>( iCurPos , 1 << m_iShiftPrec, iFillSPos, REN_IS_HOLE, riError ); |
---|
1273 | } |
---|
1274 | } |
---|
1275 | |
---|
1276 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1277 | TRenSingleModelC<iBM,bBitInc>::xShiftNewData( Int iPosX, Int iPosInNewData ) |
---|
1278 | { |
---|
1279 | RM_AOT( iPosInNewData < 0 ); |
---|
1280 | RM_AOF( iPosInNewData < m_iNewDataWidth ); |
---|
1281 | |
---|
1282 | return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_piNewDepthData[iPosInNewData] )]; |
---|
1283 | } |
---|
1284 | |
---|
1285 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1286 | TRenSingleModelC<iBM,bBitInc>::xShift( Int iPosX ) |
---|
1287 | { |
---|
1288 | RM_AOT( iPosX < 0); |
---|
1289 | RM_AOF( iPosX < m_iWidth); |
---|
1290 | |
---|
1291 | return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_pcInputSamplesRow[m_iCurViewPos][iPosX].iD )]; |
---|
1292 | } |
---|
1293 | |
---|
1294 | |
---|
1295 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1296 | TRenSingleModelC<iBM,bBitInc>::xShift( Int iPos, Int iPosInNewData ) |
---|
1297 | { |
---|
1298 | if ( (iPosInNewData >= 0) && (iPosInNewData < m_iNewDataWidth) ) |
---|
1299 | { |
---|
1300 | return xShiftNewData(iPos ,iPosInNewData ); |
---|
1301 | } |
---|
1302 | else |
---|
1303 | { |
---|
1304 | return xShift(iPos); |
---|
1305 | } |
---|
1306 | } |
---|
1307 | |
---|
1308 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1309 | TRenSingleModelC<iBM,bBitInc>::xRangeLeftL( Int iPos ) |
---|
1310 | { |
---|
1311 | return ( iPos + (1 << m_iShiftPrec) - 1) >> m_iShiftPrec; |
---|
1312 | } |
---|
1313 | |
---|
1314 | |
---|
1315 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1316 | TRenSingleModelC<iBM,bBitInc>::xRangeLeftR( Int iPos ) |
---|
1317 | { |
---|
1318 | |
---|
1319 | return xRangeRightR( iPos ) + 1; |
---|
1320 | } |
---|
1321 | |
---|
1322 | |
---|
1323 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1324 | TRenSingleModelC<iBM,bBitInc>::xRangeRightL( Int iPos ) |
---|
1325 | { |
---|
1326 | return xRangeLeftL(iPos) - 1; |
---|
1327 | } |
---|
1328 | |
---|
1329 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1330 | TRenSingleModelC<iBM,bBitInc>::xRangeRightR( Int iPos ) |
---|
1331 | { |
---|
1332 | return iPos >> m_iShiftPrec; |
---|
1333 | } |
---|
1334 | |
---|
1335 | |
---|
1336 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1337 | TRenSingleModelC<iBM,bBitInc>::xRoundL( Int iPos ) |
---|
1338 | { |
---|
1339 | return (iPos + (( 1 << m_iShiftPrec ) >> 1 )) >> m_iShiftPrec; |
---|
1340 | } |
---|
1341 | |
---|
1342 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1343 | TRenSingleModelC<iBM,bBitInc>::xRoundR( Int iPos ) |
---|
1344 | { |
---|
1345 | return (m_iShiftPrec == 0) ? iPos : xRoundL(iPos - 1); |
---|
1346 | } |
---|
1347 | |
---|
1348 | |
---|
1349 | template <BlenMod iBM, Bool bBitInc> Void |
---|
1350 | TRenSingleModelC<iBM,bBitInc>::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal ) |
---|
1351 | { |
---|
1352 | for (Int iYPos = 0; iYPos < iHeight; iYPos++) |
---|
1353 | { |
---|
1354 | for (Int iXPos = 0; iXPos < iWidth; iXPos++) |
---|
1355 | { |
---|
1356 | piPelSource[iXPos] = iVal; |
---|
1357 | } |
---|
1358 | piPelSource += iSourceStride; |
---|
1359 | } |
---|
1360 | } |
---|
1361 | |
---|
1362 | template <BlenMod iBM, Bool bBitInc> Void |
---|
1363 | TRenSingleModelC<iBM,bBitInc>::xSetInts( Int* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal ) |
---|
1364 | { |
---|
1365 | for (Int iYPos = 0; iYPos < iHeight; iYPos++) |
---|
1366 | { |
---|
1367 | for (Int iXPos = 0; iXPos < iWidth; iXPos++) |
---|
1368 | { |
---|
1369 | piPelSource[iXPos] = iVal; |
---|
1370 | } |
---|
1371 | piPelSource += iSourceStride; |
---|
1372 | } |
---|
1373 | } |
---|
1374 | |
---|
1375 | |
---|
1376 | template <BlenMod iBM, Bool bBitInc> Void |
---|
1377 | TRenSingleModelC<iBM,bBitInc>::xSetBools( Bool* pbPelSource , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal ) |
---|
1378 | { |
---|
1379 | for (Int iYPos = 0; iYPos < iHeight; iYPos++) |
---|
1380 | { |
---|
1381 | for (Int iXPos = 0; iXPos < iWidth; iXPos++) |
---|
1382 | { |
---|
1383 | pbPelSource[iXPos] = bVal; |
---|
1384 | } |
---|
1385 | pbPelSource += iSourceStride; |
---|
1386 | } |
---|
1387 | } |
---|
1388 | |
---|
1389 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1390 | TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelL(Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError ) |
---|
1391 | { |
---|
1392 | RM_AOT( iSourcePos < 0 ); |
---|
1393 | RM_AOT( iSourcePos >= m_iWidth ); |
---|
1394 | RM_AOT( iSubSourcePos < 0 ); |
---|
1395 | RM_AOT( iSubSourcePos > (1 << m_iShiftPrec) ); |
---|
1396 | RM_AOT( iTargetSPos < 0 ); |
---|
1397 | RM_AOT( iTargetSPos >= m_iWidth ); |
---|
1398 | |
---|
1399 | RenModelOutPels* pcOutSample = m_pcOutputSamplesRow + iTargetSPos; |
---|
1400 | RenModelInPels * pcInSample = m_pcInputSamplesRow[VIEWPOS_LEFT] + iSourcePos ; |
---|
1401 | |
---|
1402 | if ( iBM != BLEND_NONE ) |
---|
1403 | { |
---|
1404 | xSetShiftedPelBlendL<bSet> (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError); |
---|
1405 | } |
---|
1406 | else |
---|
1407 | { |
---|
1408 | xSetShiftedPelNoBlendL<bSet>(pcInSample, iSubSourcePos, pcOutSample, iFilled, riError); |
---|
1409 | } |
---|
1410 | } |
---|
1411 | |
---|
1412 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1413 | TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelNoBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError ) |
---|
1414 | { |
---|
1415 | if ( bSet ) |
---|
1416 | { |
---|
1417 | // Filled |
---|
1418 | pcOutSample->iFilledLeft = iFilled; |
---|
1419 | |
---|
1420 | // Yuv |
---|
1421 | pcOutSample->iYLeft = pcInSample->aiY[iSubSourcePos]; |
---|
1422 | #if H_3D_VSO_COLOR_PLANES |
---|
1423 | pcOutSample->iULeft = pcInSample->aiU[iSubSourcePos]; |
---|
1424 | pcOutSample->iVLeft = pcInSample->aiV[iSubSourcePos]; |
---|
1425 | |
---|
1426 | pcOutSample->iError = xGetDist( pcOutSample->iYLeft - pcOutSample->iYRef, |
---|
1427 | pcOutSample->iULeft - pcOutSample->iURef, |
---|
1428 | pcOutSample->iVLeft - pcOutSample->iVRef |
---|
1429 | ); |
---|
1430 | #else |
---|
1431 | pcOutSample->iError = xGetDist( pcOutSample->iYLeft - pcOutSample->iYRef ); |
---|
1432 | #endif |
---|
1433 | |
---|
1434 | } |
---|
1435 | else |
---|
1436 | { |
---|
1437 | #if H_3D_VSO_COLOR_PLANES |
---|
1438 | riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef, |
---|
1439 | pcInSample->aiU[iSubSourcePos] - pcOutSample->iURef, |
---|
1440 | pcInSample->aiV[iSubSourcePos] - pcOutSample->iVRef |
---|
1441 | ); |
---|
1442 | #else |
---|
1443 | riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef ); |
---|
1444 | #endif |
---|
1445 | |
---|
1446 | riError -= pcOutSample->iError; |
---|
1447 | } |
---|
1448 | } |
---|
1449 | |
---|
1450 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1451 | TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelBlendL(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError ) |
---|
1452 | { |
---|
1453 | Pel piBlendedValueY; |
---|
1454 | #if H_3D_VSO_COLOR_PLANES |
---|
1455 | Pel piBlendedValueU; |
---|
1456 | Pel piBlendedValueV; |
---|
1457 | #endif |
---|
1458 | |
---|
1459 | xGetBlendedValue ( |
---|
1460 | pcInSample ->aiY[iSubSourcePos], |
---|
1461 | pcOutSample->iYRight, |
---|
1462 | #if H_3D_VSO_COLOR_PLANES |
---|
1463 | pcInSample ->aiU[iSubSourcePos], |
---|
1464 | pcOutSample->iURight, |
---|
1465 | pcInSample ->aiV[iSubSourcePos], |
---|
1466 | pcOutSample->iVRight, |
---|
1467 | #endif |
---|
1468 | m_piInvZLUTLeft [RenModRemoveBitInc(m_iThisDepth) ], |
---|
1469 | m_piInvZLUTRight[RenModRemoveBitInc(pcOutSample->iDRight)], |
---|
1470 | iFilled, |
---|
1471 | pcOutSample->iFilledRight , |
---|
1472 | piBlendedValueY |
---|
1473 | #if H_3D_VSO_COLOR_PLANES |
---|
1474 | , piBlendedValueU, |
---|
1475 | piBlendedValueV |
---|
1476 | #endif |
---|
1477 | ); |
---|
1478 | |
---|
1479 | if ( bSet ) |
---|
1480 | { |
---|
1481 | // Set values |
---|
1482 | pcOutSample->iDLeft = m_iThisDepth; |
---|
1483 | pcOutSample->iYLeft = pcInSample ->aiY[iSubSourcePos]; |
---|
1484 | pcOutSample->iYBlended = piBlendedValueY; |
---|
1485 | #if H_3D_VSO_COLOR_PLANES |
---|
1486 | pcOutSample->iULeft = pcInSample ->aiU[iSubSourcePos]; |
---|
1487 | pcOutSample->iUBlended = piBlendedValueU; |
---|
1488 | pcOutSample->iVLeft = pcInSample ->aiV[iSubSourcePos]; |
---|
1489 | pcOutSample->iVBlended = piBlendedValueV; |
---|
1490 | #endif |
---|
1491 | pcOutSample->iFilledLeft = iFilled; |
---|
1492 | |
---|
1493 | // Get Error |
---|
1494 | Int iDiffY = pcOutSample->iYRef - piBlendedValueY; |
---|
1495 | #if H_3D_VSO_COLOR_PLANES |
---|
1496 | Int iDiffU = pcOutSample->iURef - piBlendedValueU; |
---|
1497 | Int iDiffV = pcOutSample->iVRef - piBlendedValueV; |
---|
1498 | pcOutSample->iError = xGetDist(iDiffY, iDiffU, iDiffV ); |
---|
1499 | #else |
---|
1500 | pcOutSample->iError = xGetDist(iDiffY ); |
---|
1501 | #endif |
---|
1502 | } |
---|
1503 | else |
---|
1504 | { |
---|
1505 | Int iDiffY = pcOutSample->iYRef - piBlendedValueY; |
---|
1506 | #if H_3D_VSO_COLOR_PLANES |
---|
1507 | Int iDiffU = pcOutSample->iURef - piBlendedValueU; |
---|
1508 | Int iDiffV = pcOutSample->iVRef - piBlendedValueV; |
---|
1509 | riError += ( xGetDist( iDiffY, iDiffU, iDiffV ) - pcOutSample->iError ); |
---|
1510 | |
---|
1511 | #else |
---|
1512 | riError += ( xGetDist( iDiffY ) - pcOutSample->iError ); |
---|
1513 | #endif |
---|
1514 | |
---|
1515 | } |
---|
1516 | } |
---|
1517 | |
---|
1518 | |
---|
1519 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1520 | TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelR(Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError ) |
---|
1521 | { |
---|
1522 | RM_AOT( iSourcePos < 0 ); |
---|
1523 | RM_AOT( iSourcePos >= m_iWidth ); |
---|
1524 | RM_AOT( iSubSourcePos < 0 ); |
---|
1525 | RM_AOT( iSubSourcePos >= (1 << m_iShiftPrec)+1 ); |
---|
1526 | RM_AOT( iTargetSPos < 0 ); |
---|
1527 | RM_AOT( iTargetSPos >= m_iWidth ); |
---|
1528 | |
---|
1529 | RenModelOutPels* pcOutSample = m_pcOutputSamplesRow + iTargetSPos; |
---|
1530 | RenModelInPels * pcInSample = m_pcInputSamplesRow[VIEWPOS_RIGHT] + iSourcePos ; |
---|
1531 | |
---|
1532 | if ( iBM != BLEND_NONE ) |
---|
1533 | { |
---|
1534 | xSetShiftedPelBlendR<bSet> (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError); |
---|
1535 | } |
---|
1536 | else |
---|
1537 | { |
---|
1538 | xSetShiftedPelNoBlendR<bSet> (pcInSample, iSubSourcePos, pcOutSample, iFilled, riError); |
---|
1539 | } |
---|
1540 | } |
---|
1541 | |
---|
1542 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1543 | TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelNoBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError ) |
---|
1544 | { |
---|
1545 | if ( bSet ) |
---|
1546 | { |
---|
1547 | // Filled |
---|
1548 | pcOutSample->iFilledRight = iFilled; |
---|
1549 | |
---|
1550 | // Yuv |
---|
1551 | pcOutSample->iYRight = pcInSample->aiY[iSubSourcePos]; |
---|
1552 | #if H_3D_VSO_COLOR_PLANES |
---|
1553 | pcOutSample->iURight = pcInSample->aiU[iSubSourcePos]; |
---|
1554 | pcOutSample->iVRight = pcInSample->aiV[iSubSourcePos]; |
---|
1555 | |
---|
1556 | pcOutSample->iError = xGetDist( |
---|
1557 | pcOutSample->iYRight - pcOutSample->iYRef, |
---|
1558 | pcOutSample->iURight - pcOutSample->iURef, |
---|
1559 | pcOutSample->iVRight - pcOutSample->iVRef |
---|
1560 | ); |
---|
1561 | #else |
---|
1562 | pcOutSample->iError = xGetDist( pcOutSample->iYRight - pcOutSample->iYRef ); |
---|
1563 | #endif |
---|
1564 | |
---|
1565 | } |
---|
1566 | else |
---|
1567 | { |
---|
1568 | #if H_3D_VSO_COLOR_PLANES |
---|
1569 | riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef, |
---|
1570 | pcInSample->aiU[iSubSourcePos] - pcOutSample->iURef, |
---|
1571 | pcInSample->aiV[iSubSourcePos] - pcOutSample->iVRef |
---|
1572 | ); |
---|
1573 | #else |
---|
1574 | riError += xGetDist( pcInSample->aiY[iSubSourcePos] - pcOutSample->iYRef ); |
---|
1575 | #endif |
---|
1576 | |
---|
1577 | riError -= pcOutSample->iError; |
---|
1578 | } |
---|
1579 | } |
---|
1580 | |
---|
1581 | template <BlenMod iBM, Bool bBitInc> template<Bool bSet> __inline Void |
---|
1582 | TRenSingleModelC<iBM,bBitInc>::xSetShiftedPelBlendR(RenModelInPels* pcInSample, Int iSubSourcePos, RenModelOutPels* pcOutSample, Pel iFilled, RMDist& riError ) |
---|
1583 | { |
---|
1584 | Pel piBlendedValueY; |
---|
1585 | #if H_3D_VSO_COLOR_PLANES |
---|
1586 | Pel piBlendedValueU; |
---|
1587 | Pel piBlendedValueV; |
---|
1588 | #endif |
---|
1589 | |
---|
1590 | xGetBlendedValue ( |
---|
1591 | pcOutSample->iYLeft, |
---|
1592 | pcInSample ->aiY[iSubSourcePos], |
---|
1593 | #if H_3D_VSO_COLOR_PLANES |
---|
1594 | pcOutSample->iULeft, |
---|
1595 | pcInSample ->aiU[iSubSourcePos], |
---|
1596 | pcOutSample->iVLeft, |
---|
1597 | pcInSample ->aiV[iSubSourcePos], |
---|
1598 | #endif |
---|
1599 | m_piInvZLUTLeft [RenModRemoveBitInc(pcOutSample->iDLeft)], |
---|
1600 | m_piInvZLUTRight [RenModRemoveBitInc(m_iThisDepth) ], |
---|
1601 | pcOutSample->iFilledLeft, |
---|
1602 | iFilled, |
---|
1603 | piBlendedValueY |
---|
1604 | #if H_3D_VSO_COLOR_PLANES |
---|
1605 | , piBlendedValueU, |
---|
1606 | piBlendedValueV |
---|
1607 | #endif |
---|
1608 | ); |
---|
1609 | |
---|
1610 | if ( bSet ) |
---|
1611 | { |
---|
1612 | // Set values |
---|
1613 | pcOutSample->iDRight = m_iThisDepth; |
---|
1614 | pcOutSample->iYRight = pcInSample ->aiY[iSubSourcePos]; |
---|
1615 | pcOutSample->iYBlended = piBlendedValueY; |
---|
1616 | #if H_3D_VSO_COLOR_PLANES |
---|
1617 | pcOutSample->iURight = pcInSample ->aiU[iSubSourcePos]; |
---|
1618 | pcOutSample->iUBlended = piBlendedValueU; |
---|
1619 | pcOutSample->iVRight = pcInSample ->aiV[iSubSourcePos]; |
---|
1620 | pcOutSample->iVBlended = piBlendedValueV; |
---|
1621 | #endif |
---|
1622 | pcOutSample->iFilledRight = iFilled; |
---|
1623 | |
---|
1624 | // Get Error |
---|
1625 | Int iDiffY = pcOutSample->iYRef - piBlendedValueY; |
---|
1626 | #if H_3D_VSO_COLOR_PLANES |
---|
1627 | Int iDiffU = pcOutSample->iURef - piBlendedValueU; |
---|
1628 | Int iDiffV = pcOutSample->iVRef - piBlendedValueV; |
---|
1629 | pcOutSample->iError = xGetDist(iDiffY, iDiffU, iDiffV ); |
---|
1630 | #else |
---|
1631 | pcOutSample->iError = xGetDist(iDiffY ); |
---|
1632 | #endif |
---|
1633 | } |
---|
1634 | else |
---|
1635 | { |
---|
1636 | Int iDiffY = pcOutSample->iYRef - piBlendedValueY; |
---|
1637 | #if H_3D_VSO_COLOR_PLANES |
---|
1638 | Int iDiffU = pcOutSample->iURef - piBlendedValueU; |
---|
1639 | Int iDiffV = pcOutSample->iVRef - piBlendedValueV; |
---|
1640 | riError += ( xGetDist( iDiffY, iDiffU, iDiffV ) - pcOutSample->iError ); |
---|
1641 | #else |
---|
1642 | riError += ( xGetDist( iDiffY ) - pcOutSample->iError ); |
---|
1643 | #endif |
---|
1644 | } |
---|
1645 | } |
---|
1646 | |
---|
1647 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1648 | TRenSingleModelC<iBM,bBitInc>::xGetDist( Int iDiffY, Int iDiffU, Int iDiffV ) |
---|
1649 | { |
---|
1650 | |
---|
1651 | if ( !bBitInc ) |
---|
1652 | { |
---|
1653 | return ( (iDiffY * iDiffY ) |
---|
1654 | + ((( (iDiffU * iDiffU ) |
---|
1655 | +(iDiffV * iDiffV ) |
---|
1656 | ) |
---|
1657 | ) >> 2 |
---|
1658 | ) |
---|
1659 | ); |
---|
1660 | } |
---|
1661 | else |
---|
1662 | { |
---|
1663 | return ( ((iDiffY * iDiffY) >> m_iDistShift) |
---|
1664 | + ((( ((iDiffU * iDiffU) >> m_iDistShift) |
---|
1665 | +((iDiffV * iDiffV) >> m_iDistShift) |
---|
1666 | ) |
---|
1667 | ) >> 2 |
---|
1668 | ) |
---|
1669 | ); |
---|
1670 | |
---|
1671 | } |
---|
1672 | } |
---|
1673 | |
---|
1674 | template <BlenMod iBM, Bool bBitInc> __inline Int |
---|
1675 | TRenSingleModelC<iBM,bBitInc>::xGetDist( Int iDiffY ) |
---|
1676 | { |
---|
1677 | if ( !bBitInc ) |
---|
1678 | { |
---|
1679 | return (iDiffY * iDiffY); |
---|
1680 | } |
---|
1681 | else |
---|
1682 | { |
---|
1683 | return ((iDiffY * iDiffY) >> m_iDistShift); |
---|
1684 | } |
---|
1685 | |
---|
1686 | } |
---|
1687 | |
---|
1688 | |
---|
1689 | #if H_3D_VSO_COLOR_PLANES |
---|
1690 | template <BlenMod iBM, Bool bBitInc> __inline Void |
---|
1691 | TRenSingleModelC<iBM,bBitInc>::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 ) |
---|
1692 | #else |
---|
1693 | template <BlenMod iBM, Bool bBitInc> __inline Void |
---|
1694 | TRenSingleModelC<iBM,bBitInc>::xGetBlendedValue( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY ) |
---|
1695 | #endif |
---|
1696 | { |
---|
1697 | |
---|
1698 | RM_AOT( iBM != BLEND_AVRG && iBM != BLEND_LEFT && iBM != BLEND_RIGHT ); |
---|
1699 | |
---|
1700 | if (iBM != BLEND_AVRG ) |
---|
1701 | { |
---|
1702 | if (iBM == BLEND_LEFT ) |
---|
1703 | { |
---|
1704 | #if H_3D_VSO_COLOR_PLANES |
---|
1705 | xGetBlendedValueBM1( iYL, iYR, iUL, iUR, iVL, iVR, iDepthL, iDepthR, iFilledL, iFilledR, riY, riU, riV ); |
---|
1706 | #else |
---|
1707 | xGetBlendedValueBM1( iYL, iYR, iDepthL, iDepthR, iFilledL, iFilledR, riY ); |
---|
1708 | #endif |
---|
1709 | } |
---|
1710 | else |
---|
1711 | { |
---|
1712 | #if H_3D_VSO_COLOR_PLANES |
---|
1713 | xGetBlendedValueBM2( iYL, iYR, iUL, iUR, iVL, iVR, iDepthL, iDepthR, iFilledL, iFilledR, riY, riU, riV ); |
---|
1714 | #else |
---|
1715 | xGetBlendedValueBM2( iYL, iYR, iDepthL, iDepthR, iFilledL, iFilledR, riY ); |
---|
1716 | #endif |
---|
1717 | } |
---|
1718 | return; |
---|
1719 | } |
---|
1720 | |
---|
1721 | if ( (iFilledL != REN_IS_HOLE ) && ( iFilledR != REN_IS_HOLE) ) |
---|
1722 | { |
---|
1723 | Int iDepthDifference = iDepthR - iDepthL; |
---|
1724 | |
---|
1725 | if ( abs ( iDepthDifference ) <= m_iBlendZThres ) |
---|
1726 | { |
---|
1727 | if ((iFilledL == REN_IS_FILLED) && ( iFilledR != REN_IS_FILLED)) |
---|
1728 | { |
---|
1729 | riY = xBlend( iYL, iYR, iFilledR >> 1 ); |
---|
1730 | #if H_3D_VSO_COLOR_PLANES |
---|
1731 | riU = xBlend( iUL, iUR, iFilledR >> 1 ); |
---|
1732 | riV = xBlend( iVL, iVR, iFilledR >> 1 ); |
---|
1733 | #endif |
---|
1734 | |
---|
1735 | } |
---|
1736 | else if ((iFilledL != REN_IS_FILLED) && ( iFilledR == REN_IS_FILLED)) |
---|
1737 | { |
---|
1738 | riY = xBlend( iYR, iYL, (iFilledL >> 1) ); |
---|
1739 | #if H_3D_VSO_COLOR_PLANES |
---|
1740 | riU = xBlend( iUR, iUL, (iFilledL >> 1) ); |
---|
1741 | riV = xBlend( iVR, iVL, (iFilledL >> 1) ); |
---|
1742 | #endif |
---|
1743 | } |
---|
1744 | else |
---|
1745 | { |
---|
1746 | riY = xBlend( iYL, iYR, m_iBlendDistWeight ); |
---|
1747 | #if H_3D_VSO_COLOR_PLANES |
---|
1748 | riU = xBlend( iUL, iUR, m_iBlendDistWeight ); |
---|
1749 | riV = xBlend( iVL, iVR, m_iBlendDistWeight ); |
---|
1750 | #endif |
---|
1751 | } |
---|
1752 | } |
---|
1753 | else if ( iDepthDifference < 0 ) |
---|
1754 | { |
---|
1755 | riY = iYL; |
---|
1756 | #if H_3D_VSO_COLOR_PLANES |
---|
1757 | riU = iUL; |
---|
1758 | riV = iVL; |
---|
1759 | #endif |
---|
1760 | } |
---|
1761 | else |
---|
1762 | { |
---|
1763 | riY = iYR; |
---|
1764 | #if H_3D_VSO_COLOR_PLANES |
---|
1765 | riU = iUR; |
---|
1766 | riV = iVR; |
---|
1767 | #endif |
---|
1768 | } |
---|
1769 | } |
---|
1770 | else if ( (iFilledL == REN_IS_HOLE) && (iFilledR == REN_IS_HOLE)) |
---|
1771 | { |
---|
1772 | if ( iDepthR < iDepthL ) |
---|
1773 | { |
---|
1774 | riY = iYR; |
---|
1775 | #if H_3D_VSO_COLOR_PLANES |
---|
1776 | riU = iUR; |
---|
1777 | riV = iVR; |
---|
1778 | #endif |
---|
1779 | } |
---|
1780 | else |
---|
1781 | { |
---|
1782 | riY = iYL; |
---|
1783 | #if H_3D_VSO_COLOR_PLANES |
---|
1784 | riU = iUL; |
---|
1785 | riV = iVL; |
---|
1786 | #endif |
---|
1787 | } |
---|
1788 | } |
---|
1789 | else |
---|
1790 | { |
---|
1791 | if (iFilledR == REN_IS_HOLE) |
---|
1792 | { |
---|
1793 | riY = iYL; |
---|
1794 | #if H_3D_VSO_COLOR_PLANES |
---|
1795 | riU = iUL; |
---|
1796 | riV = iVL; |
---|
1797 | #endif |
---|
1798 | } |
---|
1799 | else |
---|
1800 | { |
---|
1801 | riY = iYR; |
---|
1802 | #if H_3D_VSO_COLOR_PLANES |
---|
1803 | riU = iUR; |
---|
1804 | riV = iVR; |
---|
1805 | #endif |
---|
1806 | } |
---|
1807 | } |
---|
1808 | } |
---|
1809 | |
---|
1810 | template <BlenMod iBM, Bool bBitInc> __inline Void |
---|
1811 | #if H_3D_VSO_COLOR_PLANES |
---|
1812 | TRenSingleModelC<iBM,bBitInc>::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 ) |
---|
1813 | #else |
---|
1814 | TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM1( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY ) |
---|
1815 | #endif |
---|
1816 | { |
---|
1817 | if ( iFilledL == REN_IS_FILLED || iFilledR == REN_IS_HOLE ) |
---|
1818 | { |
---|
1819 | riY = iYL; |
---|
1820 | #if H_3D_VSO_COLOR_PLANES |
---|
1821 | riU = iUL; |
---|
1822 | riV = iVL; |
---|
1823 | #endif |
---|
1824 | } |
---|
1825 | else if ( iFilledL == REN_IS_HOLE ) |
---|
1826 | { |
---|
1827 | riY = iYR; |
---|
1828 | #if H_3D_VSO_COLOR_PLANES |
---|
1829 | riU = iUR; |
---|
1830 | riV = iVR; |
---|
1831 | #endif |
---|
1832 | } |
---|
1833 | else |
---|
1834 | { |
---|
1835 | riY = xBlend( iYR, iYL, iFilledL ); |
---|
1836 | #if H_3D_VSO_COLOR_PLANES |
---|
1837 | riU = xBlend( iUR, iUL, iFilledL ); |
---|
1838 | riV = xBlend( iVR, iUL, iFilledL ); |
---|
1839 | #endif |
---|
1840 | } |
---|
1841 | } |
---|
1842 | |
---|
1843 | template <BlenMod iBM, Bool bBitInc> __inline Void |
---|
1844 | #if H_3D_VSO_COLOR_PLANES |
---|
1845 | TRenSingleModelC<iBM,bBitInc>::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 ) |
---|
1846 | #else |
---|
1847 | TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM2( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY ) |
---|
1848 | #endif |
---|
1849 | { |
---|
1850 | if ( iFilledR == REN_IS_FILLED || iFilledL == REN_IS_HOLE ) |
---|
1851 | { |
---|
1852 | riY = iYR; |
---|
1853 | #if H_3D_VSO_COLOR_PLANES |
---|
1854 | riU = iUR; |
---|
1855 | riV = iVR; |
---|
1856 | #endif |
---|
1857 | } |
---|
1858 | else if ( iFilledR == REN_IS_HOLE ) |
---|
1859 | { |
---|
1860 | riY = iYL; |
---|
1861 | #if H_3D_VSO_COLOR_PLANES |
---|
1862 | riU = iUL; |
---|
1863 | riV = iVL; |
---|
1864 | #endif |
---|
1865 | } |
---|
1866 | else |
---|
1867 | { |
---|
1868 | riY = xBlend( iYL, iYR, iFilledR ); |
---|
1869 | #if H_3D_VSO_COLOR_PLANES |
---|
1870 | riU = xBlend( iUL, iUR, iFilledR ); |
---|
1871 | riV = xBlend( iVL, iUR, iFilledR ); |
---|
1872 | #endif |
---|
1873 | } |
---|
1874 | } |
---|
1875 | |
---|
1876 | template <BlenMod iBM, Bool bBitInc> __inline Pel |
---|
1877 | TRenSingleModelC<iBM,bBitInc>::xBlend( Pel pVal1, Pel pVal2, Int iWeightVal2 ) |
---|
1878 | { |
---|
1879 | return pVal1 + (Pel) ( ( (Int) ( pVal2 - pVal1) * iWeightVal2 + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC ); |
---|
1880 | } |
---|
1881 | |
---|
1882 | template <BlenMod iBM, Bool bBitInc> Void |
---|
1883 | TRenSingleModelC<iBM,bBitInc>::xCopy2PicYuv( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget ) |
---|
1884 | { |
---|
1885 | TRenFilter<REN_BIT_DEPTH>::copy ( ppiSrcVideoPel[0], piStrides[0], m_iWidth, m_iUsedHeight, rpcPicYuvTarget->getAddr( COMPONENT_Y ) + m_iHorOffset * rpcPicYuvTarget->getStride( COMPONENT_Y ), rpcPicYuvTarget->getStride( COMPONENT_Y ) ); |
---|
1886 | TRenFilter<REN_BIT_DEPTH>::sampleDown2Tap13( ppiSrcVideoPel[1], piStrides[1], m_iWidth, m_iUsedHeight, rpcPicYuvTarget->getAddr( COMPONENT_Cb ) + (m_iHorOffset >> 1) * rpcPicYuvTarget->getStride( COMPONENT_Cb ), rpcPicYuvTarget->getStride( COMPONENT_Cb) ); |
---|
1887 | TRenFilter<REN_BIT_DEPTH>::sampleDown2Tap13( ppiSrcVideoPel[2], piStrides[2], m_iWidth, m_iUsedHeight, rpcPicYuvTarget->getAddr( COMPONENT_Cr ) + (m_iHorOffset >> 1) * rpcPicYuvTarget->getStride( COMPONENT_Cr ), rpcPicYuvTarget->getStride( COMPONENT_Cr) ); |
---|
1888 | } |
---|
1889 | |
---|
1890 | template class TRenSingleModelC<BLEND_NONE ,true>; |
---|
1891 | template class TRenSingleModelC<BLEND_AVRG ,true>; |
---|
1892 | template class TRenSingleModelC<BLEND_LEFT ,true>; |
---|
1893 | template class TRenSingleModelC<BLEND_RIGHT,true>; |
---|
1894 | |
---|
1895 | template class TRenSingleModelC<BLEND_NONE ,false>; |
---|
1896 | template class TRenSingleModelC<BLEND_AVRG ,false>; |
---|
1897 | template class TRenSingleModelC<BLEND_LEFT ,false>; |
---|
1898 | template class TRenSingleModelC<BLEND_RIGHT,false>; |
---|
1899 | |
---|
1900 | #if H_3D_VSO_EARLY_SKIP |
---|
1901 | template <BlenMod iBM, Bool bBitInc> |
---|
1902 | __inline Bool |
---|
1903 | TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkipL( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride) |
---|
1904 | { |
---|
1905 | RM_AOF( m_bEarlySkip ); |
---|
1906 | const Int iCurViewPos = 0; |
---|
1907 | Int** ppiCurLUT = m_appiShiftLut [ iCurViewPos ]; |
---|
1908 | |
---|
1909 | Bool bNoDiff = true; |
---|
1910 | |
---|
1911 | for (Int iPosY=0; iPosY < iHeight; iPosY++) |
---|
1912 | { |
---|
1913 | m_pbHorSkip[iPosY] = true; |
---|
1914 | |
---|
1915 | for (Int iPosX = 0; iPosX < iWidth; iPosX++) |
---|
1916 | { |
---|
1917 | Int iDisparityRec = abs(ppiCurLUT[0][ RenModRemoveBitInc(piNewData[iPosX])]); |
---|
1918 | Int iDispartyOrg = abs(ppiCurLUT[0][ RenModRemoveBitInc(piOrgData[iPosX])]); |
---|
1919 | |
---|
1920 | if( iDispartyOrg != iDisparityRec) |
---|
1921 | { |
---|
1922 | m_pbHorSkip[iPosY] = false; |
---|
1923 | bNoDiff = false; |
---|
1924 | break; |
---|
1925 | } |
---|
1926 | } |
---|
1927 | piNewData += iStride; |
---|
1928 | piOrgData += iOrgStride; |
---|
1929 | } |
---|
1930 | return bNoDiff; |
---|
1931 | } |
---|
1932 | |
---|
1933 | template <BlenMod iBM, Bool bBitInc> |
---|
1934 | __inline Bool |
---|
1935 | TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkipR( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride) |
---|
1936 | { |
---|
1937 | RM_AOF( m_bEarlySkip ); |
---|
1938 | Bool bNoDiff = true; |
---|
1939 | |
---|
1940 | const Int iCurViewPos = 1; |
---|
1941 | Int** ppiCurLUT = m_appiShiftLut [ iCurViewPos ]; |
---|
1942 | |
---|
1943 | for ( Int iPosY = 0; iPosY < iHeight; iPosY++ ) |
---|
1944 | { |
---|
1945 | m_pbHorSkip[iPosY] = true; |
---|
1946 | |
---|
1947 | for (Int iPosX = 0; iPosX < iWidth; iPosX++) |
---|
1948 | { |
---|
1949 | Int iDisparityRec = abs( ppiCurLUT[0][ RenModRemoveBitInc(piNewData[iPosX])] ); |
---|
1950 | Int iDisparityOrg = abs( ppiCurLUT[0][ RenModRemoveBitInc(piOrgData[iPosX])] ); |
---|
1951 | |
---|
1952 | if( iDisparityRec != iDisparityOrg ) |
---|
1953 | { |
---|
1954 | m_pbHorSkip[iPosY] = false; |
---|
1955 | bNoDiff = false; |
---|
1956 | break; |
---|
1957 | } |
---|
1958 | } |
---|
1959 | |
---|
1960 | piNewData += iStride; |
---|
1961 | piOrgData += iOrgStride; |
---|
1962 | } |
---|
1963 | return bNoDiff; |
---|
1964 | } |
---|
1965 | #endif |
---|
1966 | #endif // NH_3D |
---|
1967 | |
---|