source: 3DVCSoftware/branches/0.3-nokia/source/Lib/TLibRenderer/TRenSingleModel.h @ 122

Last change on this file since 122 was 5, checked in by hhi, 13 years ago

Clean version with cfg-files

  • Property svn:eol-style set to native
File size: 10.4 KB
Line 
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-2011, 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
35
36
37#ifndef __TRENSINGLEMODEL__
38#define __TRENSINGLEMODEL__
39
40#include "TRenImage.h"
41#include "../TLibCommon/CommonDef.h"
42#include "../TLibCommon/TComPicYuv.h"
43#include "../TLibCommon/TypeDef.h"
44#include "../../App/TAppCommon/TAppComCamPara.h"
45
46
47#include <math.h>
48#include <errno.h>
49#include <iostream>
50
51#include <string>
52#include <cstdio>
53#include <cstring>
54
55
56using namespace std;
57
58
59class TRenSingleModel
60{
61
62public:
63  TRenSingleModel();
64  ~TRenSingleModel();
65
66  // Create Model
67  Void   create    ( Int iMode, Int iWidth, Int iHeight, Int iShiftPrec, Int*** aaaiSubPelShiftTable, Int iHoleMargin, Bool bUseOrgRef, Int iBlendMode );
68
69  // Set Frame dependent data
70  Void   setLRView ( Int iViewPos, Pel** apiCurVideoPel, Int* aiCurVideoStride, Pel* piCurDepthPel, Int iCurDepthStride );
71  Void   setup     ( TComPicYuv* pcOrgVideo, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight,  Int** ppiBaseShiftLutRight,  Int iDistToLeft, Bool bKeepReference );
72
73  // Set Data
74  Void   setDepth  ( Int iViewPos,                 Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
75  Void   setVideo  ( Int iViewPos,     Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
76
77  // Get Distortion
78  RMDist getDistDepth  ( Int iViewPos,             Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
79  RMDist getDistVideo  ( Int iViewPos, Int iPlane, Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData );
80
81  // Get Rendered Data
82  Void   getSynthView( Int iViewPos, Pel**& rppiRenVideoPel, Pel*& rpiRenDepthPel, Int& riStride );
83
84  // Get Reference Data
85  Void   getRefView  ( TComPicYuv*& rpcPicYuvRefView, Pel**& rppiRefVideoPel, Int*& raiStrides );
86
87private:
88  // Set and inc Current Row
89  __inline Void   xSetViewRow(  Int iPosY );
90  __inline Void   xIncViewRow();
91
92  /////  Rendering /////
93  // Left to Right
94  __inline RMDist xRenderL            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bSet);
95  __inline Void   xInitRenderPartL    ( Int iEndChangePos, Int iLastSPos  );
96  __inline Void   xRenderRangeL       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
97  __inline Void   xRenderShiftedRangeL( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
98  __inline Void   xFillHoleL          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
99  __inline Void   xExtrapolateMarginL ( Int iCurSPos,                Int iCurPos, RMDist& riError );
100  __inline Int    xRangeLeftL         ( Int iPos );
101  __inline Int    xRangeRightL        ( Int iPos );
102  __inline Int    xRoundL             ( Int iPos );
103
104  // Right to Left
105  __inline RMDist xRenderR            ( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData, Bool bSet );
106  __inline Void   xInitRenderPartR    ( Int iStartChangePos, Int iLastSPos );
107  __inline Void   xRenderShiftedRangeR( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
108  __inline Void   xRenderRangeR       ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
109  __inline Void   xFillHoleR          ( Int iCurSPos, Int iLastSPos, Int iCurPos, RMDist& riError );
110  __inline Void   xExtrapolateMarginR ( Int iCurSPos,                Int iCurPos, RMDist& riError );
111  __inline Int    xRangeLeftR         ( Int iPos );
112  __inline Int    xRangeRightR        ( Int iPos );
113  __inline Int    xRoundR             ( Int iPos );
114
115  // Blending
116  __inline Void   xSetShiftedPelBlend ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
117
118#if HHI_VSO_COLOR_PLANES
119  __inline Void   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 );
120  __inline Void   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 );
121  __inline Void   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 );
122#else
123  __inline Void   xGetBlendedValue    ( Pel iYL,   Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );
124  __inline Void   xGetBlendedValueBM1 ( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );
125  __inline Void   xGetBlendedValueBM2 ( Pel iYL, Pel iYR, Pel iDepthL, Pel iDepthR, Int iFilledL, Int iFilledR, Pel& riY );
126#endif
127  __inline Pel    xBlend              ( Pel pVal1, Pel pVal2, Int iWeightVal2 );
128
129// General
130  __inline Void   xSetShiftedPel     ( Int iSourcePos, Int iTargetSPos, Pel iFilled, RMDist& riError );
131  __inline Int    xShiftNewData      ( Int iPos, Int iPosInNewData );
132  __inline Int    xShift             ( Int iPos );
133  __inline Int    xShift             ( Int iPos, Int iPosInNewData );
134  __inline Int    xGetDist           ( Int iDiffY, Int iDiffU, Int iDiffV );
135  __inline Int    xGetDist           ( Int iDiffY );
136
137  // Utilities
138  __inline Void   xInitView  ( Int iViewPos );
139  __inline Void   xSetPels   ( Pel*  piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal );
140  __inline Void   xSetBools  ( Bool* pbSource    , Int iSourceStride, Int iWidth, Int iHeight, Bool bVal );
141  __inline Void   xSetInts   ( Int*  piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Int iVal );
142
143private:
144
145  // Image sizes
146  Int   m_iWidth;
147  Int   m_iHeight;
148  Int   m_iStride;
149  Int   m_iPad;
150
151  Int   m_iSampledWidth;
152  Int   m_iSampledHeight;
153  Int   m_iSampledStride;
154
155  // Base
156  Pel** m_aapiBaseVideoPel     [2]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane  0-> Y, 1->U, 2->V
157  Int*  m_aaiBaseVideoStrides  [2]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane  0-> Y, 1->U, 2->V
158
159  Pel*  m_apiBaseDepthPel      [2]; // Dim1: ViewPosition
160  Int   m_aiBaseDepthStrides   [2]; // Dim1: ViewPosition
161
162  // LUT
163  Int** m_appiShiftLut         [2];
164  Int** m_ppiCurLUT;
165  Int** m_aaiSubPelShiftL;
166  Int** m_aaiSubPelShiftR;
167
168  Int*  m_piInvZLUTLeft;
169  Int*  m_piInvZLUTRight;
170
171
172  //// Reference Data  ////
173  TComPicYuv* m_pcPicYuvRef       ;    // Reference PIcYuv
174  Pel*  m_aapiRefVideoPel      [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
175  Int   m_aiRefVideoStrides    [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
176
177  // Renderer State
178  Int*  m_piError                 ;
179  Pel*  m_apiFilled            [2];    // Dim1: ViewPosition
180  Bool* m_apbOccluded          [2];    // Dim1: ViewPosition
181  Pel*  m_aapiSynthVideoPel    [3][3]; // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
182  Pel*  m_apiSynthDepthPel     [3];    // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
183
184  // Rendering State
185  Bool  m_bInOcclusion;                // Currently rendering in occluded area
186  Int   m_iLastOccludedSPos;           // Position of last topmost shifted position
187  Int   m_iLastOccludedSPosFP;         // Position of last topmost shifted position in FullPels
188
189  Bool  m_bSet;                        // Set Data, or get Error
190  Int   m_iCurViewPos;                 // Current View Position 0: Left, 1: Right
191  Int   m_iOtherViewPos;               // Other View Position 0: Left, 1: Right
192  Pel*  m_piNewDepthData;              // Pointer to new depth data
193  Int   m_iStartChangePosX;            // Start Position of new data
194  Int   m_iNewDataWidth;               // Width of new data
195  Pel   m_iCurDepth;                   // Current Depth Value
196  Pel   m_iLastDepth;                  // Last Depth Value
197  Pel   m_iThisDepth;                  // Depth value to use for setting
198
199  //// Settings ////
200  // Input
201  Int   m_iMode;                       // 0: Left to Right, 1: Right to Left, 2: Merge
202  Bool  m_bUseOrgRef;
203  Int   m_iShiftPrec;
204  Int   m_iHoleMargin;
205  Int   m_iBlendMode;
206
207  // Derived settings
208  Int   m_iGapTolerance;
209  Int   m_iBlendZThres;
210  Int   m_iBlendDistWeight;
211
212  //// Current Pointers ////
213  Pel*  m_aapiBaseVideoPelRow  [2][3]; // Dim1: ViewPosition 0->Left, 1->Right; Dim2: Plane  0-> Y, 1->U, 2->V
214  Pel*  m_apiBaseDepthPelRow   [2];    // Dim1: ViewPosition
215  Bool* m_apbOccludedRow       [2];    // Dim1: ViewPosition
216  Pel*  m_apiFilledRow         [2];    // Dim1: ViewPosition
217  Int*  m_apiErrorRow             ;
218
219  Pel*  m_aapiRefVideoPelRow   [3];    // Dim1: Plane  0-> Y, 1->U, 2->V
220  Pel*  m_aapiSynthVideoPelRow [3][3]; // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged, Dim2: Plane  0-> Y, 1->U, 2->V
221  Pel*  m_apiSynthDepthPelRow  [3];    // Dim1: ViewPosition 0: Left, 1:Right, 2: Merged
222
223
224  //// MISC ////
225  const Int m_iDistShift;                  // Shift in Distortion computation
226};
227
228#endif //__TRENSINGLEMODEL__
Note: See TracBrowser for help on using the repository browser.