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