1 | |
---|
2 | |
---|
3 | #include "TRenImage.h" |
---|
4 | #include "TRenFilter.h" |
---|
5 | #include "TRenModel.h" |
---|
6 | |
---|
7 | /////////// TRENMODEL ////////////////////// |
---|
8 | TRenModel::TRenModel() |
---|
9 | { |
---|
10 | m_iPad = 12; |
---|
11 | m_iWidth = -1; |
---|
12 | m_iHeight = -1; |
---|
13 | m_iNumOfBaseViews = -1; |
---|
14 | m_iSampledWidth = -1; |
---|
15 | m_iShiftPrec = 0; |
---|
16 | m_iHoleMargin = 1; |
---|
17 | |
---|
18 | // Current Error Type /// |
---|
19 | m_iCurrentView = -1; |
---|
20 | m_iCurrentContent = -1; |
---|
21 | m_iCurrentPlane = -1; |
---|
22 | |
---|
23 | // Array of Models used to determine the Current Error /// |
---|
24 | m_iNumOfCurRenModels = -1; |
---|
25 | m_apcCurRenModels = NULL; |
---|
26 | m_aiCurPosInModels = NULL; |
---|
27 | |
---|
28 | // Array of Models /// |
---|
29 | m_iNumOfRenModels = -1; |
---|
30 | m_apcRenModels = NULL; |
---|
31 | |
---|
32 | // Mapping from View number to models /// |
---|
33 | m_aiNumOfModelsForDepthView = NULL; |
---|
34 | m_aapcRenModelForDepthView = NULL; |
---|
35 | m_aaePosInModelForDepthView = NULL; |
---|
36 | |
---|
37 | m_aiNumOfModelsForVideoView = NULL; |
---|
38 | m_aapcRenModelForVideoView = NULL; |
---|
39 | m_aaePosInModelForVideoView = NULL; |
---|
40 | m_aaeBaseViewPosInModel = NULL; |
---|
41 | |
---|
42 | // Data |
---|
43 | m_aapiCurVideoPel = NULL; |
---|
44 | m_aaiCurVideoStrides = NULL; |
---|
45 | m_apiCurDepthPel = NULL; |
---|
46 | m_aiCurDepthStrides = NULL; |
---|
47 | |
---|
48 | m_aapiOrgVideoPel = NULL; |
---|
49 | m_aaiOrgVideoStrides = NULL; |
---|
50 | m_apiOrgDepthPel = NULL; |
---|
51 | m_aiOrgDepthStrides = NULL; |
---|
52 | |
---|
53 | m_aaaiSubPelShiftLut[0]= NULL; |
---|
54 | m_aaaiSubPelShiftLut[1]= NULL; |
---|
55 | |
---|
56 | /// Current Setup data /// |
---|
57 | m_abSetupVideoFromOrgForView = NULL; |
---|
58 | m_abSetupDepthFromOrgForView = NULL; |
---|
59 | } |
---|
60 | |
---|
61 | TRenModel::~TRenModel() |
---|
62 | { |
---|
63 | if ( m_apcRenModels ) |
---|
64 | { |
---|
65 | for (Int iNumModel = 0; iNumModel < m_iNumOfRenModels; iNumModel++) |
---|
66 | { |
---|
67 | if ( m_apcRenModels[iNumModel] ) delete m_apcRenModels[iNumModel]; |
---|
68 | } |
---|
69 | |
---|
70 | delete[] m_apcRenModels; |
---|
71 | } |
---|
72 | |
---|
73 | for (Int iViewNum = 0; iViewNum < m_iNumOfBaseViews; iViewNum++) |
---|
74 | { |
---|
75 | if ( m_aapcRenModelForDepthView && m_aapcRenModelForDepthView [iViewNum] ) |
---|
76 | { |
---|
77 | delete[] m_aapcRenModelForDepthView [iViewNum]; |
---|
78 | } |
---|
79 | |
---|
80 | if ( m_aaePosInModelForDepthView && m_aaePosInModelForDepthView[iViewNum] ) |
---|
81 | { |
---|
82 | delete[] m_aaePosInModelForDepthView[iViewNum]; |
---|
83 | } |
---|
84 | |
---|
85 | if ( m_aapcRenModelForVideoView && m_aapcRenModelForVideoView[iViewNum] ) |
---|
86 | { |
---|
87 | delete[] m_aapcRenModelForVideoView[iViewNum]; |
---|
88 | } |
---|
89 | |
---|
90 | if ( m_aaePosInModelForVideoView && m_aaePosInModelForVideoView[iViewNum] ) |
---|
91 | { |
---|
92 | delete[] m_aaePosInModelForVideoView[iViewNum]; |
---|
93 | } |
---|
94 | |
---|
95 | if ( m_aaeBaseViewPosInModel && m_aaeBaseViewPosInModel[iViewNum] ) |
---|
96 | { |
---|
97 | delete[] m_aaeBaseViewPosInModel[iViewNum]; |
---|
98 | } |
---|
99 | |
---|
100 | if ( m_aapiCurVideoPel && m_aapiCurVideoPel [iViewNum] ) |
---|
101 | { |
---|
102 | delete[] ( m_aapiCurVideoPel [iViewNum][0] - m_iPad * m_aaiCurVideoStrides[iViewNum][0] - m_iPad ); |
---|
103 | delete[] ( m_aapiCurVideoPel [iViewNum][1] - m_iPad * m_aaiCurVideoStrides[iViewNum][1] - m_iPad ); |
---|
104 | delete[] ( m_aapiCurVideoPel [iViewNum][2] - m_iPad * m_aaiCurVideoStrides[iViewNum][2] - m_iPad ); |
---|
105 | delete[] m_aapiCurVideoPel [iViewNum]; |
---|
106 | } |
---|
107 | |
---|
108 | if ( m_aaiCurVideoStrides && m_aaiCurVideoStrides [iViewNum] ) |
---|
109 | { |
---|
110 | delete[] m_aaiCurVideoStrides [iViewNum]; |
---|
111 | } |
---|
112 | |
---|
113 | if ( m_apiCurDepthPel ) |
---|
114 | { |
---|
115 | delete[] ( m_apiCurDepthPel [iViewNum] - m_iPad * m_aiCurDepthStrides [iViewNum] - m_iPad ); |
---|
116 | } |
---|
117 | |
---|
118 | if ( m_aapiOrgVideoPel && m_aapiOrgVideoPel [iViewNum] ) |
---|
119 | { |
---|
120 | delete[] ( m_aapiOrgVideoPel [iViewNum][0] - m_iPad * m_aaiOrgVideoStrides[iViewNum][0] - m_iPad ); |
---|
121 | delete[] ( m_aapiOrgVideoPel [iViewNum][1] - m_iPad * m_aaiOrgVideoStrides[iViewNum][1] - m_iPad ); |
---|
122 | delete[] ( m_aapiOrgVideoPel [iViewNum][2] - m_iPad * m_aaiOrgVideoStrides[iViewNum][2] - m_iPad ); |
---|
123 | delete[] m_aapiOrgVideoPel [iViewNum]; |
---|
124 | } |
---|
125 | |
---|
126 | if ( m_aaiOrgVideoStrides && m_aaiOrgVideoStrides [iViewNum] ) |
---|
127 | { |
---|
128 | delete[] m_aaiOrgVideoStrides [iViewNum]; |
---|
129 | } |
---|
130 | |
---|
131 | if ( m_apiOrgDepthPel && m_apiOrgDepthPel [iViewNum ] ) |
---|
132 | { |
---|
133 | delete[] ( m_apiOrgDepthPel [iViewNum] - m_iPad * m_aiOrgDepthStrides [iViewNum] - m_iPad ); |
---|
134 | } |
---|
135 | } |
---|
136 | |
---|
137 | if(m_aiNumOfModelsForDepthView) delete[] m_aiNumOfModelsForDepthView; |
---|
138 | if(m_aapcRenModelForDepthView ) delete[] m_aapcRenModelForDepthView ; |
---|
139 | if(m_aaePosInModelForDepthView) delete[] m_aaePosInModelForDepthView; |
---|
140 | |
---|
141 | if(m_aiNumOfModelsForVideoView) delete[] m_aiNumOfModelsForVideoView; |
---|
142 | if(m_aapcRenModelForVideoView ) delete[] m_aapcRenModelForVideoView ; |
---|
143 | if(m_aaePosInModelForVideoView) delete[] m_aaePosInModelForVideoView; |
---|
144 | |
---|
145 | |
---|
146 | if(m_aaeBaseViewPosInModel ) delete[] m_aaeBaseViewPosInModel ; |
---|
147 | if(m_aapiCurVideoPel ) delete[] m_aapiCurVideoPel ; |
---|
148 | if(m_aaiCurVideoStrides ) delete[] m_aaiCurVideoStrides ; |
---|
149 | |
---|
150 | if(m_abSetupVideoFromOrgForView) delete[] m_abSetupVideoFromOrgForView; |
---|
151 | if(m_abSetupDepthFromOrgForView) delete[] m_abSetupDepthFromOrgForView; |
---|
152 | |
---|
153 | if(m_aapiOrgVideoPel ) delete[] m_aapiOrgVideoPel ; |
---|
154 | if(m_aaiOrgVideoStrides ) delete[] m_aaiOrgVideoStrides ; |
---|
155 | |
---|
156 | if(m_apiOrgDepthPel ) delete[] m_apiOrgDepthPel ; |
---|
157 | if(m_aiOrgDepthStrides ) delete[] m_aiOrgDepthStrides ; |
---|
158 | |
---|
159 | if(m_apiCurDepthPel ) delete[] m_apiCurDepthPel ; |
---|
160 | if(m_aiCurDepthStrides ) delete[] m_aiCurDepthStrides ; |
---|
161 | |
---|
162 | Int iNumEntries = (1 << ( m_iShiftPrec + 1) ) + 1 ; |
---|
163 | |
---|
164 | for (UInt uiEntry = 0; uiEntry < iNumEntries; uiEntry++) |
---|
165 | { |
---|
166 | if ( m_aaaiSubPelShiftLut[0] && m_aaaiSubPelShiftLut[0][uiEntry] ) |
---|
167 | delete[] m_aaaiSubPelShiftLut[0][uiEntry]; |
---|
168 | |
---|
169 | if ( m_aaaiSubPelShiftLut[1] && m_aaaiSubPelShiftLut[1][uiEntry] ) |
---|
170 | delete[] m_aaaiSubPelShiftLut[1][uiEntry]; |
---|
171 | } |
---|
172 | |
---|
173 | if( m_aaaiSubPelShiftLut[0] ) delete[] m_aaaiSubPelShiftLut[0]; |
---|
174 | if( m_aaaiSubPelShiftLut[1] ) delete[] m_aaaiSubPelShiftLut[1]; |
---|
175 | } |
---|
176 | |
---|
177 | |
---|
178 | |
---|
179 | Void |
---|
180 | TRenModel::create( Int iNumOfBaseViews, Int iNumOfModels, Int iWidth, Int iHeight, Int iShiftPrec, Int iHoleMargin ) |
---|
181 | { |
---|
182 | m_iNumOfBaseViews = iNumOfBaseViews; |
---|
183 | m_iNumOfRenModels = iNumOfModels; |
---|
184 | m_iWidth = iWidth; |
---|
185 | m_iHeight = iHeight; |
---|
186 | m_iShiftPrec = iShiftPrec; |
---|
187 | m_iHoleMargin = iHoleMargin; |
---|
188 | |
---|
189 | // LUTs for sub pel shifting |
---|
190 | Int iNumEntries = (1 << ( m_iShiftPrec + 1) ) + 1 ; |
---|
191 | m_aaaiSubPelShiftLut[0] = new Int*[ iNumEntries ]; |
---|
192 | m_aaaiSubPelShiftLut[1] = new Int*[ iNumEntries ]; |
---|
193 | for (UInt uiEntry = 0; uiEntry < iNumEntries; uiEntry++) |
---|
194 | { |
---|
195 | m_aaaiSubPelShiftLut[0][uiEntry] = new Int[ iNumEntries ]; |
---|
196 | m_aaaiSubPelShiftLut[1][uiEntry] = new Int[ iNumEntries ]; |
---|
197 | } |
---|
198 | |
---|
199 | TRenFilter::setSubPelShiftLUT( m_iShiftPrec, m_aaaiSubPelShiftLut[0], 0 ); |
---|
200 | TRenFilter::setSubPelShiftLUT( m_iShiftPrec, m_aaaiSubPelShiftLut[1], -1); |
---|
201 | |
---|
202 | m_iSampledWidth = iWidth << m_iShiftPrec; |
---|
203 | |
---|
204 | |
---|
205 | m_aapiCurVideoPel = new Pel** [m_iNumOfBaseViews]; |
---|
206 | m_aaiCurVideoStrides = new Int* [m_iNumOfBaseViews]; |
---|
207 | m_apiCurDepthPel = new Pel* [m_iNumOfBaseViews]; |
---|
208 | m_aiCurDepthStrides = new Int [m_iNumOfBaseViews]; |
---|
209 | |
---|
210 | m_aapiOrgVideoPel = new Pel** [m_iNumOfBaseViews]; |
---|
211 | m_aaiOrgVideoStrides = new Int* [m_iNumOfBaseViews]; |
---|
212 | |
---|
213 | m_apiOrgDepthPel = new Pel* [m_iNumOfBaseViews]; |
---|
214 | m_aiOrgDepthStrides = new Int [m_iNumOfBaseViews]; |
---|
215 | |
---|
216 | m_abSetupVideoFromOrgForView = new Bool[m_iNumOfBaseViews]; |
---|
217 | m_abSetupDepthFromOrgForView = new Bool[m_iNumOfBaseViews]; |
---|
218 | |
---|
219 | m_iNumOfCurRenModels = 0; |
---|
220 | m_apcCurRenModels = NULL; |
---|
221 | m_aiCurPosInModels = NULL; |
---|
222 | |
---|
223 | m_apcRenModels = new TRenSingleModel* [m_iNumOfRenModels]; |
---|
224 | |
---|
225 | m_aiNumOfModelsForDepthView = new Int [m_iNumOfBaseViews]; |
---|
226 | m_aapcRenModelForDepthView = new TRenSingleModel** [m_iNumOfBaseViews]; |
---|
227 | m_aaePosInModelForDepthView = new Int* [m_iNumOfBaseViews]; |
---|
228 | |
---|
229 | m_aiNumOfModelsForVideoView = new Int [m_iNumOfBaseViews]; |
---|
230 | m_aapcRenModelForVideoView = new TRenSingleModel** [m_iNumOfBaseViews]; |
---|
231 | m_aaePosInModelForVideoView = new Int* [m_iNumOfBaseViews]; |
---|
232 | m_aaeBaseViewPosInModel = new Int* [m_iNumOfBaseViews]; |
---|
233 | |
---|
234 | |
---|
235 | for (Int iModelNum = 0; iModelNum < m_iNumOfRenModels; iModelNum++) |
---|
236 | { |
---|
237 | m_apcRenModels [iModelNum] = new TRenSingleModel(); |
---|
238 | } |
---|
239 | |
---|
240 | for (Int iViewNum = 0; iViewNum < m_iNumOfBaseViews; iViewNum++ ) |
---|
241 | { |
---|
242 | m_aiNumOfModelsForDepthView[ iViewNum ] = 0; |
---|
243 | m_aiNumOfModelsForVideoView[ iViewNum ] = 0; |
---|
244 | |
---|
245 | m_aapcRenModelForDepthView [iViewNum] = new TRenSingleModel*[m_iNumOfRenModels]; |
---|
246 | m_aapcRenModelForVideoView [iViewNum] = new TRenSingleModel*[m_iNumOfRenModels]; |
---|
247 | |
---|
248 | m_aaePosInModelForDepthView[iViewNum] = new Int [m_iNumOfRenModels]; |
---|
249 | m_aaePosInModelForVideoView[iViewNum] = new Int [m_iNumOfRenModels]; |
---|
250 | m_aaeBaseViewPosInModel [iViewNum] = new Int [m_iNumOfRenModels]; |
---|
251 | |
---|
252 | for (Int iModelNum = 0; iModelNum< m_iNumOfRenModels; iModelNum++) |
---|
253 | { |
---|
254 | m_aapcRenModelForDepthView [iViewNum] [iModelNum] = NULL; |
---|
255 | m_aapcRenModelForVideoView [iViewNum] [iModelNum] = NULL; |
---|
256 | m_aaePosInModelForDepthView[iViewNum] [iModelNum] = VIEWPOS_INVALID; |
---|
257 | m_aaePosInModelForVideoView[iViewNum] [iModelNum] = VIEWPOS_INVALID; |
---|
258 | m_aaeBaseViewPosInModel [iViewNum] [iModelNum] = VIEWPOS_INVALID; |
---|
259 | }; |
---|
260 | |
---|
261 | m_aaiCurVideoStrides [iViewNum] = new Int[3]; |
---|
262 | m_aaiCurVideoStrides [iViewNum][0] = m_iSampledWidth + (m_iPad << 1); |
---|
263 | m_aaiCurVideoStrides [iViewNum][1] = m_iSampledWidth + (m_iPad << 1); |
---|
264 | m_aaiCurVideoStrides [iViewNum][2] = m_iSampledWidth + (m_iPad << 1); |
---|
265 | |
---|
266 | m_aapiCurVideoPel [iViewNum] = new Pel*[3]; |
---|
267 | m_aapiCurVideoPel [iViewNum][0] = new Pel [ m_aaiCurVideoStrides[iViewNum][0] * ( m_iHeight + (m_iPad << 1) )]; |
---|
268 | m_aapiCurVideoPel [iViewNum][1] = new Pel [ m_aaiCurVideoStrides[iViewNum][1] * ( m_iHeight + (m_iPad << 1) )]; |
---|
269 | m_aapiCurVideoPel [iViewNum][2] = new Pel [ m_aaiCurVideoStrides[iViewNum][2] * ( m_iHeight + (m_iPad << 1) )]; |
---|
270 | |
---|
271 | m_aapiCurVideoPel [iViewNum][0] += m_aaiCurVideoStrides[iViewNum][0] * m_iPad + m_iPad; |
---|
272 | m_aapiCurVideoPel [iViewNum][1] += m_aaiCurVideoStrides[iViewNum][1] * m_iPad + m_iPad; |
---|
273 | m_aapiCurVideoPel [iViewNum][2] += m_aaiCurVideoStrides[iViewNum][2] * m_iPad + m_iPad; |
---|
274 | |
---|
275 | m_aiCurDepthStrides [iViewNum] = m_iWidth + (m_iPad << 1); |
---|
276 | m_apiCurDepthPel [iViewNum] = new Pel[ m_aiCurDepthStrides[iViewNum] * ( m_iHeight + (m_iPad << 1) ) ]; |
---|
277 | m_apiCurDepthPel [iViewNum] += m_aiCurDepthStrides[iViewNum] * m_iPad + m_iPad; |
---|
278 | |
---|
279 | m_aaiOrgVideoStrides [iViewNum] = new Int[3]; |
---|
280 | m_aaiOrgVideoStrides [iViewNum][0] = m_iSampledWidth + (m_iPad << 1); |
---|
281 | m_aaiOrgVideoStrides [iViewNum][1] = m_iSampledWidth + (m_iPad << 1); |
---|
282 | m_aaiOrgVideoStrides [iViewNum][2] = m_iSampledWidth + (m_iPad << 1); |
---|
283 | |
---|
284 | m_aapiOrgVideoPel [iViewNum] = new Pel*[3]; |
---|
285 | m_aapiOrgVideoPel [iViewNum][0] = new Pel [ m_aaiOrgVideoStrides[iViewNum][0] * ( m_iHeight + (m_iPad << 1) )]; |
---|
286 | m_aapiOrgVideoPel [iViewNum][1] = new Pel [ m_aaiOrgVideoStrides[iViewNum][1] * ( m_iHeight + (m_iPad << 1) )]; |
---|
287 | m_aapiOrgVideoPel [iViewNum][2] = new Pel [ m_aaiOrgVideoStrides[iViewNum][2] * ( m_iHeight + (m_iPad << 1) )]; |
---|
288 | |
---|
289 | m_aapiOrgVideoPel [iViewNum][0] += m_aaiOrgVideoStrides[iViewNum][0] * m_iPad + m_iPad; |
---|
290 | m_aapiOrgVideoPel [iViewNum][1] += m_aaiOrgVideoStrides[iViewNum][1] * m_iPad + m_iPad; |
---|
291 | m_aapiOrgVideoPel [iViewNum][2] += m_aaiOrgVideoStrides[iViewNum][2] * m_iPad + m_iPad; |
---|
292 | |
---|
293 | m_aiOrgDepthStrides [iViewNum] = m_iWidth + (m_iPad << 1); |
---|
294 | m_apiOrgDepthPel [iViewNum] = new Pel[ m_aiOrgDepthStrides[iViewNum] * ( m_iHeight + (m_iPad << 1) ) ]; |
---|
295 | m_apiOrgDepthPel [iViewNum] += m_aiOrgDepthStrides[iViewNum] * m_iPad + m_iPad; |
---|
296 | |
---|
297 | m_abSetupVideoFromOrgForView[iViewNum] = false; |
---|
298 | m_abSetupDepthFromOrgForView[iViewNum] = false; |
---|
299 | } |
---|
300 | } |
---|
301 | |
---|
302 | Void |
---|
303 | TRenModel::createSingleModel( Int iBaseViewNum, Int iContent, Int iModelNum, Int iLeftViewNum, Int iRightViewNum, Bool bUseOrgRef, Int iBlendMode ) |
---|
304 | { |
---|
305 | Int iMode = ( (iLeftViewNum != -1) && ( iRightViewNum != -1 ) ) ? 2 : ( iLeftViewNum != -1 ? 0 : ( iRightViewNum != -1 ? 1 : -1 ) ); |
---|
306 | |
---|
307 | AOT( iMode == -1); |
---|
308 | AOT( iModelNum < 0 || iModelNum > m_iNumOfRenModels ); |
---|
309 | AOF( m_apcRenModels[iModelNum] ); |
---|
310 | AOT( iLeftViewNum < -1 || iLeftViewNum > m_iNumOfBaseViews ); |
---|
311 | AOT( iRightViewNum < -1 || iRightViewNum > m_iNumOfBaseViews ); |
---|
312 | AOT( iBaseViewNum < -1 || iBaseViewNum > m_iNumOfBaseViews ); |
---|
313 | AOT( iBaseViewNum != -1 && iBaseViewNum != iLeftViewNum && iBaseViewNum != iRightViewNum ); |
---|
314 | AOT( iContent < -1 || iContent > 1 ); |
---|
315 | AOT( iBlendMode < -1 || iBlendMode > 2 ); |
---|
316 | |
---|
317 | m_apcRenModels[iModelNum]->create( iMode ,m_iWidth, m_iHeight, m_iShiftPrec, m_aaaiSubPelShiftLut, m_iHoleMargin, bUseOrgRef, iBlendMode ); |
---|
318 | |
---|
319 | if ( iLeftViewNum != -1 ) |
---|
320 | { |
---|
321 | xSetLRViewAndAddModel( iModelNum, iLeftViewNum, iContent, VIEWPOS_LEFT, (iBaseViewNum == -1 || iBaseViewNum == iLeftViewNum ) ); |
---|
322 | } |
---|
323 | |
---|
324 | if ( iRightViewNum != -1) |
---|
325 | { |
---|
326 | xSetLRViewAndAddModel( iModelNum, iRightViewNum, iContent, VIEWPOS_RIGHT, (iBaseViewNum == -1 || iBaseViewNum == iRightViewNum ) ); |
---|
327 | } |
---|
328 | } |
---|
329 | |
---|
330 | |
---|
331 | Void |
---|
332 | TRenModel::setBaseView( Int iViewNum, TComPicYuv* pcPicYuvVideoData, TComPicYuv* pcPicYuvDepthData, TComPicYuv* pcPicYuvOrgVideoData, TComPicYuv* pcPicYuvOrgDepthData ) |
---|
333 | { |
---|
334 | AOT( iViewNum < 0 || iViewNum > m_iNumOfBaseViews ); |
---|
335 | AOF( pcPicYuvVideoData->getHeight() == m_iHeight || pcPicYuvVideoData->getWidth() == m_iWidth ); |
---|
336 | AOF( pcPicYuvDepthData->getHeight() == m_iHeight || pcPicYuvDepthData->getWidth() == m_iWidth ); |
---|
337 | |
---|
338 | pcPicYuvVideoData->extendPicBorder(); |
---|
339 | TRenFilter::sampleHorUp ( m_iShiftPrec, pcPicYuvVideoData->getLumaAddr(), pcPicYuvVideoData->getStride() , m_iWidth, m_iHeight, m_aapiCurVideoPel[ iViewNum ][0], m_aaiCurVideoStrides[iViewNum][0] ); |
---|
340 | TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCbAddr() , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiCurVideoPel[ iViewNum ][1], m_aaiCurVideoStrides[iViewNum][1] ); |
---|
341 | TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvVideoData->getCrAddr() , pcPicYuvVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiCurVideoPel[ iViewNum ][2], m_aaiCurVideoStrides[iViewNum][2] ); |
---|
342 | TRenFilter::copy ( pcPicYuvDepthData->getLumaAddr(), pcPicYuvDepthData->getStride(), m_iWidth, m_iHeight, m_apiCurDepthPel [ iViewNum], m_aiCurDepthStrides [iViewNum] ); |
---|
343 | |
---|
344 | // Used for rendering reference pic from original video data |
---|
345 | m_abSetupVideoFromOrgForView[iViewNum] = (pcPicYuvOrgVideoData != NULL); |
---|
346 | m_abSetupDepthFromOrgForView[iViewNum] = (pcPicYuvOrgDepthData != NULL); |
---|
347 | |
---|
348 | if ( m_abSetupVideoFromOrgForView[iViewNum] ) |
---|
349 | { |
---|
350 | AOF( pcPicYuvOrgVideoData->getHeight() == m_iHeight || pcPicYuvOrgVideoData->getWidth() == m_iWidth ); |
---|
351 | pcPicYuvOrgVideoData->extendPicBorder(); |
---|
352 | TRenFilter::sampleHorUp ( m_iShiftPrec, pcPicYuvOrgVideoData->getLumaAddr(), pcPicYuvOrgVideoData->getStride() , m_iWidth, m_iHeight, m_aapiOrgVideoPel[ iViewNum ][0], m_aaiOrgVideoStrides[iViewNum][0] ); |
---|
353 | TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCbAddr() , pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][1], m_aaiOrgVideoStrides[iViewNum][1] ); |
---|
354 | TRenFilter::sampleCUpHorUp( m_iShiftPrec, pcPicYuvOrgVideoData->getCrAddr() , pcPicYuvOrgVideoData->getCStride(), m_iWidth >> 1, m_iHeight >> 1, m_aapiOrgVideoPel[ iViewNum ][2], m_aaiOrgVideoStrides[iViewNum][2] ); |
---|
355 | } |
---|
356 | |
---|
357 | if ( m_abSetupDepthFromOrgForView[iViewNum] ) |
---|
358 | { |
---|
359 | AOF( pcPicYuvOrgDepthData->getHeight() == m_iHeight || pcPicYuvOrgDepthData->getWidth() == m_iWidth ); |
---|
360 | TRenFilter::copy ( pcPicYuvOrgDepthData->getLumaAddr(), pcPicYuvOrgDepthData->getStride(), m_iWidth, m_iHeight, m_apiOrgDepthPel [ iViewNum], m_aiOrgDepthStrides [iViewNum] ); |
---|
361 | } |
---|
362 | } |
---|
363 | |
---|
364 | Void |
---|
365 | TRenModel::setSingleModel( Int iModelNum, Int** ppiShiftLutLeft, Int** ppiBaseShiftLutLeft, Int** ppiShiftLutRight, Int** ppiBaseShiftLutRight, Int iDistToLeft, TComPicYuv* pcPicYuvRefView ) |
---|
366 | { |
---|
367 | AOT( iModelNum < 0 || iModelNum > m_iNumOfRenModels ); |
---|
368 | |
---|
369 | // Switch model to original data for setup if given to render reference |
---|
370 | Bool bAnyRefFromOrg = false; |
---|
371 | for (Int iBaseViewIdx = 0; iBaseViewIdx < m_iNumOfBaseViews; iBaseViewIdx++ ) |
---|
372 | { |
---|
373 | Bool bSetupFromOrgVideo = m_abSetupVideoFromOrgForView[iBaseViewIdx]; |
---|
374 | Bool bSetupFromOrgDepth = m_abSetupDepthFromOrgForView[iBaseViewIdx]; |
---|
375 | |
---|
376 | if ( ( bSetupFromOrgVideo || bSetupFromOrgDepth ) && m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum] != VIEWPOS_INVALID ) |
---|
377 | { |
---|
378 | bAnyRefFromOrg = true; |
---|
379 | m_apcRenModels[iModelNum]->setLRView( m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum], |
---|
380 | ( bSetupFromOrgVideo ? m_aapiOrgVideoPel : m_aapiCurVideoPel ) [iBaseViewIdx], |
---|
381 | ( bSetupFromOrgVideo ? m_aaiOrgVideoStrides: m_aaiCurVideoStrides) [iBaseViewIdx], |
---|
382 | ( bSetupFromOrgDepth ? m_apiOrgDepthPel : m_apiCurDepthPel ) [iBaseViewIdx], |
---|
383 | ( bSetupFromOrgDepth ? m_aiOrgDepthStrides : m_aiCurDepthStrides ) [iBaseViewIdx] ); |
---|
384 | } |
---|
385 | } |
---|
386 | |
---|
387 | m_apcRenModels[iModelNum]->setup ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, false ); |
---|
388 | |
---|
389 | // Setup to Org |
---|
390 | if ( bAnyRefFromOrg ) |
---|
391 | { |
---|
392 | // Restore old values |
---|
393 | for (Int iBaseViewIdx = 0; iBaseViewIdx < m_iNumOfBaseViews; iBaseViewIdx++ ) |
---|
394 | { |
---|
395 | if ( m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum] != VIEWPOS_INVALID ) |
---|
396 | { |
---|
397 | m_apcRenModels[iModelNum]->setLRView( |
---|
398 | m_aaeBaseViewPosInModel[iBaseViewIdx][iModelNum], |
---|
399 | m_aapiCurVideoPel [iBaseViewIdx], |
---|
400 | m_aaiCurVideoStrides [iBaseViewIdx], |
---|
401 | m_apiCurDepthPel [iBaseViewIdx], |
---|
402 | m_aiCurDepthStrides [iBaseViewIdx] |
---|
403 | ); |
---|
404 | } |
---|
405 | } |
---|
406 | |
---|
407 | // setup keeping reference from original data |
---|
408 | m_apcRenModels[iModelNum]->setup ( pcPicYuvRefView, ppiShiftLutLeft, ppiBaseShiftLutLeft, ppiShiftLutRight, ppiBaseShiftLutRight, iDistToLeft, true ); |
---|
409 | } |
---|
410 | } |
---|
411 | |
---|
412 | Void |
---|
413 | TRenModel::setErrorMode( Int iView, Int iContent, int iPlane ) |
---|
414 | { |
---|
415 | AOT(iView > m_iNumOfBaseViews || iView < 0); |
---|
416 | AOT(iContent != 0 && iContent != 1); |
---|
417 | AOT(iPlane < 0 || iPlane > 3); |
---|
418 | |
---|
419 | m_iCurrentView = iView; |
---|
420 | m_iCurrentContent = iContent; |
---|
421 | m_iCurrentPlane = iPlane; |
---|
422 | |
---|
423 | if ( iContent == 1 ) |
---|
424 | { |
---|
425 | m_iNumOfCurRenModels = m_aiNumOfModelsForDepthView[iView]; |
---|
426 | m_apcCurRenModels = m_aapcRenModelForDepthView [iView]; |
---|
427 | m_aiCurPosInModels = m_aaePosInModelForDepthView[iView]; |
---|
428 | } |
---|
429 | else |
---|
430 | { |
---|
431 | m_iNumOfCurRenModels = m_aiNumOfModelsForVideoView[iView]; |
---|
432 | m_apcCurRenModels = m_aapcRenModelForVideoView [iView]; |
---|
433 | m_aiCurPosInModels = m_aaePosInModelForVideoView[iView]; |
---|
434 | } |
---|
435 | } |
---|
436 | |
---|
437 | RMDist |
---|
438 | TRenModel::getDist( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) |
---|
439 | { |
---|
440 | AOT( iWidth + iStartPosX > m_iWidth ); |
---|
441 | AOT( iHeight + iStartPosY > m_iHeight ); |
---|
442 | AOT( iStartPosX < 0); |
---|
443 | AOT( iStartPosY < 0); |
---|
444 | AOT( iWidth < 0); |
---|
445 | AOT( iHeight < 0); |
---|
446 | |
---|
447 | RMDist iDist = 0; |
---|
448 | |
---|
449 | for (Int iModelNum = 0; iModelNum < m_iNumOfCurRenModels; iModelNum++ ) |
---|
450 | { |
---|
451 | if (m_iCurrentContent == 1) |
---|
452 | { |
---|
453 | iDist += m_apcCurRenModels[iModelNum]->getDistDepth ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData ); |
---|
454 | } |
---|
455 | else |
---|
456 | { |
---|
457 | iDist += m_apcCurRenModels[iModelNum]->getDistVideo ( m_aiCurPosInModels[iModelNum], m_iCurrentPlane ,iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData ); |
---|
458 | } |
---|
459 | } |
---|
460 | |
---|
461 | return ( iDist + (m_iNumOfCurRenModels >> 1) ) / m_iNumOfCurRenModels; |
---|
462 | } |
---|
463 | |
---|
464 | Void |
---|
465 | TRenModel::setData( Int iStartPosX, Int iStartPosY, Int iWidth, Int iHeight, Int iStride, Pel* piNewData ) |
---|
466 | { |
---|
467 | iWidth = min(iWidth , m_iWidth - iStartPosX ); |
---|
468 | iHeight = min(iHeight, m_iHeight - iStartPosY ); |
---|
469 | |
---|
470 | AOT( iStartPosX < 0); |
---|
471 | AOT( iStartPosY < 0); |
---|
472 | AOT( iWidth < 0); |
---|
473 | AOT( iHeight < 0); |
---|
474 | |
---|
475 | for (Int iModelNum = 0; iModelNum < m_iNumOfCurRenModels; iModelNum++ ) |
---|
476 | { |
---|
477 | if (m_iCurrentContent == 1) |
---|
478 | { |
---|
479 | m_apcCurRenModels[iModelNum]->setDepth ( m_aiCurPosInModels[iModelNum], iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData ); |
---|
480 | |
---|
481 | } |
---|
482 | else |
---|
483 | { |
---|
484 | m_apcCurRenModels[iModelNum]->setVideo ( m_aiCurPosInModels[iModelNum], m_iCurrentPlane ,iStartPosX, iStartPosY, iWidth, iHeight, iStride, piNewData ); |
---|
485 | } |
---|
486 | } |
---|
487 | |
---|
488 | if (m_iCurrentContent == 1) |
---|
489 | { |
---|
490 | Int iTargetStride = m_aiCurDepthStrides[ m_iCurrentView ]; |
---|
491 | TRenFilter::copy( piNewData, iStride, iWidth, iHeight, m_apiCurDepthPel[ m_iCurrentView ] + iStartPosY * iTargetStride + iStartPosX, iTargetStride ); |
---|
492 | } |
---|
493 | else |
---|
494 | { |
---|
495 | Int iTargetStride = m_aaiCurVideoStrides[ m_iCurrentView ][m_iCurrentPlane]; |
---|
496 | TRenFilter::copy( piNewData, iStride, iWidth, iHeight, m_aapiCurVideoPel[ m_iCurrentView ][m_iCurrentPlane] + iStartPosY * iTargetStride + iStartPosX, iTargetStride); |
---|
497 | } |
---|
498 | } |
---|
499 | |
---|
500 | Void |
---|
501 | TRenModel::getSynthVideo( Int iModelNum, Int iViewNum, TComPicYuv*& rpcPicYuvSynthVideo ) |
---|
502 | { |
---|
503 | Pel** ppiSynthVideoPel = NULL; |
---|
504 | Pel* ppiSynthDepthPel = NULL; |
---|
505 | Int iStride = -1; |
---|
506 | Int aiStrides[3]; |
---|
507 | |
---|
508 | m_apcRenModels[iModelNum]->getSynthView(iViewNum, ppiSynthVideoPel, ppiSynthDepthPel, iStride ); |
---|
509 | |
---|
510 | aiStrides[0] = iStride; aiStrides[1] = iStride; aiStrides[2] = iStride; |
---|
511 | xCopy2PicYuv( ppiSynthVideoPel, aiStrides, rpcPicYuvSynthVideo ); |
---|
512 | } |
---|
513 | |
---|
514 | Void |
---|
515 | TRenModel::getSynthDepth( Int iModelNum, Int iViewNum, TComPicYuv*& rpcPicYuvSynthDepth ) |
---|
516 | { |
---|
517 | Pel** ppiSynthVideoPel = NULL; |
---|
518 | Pel* piSynthDepthPel = NULL; |
---|
519 | Int iStride = -1; |
---|
520 | |
---|
521 | m_apcRenModels[iModelNum]->getSynthView(iViewNum, ppiSynthVideoPel, piSynthDepthPel, iStride ); |
---|
522 | TRenFilter::copy( piSynthDepthPel, iStride, m_iWidth, m_iHeight, rpcPicYuvSynthDepth->getLumaAddr(), rpcPicYuvSynthDepth->getStride() ); |
---|
523 | rpcPicYuvSynthDepth->setChromaTo( 128 << g_uiBitIncrement ); |
---|
524 | } |
---|
525 | |
---|
526 | |
---|
527 | Void |
---|
528 | TRenModel::getTotalSSE( Int64& riSSEY, Int64& riSSEU, Int64& riSSEV ) |
---|
529 | { |
---|
530 | TComPicYuv cPicYuvSynth; |
---|
531 | cPicYuvSynth.create( m_iWidth, m_iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
532 | |
---|
533 | TComPicYuv cPicYuvTempRef; |
---|
534 | cPicYuvTempRef.create( m_iWidth, m_iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); |
---|
535 | |
---|
536 | Int64 iSSEY = 0; |
---|
537 | Int64 iSSEU = 0; |
---|
538 | Int64 iSSEV = 0; |
---|
539 | |
---|
540 | for (Int iCurModel = 0; iCurModel < m_iNumOfCurRenModels; iCurModel++) |
---|
541 | { |
---|
542 | Pel** ppiSynthVideoPel = NULL; |
---|
543 | Pel* ppiSynthDepthPel = NULL; |
---|
544 | Pel** ppiRefVideoPel = NULL; |
---|
545 | Int iSynStride = -1; |
---|
546 | Int* piRefStrides = NULL; |
---|
547 | Int aiSynStrides[3]; |
---|
548 | |
---|
549 | m_apcCurRenModels[iCurModel]->getSynthView( m_aiCurPosInModels[iCurModel], ppiSynthVideoPel, ppiSynthDepthPel, iSynStride ); |
---|
550 | aiSynStrides[0] = iSynStride; aiSynStrides[1] = iSynStride; aiSynStrides[2] = iSynStride; |
---|
551 | xCopy2PicYuv( ppiSynthVideoPel, aiSynStrides, &cPicYuvSynth ); |
---|
552 | |
---|
553 | TComPicYuv* pcPicYuvOrgRef; |
---|
554 | TComPicYuv* pcPicYuvRef; |
---|
555 | m_apcCurRenModels[iCurModel]->getRefView ( pcPicYuvOrgRef, ppiRefVideoPel, piRefStrides ); |
---|
556 | |
---|
557 | if (!pcPicYuvOrgRef ) |
---|
558 | { |
---|
559 | xCopy2PicYuv( ppiRefVideoPel, piRefStrides, &cPicYuvTempRef); |
---|
560 | pcPicYuvRef = &cPicYuvTempRef; |
---|
561 | } |
---|
562 | else |
---|
563 | { |
---|
564 | pcPicYuvRef = pcPicYuvOrgRef; |
---|
565 | } |
---|
566 | |
---|
567 | iSSEY += TRenFilter::SSE( cPicYuvSynth.getLumaAddr(), cPicYuvSynth.getStride(), m_iWidth, m_iHeight , pcPicYuvRef->getLumaAddr(), pcPicYuvRef->getStride() ); |
---|
568 | iSSEU += TRenFilter::SSE( cPicYuvSynth.getCbAddr() , cPicYuvSynth.getCStride(), m_iWidth >> 1, m_iHeight >> 1, pcPicYuvRef->getCbAddr() , pcPicYuvRef->getCStride()); |
---|
569 | iSSEV += TRenFilter::SSE( cPicYuvSynth.getCrAddr() , cPicYuvSynth.getCStride(), m_iWidth >> 1, m_iHeight >> 1, pcPicYuvRef->getCrAddr() , pcPicYuvRef->getCStride()); |
---|
570 | } |
---|
571 | |
---|
572 | riSSEY = ( iSSEY + (m_iNumOfCurRenModels >> 1) ) / m_iNumOfCurRenModels; |
---|
573 | riSSEU = ( iSSEU + (m_iNumOfCurRenModels >> 1) ) / m_iNumOfCurRenModels; |
---|
574 | riSSEV = ( iSSEV + (m_iNumOfCurRenModels >> 1) ) / m_iNumOfCurRenModels; |
---|
575 | |
---|
576 | cPicYuvTempRef.destroy(); |
---|
577 | cPicYuvSynth .destroy(); |
---|
578 | } |
---|
579 | |
---|
580 | Void |
---|
581 | TRenModel::xSetLRViewAndAddModel( Int iModelNum, Int iBaseViewNum, Int iContent, Int iViewPos, Bool bAdd ) |
---|
582 | { |
---|
583 | AOF(iViewPos == VIEWPOS_LEFT || iViewPos == VIEWPOS_RIGHT); |
---|
584 | AOF(iContent == -1 || iContent == 0 || iContent == 1); |
---|
585 | AOT( iBaseViewNum < 0 || iBaseViewNum > m_iNumOfBaseViews ); |
---|
586 | AOT( m_aaeBaseViewPosInModel[iBaseViewNum][iModelNum] != VIEWPOS_INVALID ); |
---|
587 | m_aaeBaseViewPosInModel[iBaseViewNum][iModelNum] = iViewPos; |
---|
588 | |
---|
589 | m_apcRenModels[iModelNum]->setLRView( iViewPos, m_aapiCurVideoPel[iBaseViewNum], m_aaiCurVideoStrides[iBaseViewNum], m_apiCurDepthPel[iBaseViewNum], m_aiCurDepthStrides [iBaseViewNum] ); |
---|
590 | |
---|
591 | if (bAdd) |
---|
592 | { |
---|
593 | if (iContent == 0 || iContent == -1 ) |
---|
594 | { |
---|
595 | Int iNewModelIdxForView = m_aiNumOfModelsForVideoView[iBaseViewNum]++; |
---|
596 | m_aapcRenModelForVideoView [ iBaseViewNum ][ iNewModelIdxForView ] = m_apcRenModels[iModelNum]; |
---|
597 | m_aaePosInModelForVideoView[ iBaseViewNum ][ iNewModelIdxForView ] = iViewPos; |
---|
598 | } |
---|
599 | |
---|
600 | if (iContent == 1 || iContent == -1 ) |
---|
601 | { |
---|
602 | Int iNewModelIdxForView = m_aiNumOfModelsForDepthView[iBaseViewNum]++; |
---|
603 | m_aapcRenModelForDepthView [ iBaseViewNum ][ iNewModelIdxForView ] = m_apcRenModels[iModelNum]; |
---|
604 | m_aaePosInModelForDepthView[ iBaseViewNum ][ iNewModelIdxForView ] = iViewPos; |
---|
605 | } |
---|
606 | } |
---|
607 | } |
---|
608 | |
---|
609 | Void |
---|
610 | TRenModel::xCopy2PicYuv( Pel** ppiSrcVideoPel, Int* piStrides, TComPicYuv* rpcPicYuvTarget ) |
---|
611 | { |
---|
612 | TRenFilter::copy ( ppiSrcVideoPel[0], piStrides[0], m_iWidth, m_iHeight, rpcPicYuvTarget->getLumaAddr(), rpcPicYuvTarget->getStride() ); |
---|
613 | TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[1], piStrides[1], m_iWidth, m_iHeight, rpcPicYuvTarget->getCbAddr (), rpcPicYuvTarget->getCStride() ); |
---|
614 | TRenFilter::sampleDown2Tap13( ppiSrcVideoPel[2], piStrides[2], m_iWidth, m_iHeight, rpcPicYuvTarget->getCrAddr (), rpcPicYuvTarget->getCStride() ); |
---|
615 | } |
---|
616 | |
---|
617 | #if GERHARD_RM_DEBUG_MM |
---|
618 | Bool |
---|
619 | TRenModel::compareAll( TRenModel* pcModel ) |
---|
620 | { |
---|
621 | Bool bEqual = true; |
---|
622 | for (Int iCurModel = 0; iCurModel < m_iNumOfRenModels; iCurModel++) |
---|
623 | { |
---|
624 | bEqual = bEqual && m_apcRenModels[iCurModel]->compare( pcModel->m_apcRenModels[iCurModel] ); |
---|
625 | } |
---|
626 | return bEqual; |
---|
627 | } |
---|
628 | |
---|
629 | Bool |
---|
630 | TRenModel::compare( TRenModel* pcModel ) |
---|
631 | { |
---|
632 | Bool bEqual = true; |
---|
633 | for (Int iCurModel = 0; iCurModel < m_iNumOfCurRenModels; iCurModel++) |
---|
634 | { |
---|
635 | bEqual = bEqual && m_apcCurRenModels[iCurModel]->compare( pcModel->m_apcCurRenModels[iCurModel] ); |
---|
636 | } |
---|
637 | return bEqual; |
---|
638 | } |
---|
639 | #endif |
---|