source: 3DVCSoftware/branches/HTM-16.1-dev/source/Lib/TLibRenderer/TRenSingleModel.cpp @ 1402

Last change on this file since 1402 was 1401, checked in by tech, 9 years ago

Exchange copy right dates.

  • Property svn:eol-style set to native
File size: 52.9 KB
RevLine 
[5]1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
[1401]6 * Copyright (c) 2010-2016, ITU/ISO/IEC
[5]7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
[2]33
34#include "TRenImage.h"
35#include "TRenFilter.h"
36#include "TRenSingleModel.h"
37
[1313]38#if NH_3D_VSO
[608]39
[2]40////////////// TRENSINGLE MODEL ///////////////
[100]41template <BlenMod iBM, Bool bBitInc>
42TRenSingleModelC<iBM,bBitInc>::TRenSingleModelC()
[1313]43:  m_iDistShift ( ( ENC_INTERNAL_BIT_DEPTH  - REN_BIT_DEPTH) << 1 )
[2]44{
45  m_iWidth  = -1;
46  m_iHeight = -1;
47  m_iStride = -1;
[124]48  m_iUsedHeight = -1; 
49  m_iHorOffset  = -1; 
[2]50  m_iMode   = -1;
[56]51  m_iPad    = PICYUV_PAD;
[2]52  m_iGapTolerance = -1;
53  m_bUseOrgRef = false;
54
55  m_pcPicYuvRef          = NULL;
[100]56
57  m_pcOutputSamples      = NULL; 
[1396]58  m_pcOutputSamplesRow   = NULL; 
[100]59  m_iOutputSamplesStride = -1; 
60
61  m_ppiCurLUT            = NULL;
62  m_piInvZLUTLeft        = NULL;
63  m_piInvZLUTRight       = NULL;
64
[2]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
[100]73
[2]74  for (UInt uiViewNum = 0 ; uiViewNum < 2; uiViewNum++)
75  {
76    // LUT
77    m_appiShiftLut[uiViewNum] = NULL;
[100]78
79    m_pcInputSamples[uiViewNum] = NULL; 
80    m_iInputSamplesStride       = -1; 
81
[2]82    m_ppiCurLUT               = NULL;
83    m_piInvZLUTLeft           = NULL;
84    m_piInvZLUTRight          = NULL;
[100]85  }
[2]86
[608]87#if H_3D_VSO_EARLY_SKIP
[100]88  m_pbHorSkip = NULL;
89#endif
[2]90}
91
[100]92template <BlenMod iBM, Bool bBitInc>
93TRenSingleModelC<iBM,bBitInc>::~TRenSingleModelC()
[2]94{
[608]95#if H_3D_VSO_EARLY_SKIP
[124]96  if ( m_pbHorSkip ) 
[2]97  {
[100]98    delete[] m_pbHorSkip;
99    m_pbHorSkip = NULL;
[2]100  }
[100]101#endif
[2]102
[100]103  if ( m_pcInputSamples [0] ) delete[] m_pcInputSamples [0];
104  if ( m_pcInputSamples [1] ) delete[] m_pcInputSamples [1];
[121]105
106  if ( m_pcOutputSamples    ) delete[] m_pcOutputSamples   ;
107
[1396]108  if ( m_piInvZLUTLeft      ) delete[] m_piInvZLUTLeft ;
109  if ( m_piInvZLUTRight     ) delete[] m_piInvZLUTRight;
[121]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 ) );
[2]114}
115
[100]116template <BlenMod iBM, Bool bBitInc> Void
[608]117#if H_3D_VSO_EARLY_SKIP
[1396]118TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bLimOutput, Bool bEarlySkip )
[100]119#else
[1396]120TRenSingleModelC<iBM,bBitInc>::create( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode, Bool bLimOutput )
[100]121#endif
122
[2]123{
[1396]124  m_bLimOutput = bLimOutput; 
[608]125#if H_3D_VSO_EARLY_SKIP
[100]126  m_pbHorSkip     = new Bool [MAX_CU_SIZE];
127  m_bEarlySkip    = bEarlySkip; 
128#endif
129
[1396]130  AOF( ( iBlendMode == iBM ) || ( iBM == BLEND_NONE ) ); 
[2]131  m_iMode = iMode;
[100]132
[2]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
[100]167  m_iInputSamplesStride  = m_iWidth+1;
168  m_iOutputSamplesStride = m_iWidth;
[2]169
[100]170  m_pcInputSamples[0]     = new RenModelInPels[m_iInputSamplesStride*m_iHeight];
171  m_pcInputSamples[1]     = new RenModelInPels[m_iInputSamplesStride*m_iHeight];
[2]172
[1396]173  m_pcOutputSamples       = new RenModelOutPels   [m_iOutputSamplesStride*m_iHeight];
174  m_pcLimOutputSamples    = m_bLimOutput ? new RenModelLimOutPels[m_iOutputSamplesStride*m_iHeight] : NULL;
[100]175}
[2]176
[100]177template <BlenMod iBM, Bool bBitInc> Void
178TRenSingleModelC<iBM,bBitInc>::setLRView( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride )
179{
180  AOF(( iViewPos == 0) || (iViewPos == 1) );
181
182  RenModelInPels* pcCurInputSampleRow = m_pcInputSamples[iViewPos];
183 
184  Pel* piDRow = piCurDepthPel;
185  Pel* piYRow = apiCurVideoPel[0];
[608]186#if H_3D_VSO_COLOR_PLANES
[100]187  Pel* piURow = apiCurVideoPel[1];
188  Pel* piVRow = apiCurVideoPel[2];
189#endif 
190
191
192  Int iOffsetX = ( iViewPos == VIEWPOS_RIGHT ) ? 1 : 0;
193
[124]194  for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )
[2]195  {
[100]196    if ( iViewPos == VIEWPOS_RIGHT )
[2]197    {
[100]198      Int iSubPosX = (1 << m_iShiftPrec); 
199      pcCurInputSampleRow[0].aiY[iSubPosX] = piYRow[0];
[608]200#if H_3D_VSO_COLOR_PLANES
[100]201      pcCurInputSampleRow[0].aiU[iSubPosX] = piURow[0];
202      pcCurInputSampleRow[0].aiV[iSubPosX] = piVRow[0];
203#endif
[2]204    }
205
[100]206    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
207    {
208      pcCurInputSampleRow[iPosX].iD = piDRow[iPosX];
[2]209
[100]210      for (Int iSubPosX = 0; iSubPosX < (1 << m_iShiftPrec)+1; iSubPosX++ )
211      { 
212        Int iShift = (iPosX << m_iShiftPrec) + iSubPosX;
213        pcCurInputSampleRow[iPosX+iOffsetX].aiY[iSubPosX] = piYRow[iShift];
[608]214#if H_3D_VSO_COLOR_PLANES
[100]215        pcCurInputSampleRow[iPosX+iOffsetX].aiU[iSubPosX] = piURow[iShift];
216        pcCurInputSampleRow[iPosX+iOffsetX].aiV[iSubPosX] = piVRow[iShift];
217#endif
218      }
219    } 
220
221    pcCurInputSampleRow += m_iInputSamplesStride; 
222
223    piDRow += iCurDepthStride;
224    piYRow += aiCurVideoStride[0];
[608]225#if H_3D_VSO_COLOR_PLANES
[100]226    piURow += aiCurVideoStride[1];
227    piVRow += aiCurVideoStride[2];
228#endif
[2]229  }
230
[100]231 
[2]232  m_aapiBaseVideoPel      [iViewPos] = apiCurVideoPel;
233  m_aaiBaseVideoStrides   [iViewPos] = aiCurVideoStride;
234  m_apiBaseDepthPel       [iViewPos] = piCurDepthPel;
235  m_aiBaseDepthStrides    [iViewPos] = iCurDepthStride;
[100]236
[2]237}
[124]238template <BlenMod iBM, Bool bBitInc> Void
239TRenSingleModelC<iBM,bBitInc>::setupPart ( UInt uiHorOffset,       Int iUsedHeight )
240{
241  AOT( iUsedHeight > m_iHeight );   
[2]242
[124]243  m_iUsedHeight =       iUsedHeight; 
244  m_iHorOffset  = (Int) uiHorOffset;
245}
246
[1396]247
248#if !RM_FIX_SETUP
[100]249template <BlenMod iBM, Bool bBitInc> Void
[1396]250  TRenSingleModelC<iBM,bBitInc>::setupInitialState( Int curViewPosInModel )
[2]251{
[1396]252  xRenderAll( );
253
254  if ( m_bLimOutput )
255  {
256    AOT( curViewPosInModel == VIEWPOS_INVALID )
257    xSetLimOutStruct( (curViewPosInModel == VIEWPOS_RIGHT)  ? VIEWPOS_LEFT : VIEWPOS_RIGHT );
258  }
259}
260#endif
261
262#if RM_FIX_SETUP
263template <BlenMod iBM, Bool bBitInc> Void
264  TRenSingleModelC<iBM,bBitInc>::setupRefView      ( TComPicYuv* pcOrgVideo )
265{
266  m_pcPicYuvRef = pcOrgVideo;
267  // Use provided ref view reference
268 
269  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]);
270  switch ( pcOrgVideo->getChromaFormat() )
271  {
272  case CHROMA_420:
273    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]);
274    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]);
275    break;
276  case CHROMA_444:
277    TRenFilter<REN_BIT_DEPTH>::copy(             pcOrgVideo->getAddr( COMPONENT_Cb  ) +  m_iHorOffset       * pcOrgVideo->getStride( COMPONENT_Cb  ), pcOrgVideo->getStride( COMPONENT_Cb  ), m_iWidth,      m_iUsedHeight,      m_aapiRefVideoPel[1], m_aiRefVideoStrides[1]);
278    TRenFilter<REN_BIT_DEPTH>::copy(             pcOrgVideo->getAddr( COMPONENT_Cr  ) +  m_iHorOffset       * pcOrgVideo->getStride( COMPONENT_Cr  ), pcOrgVideo->getStride( COMPONENT_Cr  ), m_iWidth,      m_iUsedHeight,      m_aapiRefVideoPel[2], m_aiRefVideoStrides[2]);
279    break;
280  default:
281    break; 
282  }
283  xSetStructRefView();
284}
285
286
287template <BlenMod iBM, Bool bBitInc> Void
288  TRenSingleModelC<iBM,bBitInc>::setupLut( Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft )
289#else
290template <BlenMod iBM, Bool bBitInc> Void
291  TRenSingleModelC<iBM,bBitInc>::setupLutAndRef( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bRenderRef )
292#endif
293{
294#if !RM_FIX_SETUP
[2]295  AOT( !m_bUseOrgRef && pcOrgVideo );
[1396]296#endif
[2]297  AOT( (ppiShiftLutLeft  == NULL) && (m_iMode == 0 || m_iMode == 2) );
298  AOT( (ppiShiftLutRight == NULL) && (m_iMode == 1 || m_iMode == 2) );
299
300  m_appiShiftLut[0] = ppiShiftLutLeft;
301  m_appiShiftLut[1] = ppiShiftLutRight;
302
[1396]303
304  if ( m_iMode == 2 )
305  {
306    TRenFilter<REN_BIT_DEPTH>::setupZLUT( true, 30, iDistToLeft, ppiBaseShiftLutLeft, ppiBaseShiftLutRight, m_iBlendZThres, m_iBlendDistWeight, m_piInvZLUTLeft, m_piInvZLUTRight );
307  }
308
309#if !RM_FIX_SETUP
[2]310  // Copy Reference
311  m_pcPicYuvRef = pcOrgVideo;
312
[1396]313  if ( pcOrgVideo )
[2]314  {
[1396]315    assert( pcOrgVideo->getChromaFormat() == CHROMA_420 );     
[1313]316
317    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]);
318    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]);
319    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]);   
[100]320    xSetStructRefView();
[2]321  }
[1396]322  else
323  {
324    if ( bRenderRef )
325    {   
326      xRenderAll( ); 
327      xSetStructSynthViewAsRefView();
328    }
329  }
330#endif
331}
[2]332
[1396]333template <BlenMod iBM, Bool bBitInc> Void
334#if RM_FIX_SETUP
335TRenSingleModelC<iBM,bBitInc>::renderAll( )
336#else
337TRenSingleModelC<iBM,bBitInc>::xRenderAll( )
338#endif
339{
[2]340  // Initial Rendering
[1396]341#if RM_FIX_SETUP
342  resetStructError();
343#else
[100]344  xResetStructError();
[1396]345#endif
[100]346  xInitSampleStructs();
[2]347  switch ( m_iMode )
[100]348  { 
349  case 0:   
[608]350#if H_3D_VSO_EARLY_SKIP
[1396]351    xRender<true, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false );
[124]352#else
[1396]353    xRender<true, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );
[124]354#endif   
355    break;
356  case 1:   
[608]357#if H_3D_VSO_EARLY_SKIP
[1396]358    xRender<false, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);
[124]359#else
[1396]360    xRender<false, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );
[124]361#endif
362    break;
363  case 2:
[608]364#if H_3D_VSO_EARLY_SKIP
[1396]365    xRender<true , SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0],false);
366    xRender<false, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1],false);
[124]367#else     
[1396]368    xRender<true,  SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[0], m_apiBaseDepthPel[0] );
369    xRender<false, SET_FULL>( 0, 0, m_iWidth, m_iUsedHeight, m_aiBaseDepthStrides[1], m_apiBaseDepthPel[1] );
[124]370#endif
371    break;
372  default:
373    AOT(true);
374  }
[2]375}
376
[100]377template <BlenMod iBM, Bool bBitInc> Void
[608]378#if H_3D_VSO_COLOR_PLANES
[100]379TRenSingleModelC<iBM,bBitInc>::xGetSampleStrTextPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY, Pel RenModelOutPels::*& rpiSrcU, Pel RenModelOutPels::*& rpiSrcV )
380#else
381TRenSingleModelC<iBM,bBitInc>::xGetSampleStrTextPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcY )
382#endif
[2]383{
[100]384  switch ( iViewNum )
[2]385  {
[1396]386
387  case -1: 
388    rpiSrcY = &RenModelOutPels::iYRef;
389#if H_3D_VSO_COLOR_PLANES 
390    rpiSrcU = &RenModelOutPels::iURef;
391    rpiSrcV = &RenModelOutPels::iVRef;
392#endif
393    break;
[2]394  case 0:
[100]395    rpiSrcY = &RenModelOutPels::iYLeft;
[608]396#if H_3D_VSO_COLOR_PLANES 
[100]397    rpiSrcU = &RenModelOutPels::iULeft;
398    rpiSrcV = &RenModelOutPels::iVLeft;
399#endif
[2]400    break;
401  case 1:
[100]402    rpiSrcY = &RenModelOutPels::iYRight;
[608]403#if H_3D_VSO_COLOR_PLANES 
[100]404    rpiSrcU = &RenModelOutPels::iURight;
405    rpiSrcV = &RenModelOutPels::iVRight;
406#endif
[2]407    break;
[100]408  case 2:
409    rpiSrcY = &RenModelOutPels::iYBlended;
[608]410#if H_3D_VSO_COLOR_PLANES 
[100]411    rpiSrcU = &RenModelOutPels::iUBlended;
412    rpiSrcV = &RenModelOutPels::iVBlended;
413#endif
414    break;
[2]415  }
416}
417
[100]418
419template <BlenMod iBM, Bool bBitInc> Void
420TRenSingleModelC<iBM,bBitInc>::xGetSampleStrDepthPtrs( Int iViewNum, Pel RenModelOutPels::*& rpiSrcD )
[2]421{
[100]422  AOT(iViewNum != 0 && iViewNum != 1); 
423  rpiSrcD = (iViewNum == 1) ? &RenModelOutPels::iDRight : &RenModelOutPels::iDLeft; 
[2]424}
425
[1396]426template <BlenMod iBM, Bool bBitInc> Void
427  TRenSingleModelC<iBM,bBitInc>::xGetSampleStrFilledPtrs( Int iViewNum, Int RenModelOutPels::*& rpiSrcFilled )
428{
429  AOT(iViewNum != 0 && iViewNum != 1); 
430  rpiSrcFilled = (iViewNum == 1) ? &RenModelOutPels::iFilledRight : &RenModelOutPels::iFilledLeft; 
431}
[2]432
[1396]433
[100]434template <BlenMod iBM, Bool bBitInc> Void
435TRenSingleModelC<iBM,bBitInc>::xSetStructRefView( )
[2]436{
[100]437  RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;
438 
439  Pel* piYRow = m_aapiRefVideoPel[0];
[608]440#if H_3D_VSO_COLOR_PLANES
[100]441  Pel* piURow = m_aapiRefVideoPel[1];
442  Pel* piVRow = m_aapiRefVideoPel[2];
443#endif 
444
[124]445  for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )
[100]446  {
447    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
448    {     
449      pcCurOutSampleRow[iPosX].iYRef = piYRow[iPosX];
[608]450#if H_3D_VSO_COLOR_PLANES
[100]451      pcCurOutSampleRow[iPosX].iURef = piURow[iPosX];
452      pcCurOutSampleRow[iPosX].iVRef = piVRow[iPosX];
453#endif
454    } 
455
456    pcCurOutSampleRow += m_iOutputSamplesStride; 
457   
458    piYRow += m_aiRefVideoStrides[0];
[608]459#if H_3D_VSO_COLOR_PLANES
[100]460    piURow += m_aiRefVideoStrides[1];
461    piVRow += m_aiRefVideoStrides[2];
462#endif
463  }
[2]464}
465
[100]466template <BlenMod iBM, Bool bBitInc> Void
[1396]467#if RM_FIX_SETUP
468TRenSingleModelC<iBM,bBitInc>::resetStructError( )
469#else
[100]470TRenSingleModelC<iBM,bBitInc>::xResetStructError( )
[1396]471#endif
[100]472{
473  RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;
[2]474
[100]475  for ( Int iPosY = 0; iPosY < m_iHeight; iPosY++ )
476  {
477    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
478    {     
479      pcCurOutSampleRow[iPosX].iError = 0;
480    } 
481    pcCurOutSampleRow += m_iOutputSamplesStride; 
482  }
[2]483}
484
[100]485template <BlenMod iBM, Bool bBitInc> Void
[1396]486#if RM_FIX_SETUP
487  TRenSingleModelC<iBM,bBitInc>::setLimOutStruct(Int iSourceViewPos )
488#else
489  TRenSingleModelC<iBM,bBitInc>::xSetLimOutStruct(Int iSourceViewPos )
490#endif
491{ 
492  RM_AOF( m_bLimOutput ); 
493  RM_AOT( iSourceViewPos < 0 || iSourceViewPos > 1);
494
495  RenModelOutPels*    pcCurOutSampleRow    = m_pcOutputSamples;
496  RenModelLimOutPels* pcCurLimOutSampleRow = m_pcLimOutputSamples;
497
498  Int RenModelOutPels::* piFilled = NULL;
499  xGetSampleStrFilledPtrs( iSourceViewPos, piFilled );
500 
501  Pel RenModelOutPels::* piDepth  = NULL;
502  xGetSampleStrDepthPtrs ( iSourceViewPos, piDepth  );
503
504  Pel RenModelOutPels::* piSrcY = NULL;
505 
506#if H_3D_VSO_COLOR_PLANES 
507  Pel RenModelOutPels::* piSrcU = NULL; 
508  Pel RenModelOutPels::* piSrcV = NULL;
509  xGetSampleStrTextPtrs  ( iSourceViewPos, piSrcY, piSrcU, piSrcV );
510#else
511  xGetSampleStrTextPtrs  ( iSourceViewPos, piSrcY );
512#endif
513 
514  for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )
515  {
516    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
517    {     
518      pcCurLimOutSampleRow[iPosX].iYOther      = pcCurOutSampleRow[iPosX].*piSrcY;
519      pcCurLimOutSampleRow[iPosX].iYRef        = pcCurOutSampleRow[iPosX].iYRef;
520
521#if H_3D_VSO_COLOR_PLANES     
522      pcCurLimOutSampleRow[iPosX].iUOther      = pcCurOutSampleRow[iPosX].*piSrcU;
523      pcCurLimOutSampleRow[iPosX].iURef        = pcCurOutSampleRow[iPosX].iURef;
524
525      pcCurLimOutSampleRow[iPosX].iVOther      = pcCurOutSampleRow[iPosX].*piSrcV;     
526      pcCurLimOutSampleRow[iPosX].iVRef        = pcCurOutSampleRow[iPosX].iVRef;
527#endif
528      pcCurLimOutSampleRow[iPosX].iDOther      = pcCurOutSampleRow[iPosX].*piDepth;     
529      pcCurLimOutSampleRow[iPosX].iFilledOther = pcCurOutSampleRow[iPosX].*piFilled;     
530      pcCurLimOutSampleRow[iPosX].iError       = pcCurOutSampleRow[iPosX].iError;     
531
532    } 
533    pcCurOutSampleRow    += m_iOutputSamplesStride; 
534    pcCurLimOutSampleRow += m_iOutputSamplesStride; 
535  }
536}
537
538template <BlenMod iBM, Bool bBitInc> Void
539#if RM_FIX_SETUP
540TRenSingleModelC<iBM,bBitInc>::setStructSynthViewAsRefView( )
541#else
[100]542TRenSingleModelC<iBM,bBitInc>::xSetStructSynthViewAsRefView( )
[1396]543#endif
[100]544{
545  AOT( m_iMode < 0 || m_iMode > 2);
[2]546
[100]547  RenModelOutPels* pcCurOutSampleRow = m_pcOutputSamples;
548
549  Pel RenModelOutPels::* piSrcY = NULL;
550
[608]551#if H_3D_VSO_COLOR_PLANES 
[100]552  Pel RenModelOutPels::* piSrcU = NULL;
553  Pel RenModelOutPels::* piSrcV = NULL;
554  xGetSampleStrTextPtrs( m_iMode, piSrcY, piSrcU, piSrcV );
555#else
556  xGetSampleStrTextPtrs( m_iMode, piSrcY );
557#endif
558
[124]559  for ( Int iPosY = 0; iPosY < m_iUsedHeight; iPosY++ )
[100]560  {
561    for ( Int iPosX = 0; iPosX < m_iWidth; iPosX++ )
562    {     
563      pcCurOutSampleRow[iPosX].iYRef = pcCurOutSampleRow[iPosX].*piSrcY;
[608]564#if H_3D_VSO_COLOR_PLANES
[100]565      pcCurOutSampleRow[iPosX].iURef = pcCurOutSampleRow[iPosX].*piSrcU;
566      pcCurOutSampleRow[iPosX].iVRef = pcCurOutSampleRow[iPosX].*piSrcV;
567#endif
568    } 
569    pcCurOutSampleRow += m_iOutputSamplesStride; 
570  }
[2]571}
572
[100]573template <BlenMod iBM, Bool bBitInc> Void
574TRenSingleModelC<iBM,bBitInc>::xInitSampleStructs()
[2]575{
[100]576  RenModelOutPels* pcOutSampleRow      = m_pcOutputSamples;
577  RenModelInPels * pcLeftInSampleRow   = m_pcInputSamples[0];
578  RenModelInPels * pcRightInSampleRow  = m_pcInputSamples[1];
579
580
581  for (Int iPosY = 0; iPosY < m_iHeight; iPosY++)
582  {
583    for (Int iPosX = 0; iPosX < m_iWidth; iPosX++)
584    {
585      //// Output Samples
586      pcOutSampleRow[iPosX].iFilledLeft   = REN_IS_HOLE;
587      pcOutSampleRow[iPosX].iFilledRight  = REN_IS_HOLE;
588
589      pcOutSampleRow[iPosX].iDLeft        = 0;
590      pcOutSampleRow[iPosX].iDRight       = 0;
591      pcOutSampleRow[iPosX].iDBlended     = 0;     
[1396]592      pcOutSampleRow[iPosX].iError        = 0; 
[100]593                                     
594      // Y Planes                   
595      pcOutSampleRow[iPosX].iYLeft        = 0;
596      pcOutSampleRow[iPosX].iYRight       = 0;
597      pcOutSampleRow[iPosX].iYBlended     = 0;
[608]598#if H_3D_VSO_COLOR_PLANES             
[100]599      // U Planes                   
[1313]600      pcOutSampleRow[iPosX].iULeft        = 1 << (REN_BIT_DEPTH  - 1);
601      pcOutSampleRow[iPosX].iURight       = 1 << (REN_BIT_DEPTH  - 1);
602      pcOutSampleRow[iPosX].iUBlended     = 1 << (REN_BIT_DEPTH  - 1);
603                                                 
604      // V Planes                                 
605      pcOutSampleRow[iPosX].iVLeft        = 1 << (REN_BIT_DEPTH  - 1);
606      pcOutSampleRow[iPosX].iVRight       = 1 << (REN_BIT_DEPTH  - 1);
607      pcOutSampleRow[iPosX].iVBlended     = 1 << (REN_BIT_DEPTH  - 1);
[100]608#endif
[1396]609  //// Input Samples
610      pcLeftInSampleRow [iPosX].aiOccludedPos = MAX_INT;
611      pcRightInSampleRow[iPosX].aiOccludedPos = MIN_INT;
[100]612    }
613
614    pcOutSampleRow     += m_iOutputSamplesStride;
615    pcLeftInSampleRow  += m_iInputSamplesStride;
616    pcRightInSampleRow += m_iInputSamplesStride;
617  } 
[2]618}
619
620
[608]621#if H_3D_VSO_EARLY_SKIP
[100]622template <BlenMod iBM, Bool bBitInc> RMDist
[1313]623TRenSingleModelC<iBM,bBitInc>::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData , const Pel * piOrgData, Int iOrgStride )
[100]624#else
625template <BlenMod iBM, Bool bBitInc> RMDist
[1313]626TRenSingleModelC<iBM,bBitInc>::getDistDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )
[100]627#endif
628{
629  RMDist iSSE = 0;
[608]630#if H_3D_VSO_EARLY_SKIP
[100]631  Bool   bEarlySkip;
632#endif
633  switch ( iViewPos )
634  {
635  case 0:
[608]636#if H_3D_VSO_EARLY_SKIP
[1396]637    bEarlySkip = m_bEarlySkip ? xDetectEarlySkip<true>(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData, iOrgStride) : false;
[100]638    if( !bEarlySkip )
639    {
[1396]640      iSSE = xRender<true, GET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
[100]641    }   
642#else
[1396]643    iSSE = xRender<true, GET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
[100]644#endif
645    break;
646  case 1:
[608]647#if H_3D_VSO_EARLY_SKIP
[1396]648    bEarlySkip = m_bEarlySkip ? xDetectEarlySkip<false>(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData, iOrgStride) : false;
[100]649    if( !bEarlySkip )
650    {
[1396]651      iSSE = xRender<false, GET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
[100]652    }   
653#else
[1396]654    iSSE = xRender<false, GET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
[100]655#endif
656    break;
657  default:
658    assert(0);
659  }
[2]660
[100]661  return iSSE;
662}
[608]663#if H_3D_VSO_EARLY_SKIP
[100]664template <BlenMod iBM, Bool bBitInc> Void
[1313]665TRenSingleModelC<iBM,bBitInc>::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride )
[100]666#else
667template <BlenMod iBM, Bool bBitInc> Void
[1313]668TRenSingleModelC<iBM,bBitInc>::setDepth( Int iViewPos, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )
[100]669#endif
[2]670{
[1396]671#if  H_3D_VSO_EARLY_SKIP
[100]672  Bool bEarlySkip;
673#endif
674  switch ( iViewPos )
675  {
676  case 0:
[608]677#if H_3D_VSO_EARLY_SKIP
[1396]678    bEarlySkip = m_bEarlySkip ? xDetectEarlySkip<true>(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData,iOrgStride) : false;
[100]679    if( !bEarlySkip )
680    {
[1396]681      xRender<true, SET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true );
[100]682    }   
683#else
[1396]684    xRender<true, SET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
[100]685#endif     
686    break;
687  case 1:
[608]688#if H_3D_VSO_EARLY_SKIP
[1396]689    bEarlySkip = m_bEarlySkip ? xDetectEarlySkip<false>(iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData, piOrgData,iOrgStride) : false;
[100]690    if( !bEarlySkip )
691    {
[1396]692      xRender<false, SET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData,true ); 
[100]693    }   
694#else
[1396]695    xRender<false, SET_SIMP>( iStartPosX,   iStartPosY,   iWidth,   iHeight,   iStride, piNewData );
[100]696#endif     
697    break;
698  default:
699    assert(0);
700  }
701}
[2]702
[100]703template <BlenMod iBM, Bool bBitInc> Void
[124]704TRenSingleModelC<iBM,bBitInc>::getSynthVideo( Int iViewPos, TComPicYuv* pcPicYuv )
705{ 
[1313]706  AOT( pcPicYuv->getWidth( COMPONENT_Y  )  != m_iWidth );
707  AOT( pcPicYuv->getChromaFormat()         != CHROMA_420 ); 
[124]708
[1313]709  AOT( pcPicYuv->getHeight( COMPONENT_Y ) < m_iUsedHeight + m_iHorOffset );
710
[608]711#if H_3D_VSO_COLOR_PLANES
[124]712  Pel RenModelOutPels::* piText[3] = { NULL, NULL, NULL };
713  xGetSampleStrTextPtrs(iViewPos, piText[0], piText[1], piText[2]); 
714
715  // Temp image for chroma down sampling
716  PelImage cTempImage( m_iWidth, m_iUsedHeight, 3, 0);
717
718  Int  aiStrides[3]; 
719  Pel* apiData  [3]; 
720
721  cTempImage.getDataAndStrides( apiData, aiStrides ); 
722
723  for (UInt uiCurPlane = 0; uiCurPlane < 3; uiCurPlane++ )
724  {
725    xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iUsedHeight);
726  } 
727  xCopy2PicYuv( apiData, aiStrides, pcPicYuv );
728#else
729  Pel RenModelOutPels::* piY;
730  xGetSampleStrTextPtrs(iViewPos, piY); 
[1396]731  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piY, pcPicYuv->getAddr(COMPONENT_Y) + m_iHorOffset * pcPicYuv->getStride(COMPONENT_Y), pcPicYuv->getStride(COMPONENT_Y), m_iWidth, m_iUsedHeight );
732  pcPicYuv->setChromaTo( 1 << (REN_BIT_DEPTH - 1) );   
[124]733#endif 
734}
[2]735
[124]736template <BlenMod iBM, Bool bBitInc> Void
737TRenSingleModelC<iBM,bBitInc>::getSynthDepth( Int iViewPos, TComPicYuv* pcPicYuv )
738{ 
739  AOT( iViewPos != 0 && iViewPos != 1); 
[1313]740  AOT( pcPicYuv->getWidth( COMPONENT_Y)  != m_iWidth  );
741  AOT( pcPicYuv->getChromaFormat( )  != CHROMA_420 );
742  AOT( pcPicYuv->getHeight( COMPONENT_Y ) < m_iUsedHeight + m_iHorOffset );
[100]743
[124]744  Pel RenModelOutPels::* piD = 0;
745  xGetSampleStrDepthPtrs(iViewPos, piD); 
[1313]746  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piD, pcPicYuv->getAddr( COMPONENT_Y ) + pcPicYuv->getStride( COMPONENT_Y ) * m_iHorOffset, pcPicYuv->getStride( COMPONENT_Y ), m_iWidth, m_iUsedHeight );
747  pcPicYuv->setChromaTo( 1 << (REN_BIT_DEPTH - 1) );   
[124]748}
749
[100]750
751template <BlenMod iBM, Bool bBitInc> Void
[124]752TRenSingleModelC<iBM,bBitInc>::getRefVideo ( Int iViewPos, TComPicYuv* pcPicYuv )
753{ 
[1313]754  AOT( pcPicYuv->getChromaFormat( ) != CHROMA_420 );
755  AOT( pcPicYuv->getWidth( COMPONENT_Y )  != m_iWidth  );
756  AOT( pcPicYuv->getHeight( COMPONENT_Y ) <  m_iUsedHeight + m_iHorOffset);
[124]757
[608]758#if H_3D_VSO_COLOR_PLANES
[124]759  Pel RenModelOutPels::* piText[3];
760  piText[0] = &RenModelOutPels::iYRef;
761  piText[1] = &RenModelOutPels::iURef;
762  piText[2] = &RenModelOutPels::iVRef;
763
764  // Temp image for chroma down sampling
765
766  PelImage cTempImage( m_iWidth, m_iUsedHeight, 3, 0);
767  Int  aiStrides[3]; 
768  Pel* apiData  [3]; 
769
770  cTempImage.getDataAndStrides( apiData, aiStrides ); 
771
772  for (UInt uiCurPlane = 0; uiCurPlane < 3; uiCurPlane++ )
773  {
774    xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, piText[uiCurPlane], apiData[uiCurPlane], aiStrides[uiCurPlane] , m_iWidth, m_iUsedHeight);
775  } 
776
777  xCopy2PicYuv( apiData, aiStrides, pcPicYuv );
778#else
[1396]779  xCopyFromSampleStruct( m_pcOutputSamples, m_iOutputSamplesStride, &RenModelOutPels::iYRef, pcPicYuv->getAddr(COMPONENT_Y), pcPicYuv->getStride(COMPONENT_Y), m_iWidth, m_iUsedHeight );
780  pcPicYuv->setChromaTo( 1 << ( REN_BIT_DEPTH - 1 ) );   
[124]781#endif 
782}
[2]783
[100]784template <BlenMod iBM, Bool bBitInc> RMDist
[1313]785TRenSingleModelC<iBM,bBitInc>::getDistVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )
[100]786{
787  AOF(false);
788  return 0;
[2]789}
790
[100]791template <BlenMod iBM, Bool bBitInc> Void
[1313]792TRenSingleModelC<iBM,bBitInc>::setVideo( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData )
[2]793{
[100]794  AOF(false);
795}
[2]796
[100]797
798
[1396]799template <BlenMod iBM, Bool bBitInc> template<SetMod bSM> __inline Void
[100]800TRenSingleModelC<iBM,bBitInc>::xSetViewRow( Int iPosY )
801{
802  m_pcInputSamplesRow[0] = m_pcInputSamples[0] + m_iInputSamplesStride  * iPosY;
803  m_pcInputSamplesRow[1] = m_pcInputSamples[1] + m_iInputSamplesStride  * iPosY;
[1396]804  if (bSM == SET_FULL || bSM == GET_FULL )
805  { 
806    m_pcOutputSamplesRow   = m_pcOutputSamples   + m_iOutputSamplesStride * iPosY; 
807  }
808  else
809  {
810    m_pcLimOutputSamplesRow   = m_pcLimOutputSamples  + m_iOutputSamplesStride * iPosY; 
811  }
[100]812}
813
[1396]814template <BlenMod iBM, Bool bBitInc> template<SetMod bSM> __inline Void
[100]815TRenSingleModelC<iBM,bBitInc>::xIncViewRow( )
816{
817  m_pcInputSamplesRow[0] += m_iInputSamplesStride ;
818  m_pcInputSamplesRow[1] += m_iInputSamplesStride ;
[1396]819 
820  if (bSM == SET_FULL || bSM == GET_FULL )
821  { 
822    m_pcOutputSamplesRow   += m_iOutputSamplesStride;
823  }
824  else
825  {
826    m_pcLimOutputSamplesRow   += m_iOutputSamplesStride;
827  }
[100]828}
[608]829#if H_3D_VSO_EARLY_SKIP
[1396]830template <BlenMod iBM, Bool bBitInc> template<SetMod bSM> __inline RMDist
831TRenSingleModelC<iBM,bBitInc>::xGetSSE( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast)
[100]832#else
[1396]833template <BlenMod iBM, Bool bBitInc> template<SetMod bSM> __inline RMDist
834TRenSingleModelC<iBM,bBitInc>::xGetSSE( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData)
[100]835#endif
836{
837  const Int iCurViewPos   = 0;
838  const Int iOtherViewPos = 1;
839
[1396]840  m_piNewDepthData   = piNewData; 
841  m_iNewDataWidth    = iWidth;     
842  m_iStartChangePosX = iStartPosX; 
[100]843
[2]844  if ((iWidth == 0) || (iHeight == 0))
845    return 0;
846
[1396]847  xSetViewRow<bSM>      ( iStartPosY);
[2]848
849  // Init Start
[1396]850  RMDist iError = 0;     
851  Int iStartChangePos = m_iStartChangePosX; 
852  Int iEndChangePos   = m_iStartChangePosX + iWidth - 1;
[2]853
854  for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )
[1396]855  {   
856    Int iPosXinNewData        = iWidth - 1;                       
857    for ( Int iCurPosX = iEndChangePos; iCurPosX >= iStartChangePos; iCurPosX-- )
[100]858    {
[1396]859      Int iCurDepth   = m_piNewDepthData[iPosXinNewData];
860      Int iOldDepth   = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD; 
861      Int iDiff = (iCurDepth - iOldDepth);
862      iError += iDiff * iDiff;
863      iPosXinNewData--; 
[100]864    }
[1396]865    xIncViewRow<bSM>();
[2]866    m_piNewDepthData += iStride;
867  }
868  return iError;
869}
870
[1396]871#if H_3D_VSO_EARLY_SKIP
872template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline RMDist
873TRenSingleModelC<iBM,bBitInc>::xRender( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, Bool bFast)
[100]874#else
[1396]875template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline RMDist
876TRenSingleModelC<iBM,bBitInc>::xRender( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData)
[100]877#endif
[2]878{
[1396]879  const Int iCurViewPos   = bL ? 0 : 1;
[2]880
881  m_piNewDepthData   = piNewData;
882  m_iNewDataWidth    = iWidth;
883  m_iStartChangePosX = iStartPosX;
884
885  if ((iWidth == 0) || (iHeight == 0))
[1396]886  {
[2]887    return 0;
[1396]888  }
[2]889
890  // Get Data
[100]891  m_ppiCurLUT      = m_appiShiftLut   [iCurViewPos];
[1396]892  xSetViewRow<bSM>( iStartPosY);
[2]893
894  // Init Start
895  RMDist iError = 0;
[1396]896  Int   iStartChangePos;
[2]897
[1396]898  iStartChangePos = m_iStartChangePosX + ( bL ? 0  : (iWidth - 1));
[2]899
900  for (Int iPosY = iStartPosY; iPosY < iStartPosY + iHeight; iPosY++ )
901  {
[608]902#if H_3D_VSO_EARLY_SKIP
[100]903    if( m_bEarlySkip && bFast )
904    {
905      if ( m_pbHorSkip[iPosY-iStartPosY] )
906      {
[1396]907        xIncViewRow<bSM>();
[100]908        m_piNewDepthData += iStride;
909        continue;
910      }
911    }
912#endif
[2]913    m_bInOcclusion = false;
914
915    Int iLastSPos;
[1396]916    Int iEndChangePos         = m_iStartChangePosX + ( bL ? (iWidth - 1) : 0 ) ;
[2]917
[1396]918    Int iEndChangePosInSubPel = iEndChangePos << m_iShiftPrec;
919    Int iPosXinNewData        = bL ? iWidth - 1 : 0; 
920    Int iMinChangedSPos       = bL ? m_iSampledWidth : -1;
921    if ( iEndChangePos == xWidthMinus1<bL>() )
[2]922    {
923      m_iCurDepth           = m_piNewDepthData[iPosXinNewData];
[1396]924      Int iCurSPos          = xShiftDept(iEndChangePosInSubPel, m_iCurDepth );
[100]925
[1396]926      m_curRangeStart       = xRangeLeft<bL>( iCurSPos );
927      xExtrapolateMargin<bL, bSM>  ( iCurSPos, iEndChangePos, iError );
928
929      Int iOldDepth          = m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD;
930      iMinChangedSPos        = xMin<Int, bL>( ( iOldDepth <= m_iCurDepth ) ? iCurSPos : xShiftDept(iEndChangePosInSubPel, iOldDepth ), iMinChangedSPos);
931      iLastSPos           = iCurSPos;
932      m_lastRangeStart    = m_curRangeStart;
933      m_iLastDepth        = m_iCurDepth;
934      m_iLastOccludedSPos = iLastSPos;
935
936      if ( bSM == SET_FULL || bSM == SET_SIMP )
[100]937      {
[1396]938        m_pcInputSamplesRow[iCurViewPos][iEndChangePos].iD = m_piNewDepthData[iPosXinNewData];
[100]939      }
940
[1396]941      xDec<Int, bL>(iPosXinNewData);
942      xDec<Int, bL>(iEndChangePos);
[2]943    }
944    else
945    {
[1396]946      m_iLastDepth = m_pcInputSamplesRow [iCurViewPos][xPlus<Int,bL>(iEndChangePos,1)].iD;
947      iLastSPos    = xShiftDept(xPlus<Int,bL>(iEndChangePosInSubPel, ( 1 << m_iShiftPrec ) ), m_iLastDepth );
948      xInitRenderPart<bL>( iEndChangePos, iLastSPos );
[2]949    }
950
951    //// RENDER NEW DATA
952    Int iCurPosX;
[1396]953    for ( iCurPosX = iEndChangePos; xGeQ<Int,bL>(iCurPosX,iStartChangePos); xDec<Int,bL>(iCurPosX))
[2]954    {
[1396]955      Int iCurPosXInSubPel = iCurPosX << m_iShiftPrec;
956      m_iCurDepth     = m_piNewDepthData[iPosXinNewData]        ;
957      Int iCurSPos    = xShiftDept(iCurPosXInSubPel,m_iCurDepth); 
[100]958
[1396]959      Int iOldDepth   = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;
960      iMinChangedSPos = xMin<Int,bL>( ( iOldDepth <= m_iCurDepth ) ? iCurSPos : xShiftDept(iCurPosXInSubPel, iOldDepth ), iMinChangedSPos);
961
962      xRenderRange<bL,bSM>(iCurSPos, iLastSPos, iCurPosX, iError );
963      iLastSPos       = iCurSPos;
[2]964      m_iLastDepth    = m_iCurDepth;
[100]965
[1396]966      if ( bSM == SET_FULL || bSM == SET_SIMP )
[100]967      {
968        m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD = m_piNewDepthData[iPosXinNewData];
969      }
[1396]970      xDec<Int,bL>(iPosXinNewData);
[2]971    }
972
973    //// RE-RENDER DATA LEFT TO NEW DATA
[1396]974
975    while ( xGeQ<Int,bL>(iCurPosX, xZero<bL>() ) )
[2]976    {
[1396]977      Int iCurPosXInSubPel = iCurPosX << m_iShiftPrec;
[100]978      m_iCurDepth  = m_pcInputSamplesRow[iCurViewPos][iCurPosX].iD;
[1396]979      Int iCurSPos = xShiftDept(iCurPosXInSubPel,m_iCurDepth);     
980      xRenderRange<bL,bSM>( iCurSPos, iLastSPos, iCurPosX, iError );
981      if ( xLess<Int,bL>(iCurSPos,iMinChangedSPos) )
982      {
983        break;
984      }
[100]985
[1396]986      xDec<Int,bL>(iCurPosX);
[2]987      iLastSPos    = iCurSPos;
988      m_iLastDepth = m_iCurDepth;
989    }
[100]990
[1396]991
992
993
994    xIncViewRow<bSM>();
[2]995    m_piNewDepthData += iStride;
996  }
997  return iError;
998}
999
[1396]1000template <BlenMod iBM, Bool bBitInc> template<Bool bL> __inline Void
1001TRenSingleModelC<iBM,bBitInc>::xInitRenderPart(  Int iEndChangePos, Int iLastSPos )
[2]1002{
[1396]1003  const Int iCurViewPos = bL ? 0 : 1;   
1004  m_iLastOccludedSPos = m_pcInputSamplesRow[iCurViewPos][ xPlus<Int,bL>(iEndChangePos,1) ].aiOccludedPos; 
1005  m_bInOcclusion      = xGeQ<Int,bL>( iLastSPos, m_iLastOccludedSPos ); 
[2]1006
[1396]1007  if( m_bInOcclusion )
[2]1008  {
[1396]1009    m_lastRangeStart = xRound<bL>( m_iLastOccludedSPos ); 
[2]1010  }
1011  else
1012  {
[1396]1013    m_iLastOccludedSPos = iLastSPos; 
1014    m_lastRangeStart = xRangeLeft<bL>( iLastSPos ); 
[2]1015  }
1016};
1017
[1396]1018template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline Void
1019TRenSingleModelC<iBM,bBitInc>::xRenderShiftedRange(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
[2]1020{
[1396]1021  RM_AOF( (xGeQ<Int,bL>(iLastSPos,iCurSPos)) );
1022  Int iDeltaSPos = bL ? iLastSPos - iCurSPos : iCurSPos - iLastSPos;
[2]1023
[1396]1024  m_curRangeStart = xRangeLeft<bL>( iCurSPos ); 
[2]1025  if ( iDeltaSPos > m_iGapTolerance )
1026  {
[1396]1027    xFillHole<bL,bSM>( iCurSPos, iLastSPos, iCurPos, riError );
[2]1028  }
1029  else
1030  {
[1396]1031    if (!xGeQ<Int,bL>(iLastSPos, bL ? 0 : ( m_iSampledWidth - 1) ))
1032    {
[2]1033      return;
[1396]1034    }
[2]1035
[100]1036    RM_AOT( iDeltaSPos    > m_iGapTolerance );
[2]1037
1038    m_iThisDepth = m_iCurDepth;
[1396]1039
1040    for (Int iFillSPos = xMax<Int,bL>(xZero<bL>(), m_curRangeStart ); xLess<Int,bL>(iFillSPos,m_lastRangeStart); xInc<Int,bL>(iFillSPos))
[2]1041    {
[1396]1042      Int iDeltaCurSPos  = (iFillSPos << m_iShiftPrec) - (bL ? iCurSPos : iLastSPos); 
[2]1043
[100]1044      RM_AOT( iDeltaCurSPos > iDeltaSPos );
1045      RM_AOT( iDeltaCurSPos < 0 );
1046      RM_AOT( m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos] == 0xdeaddead);
[2]1047
[1396]1048      xSetShiftedPel<bL, bSM>( iCurPos, m_aaiSubPelShiftL[iDeltaSPos][iDeltaCurSPos], iFillSPos, REN_IS_FILLED, riError );
[2]1049    }
1050  };
[1396]1051  m_lastRangeStart = m_curRangeStart; 
[2]1052}
1053
[1396]1054template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline Void
1055TRenSingleModelC<iBM,bBitInc>::xRenderRange(Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
[2]1056{
[1396]1057  const Int iCurViewPos = bL ? 0 : 1; 
[2]1058
[1396]1059  if ( bSM == SET_FULL || bSM == SET_SIMP )
[2]1060  {
[1396]1061    m_pcInputSamplesRow[iCurViewPos][ iCurPos ].aiOccludedPos = m_iLastOccludedSPos;
[2]1062  }
1063
[1396]1064  if ( xLess<Int,bL>(iCurSPos,m_iLastOccludedSPos ))
[2]1065  {
[1396]1066    m_bInOcclusion      = false;
1067    m_iLastOccludedSPos = iCurSPos; 
1068    xRenderShiftedRange<bL,bSM>(iCurSPos, iLastSPos, iCurPos, riError );
[2]1069  }
1070  else
1071  {
[1396]1072    if ( !m_bInOcclusion )
1073    {     
1074      RM_AOF( (xGeQ<Int,bL>(iLastSPos, m_iLastOccludedSPos)) ); 
1075      Int iRightSPosFP = xRound<bL>( iLastSPos );     
1076      if ( ( iRightSPosFP == xPlus<Int,bL>(m_lastRangeStart, -1) ) && xGeQ<Int,bL>(iRightSPosFP, xZero<bL>()) )
[2]1077      {
1078        m_iThisDepth = m_iLastDepth;
[1396]1079        xSetShiftedPel<bL, bSM>( xPlus<Int,bL>(iCurPos,1), bL ? 0 : (1 << m_iShiftPrec), iRightSPosFP, REN_IS_FILLED, riError );
[2]1080      }
[1396]1081      m_lastRangeStart = iRightSPosFP;
1082      m_bInOcclusion   = true; 
[2]1083    }
1084  }
1085}
1086
[1396]1087template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline Void
1088TRenSingleModelC<iBM,bBitInc>::xFillHole( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError )
[2]1089{
1090  if (iLastSPos < 0)
[1396]1091  {
[2]1092    return;
[1396]1093  }
[2]1094
1095  Int iStartFillSPos = iCurSPos;
1096  Int iStartFillPos  = iCurPos;
[1396]1097  Int iLastPos       = xPlus<Int,bL>( iCurPos,1);
[2]1098
[1396]1099  Int iStartFillSPosFP = m_curRangeStart; 
1100  if (iStartFillSPosFP == xRound<bL>(iStartFillSPos))
[2]1101  {
[1396]1102    if ( xGeQ<Int,bL>(iStartFillSPosFP, xZero<bL>())  && xLess<Int,bL>(iStartFillSPosFP, m_lastRangeStart) )
[2]1103    {
1104      m_iThisDepth = m_iCurDepth;
[1396]1105      xSetShiftedPel<bL, bSM>    ( iStartFillPos, bL ? 0 : ( 1 << m_iShiftPrec), iStartFillSPosFP, REN_IS_FILLED, riError );
[2]1106    }
1107  }
1108  else
1109  {
[1396]1110    xDec<Int,bL>( iStartFillSPosFP );
[2]1111  }
1112
1113  m_iThisDepth = m_iLastDepth;
[1396]1114  for (Int iFillSPos = xMax<Int,bL>(xPlus<Int,bL>(iStartFillSPosFP,1),xZero<bL>()); xLess<Int,bL>(iFillSPos, m_lastRangeStart); xInc<Int,bL>(iFillSPos))
[2]1115  {
[1396]1116    xSetShiftedPel<bL, bSM>( iLastPos, bL ? 0 : (1 << m_iShiftPrec),  iFillSPos, REN_IS_HOLE, riError );
[2]1117  }
1118}
1119
[1396]1120template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline Void
1121TRenSingleModelC<iBM,bBitInc>::xExtrapolateMargin(Int iCurSPos, Int iCurPos, RMDist& riError )
[2]1122{
[1396]1123  Int iSPosFullPel = xMax<Int,bL>(xZero<bL>(),m_curRangeStart);
[2]1124
1125  m_iThisDepth = m_iCurDepth;
[1396]1126  if ( xGeQ<Int,bL>(xWidthMinus1<bL>(), iSPosFullPel) )
[2]1127  {
[1396]1128    xSetShiftedPel<bL, bSM>( iCurPos, bL ? 0 : (1 << m_iShiftPrec) , iSPosFullPel, REN_IS_FILLED, riError );
[2]1129  }
[1396]1130  for (Int iFillSPos = xPlus<Int,bL>(iSPosFullPel ,1); xGeQ<Int,bL>( xWidthMinus1<bL>(), iFillSPos ); xInc<Int,bL>(iFillSPos))
[2]1131  {
[1396]1132    xSetShiftedPel<bL, bSM>( iCurPos, bL ? 0 : ( 1 << m_iShiftPrec ), iFillSPos, REN_IS_HOLE, riError );
[2]1133  }
1134}
1135
[1396]1136template <BlenMod iBM, Bool bBitInc> template <Bool bL> __inline Int
[100]1137TRenSingleModelC<iBM,bBitInc>::xShiftNewData( Int iPosX, Int iPosInNewData )
[2]1138{
[100]1139  RM_AOT( iPosInNewData <               0 );
1140  RM_AOF( iPosInNewData < m_iNewDataWidth );
1141  return (iPosX << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_piNewDepthData[iPosInNewData] )];
[2]1142}
1143
[1396]1144
[100]1145template <BlenMod iBM, Bool bBitInc> __inline Int
[1396]1146TRenSingleModelC<iBM,bBitInc>::xShiftDept( Int iPosXinSubPel, Int iDepth )
1147{
1148  return (iPosXinSubPel) - m_ppiCurLUT[0][ RenModRemoveBitInc( iDepth )];
1149}
1150
1151
1152template <BlenMod iBM, Bool bBitInc> template <Bool bL> __inline Int
[100]1153TRenSingleModelC<iBM,bBitInc>::xShift( Int iPosX )
[2]1154{
[100]1155 RM_AOT( iPosX <        0);
1156 RM_AOF( iPosX < m_iWidth);
[1396]1157 return (iPosX  << m_iShiftPrec) - m_ppiCurLUT[0][ RenModRemoveBitInc( m_pcInputSamplesRow[(bL ? 0 : 1)][iPosX].iD )];
[2]1158}
1159
1160
[1396]1161template <BlenMod iBM, Bool bBitInc> template <Bool bL> __inline Int
[100]1162TRenSingleModelC<iBM,bBitInc>::xShift( Int iPos, Int iPosInNewData )
[2]1163{
1164  if ( (iPosInNewData >= 0) && (iPosInNewData < m_iNewDataWidth) )
1165  {
1166    return xShiftNewData(iPos ,iPosInNewData );
1167  }
1168  else
1169  {
[1396]1170    return xShift<bL>(iPos);
[2]1171  }
1172}
1173
[1396]1174template <BlenMod iBM, Bool bBitInc> template<Bool bL> __inline Int
1175TRenSingleModelC<iBM,bBitInc>::xRangeLeft( Int iPos )
[2]1176{
[1396]1177  if ( bL )
1178  {
1179    return  ( iPos +  (1 << m_iShiftPrec) - 1) >> m_iShiftPrec;
1180  }
1181  else
1182  {
1183    return iPos >> m_iShiftPrec;
1184  }
[2]1185}
1186
1187
1188
[1396]1189template <BlenMod iBM, Bool bBitInc> template<Bool bL> __inline Int
1190TRenSingleModelC<iBM,bBitInc>::xRangeRight( Int iPos )
[2]1191{
[1396]1192  if ( bL )
1193  {
1194    return xRangeLeft<true>(iPos)    - 1;
1195  }
1196  else
1197  {
1198    return xRangeLeft<false>( iPos ) + 1;   
1199  } 
[2]1200}
1201
[1396]1202template <BlenMod iBM, Bool bBitInc> template<Bool bL> __inline Int
1203TRenSingleModelC<iBM,bBitInc>::xRound( Int iPos )
[2]1204{
[1396]1205  if( bL )
1206  { 
1207    return  (iPos + (( 1 << m_iShiftPrec ) >> 1 )) >> m_iShiftPrec;
1208  }
1209  else
1210  {
1211    return  (m_iShiftPrec == 0) ? iPos : xRound<true>(iPos - 1);
1212  }
[2]1213}
1214
1215
[100]1216template <BlenMod iBM, Bool bBitInc> Void
1217TRenSingleModelC<iBM,bBitInc>::xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal )
[2]1218{
1219  for (Int iYPos = 0; iYPos < iHeight; iYPos++)
1220  {
1221    for (Int iXPos = 0; iXPos < iWidth; iXPos++)
1222    {
1223      piPelSource[iXPos] = iVal;
1224    }
1225    piPelSource += iSourceStride;
1226  }
1227}
1228
[100]1229template <BlenMod iBM, Bool bBitInc> Void
1230TRenSingleModelC<iBM,bBitInc>::xSetInts( Int* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal )
[2]1231{
1232  for (Int iYPos = 0; iYPos < iHeight; iYPos++)
1233  {
1234    for (Int iXPos = 0; iXPos < iWidth; iXPos++)
1235    {
1236      piPelSource[iXPos] = iVal;
1237    }
1238    piPelSource += iSourceStride;
1239  }
1240}
1241
1242
[100]1243template <BlenMod iBM, Bool bBitInc> Void
1244TRenSingleModelC<iBM,bBitInc>::xSetBools( Bool* pbPelSource , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal )
[2]1245{
1246  for (Int iYPos = 0; iYPos < iHeight; iYPos++)
1247  {
1248    for (Int iXPos = 0; iXPos < iWidth; iXPos++)
1249    {
1250      pbPelSource[iXPos] = bVal;
1251    }
1252    pbPelSource += iSourceStride;
1253  }
1254}
1255
[1396]1256template <BlenMod iBM, Bool bBitInc> template<Bool bL, SetMod bSM> __inline Void
1257TRenSingleModelC<iBM,bBitInc>::xSetShiftedPel(Int iSourcePos, Int iSubSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError )
[2]1258{
[100]1259  RM_AOT( iSourcePos    <  0                   );
1260  RM_AOT( iSourcePos    >= m_iWidth            );
1261  RM_AOT( iSubSourcePos < 0                    );
1262  RM_AOT( iSubSourcePos >  (1 << m_iShiftPrec) );
1263  RM_AOT( iTargetSPos   < 0                    );
[1396]1264  RM_AOT( iTargetSPos   >= m_iWidth            );
[2]1265
[1396]1266  RenModelInPels * pcInSample  = m_pcInputSamplesRow[ bL ? VIEWPOS_LEFT : VIEWPOS_RIGHT ] + iSourcePos ;
[2]1267
[1396]1268  Pel iY;
1269  Pel iYCurNew = pcInSample->aiY[iSubSourcePos];   
[608]1270#if H_3D_VSO_COLOR_PLANES
[1396]1271  Pel iU;
1272  Pel iUCurNew = pcInSample->aiU[iSubSourcePos];
1273  Pel iV;
1274  Pel iVCurNew = pcInSample->aiV[iSubSourcePos];;
[100]1275#endif   
[2]1276
[1396]1277  const Bool bFullMode = ( bSM == GET_FULL || bSM == SET_FULL ); 
[100]1278
[1396]1279  RenModelOutPels*    pcOutSample    = bFullMode ? ( m_pcOutputSamplesRow    + iTargetSPos ) : NULL; 
1280  RenModelLimOutPels* pcLimOutSample = bFullMode ? NULL  : ( m_pcLimOutputSamplesRow + iTargetSPos ); 
[100]1281
[1396]1282  if ( iBM == BLEND_NONE )
[2]1283  {
[1396]1284    iY = iYCurNew; 
[608]1285#if H_3D_VSO_COLOR_PLANES
[1396]1286    iU = iUCurNew; 
1287    iV = iVCurNew; 
[2]1288#endif
1289  }
[100]1290  else
1291  { 
[1396]1292    Pel iYOther      = bFullMode ? ( bL ? pcOutSample->iYRight : pcOutSample->iYLeft) : pcLimOutSample->iYOther; 
[608]1293#if H_3D_VSO_COLOR_PLANES
[1396]1294    Pel iUOther      = bFullMode ? ( bL ? pcOutSample->iURight : pcOutSample->iULeft ) : pcLimOutSample->iUOther; 
1295    Pel iVOther      = bFullMode ? ( bL ? pcOutSample->iVRight : pcOutSample->iVLeft ) : pcLimOutSample->iVOther; 
1296#endif
1297    Int iFilledOther = bFullMode ? ( bL ? pcOutSample->iFilledRight : pcOutSample->iFilledLeft ) : pcLimOutSample->iFilledOther; 
1298    Pel iDOther      = bFullMode ? ( bL ? pcOutSample->iDRight      : pcOutSample->iDLeft      ) : pcLimOutSample->iDOther; 
[2]1299
[1396]1300    xGetBlendedValue<bL, bSM>(
1301      iY,
1302      bL ? iYCurNew : iYOther,
1303      bL ? iYOther  : iYCurNew,
[608]1304#if H_3D_VSO_COLOR_PLANES
[1396]1305      iU,
1306      bL ? iUCurNew  : iUOther,
1307      bL ? iUOther   : iUCurNew,
1308      iV,
1309      bL ? iVCurNew  : iVOther,
1310      bL ? iVOther   : iVCurNew,         
[2]1311#endif
[1396]1312      bL ? iFilled      : iFilledOther,
1313      bL ? iFilledOther : iFilled,
1314      m_piInvZLUTLeft [RenModRemoveBitInc( bL ? m_iThisDepth : iDOther)],
1315      m_piInvZLUTRight[RenModRemoveBitInc( bL ? iDOther      : m_iThisDepth)]
1316      ); 
[100]1317  }
1318
1319
[1396]1320  Int iDist = xGetDist( 
1321    iY - ( bFullMode ? pcOutSample->iYRef : pcLimOutSample->iYRef ) 
[608]1322#if H_3D_VSO_COLOR_PLANES
[1396]1323  , iU - ( bFullMode ? pcOutSample->iURef : pcLimOutSample->iURef )
1324  , iV - ( bFullMode ? pcOutSample->iVRef : pcLimOutSample->iVRef )
[2]1325#endif
[1396]1326  );
[2]1327
[1396]1328  if ( bSM == GET_FULL || bSM == GET_SIMP )
[100]1329  {   
[1396]1330    riError += ( iDist - ( bFullMode ? pcOutSample->iError : pcLimOutSample->iError ) );
[2]1331  }
[1396]1332  else // bSM == SET_FULL
[2]1333  {
[1396]1334    Int& riErrorStr = bFullMode ? pcOutSample->iError : pcLimOutSample->iError; 
1335    riErrorStr      = iDist; 
1336
1337    if ( bFullMode )
1338    {     
1339      if ( iBM != BLEND_NONE )
1340      {       
1341        pcOutSample->iYBlended   = iY; 
[608]1342#if H_3D_VSO_COLOR_PLANES
[1396]1343        pcOutSample->iUBlended   = iU; 
1344        pcOutSample->iVBlended   = iV; 
[2]1345#endif
[1396]1346      }
1347
1348      if ( bL )
1349      {
1350        pcOutSample->iDLeft      = m_iThisDepth; 
1351        pcOutSample->iFilledLeft = iFilled; 
1352        pcOutSample->iYLeft      = iYCurNew;
1353#if  H_3D_VSO_COLOR_PLANES
1354        pcOutSample->iULeft      = iUCurNew;
1355        pcOutSample->iVLeft      = iVCurNew;
1356#endif
1357      }
1358      else
1359      {
1360        pcOutSample->iDRight      = m_iThisDepth; 
1361        pcOutSample->iFilledRight = iFilled; 
1362        pcOutSample->iYRight      = iYCurNew;
1363#if  H_3D_VSO_COLOR_PLANES
1364        pcOutSample->iURight      = iUCurNew;
1365        pcOutSample->iVRight      = iVCurNew;
1366#endif
1367      }
1368    }
1369  }   
[2]1370}
1371
[100]1372template <BlenMod iBM, Bool bBitInc> __inline Int
1373TRenSingleModelC<iBM,bBitInc>::xGetDist( Int iDiffY, Int iDiffU, Int iDiffV )
1374{
[2]1375
[100]1376  if ( !bBitInc )
1377  {
1378    return (          (iDiffY * iDiffY )
1379               +  ((( (iDiffU * iDiffU )
1380                     +(iDiffV * iDiffV )
1381                    )
1382                   ) >> 2
[2]1383                  )
[100]1384           );
1385  }
1386  else
1387  {
1388    return (          ((iDiffY * iDiffY) >> m_iDistShift)
1389               +  ((( ((iDiffU * iDiffU) >> m_iDistShift)
1390                     +((iDiffV * iDiffV) >> m_iDistShift)
1391                    )
1392                   ) >> 2
1393                  )
1394           );
1395 
1396  }
[2]1397}
1398
[100]1399template <BlenMod iBM, Bool bBitInc> __inline Int
1400TRenSingleModelC<iBM,bBitInc>::xGetDist( Int iDiffY )
[2]1401{
[100]1402  if ( !bBitInc )
1403  {
1404    return (iDiffY * iDiffY);
1405  }
1406  else
1407  {
1408    return ((iDiffY * iDiffY) >> m_iDistShift);
1409  }
1410
[2]1411}
1412
[100]1413
[1396]1414
1415template <BlenMod iBM, Bool bBitInc>  template< Bool bL, SetMod bSM > __inline Void
1416  TRenSingleModelC<iBM,bBitInc>::xGetBlendedValue( Pel& riY, Pel iYL,  Pel iYR, 
[608]1417#if H_3D_VSO_COLOR_PLANES
[1396]1418                                                   Pel& riU, Pel iUL,  Pel iUR,  Pel& riV, Pel iVL,  Pel iVR, 
[2]1419#endif
[1396]1420                                                   Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR  )
1421{ 
[100]1422  RM_AOT( iBM != BLEND_AVRG && iBM != BLEND_LEFT && iBM != BLEND_RIGHT );
1423
1424  if (iBM != BLEND_AVRG )
[2]1425  {
[100]1426    if (iBM == BLEND_LEFT )
[2]1427    {
[1396]1428      xGetBlendedValueBM1<bL, bSM>( riY, iYL,  iYR, 
[608]1429#if H_3D_VSO_COLOR_PLANES
[1396]1430        riU, iUL,  iUR,  riV, iVL,  iVR, 
[5]1431#endif
[1396]1432        iFilledL,  iFilledR, iDepthL,  iDepthR  );
[2]1433    }
1434    else
1435    {
[1396]1436      xGetBlendedValueBM2<bL, bSM>(  riY, iYL,  iYR, 
[608]1437#if H_3D_VSO_COLOR_PLANES
[1396]1438        riU, iUL,  iUR,  riV, iVL,  iVR, 
[5]1439#endif
[1396]1440        iFilledL,  iFilledR, iDepthL,  iDepthR );
[2]1441    }
1442    return;
1443  }
1444
1445  if (  (iFilledL != REN_IS_HOLE ) && ( iFilledR != REN_IS_HOLE) )
1446  {
1447    Int iDepthDifference = iDepthR - iDepthL;
1448
1449    if ( abs ( iDepthDifference ) <= m_iBlendZThres )
1450    {
1451      {
[81]1452        riY = xBlend( iYL, iYR, m_iBlendDistWeight );
[608]1453#if H_3D_VSO_COLOR_PLANES   
[81]1454        riU = xBlend( iUL, iUR, m_iBlendDistWeight );
1455        riV = xBlend( iVL, iVR, m_iBlendDistWeight );
1456#endif
[2]1457      }
1458    }
1459    else if ( iDepthDifference < 0 )
1460    {
1461      riY = iYL;
[608]1462#if H_3D_VSO_COLOR_PLANES
[2]1463      riU = iUL;
1464      riV = iVL;
1465#endif
1466    }
1467    else
[1396]1468    {     
[2]1469      riY = iYR;
[608]1470#if H_3D_VSO_COLOR_PLANES
[2]1471      riU = iUR;
1472      riV = iVR;
1473#endif
1474    }
1475  }
1476  else if ( (iFilledL == REN_IS_HOLE) && (iFilledR == REN_IS_HOLE))
1477  {
1478    if ( iDepthR < iDepthL )
1479    {
1480        riY =  iYR;
[608]1481#if H_3D_VSO_COLOR_PLANES
[2]1482        riU =  iUR;
1483        riV =  iVR;
1484#endif
1485    }
1486    else
1487    {
1488        riY =  iYL;
[608]1489#if H_3D_VSO_COLOR_PLANES
[2]1490        riU =  iUL;
1491        riV =  iVL;
1492#endif
1493    }
1494  }
1495  else
1496  {
1497    if (iFilledR == REN_IS_HOLE)
1498    {
1499        riY = iYL;
[608]1500#if H_3D_VSO_COLOR_PLANES
[2]1501        riU = iUL;
1502        riV = iVL;
1503#endif
1504    }
1505    else
1506    {
1507      riY = iYR;
[608]1508#if H_3D_VSO_COLOR_PLANES
[2]1509      riU = iUR;
1510      riV = iVR;
1511#endif
1512    }
1513  }
1514}
1515
[1396]1516template <BlenMod iBM, Bool bBitInc> template< Bool bL, SetMod SM > __inline Void
1517TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM1( Pel& riY, Pel iYL,  Pel iYR, 
[608]1518#if H_3D_VSO_COLOR_PLANES
[1396]1519                                                    Pel& riU, Pel iUL,  Pel iUR,  Pel& riV, Pel iVL,  Pel iVR, 
[5]1520#endif
[1396]1521                                                    Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR  )
[2]1522{
[100]1523  if ( iFilledL == REN_IS_FILLED ||  iFilledR == REN_IS_HOLE )
[2]1524  {
1525    riY = iYL;
[608]1526#if H_3D_VSO_COLOR_PLANES
[2]1527    riU = iUL;
1528    riV = iVL;
1529#endif
1530  }
1531  else if ( iFilledL == REN_IS_HOLE  )
1532  {
1533    riY = iYR;
[608]1534#if H_3D_VSO_COLOR_PLANES
[2]1535    riU = iUR;
1536    riV = iVR;
1537#endif
1538  }
1539  else
1540  {
1541    riY = xBlend( iYR, iYL, iFilledL );
[608]1542#if H_3D_VSO_COLOR_PLANES
[2]1543    riU = xBlend( iUR, iUL, iFilledL );
1544    riV = xBlend( iVR, iUL, iFilledL );
1545#endif
1546  }
1547}
1548
[1396]1549template <BlenMod iBM, Bool bBitInc> template< Bool bL, SetMod SM > __inline Void
1550  TRenSingleModelC<iBM,bBitInc>::xGetBlendedValueBM2( Pel& riY, Pel iYL,  Pel iYR, 
[608]1551#if H_3D_VSO_COLOR_PLANES
[1396]1552                                                      Pel& riU, Pel iUL,  Pel iUR,  Pel& riV, Pel iVL,  Pel iVR, 
[5]1553#endif
[1396]1554                                                      Int iFilledL,  Int iFilledR, Pel iDepthL,  Pel iDepthR  )
[2]1555{
1556  if      ( iFilledR == REN_IS_FILLED ||  iFilledL == REN_IS_HOLE )
1557  {
1558    riY = iYR;
[608]1559#if H_3D_VSO_COLOR_PLANES
[2]1560    riU = iUR;
1561    riV = iVR;
1562#endif
1563  }
1564  else if ( iFilledR == REN_IS_HOLE  )
1565  {
1566    riY = iYL;
[608]1567#if H_3D_VSO_COLOR_PLANES
[2]1568    riU = iUL;
1569    riV = iVL;
1570#endif
1571  }
1572  else
1573  {
1574    riY = xBlend( iYL, iYR, iFilledR );
[608]1575#if H_3D_VSO_COLOR_PLANES
[2]1576    riU = xBlend( iUL, iUR, iFilledR );
1577    riV = xBlend( iVL, iUR, iFilledR );
1578#endif
1579  }
1580}
1581
[100]1582template <BlenMod iBM, Bool bBitInc> __inline Pel
1583TRenSingleModelC<iBM,bBitInc>::xBlend( Pel pVal1, Pel pVal2, Int iWeightVal2 )
[2]1584{
1585  return pVal1  +  (Pel) (  ( (Int) ( pVal2 - pVal1) * iWeightVal2 + (1 << (REN_VDWEIGHT_PREC - 1)) ) >> REN_VDWEIGHT_PREC );
1586}
[100]1587
1588template <BlenMod iBM, Bool bBitInc> Void
[124]1589TRenSingleModelC<iBM,bBitInc>::xCopy2PicYuv( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget )
1590{
[1313]1591  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 ) );
1592  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) );
1593  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) );
[124]1594}
[100]1595
1596template class TRenSingleModelC<BLEND_NONE ,true>;
1597template class TRenSingleModelC<BLEND_AVRG ,true>;
1598template class TRenSingleModelC<BLEND_LEFT ,true>;
1599template class TRenSingleModelC<BLEND_RIGHT,true>;
1600
1601template class TRenSingleModelC<BLEND_NONE ,false>;
1602template class TRenSingleModelC<BLEND_AVRG ,false>;
1603template class TRenSingleModelC<BLEND_LEFT ,false>;
1604template class TRenSingleModelC<BLEND_RIGHT,false>;
1605
[608]1606#if H_3D_VSO_EARLY_SKIP
[1396]1607template <BlenMod iBM, Bool bBitInc> template <Bool bL > __inline Bool
1608TRenSingleModelC<iBM,bBitInc>::xDetectEarlySkip( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, const Pel* piNewData, const Pel* piOrgData, Int iOrgStride)
[100]1609{
1610  RM_AOF( m_bEarlySkip ); 
[1396]1611  const Int iCurViewPos = bL ? 0 : 1;
[100]1612  Int** ppiCurLUT       = m_appiShiftLut   [ iCurViewPos ];
1613 
1614  Bool bNoDiff          = true;   
1615 
1616  for (Int iPosY=0; iPosY < iHeight; iPosY++)
1617  {
1618    m_pbHorSkip[iPosY] = true;
1619
1620    for (Int iPosX = 0; iPosX < iWidth; iPosX++)
1621    {
1622      Int iDisparityRec = abs(ppiCurLUT[0][ RenModRemoveBitInc(piNewData[iPosX])]);
1623      Int iDispartyOrg  = abs(ppiCurLUT[0][ RenModRemoveBitInc(piOrgData[iPosX])]);
1624
1625      if( iDispartyOrg != iDisparityRec)
1626      {
1627        m_pbHorSkip[iPosY] = false;
1628        bNoDiff            = false;
1629        break;
1630      }
1631    }
1632    piNewData += iStride;
1633    piOrgData += iOrgStride;
1634  }
1635  return bNoDiff;
1636}
[189]1637#endif
[1313]1638#endif // NH_3D
[210]1639
Note: See TracBrowser for help on using the repository browser.