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