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 | /** \file TComDepthMapGenerator.cpp |
---|
37 | \brief depth map generator class |
---|
38 | */ |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | #include "CommonDef.h" |
---|
43 | #include "TComDepthMapGenerator.h" |
---|
44 | |
---|
45 | |
---|
46 | #if DEPTH_MAP_GENERATION |
---|
47 | |
---|
48 | |
---|
49 | TComDepthMapGenerator::TComDepthMapGenerator() |
---|
50 | { |
---|
51 | m_bCreated = false; |
---|
52 | m_bInit = false; |
---|
53 | m_bDecoder = false; |
---|
54 | m_pcPrediction = 0; |
---|
55 | m_pcSPSAccess = 0; |
---|
56 | m_pcAUPicAccess = 0; |
---|
57 | m_uiMaxDepth = 0; |
---|
58 | m_uiOrgDepthBitDepth = 0; |
---|
59 | m_uiSubSampExpX = 0; |
---|
60 | m_uiSubSampExpY = 0; |
---|
61 | m_ppcYuv = 0; |
---|
62 | m_ppcCU = 0; |
---|
63 | } |
---|
64 | |
---|
65 | TComDepthMapGenerator::~TComDepthMapGenerator() |
---|
66 | { |
---|
67 | destroy (); |
---|
68 | uninit (); |
---|
69 | } |
---|
70 | |
---|
71 | Void |
---|
72 | TComDepthMapGenerator::create( Bool bDecoder, UInt uiPicWidth, UInt uiPicHeight, UInt uiMaxCUDepth, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiOrgBitDepth, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
73 | { |
---|
74 | destroy(); |
---|
75 | m_bDecoder = bDecoder; |
---|
76 | m_uiMaxDepth = uiMaxCUDepth; |
---|
77 | m_uiOrgDepthBitDepth = uiOrgBitDepth; |
---|
78 | m_uiSubSampExpX = uiSubSampExpX; |
---|
79 | m_uiSubSampExpY = uiSubSampExpY; |
---|
80 | #if !QC_MULTI_DIS_CAN |
---|
81 | m_ppcYuv = new TComYuv* [ m_uiMaxDepth ]; |
---|
82 | m_ppcCU = new TComDataCU* [ m_uiMaxDepth ]; |
---|
83 | for( UInt uiDepth = 0; uiDepth < m_uiMaxDepth; uiDepth++ ) |
---|
84 | { |
---|
85 | UInt uiNumPart = 1 << ( ( m_uiMaxDepth - uiDepth ) << 1 ); |
---|
86 | UInt uiWidth = uiMaxCUWidth >> uiDepth; |
---|
87 | UInt uiHeight = uiMaxCUHeight >> uiDepth; |
---|
88 | |
---|
89 | m_ppcYuv[ uiDepth ] = new TComYuv; m_ppcYuv[ uiDepth ]->create( uiWidth >> m_uiSubSampExpX, uiHeight >> m_uiSubSampExpY ); |
---|
90 | m_ppcCU [ uiDepth ] = new TComDataCU; m_ppcCU [ uiDepth ]->create( uiNumPart, uiWidth, uiHeight, true, uiMaxCUWidth >> (uiMaxCUDepth - 1) ); |
---|
91 | } |
---|
92 | m_cTmpPic.create( uiPicWidth >> m_uiSubSampExpX, uiPicHeight >> m_uiSubSampExpY, uiMaxCUWidth >> m_uiSubSampExpX, uiMaxCUHeight >> m_uiSubSampExpY, uiMaxCUDepth ); |
---|
93 | xSetChroma( &m_cTmpPic, ( 1 << uiOrgBitDepth ) >> 1 ); |
---|
94 | #endif |
---|
95 | m_bCreated = true; |
---|
96 | } |
---|
97 | |
---|
98 | Void |
---|
99 | TComDepthMapGenerator::destroy() |
---|
100 | { |
---|
101 | if( m_bCreated ) |
---|
102 | { |
---|
103 | m_bCreated = false; |
---|
104 | #if !QC_MULTI_DIS_CAN |
---|
105 | for( UInt uiDepth = 0; uiDepth < m_uiMaxDepth; uiDepth++ ) |
---|
106 | { |
---|
107 | if( m_ppcYuv[ uiDepth ] ) |
---|
108 | { |
---|
109 | m_ppcYuv[ uiDepth ]->destroy(); delete m_ppcYuv[ uiDepth ]; m_ppcYuv[ uiDepth ] = 0; |
---|
110 | } |
---|
111 | if( m_ppcCU [ uiDepth ] ) |
---|
112 | { |
---|
113 | m_ppcCU [ uiDepth ]->destroy(); delete m_ppcCU [ uiDepth ]; m_ppcCU [ uiDepth ] = 0; |
---|
114 | } |
---|
115 | } |
---|
116 | delete [] m_ppcYuv; m_ppcYuv = 0; |
---|
117 | delete [] m_ppcCU; m_ppcCU = 0; |
---|
118 | m_cTmpPic.destroy(); |
---|
119 | #endif |
---|
120 | m_uiMaxDepth = 0; |
---|
121 | m_uiOrgDepthBitDepth = 0; |
---|
122 | m_uiSubSampExpX = 0; |
---|
123 | m_uiSubSampExpY = 0; |
---|
124 | m_bDecoder = false; |
---|
125 | } |
---|
126 | } |
---|
127 | |
---|
128 | #if VIDYO_VPS_INTEGRATION |
---|
129 | Void |
---|
130 | TComDepthMapGenerator::init( TComPrediction* pcPrediction, TComVPSAccess* pcVPSAccess, TComSPSAccess* pcSPSAccess, TComAUPicAccess* pcAUPicAccess ) |
---|
131 | #else |
---|
132 | Void |
---|
133 | TComDepthMapGenerator::init( TComPrediction* pcPrediction, TComSPSAccess* pcSPSAccess, TComAUPicAccess* pcAUPicAccess ) |
---|
134 | #endif |
---|
135 | { |
---|
136 | AOF( pcPrediction ); |
---|
137 | AOF( pcSPSAccess ); |
---|
138 | AOF( pcAUPicAccess ); |
---|
139 | uninit(); |
---|
140 | m_pcPrediction = pcPrediction; |
---|
141 | #if VIDYO_VPS_INTEGRATION |
---|
142 | m_pcVPSAccess = pcVPSAccess; |
---|
143 | #endif |
---|
144 | m_pcSPSAccess = pcSPSAccess; |
---|
145 | m_pcAUPicAccess = pcAUPicAccess; |
---|
146 | m_bInit = true; |
---|
147 | } |
---|
148 | |
---|
149 | Void |
---|
150 | TComDepthMapGenerator::uninit() |
---|
151 | { |
---|
152 | if( m_bInit ) |
---|
153 | { |
---|
154 | m_bInit = false; |
---|
155 | m_pcPrediction = 0; |
---|
156 | m_pcSPSAccess = 0; |
---|
157 | m_pcAUPicAccess = 0; |
---|
158 | } |
---|
159 | } |
---|
160 | |
---|
161 | Void |
---|
162 | TComDepthMapGenerator::initViewComponent( TComPic* pcPic ) |
---|
163 | { |
---|
164 | AOF ( m_bCreated && m_bInit ); |
---|
165 | AOF ( pcPic ); |
---|
166 | AOT ( pcPic->getSPS()->getViewId() && !pcPic->getSPS()->isDepth() && pcPic->getPOC() && pcPic->getSPS()->getPredDepthMapGeneration() != m_pcSPSAccess->getPdm() ); |
---|
167 | m_bPDMAvailable = false; |
---|
168 | m_uiCurrViewId = pcPic->getSPS()->getViewId(); |
---|
169 | #if PDM_REMOVE_DEPENDENCE |
---|
170 | pcPic->setStoredPDMforV2(0); |
---|
171 | #endif |
---|
172 | // update SPS list and AU pic list and set depth map generator in SPS |
---|
173 | #if VIDYO_VPS_INTEGRATION |
---|
174 | m_pcVPSAccess ->addVPS( pcPic->getVPS() ); |
---|
175 | #endif |
---|
176 | m_pcSPSAccess ->addSPS( pcPic->getSPS() ); |
---|
177 | m_pcAUPicAccess->addPic( pcPic ); |
---|
178 | pcPic->getSPS()->setDepthMapGenerator( this ); |
---|
179 | |
---|
180 | // check whether we have depth data or don't use pred depth prediction |
---|
181 | ROFVS( pcPic->getSPS()->getViewId() ); |
---|
182 | ROTVS( pcPic->getSPS()->isDepth () ); |
---|
183 | ROFVS( m_pcSPSAccess->getPdm () ); |
---|
184 | |
---|
185 | // set basic SPS parameters |
---|
186 | //#if !QC_MULTI_DIS_CAN |
---|
187 | const Int iDisparityDir = 1; // 1 or -1, depending on the usage of disparity vectors |
---|
188 | //#endif |
---|
189 | TComSPS* pcSPS = pcPic->getSPS (); |
---|
190 | Int iVOI = pcSPS->getViewOrderIdx (); |
---|
191 | //#if !QC_MULTI_DIS_CAN |
---|
192 | UInt uiPdmPrec = pcSPS->getPdmPrecision (); |
---|
193 | UInt uiCamPrec = pcSPS->getCamParPrecision (); |
---|
194 | Bool bInSlice = pcSPS->hasCamParInSliceHeader (); |
---|
195 | Int iScaleVOI01 = ( 1 << ( uiPdmPrec + PDM_INTER_CALC_SHIFT + PDM_VIRT_DEPTH_PRECISION - 2 ) ); |
---|
196 | //#endif |
---|
197 | // check availability of base views and set base id list |
---|
198 | std::vector<Int> aiAbsDeltaVOI; |
---|
199 | for( UInt uiBaseId = 0; uiBaseId < m_uiCurrViewId; uiBaseId++ ) |
---|
200 | { |
---|
201 | TComSPS* pcBaseSPS = m_pcSPSAccess ->getSPS( uiBaseId ); |
---|
202 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseId ); |
---|
203 | AOF( pcBaseSPS != 0 && pcBasePic != 0 ); |
---|
204 | Int iDeltaVOI = iVOI - pcBaseSPS->getViewOrderIdx(); |
---|
205 | Int iAbsDeltaVOI = ( iDeltaVOI < 0 ? -iDeltaVOI : iDeltaVOI ); |
---|
206 | AOT( iAbsDeltaVOI == 0 ); |
---|
207 | aiAbsDeltaVOI.push_back( iAbsDeltaVOI ); |
---|
208 | } |
---|
209 | m_auiBaseIdList.clear(); |
---|
210 | while( (UInt)m_auiBaseIdList.size() < m_uiCurrViewId ) |
---|
211 | { |
---|
212 | Int iMinAbsDelta = MAX_INT; |
---|
213 | UInt uiNextBaseId = MAX_VIEW_NUM; |
---|
214 | for( UInt uiBaseId = 0; uiBaseId < m_uiCurrViewId; uiBaseId++ ) |
---|
215 | { |
---|
216 | if( aiAbsDeltaVOI[ uiBaseId ] > 0 && aiAbsDeltaVOI[ uiBaseId ] <= iMinAbsDelta ) |
---|
217 | { |
---|
218 | iMinAbsDelta = aiAbsDeltaVOI[ uiBaseId ]; |
---|
219 | uiNextBaseId = uiBaseId; |
---|
220 | } |
---|
221 | } |
---|
222 | m_auiBaseIdList.push_back( uiNextBaseId ); |
---|
223 | aiAbsDeltaVOI[ uiNextBaseId ] = 0; |
---|
224 | } |
---|
225 | //#if !QC_MULTI_DIS_CAN |
---|
226 | // check availability of prediction depth map |
---|
227 | if( m_uiCurrViewId ) |
---|
228 | { |
---|
229 | #if PDM_REMOVE_DEPENDENCE |
---|
230 | UInt uiBaseVId = m_auiBaseIdList[0]; |
---|
231 | #else |
---|
232 | Bool bCheckVId1 = ( m_uiCurrViewId > 1 && m_auiBaseIdList[0] == 0 ); |
---|
233 | UInt uiBaseVId = ( bCheckVId1 ? 1 : m_auiBaseIdList[0] ); |
---|
234 | #endif |
---|
235 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseVId ); |
---|
236 | SliceType eSliceType = pcBasePic->getCurrSlice()->getSliceType(); |
---|
237 | Bool bNoRAPdm = ( pcPic->getSPS()->getPredDepthMapGeneration() == 1 ); |
---|
238 | m_bPDMAvailable = ( eSliceType != I_SLICE || !bNoRAPdm ); |
---|
239 | } |
---|
240 | |
---|
241 | // update disparity depth conversion parameters |
---|
242 | for( UInt uiBaseId = 0; uiBaseId < m_uiCurrViewId; uiBaseId++ ) |
---|
243 | { |
---|
244 | TComSPS* pcBaseSPS = m_pcSPSAccess->getSPS( uiBaseId ); |
---|
245 | Int iBaseVOI = pcBaseSPS->getViewOrderIdx(); |
---|
246 | |
---|
247 | // disparity -> virtual depth |
---|
248 | Int iVNominator = ( 1 << PDM_LOG4_SCALE_DENOMINATOR ) + pcSPS->getPdmScaleNomDelta()[ uiBaseId ]; |
---|
249 | Int iVDiv = iVOI - iBaseVOI; |
---|
250 | Int iVAdd = ( iVDiv > 0 ? iVDiv / 2 : -iVDiv / 2 ); |
---|
251 | Int iVScalePred = ( iScaleVOI01 + iVAdd ) / iVDiv; |
---|
252 | Int iVShift = PDM_INTER_CALC_SHIFT; |
---|
253 | Int iVScale = Int( ( (Int64)iVNominator * (Int64)iVScalePred + (Int64)( ( 1 << PDM_LOG4_SCALE_DENOMINATOR ) >> 1 ) ) >> PDM_LOG4_SCALE_DENOMINATOR ); |
---|
254 | Int iVOffset = pcSPS->getPdmOffset()[ uiBaseId ] << PDM_OFFSET_SHIFT; |
---|
255 | m_aaiConvParsDisparity2VirtDepth[ uiBaseId ][ 0 ] = iDisparityDir * iVScale; |
---|
256 | m_aaiConvParsDisparity2VirtDepth[ uiBaseId ][ 1 ] = iDisparityDir * iVOffset + ( ( 1 << iVShift ) >> 1 ); |
---|
257 | m_aaiConvParsDisparity2VirtDepth[ uiBaseId ][ 2 ] = iVShift; |
---|
258 | |
---|
259 | // virtual depth -> disparity |
---|
260 | Int iVInvAdd = ( iVScale > 0 ? iVScale / 2 : -iVScale / 2 ); |
---|
261 | Int iVInvScale = Int( ( ( Int64( 1 ) << ( iVShift << 1 ) ) + iVInvAdd ) / Int64( iVScale ) ); |
---|
262 | Int iVInvOffset = Int( ( ( Int64( -iVOffset ) << iVShift ) + iVInvAdd ) / Int64( iVScale ) ); |
---|
263 | m_aaiConvParsVirtDepth2Disparity[ uiBaseId ][ 0 ] = iDisparityDir * iVInvScale; |
---|
264 | m_aaiConvParsVirtDepth2Disparity[ uiBaseId ][ 1 ] = iDisparityDir * iVInvOffset + ( ( 1 << iVShift ) >> 1 ); |
---|
265 | m_aaiConvParsVirtDepth2Disparity[ uiBaseId ][ 2 ] = iVShift; |
---|
266 | |
---|
267 | // coded depth -> virtual depth |
---|
268 | Int iCScale = ( bInSlice ? pcPic->getCurrSlice()->getCodedScale () : pcSPS->getCodedScale () )[ uiBaseId ]; |
---|
269 | Int iCOffset = ( bInSlice ? pcPic->getCurrSlice()->getCodedOffset() : pcSPS->getCodedOffset() )[ uiBaseId ] << m_uiOrgDepthBitDepth; |
---|
270 | Int iCShift = m_uiOrgDepthBitDepth + uiCamPrec + 1 - 2; |
---|
271 | Int iCVShift = PDM_INTER_CALC_SHIFT; |
---|
272 | Int iTmpShift = iVShift + iCShift - iCVShift; AOF( iTmpShift >= 0 ) |
---|
273 | Int iCVScale = Int( ( Int64( iVScale ) * Int64( iCScale ) + Int64( ( 1 << iTmpShift ) >> 1 ) ) >> iTmpShift ); |
---|
274 | Int iCVOffset = Int( ( Int64( iVScale ) * Int64( iCOffset ) + Int64( ( 1 << iTmpShift ) >> 1 ) ) >> iTmpShift ); |
---|
275 | iTmpShift = iVShift - iCVShift; AOF( iTmpShift >= 0 ) |
---|
276 | iCVOffset += ( iVOffset + ( ( 1 << iTmpShift ) >> 1 ) ) >> iTmpShift; |
---|
277 | m_aaiConvParsOrigDepth2VirtDepth[ uiBaseId ][ 0 ] = iCVScale; |
---|
278 | m_aaiConvParsOrigDepth2VirtDepth[ uiBaseId ][ 1 ] = iCVOffset + ( ( 1 << iCVShift ) >> 1 ); |
---|
279 | m_aaiConvParsOrigDepth2VirtDepth[ uiBaseId ][ 2 ] = iCVShift; |
---|
280 | |
---|
281 | // virtual depth -> coded depth |
---|
282 | Int iCVAdd = ( iCVScale > 0 ? iCVScale / 2 : -iCVScale / 2 ); |
---|
283 | Int iCVInvScale = Int( ( ( Int64( 1 ) << ( iCVShift << 1 ) ) + iCVAdd ) / Int64( iCVScale ) ); |
---|
284 | Int iCVInvOffset= Int( ( ( Int64( -iCVOffset ) << iCVShift ) + iCVAdd ) / Int64( iCVScale ) ); |
---|
285 | m_aaiConvParsVirtDepth2OrigDepth[ uiBaseId ][ 0 ] = iCVInvScale; |
---|
286 | m_aaiConvParsVirtDepth2OrigDepth[ uiBaseId ][ 1 ] = iCVInvOffset + ( ( 1 << iCVShift ) >> 1 ); |
---|
287 | m_aaiConvParsVirtDepth2OrigDepth[ uiBaseId ][ 2 ] = iCVShift; |
---|
288 | } |
---|
289 | |
---|
290 | if( m_uiCurrViewId > 0 ) |
---|
291 | { |
---|
292 | UInt uiBaseId = 0; |
---|
293 | UInt uiBaseVOI = 0; // per definition |
---|
294 | Int iVNominator = ( 1 << PDM_LOG4_SCALE_DENOMINATOR ) + pcSPS->getPdmScaleNomDelta()[ uiBaseId ]; |
---|
295 | Int iVDiv = iVOI - uiBaseVOI; |
---|
296 | Int iVAdd = ( iVDiv > 0 ? iVDiv / 2 : -iVDiv / 2 ); |
---|
297 | Int iVScalePred = ( iScaleVOI01 + iVAdd ) / iVDiv; |
---|
298 | Int iVShift = PDM_INTER_CALC_SHIFT; |
---|
299 | Int iVScale = Int( ( (Int64)iVNominator * (Int64)iVScalePred + (Int64)( ( 1 << PDM_LOG4_SCALE_DENOMINATOR ) >> 1 ) ) >> PDM_LOG4_SCALE_DENOMINATOR ); |
---|
300 | Int iVOffset = pcSPS->getPdmOffset()[ uiBaseId ] << PDM_OFFSET_SHIFT; |
---|
301 | |
---|
302 | // coded depth -> virtual depth (current view) |
---|
303 | Int iCScale = ( bInSlice ? pcPic->getCurrSlice()->getInvCodedScale () : pcSPS->getInvCodedScale () )[ uiBaseId ]; |
---|
304 | Int iCOffset = ( bInSlice ? pcPic->getCurrSlice()->getInvCodedOffset() : pcSPS->getInvCodedOffset() )[ uiBaseId ] << m_uiOrgDepthBitDepth; |
---|
305 | Int iCShift = m_uiOrgDepthBitDepth + uiCamPrec + 1 - 2; |
---|
306 | Int iCVShift = PDM_INTER_CALC_SHIFT; |
---|
307 | Int iTmpShift = iVShift + iCShift - iCVShift; AOF( iTmpShift >= 0 ) |
---|
308 | Int iCVScale = Int( ( Int64( -iVScale ) * Int64( iCScale ) + Int64( ( 1 << iTmpShift ) >> 1 ) ) >> iTmpShift ); |
---|
309 | Int iCVOffset = Int( ( Int64( -iVScale ) * Int64( iCOffset ) + Int64( ( 1 << iTmpShift ) >> 1 ) ) >> iTmpShift ); |
---|
310 | iTmpShift = iVShift - iCVShift; AOF( iTmpShift >= 0 ) |
---|
311 | iCVOffset += ( iVOffset + ( ( 1 << iTmpShift ) >> 1 ) ) >> iTmpShift; |
---|
312 | m_aaiConvParsOrigDepth2VirtDepth[ m_uiCurrViewId ][ 0 ] = iCVScale; |
---|
313 | m_aaiConvParsOrigDepth2VirtDepth[ m_uiCurrViewId ][ 1 ] = iCVOffset + ( ( 1 << iCVShift ) >> 1 ); |
---|
314 | m_aaiConvParsOrigDepth2VirtDepth[ m_uiCurrViewId ][ 2 ] = iCVShift; |
---|
315 | |
---|
316 | // virtual depth -> coded depth |
---|
317 | Int iCVAdd = ( iCVScale > 0 ? iCVScale / 2 : -iCVScale / 2 ); |
---|
318 | Int iCVInvScale = Int( ( ( Int64( 1 ) << ( iCVShift << 1 ) ) + iCVAdd ) / Int64( iCVScale ) ); |
---|
319 | Int iCVInvOffset= Int( ( ( Int64( -iCVOffset ) << iCVShift ) + iCVAdd ) / Int64( iCVScale ) ); |
---|
320 | m_aaiConvParsVirtDepth2OrigDepth[ m_uiCurrViewId ][ 0 ] = iCVInvScale; |
---|
321 | m_aaiConvParsVirtDepth2OrigDepth[ m_uiCurrViewId ][ 1 ] = iCVInvOffset + ( ( 1 << iCVShift ) >> 1 ); |
---|
322 | m_aaiConvParsVirtDepth2OrigDepth[ m_uiCurrViewId ][ 2 ] = iCVShift; |
---|
323 | } |
---|
324 | else if( pcPic->getPOC() == 0 ) |
---|
325 | { // set dummy values |
---|
326 | m_aaiConvParsOrigDepth2VirtDepth[ m_uiCurrViewId ][ 0 ] = 0; |
---|
327 | m_aaiConvParsOrigDepth2VirtDepth[ m_uiCurrViewId ][ 1 ] = 0; |
---|
328 | m_aaiConvParsOrigDepth2VirtDepth[ m_uiCurrViewId ][ 2 ] = 0; |
---|
329 | m_aaiConvParsVirtDepth2OrigDepth[ m_uiCurrViewId ][ 0 ] = 0; |
---|
330 | m_aaiConvParsVirtDepth2OrigDepth[ m_uiCurrViewId ][ 1 ] = 0; |
---|
331 | m_aaiConvParsVirtDepth2OrigDepth[ m_uiCurrViewId ][ 2 ] = 0; |
---|
332 | } |
---|
333 | |
---|
334 | |
---|
335 | #if 0 // print out for debugging |
---|
336 | if( m_uiCurrViewId ) |
---|
337 | { |
---|
338 | printf( "\n\ninit slice of view %d (VOI=%2d):\n===============================\n", m_uiCurrViewId, iVOI ); |
---|
339 | { |
---|
340 | printf( "\n disparity -> virtual depth:\n" ); |
---|
341 | for( UInt uiBaseId = 0; uiBaseId < m_uiCurrViewId; uiBaseId++ ) |
---|
342 | { |
---|
343 | Int* pP = m_aaiConvParsDisparity2VirtDepth[ uiBaseId ]; |
---|
344 | Double dF = 1.0 / Double( 1 << pP[ 2 ] ); |
---|
345 | Double dA = dF * Double( pP[ 0 ] ); |
---|
346 | Double dB = dF * Double( pP[ 1 ] - ( ( 1 << pP[ 2 ] ) >> 1 ) ); |
---|
347 | printf( " BId=%d: a = %10.4lf b = %10.4lf\n", uiBaseId, dA, dB ); |
---|
348 | } |
---|
349 | printf( "\n virtual depth -> disparity:\n" ); |
---|
350 | for( UInt uiBaseId = 0; uiBaseId < m_uiCurrViewId; uiBaseId++ ) |
---|
351 | { |
---|
352 | Int* pP = m_aaiConvParsVirtDepth2Disparity[ uiBaseId ]; |
---|
353 | Double dF = 1.0 / Double( 1 << pP[ 2 ] ); |
---|
354 | Double dA = dF * Double( pP[ 0 ] ); |
---|
355 | Double dB = dF * Double( pP[ 1 ] - ( ( 1 << pP[ 2 ] ) >> 1 ) ); |
---|
356 | printf( " BId=%d: a = %10.4lf b = %10.4lf\n", uiBaseId, dA, dB ); |
---|
357 | } |
---|
358 | printf( "\n original depth -> virtual depth:\n" ); |
---|
359 | for( UInt uiBaseId = 0; uiBaseId <= m_uiCurrViewId; uiBaseId++ ) |
---|
360 | { |
---|
361 | Int* pP = m_aaiConvParsOrigDepth2VirtDepth[ uiBaseId ]; |
---|
362 | Double dF = 1.0 / Double( 1 << pP[ 2 ] ); |
---|
363 | Double dA = dF * Double( pP[ 0 ] ); |
---|
364 | Double dB = dF * Double( pP[ 1 ] - ( ( 1 << pP[ 2 ] ) >> 1 ) ); |
---|
365 | printf( " VId=%d: a = %10.4lf b = %10.4lf\n", uiBaseId, dA, dB ); |
---|
366 | } |
---|
367 | printf( "\n virtual depth -> original depth:\n" ); |
---|
368 | for( UInt uiBaseId = 0; uiBaseId <= m_uiCurrViewId; uiBaseId++ ) |
---|
369 | { |
---|
370 | Int* pP = m_aaiConvParsVirtDepth2OrigDepth[ uiBaseId ]; |
---|
371 | Double dF = 1.0 / Double( 1 << pP[ 2 ] ); |
---|
372 | Double dA = dF * Double( pP[ 0 ] ); |
---|
373 | Double dB = dF * Double( pP[ 1 ] - ( ( 1 << pP[ 2 ] ) >> 1 ) ); |
---|
374 | printf( " VId=%d: a = %10.4lf b = %10.4lf\n", uiBaseId, dA, dB ); |
---|
375 | } |
---|
376 | printf( "\n" ); |
---|
377 | } |
---|
378 | } |
---|
379 | #endif |
---|
380 | //#else |
---|
381 | // if( m_uiCurrViewId ) |
---|
382 | // { |
---|
383 | // Bool bCheckVId1 = ( m_uiCurrViewId > 1 && m_auiBaseIdList[0] == 0 ); |
---|
384 | // UInt uiBaseVId = ( bCheckVId1 ? 1 : m_auiBaseIdList[0] ); |
---|
385 | // TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseVId ); |
---|
386 | // SliceType eSliceType = pcBasePic->getCurrSlice()->getSliceType(); |
---|
387 | // Bool bNoRAPdm = ( pcPic->getSPS()->getPredDepthMapGeneration() == 1 ); |
---|
388 | // m_bPDMAvailable = ( eSliceType != I_SLICE || !bNoRAPdm ); |
---|
389 | //} |
---|
390 | //#endif |
---|
391 | |
---|
392 | } |
---|
393 | |
---|
394 | #if !QC_MULTI_DIS_CAN |
---|
395 | Bool |
---|
396 | TComDepthMapGenerator::predictDepthMap( TComPic* pcPic ) |
---|
397 | { |
---|
398 | AOF ( m_bCreated && m_bInit ); |
---|
399 | AOF ( pcPic ); |
---|
400 | ROTRS( pcPic->getSPS()->isDepth(), true ); |
---|
401 | ROFRS( m_pcSPSAccess->getPdm(), true ); |
---|
402 | AOF ( pcPic->getPredDepthMap() ); |
---|
403 | AOF ( pcPic->getSPS()->getViewId() == m_uiCurrViewId ); |
---|
404 | |
---|
405 | #if PDM_OUTPUT_PRED_DEPTH_MAP |
---|
406 | Char acFilenameBase[1024]; |
---|
407 | ::sprintf( acFilenameBase, "PDM_%s_Prd", ( m_bDecoder ? "Dec" : "Enc" ) ); |
---|
408 | #endif |
---|
409 | |
---|
410 | Bool bUndefined = true; |
---|
411 | if( m_uiCurrViewId ) |
---|
412 | { |
---|
413 | AOF( m_auiBaseIdList.size() ); |
---|
414 | UInt uiBaseId = m_auiBaseIdList[ 0 ]; |
---|
415 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseId ); |
---|
416 | AOF( pcBasePic ); |
---|
417 | |
---|
418 | if( m_uiCurrViewId == 1 ) |
---|
419 | { |
---|
420 | if( pcBasePic->getPOC() == 0 ) |
---|
421 | { |
---|
422 | pcBasePic->removePrdDepthMapBuffer(); |
---|
423 | pcBasePic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_pcSPSAccess->getPdm()), PDM_SUB_SAMP_EXP_Y(m_pcSPSAccess->getPdm()) ); |
---|
424 | xClearDepthMap( pcBasePic ); |
---|
425 | #if PDM_REMOVE_DEPENDENCE |
---|
426 | xClearDepthMap( pcBasePic, PDM_UNDEFINED_DEPTH, 1 ); |
---|
427 | #endif |
---|
428 | } |
---|
429 | #if PDM_OUTPUT_PRED_DEPTH_MAP |
---|
430 | dumpDepthMap( pcBasePic, acFilenameBase ); |
---|
431 | #endif |
---|
432 | } |
---|
433 | |
---|
434 | Bool bLoadDepth = ( m_pcSPSAccess->getPdm() == 2 ); |
---|
435 | if( m_pcSPSAccess->getPdm() > 2 ) |
---|
436 | { |
---|
437 | bLoadDepth = ( pcBasePic->getCurrSlice()->getSliceType() == I_SLICE ); |
---|
438 | } |
---|
439 | |
---|
440 | if( bLoadDepth) |
---|
441 | { // load coded depth of base view |
---|
442 | TComPic* pcBaseDepth = m_pcAUPicAccess->getPic( uiBaseId, true ); |
---|
443 | AOF( pcBaseDepth ); |
---|
444 | AOF( pcBaseDepth->getPicYuvRec() ); |
---|
445 | AOF( pcBaseDepth->getPicYuvRec()->getWidth () == pcBasePic->getPredDepthMap()->getWidth () ); |
---|
446 | AOF( pcBaseDepth->getPicYuvRec()->getHeight() == pcBasePic->getPredDepthMap()->getHeight() ); |
---|
447 | Int iWidth = pcBasePic ->getPredDepthMap()->getWidth (); |
---|
448 | Int iHeight = pcBasePic ->getPredDepthMap()->getHeight (); |
---|
449 | Int iDesStride = pcBasePic ->getPredDepthMap()->getStride (); |
---|
450 | Int iSrcStride = pcBaseDepth->getPicYuvRec ()->getStride (); |
---|
451 | Pel* pDesSamples = pcBasePic ->getPredDepthMap()->getLumaAddr ( 0 ); |
---|
452 | Pel* pSrcSamples = pcBaseDepth->getPicYuvRec ()->getLumaAddr ( 0 ); |
---|
453 | for( Int iY = 0; iY < iHeight; iY++, pSrcSamples += iSrcStride, pDesSamples += iDesStride ) |
---|
454 | { |
---|
455 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
456 | { |
---|
457 | pDesSamples[ iX ] = xGetVirtDepthFromOrigDepth( uiBaseId, pSrcSamples[ iX ] ); |
---|
458 | } |
---|
459 | } |
---|
460 | } |
---|
461 | |
---|
462 | // convert depth of base view to current view |
---|
463 | bUndefined = xConvertDepthMapRef2Curr( pcPic, pcBasePic ); |
---|
464 | |
---|
465 | #if PDM_OUTPUT_PRED_DEPTH_MAP |
---|
466 | dumpDepthMap( pcPic, acFilenameBase ); |
---|
467 | #endif |
---|
468 | } |
---|
469 | else |
---|
470 | { |
---|
471 | xClearDepthMap( pcPic ); |
---|
472 | #if PDM_REMOVE_DEPENDENCE |
---|
473 | xClearDepthMap( pcPic, PDM_UNDEFINED_DEPTH, 1 ); |
---|
474 | #endif |
---|
475 | } |
---|
476 | return bUndefined; |
---|
477 | } |
---|
478 | |
---|
479 | |
---|
480 | Void |
---|
481 | TComDepthMapGenerator::updateDepthMap( TComPic* pcPic ) |
---|
482 | { |
---|
483 | AOF ( m_bCreated && m_bInit ); |
---|
484 | AOF ( pcPic ); |
---|
485 | ROTVS( pcPic->getSPS()->isDepth() ); |
---|
486 | ROFVS( m_pcSPSAccess->getPdm() == 1 || m_pcSPSAccess->getPdm() == 3 ); |
---|
487 | AOF ( pcPic->getPredDepthMap() ); |
---|
488 | AOF ( pcPic->getSPS()->getViewId() == m_uiCurrViewId ); |
---|
489 | |
---|
490 | #if PDM_OUTPUT_PRED_DEPTH_MAP |
---|
491 | Char acFilenameBase[1024]; |
---|
492 | ::sprintf( acFilenameBase, "PDM_%s_Upd", ( m_bDecoder ? "Dec" : "Enc" ) ); |
---|
493 | #endif |
---|
494 | |
---|
495 | // predict depth map using current coding symbols |
---|
496 | #if PDM_REMOVE_DEPENDENCE |
---|
497 | pcPic->setStoredPDMforV2(0); |
---|
498 | xPredictDepthMap( pcPic ); |
---|
499 | if(m_uiCurrViewId==0) |
---|
500 | { |
---|
501 | pcPic->setStoredPDMforV2(1); |
---|
502 | xPredictDepthMap( pcPic ); |
---|
503 | pcPic->setStoredPDMforV2(0); |
---|
504 | } |
---|
505 | #else |
---|
506 | xPredictDepthMap( pcPic ); |
---|
507 | #if PDM_OUTPUT_PRED_DEPTH_MAP |
---|
508 | if( m_uiCurrViewId ) |
---|
509 | { |
---|
510 | dumpDepthMap( pcPic, acFilenameBase ); |
---|
511 | } |
---|
512 | #endif |
---|
513 | #endif |
---|
514 | |
---|
515 | // generate base depth map |
---|
516 | if( m_uiCurrViewId == 1 ) |
---|
517 | { |
---|
518 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( 0 ); |
---|
519 | AOF( pcBasePic ); |
---|
520 | xConvertDepthMapCurr2Ref( pcBasePic, pcPic ); |
---|
521 | #if PDM_OUTPUT_PRED_DEPTH_MAP |
---|
522 | dumpDepthMap( pcBasePic, acFilenameBase ); |
---|
523 | #endif |
---|
524 | } |
---|
525 | #if PDM_REMOVE_DEPENDENCE |
---|
526 | if( m_uiCurrViewId == 2 ) |
---|
527 | { |
---|
528 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( 0 ); |
---|
529 | AOF( pcBasePic ); |
---|
530 | xConvertDepthMapCurr2Ref( pcBasePic, pcPic ); |
---|
531 | #if PDM_OUTPUT_PRED_DEPTH_MAP |
---|
532 | dumpDepthMap( pcBasePic, acFilenameBase ); |
---|
533 | #endif |
---|
534 | } |
---|
535 | #endif |
---|
536 | } |
---|
537 | |
---|
538 | |
---|
539 | Void |
---|
540 | TComDepthMapGenerator::dumpDepthMap( TComPic* pcPic, char* pFilenameBase ) |
---|
541 | { |
---|
542 | AOF( m_bCreated && m_bInit ); |
---|
543 | AOF( pcPic ); |
---|
544 | AOF( pFilenameBase ); |
---|
545 | AOF( m_uiOrgDepthBitDepth == 8 + g_uiBitIncrement ); |
---|
546 | AOF( pcPic->getSPS()->getViewId() <= m_uiCurrViewId ); |
---|
547 | |
---|
548 | // convert to output format |
---|
549 | Int iMax = ( 1 << m_uiOrgDepthBitDepth ) - 1; |
---|
550 | UInt uiViewId = pcPic->getSPS()->getViewId(); |
---|
551 | TComPicYuv* pcPicYuv = pcPic->getPredDepthMap(); |
---|
552 | Int iWidth = pcPicYuv->getWidth (); |
---|
553 | Int iHeight = pcPicYuv->getHeight (); |
---|
554 | Int iSrcStride = pcPicYuv->getStride (); |
---|
555 | Int iDstStride = m_cTmpPic.getStride (); |
---|
556 | #if PDM_REMOVE_DEPENDENCE |
---|
557 | if(pcPic->getStoredPDMforV2()) |
---|
558 | pcPicYuv = pcPic->getPredDepthMapTemp(); |
---|
559 | #endif |
---|
560 | Pel* pSrcSamples = pcPicYuv->getLumaAddr ( 0 ); |
---|
561 | Pel* pDstSamples = m_cTmpPic.getLumaAddr ( 0 ); |
---|
562 | Int iMidOrgDpth = ( 1 << m_uiOrgDepthBitDepth ) >> 1; |
---|
563 | AOF( m_cTmpPic.getWidth () == iWidth ); |
---|
564 | AOF( m_cTmpPic.getHeight() == iHeight ); |
---|
565 | for( Int iY = 0; iY < iHeight; iY++, pSrcSamples += iSrcStride, pDstSamples += iDstStride ) |
---|
566 | { |
---|
567 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
568 | { |
---|
569 | Int iOrgDepth = ( pSrcSamples[ iX ] != PDM_UNDEFINED_DEPTH ? xGetOrigDepthFromVirtDepth( uiViewId, pSrcSamples[ iX ] ) : iMidOrgDpth ); |
---|
570 | pDstSamples[ iX ] = Max( 0, Min( iMax, iOrgDepth ) ); |
---|
571 | } |
---|
572 | } |
---|
573 | |
---|
574 | // output |
---|
575 | Char acFilename[1024]; |
---|
576 | ::sprintf ( acFilename, "%s_V%d.yuv", pFilenameBase, uiViewId ); |
---|
577 | m_cTmpPic.dump( acFilename, ( pcPic->getPOC() != 0 ) ); |
---|
578 | } |
---|
579 | #endif |
---|
580 | |
---|
581 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
582 | Void |
---|
583 | TComDepthMapGenerator::covertOrgDepthMap( TComPic* pcPic ) |
---|
584 | { |
---|
585 | AOF ( m_bCreated && m_bInit ); |
---|
586 | AOF ( pcPic ); |
---|
587 | ROFVS( pcPic->getOrgDepthMap() ); |
---|
588 | AOF ( pcPic->getViewId() ); |
---|
589 | |
---|
590 | UInt uiBaseId = pcPic->getViewId(); |
---|
591 | Int iWidth = pcPic->getOrgDepthMap()->getWidth (); |
---|
592 | Int iHeight = pcPic->getOrgDepthMap()->getHeight (); |
---|
593 | Int iStride = pcPic->getOrgDepthMap()->getStride (); |
---|
594 | Pel* pSamples = pcPic->getOrgDepthMap()->getLumaAddr ( 0 ); |
---|
595 | for( Int iY = 0; iY < iHeight; iY++, pSamples += iStride ) |
---|
596 | { |
---|
597 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
598 | { |
---|
599 | pSamples[ iX ] = xGetVirtDepthFromOrigDepth( uiBaseId, pSamples[ iX ] ); |
---|
600 | } |
---|
601 | } |
---|
602 | } |
---|
603 | #endif |
---|
604 | |
---|
605 | Int |
---|
606 | TComDepthMapGenerator::getDisparity( TComPic* pcPic, Int iPosX, Int iPosY, UInt uiRefViewId ) |
---|
607 | { |
---|
608 | AOF( pcPic ); |
---|
609 | AOF( pcPic->getPredDepthMap() ); |
---|
610 | AOF( iPosX >= 0 && iPosX < pcPic->getPredDepthMap()->getWidth () ); |
---|
611 | AOF( iPosY >= 0 && iPosY < pcPic->getPredDepthMap()->getHeight() ); |
---|
612 | Pel* piPdmMap = pcPic->getPredDepthMap()->getLumaAddr( 0 ); |
---|
613 | Int iStride = pcPic->getPredDepthMap()->getStride (); |
---|
614 | Int iPrdDepth = piPdmMap[ iPosX + iPosY * iStride ]; |
---|
615 | Int iDisparity = xGetDisparityFromVirtDepth( uiRefViewId, iPrdDepth ); |
---|
616 | return iDisparity; |
---|
617 | } |
---|
618 | |
---|
619 | |
---|
620 | |
---|
621 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
622 | #if QC_MULTI_DIS_CAN |
---|
623 | Int |
---|
624 | TComDepthMapGenerator::getPdmMergeCandidate( TComDataCU* pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo ) |
---|
625 | #else |
---|
626 | Int |
---|
627 | TComDepthMapGenerator::getPdmMergeCandidate( TComDataCU* pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv ) |
---|
628 | #endif |
---|
629 | { |
---|
630 | Int iMaxNumInterPics = 1; |
---|
631 | Int iMaxNumAllPics = 2; |
---|
632 | |
---|
633 | // inter-only |
---|
634 | Bool abPdmAvailable[2] = {false,false}; |
---|
635 | for( Int iRefListId = 0; iRefListId < 2; iRefListId++ ) |
---|
636 | { |
---|
637 | RefPicList eRefPicList = RefPicList( iRefListId ); |
---|
638 | Int iNumRefPics = pcCU->getSlice()->getNumRefIdx( eRefPicList ); |
---|
639 | TComMv cMv; |
---|
640 | for( Int iPdmRefIdx = 0, iInterPics = 0; iPdmRefIdx < iNumRefPics && iInterPics < iMaxNumInterPics; iPdmRefIdx++ ) |
---|
641 | { |
---|
642 | if( pcCU->getSlice()->getRefPOC( eRefPicList, iPdmRefIdx ) != pcCU->getSlice()->getPOC() ) |
---|
643 | { |
---|
644 | #if QC_MULTI_DIS_CAN |
---|
645 | if( getDisCanPdmMvPred (pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, pDInfo, true ) ) |
---|
646 | #else |
---|
647 | if( getPdmMvPred( pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, true ) ) |
---|
648 | #endif |
---|
649 | { |
---|
650 | pcCU->clipMv( cMv ); |
---|
651 | abPdmAvailable[ iRefListId ] = true; |
---|
652 | paiPdmRefIdx [ iRefListId ] = iPdmRefIdx; |
---|
653 | pacPdmMv [ iRefListId ] = cMv; |
---|
654 | break; |
---|
655 | } |
---|
656 | iInterPics++; |
---|
657 | } |
---|
658 | } |
---|
659 | } |
---|
660 | Int iPdmInterDir = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 ); |
---|
661 | if( 0==iPdmInterDir ) |
---|
662 | { // check all, including inter view references |
---|
663 | for( Int iRefListId = 0; iRefListId < 2; iRefListId++ ) |
---|
664 | { |
---|
665 | RefPicList eRefPicList = RefPicList( iRefListId ); |
---|
666 | Int iNumRefPics = Min( iMaxNumAllPics, pcCU->getSlice()->getNumRefIdx( eRefPicList ) ); |
---|
667 | TComMv cMv; |
---|
668 | for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ ) |
---|
669 | { |
---|
670 | #if QC_MULTI_DIS_CAN |
---|
671 | if ( getDisCanPdmMvPred (pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, pDInfo, true ) ) |
---|
672 | #else |
---|
673 | if( getPdmMvPred( pcCU, uiPartIdx, eRefPicList, iPdmRefIdx, cMv, true ) ) |
---|
674 | #endif |
---|
675 | { |
---|
676 | pcCU->clipMv( cMv ); |
---|
677 | abPdmAvailable[ iRefListId ] = true; |
---|
678 | paiPdmRefIdx [ iRefListId ] = iPdmRefIdx; |
---|
679 | pacPdmMv [ iRefListId ] = cMv; |
---|
680 | break; |
---|
681 | } |
---|
682 | } |
---|
683 | } |
---|
684 | iPdmInterDir = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 ); |
---|
685 | } |
---|
686 | return iPdmInterDir; |
---|
687 | } |
---|
688 | |
---|
689 | #if QC_MULTI_DIS_CAN |
---|
690 | Bool |
---|
691 | TComDepthMapGenerator::getDisCanPdmMvPred ( TComDataCU* pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge ) |
---|
692 | { |
---|
693 | AOF ( m_bCreated && m_bInit ); |
---|
694 | AOF ( iRefIdx >= 0 ); |
---|
695 | AOF ( pcCU ); |
---|
696 | //ROFRS( m_bPDMAvailable, false ); |
---|
697 | TComSlice* pcSlice = pcCU->getSlice (); |
---|
698 | TComSPS* pcSPS = pcSlice->getSPS(); |
---|
699 | AOF ( pcSPS->getViewId() == m_uiCurrViewId ); |
---|
700 | TComPic* pcRefPic = pcSlice->getRefPic( eRefPicList, iRefIdx ); |
---|
701 | UInt uiRefViewId = pcRefPic->getSPS()->getViewId(); |
---|
702 | Int iRefPoc = pcRefPic->getPOC(); |
---|
703 | Bool bInterview = ( uiRefViewId < m_uiCurrViewId ); |
---|
704 | AOT( bInterview && iRefPoc != pcSlice->getPOC() ); |
---|
705 | AOT( !bInterview && iRefPoc == pcSlice->getPOC() ); |
---|
706 | Bool bPdmIView = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_IVIEW ) == PDM_USE_FOR_IVIEW ); |
---|
707 | Bool bPdmInter = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_INTER ) == PDM_USE_FOR_INTER ); |
---|
708 | Bool bPdmMerge = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE ); |
---|
709 | ROTRS( ( bInterview && !bMerge ) && !bPdmIView, false ); |
---|
710 | ROTRS( (!bInterview && !bMerge ) && !bPdmInter, false ); |
---|
711 | ROTRS( bMerge && !bPdmMerge, false ); |
---|
712 | Int iCurrPosX, iCurrPosY; |
---|
713 | TComMv cDisMv; |
---|
714 | |
---|
715 | if( bInterview ) |
---|
716 | { |
---|
717 | rcMv = pDInfo->m_acMvCand[0]; |
---|
718 | rcMv.setVer(0); |
---|
719 | return true; |
---|
720 | } |
---|
721 | for( UInt uiBId = 0; uiBId < m_uiCurrViewId; uiBId++ ) |
---|
722 | { |
---|
723 | UInt uiBaseId = uiBId; //m_auiBaseIdList[ uiBId ]; |
---|
724 | if (m_uiCurrViewId >1 && uiBaseId ==1 ) continue; |
---|
725 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseId ); |
---|
726 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
---|
727 | UInt uiPartAddr; |
---|
728 | Int iWidth; |
---|
729 | Int iHeight; |
---|
730 | pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
731 | pcBaseRec->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
732 | iCurrPosX += ( ( iWidth - 1 ) >> 1 ); |
---|
733 | iCurrPosY += ( ( iHeight - 1 ) >> 1 ); |
---|
734 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (pDInfo->m_acMvCand[0].getHor() + 2 ) >> 2 ) ); |
---|
735 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (pDInfo->m_acMvCand[0].getVer() + 2 ) >> 2 )); |
---|
736 | Int iBaseCUAddr; |
---|
737 | Int iBaseAbsPartIdx; |
---|
738 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
---|
739 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
740 | if( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_INTER && pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_SKIP ) |
---|
741 | { |
---|
742 | continue; |
---|
743 | } |
---|
744 | for( UInt uiBaseRefListId = 0; uiBaseRefListId < 2; uiBaseRefListId++ ) |
---|
745 | { |
---|
746 | RefPicList eBaseRefPicList = RefPicList( uiBaseRefListId ); |
---|
747 | TComMvField cBaseMvField; |
---|
748 | pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); |
---|
749 | Int iBaseRefIdx = cBaseMvField.getRefIdx(); |
---|
750 | Int iBaseRefPoc = ( iBaseRefIdx >= 0 ? pcBaseCU->getSlice()->getRefPic( eBaseRefPicList, iBaseRefIdx )->getPOC() : -(1<<30) ); |
---|
751 | if( iBaseRefIdx >= 0 && iBaseRefPoc == iRefPoc ) |
---|
752 | { |
---|
753 | rcMv.set( cBaseMvField.getHor(), cBaseMvField.getVer() ); |
---|
754 | return true; |
---|
755 | } |
---|
756 | } |
---|
757 | } |
---|
758 | return false; |
---|
759 | } |
---|
760 | #else |
---|
761 | Bool |
---|
762 | TComDepthMapGenerator::getPdmMvPred( TComDataCU* pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, Bool bMerge ) |
---|
763 | { |
---|
764 | AOF ( m_bCreated && m_bInit ); |
---|
765 | AOF ( iRefIdx >= 0 ); |
---|
766 | AOF ( pcCU ); |
---|
767 | ROFRS( m_bPDMAvailable, false ); |
---|
768 | |
---|
769 | TComSlice* pcSlice = pcCU->getSlice (); |
---|
770 | TComPic* pcPic = pcCU->getPic (); |
---|
771 | TComSPS* pcSPS = pcSlice->getSPS(); |
---|
772 | AOF ( pcPic->getPredDepthMap() ); |
---|
773 | AOF ( pcSPS->getViewId() == m_uiCurrViewId ); |
---|
774 | |
---|
775 | TComPic* pcRefPic = pcSlice->getRefPic( eRefPicList, iRefIdx ); |
---|
776 | UInt uiRefViewId = pcRefPic->getSPS()->getViewId(); |
---|
777 | Int iRefPoc = pcRefPic->getPOC(); |
---|
778 | Bool bInterview = ( uiRefViewId < m_uiCurrViewId ); |
---|
779 | AOT( bInterview && iRefPoc != pcSlice->getPOC() ); |
---|
780 | AOT( !bInterview && iRefPoc == pcSlice->getPOC() ); |
---|
781 | |
---|
782 | Bool bPdmIView = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_IVIEW ) == PDM_USE_FOR_IVIEW ); |
---|
783 | Bool bPdmInter = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_INTER ) == PDM_USE_FOR_INTER ); |
---|
784 | Bool bPdmMerge = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE ); |
---|
785 | ROTRS( ( bInterview && !bMerge ) && !bPdmIView, false ); |
---|
786 | ROTRS( (!bInterview && !bMerge ) && !bPdmInter, false ); |
---|
787 | ROTRS( bMerge && !bPdmMerge, false ); |
---|
788 | |
---|
789 | //===== get predicted depth for middle position of current PU ===== |
---|
790 | Int iPrdDepth, iCurrPosX, iCurrPosY; |
---|
791 | Bool bAvailable = xGetPredDepth( pcCU, uiPartIdx, iPrdDepth, &iCurrPosX, &iCurrPosY ); |
---|
792 | AOF( bAvailable ); |
---|
793 | |
---|
794 | //===== inter-view motion vector prediction ===== |
---|
795 | if( bInterview ) |
---|
796 | { |
---|
797 | Int iDisparity = xGetDisparityFromVirtDepth( uiRefViewId, iPrdDepth ); |
---|
798 | rcMv.set ( iDisparity, 0 ); |
---|
799 | return true; |
---|
800 | } |
---|
801 | |
---|
802 | //===== inter motion vector prediction ===== |
---|
803 | for( UInt uiBId = 0; uiBId < m_uiCurrViewId; uiBId++ ) |
---|
804 | { |
---|
805 | //--- get base CU/PU and check prediction mode --- |
---|
806 | UInt uiBaseId = m_auiBaseIdList[ uiBId ]; |
---|
807 | #if PDM_REMOVE_DEPENDENCE |
---|
808 | if( uiBaseId != 0) |
---|
809 | continue; |
---|
810 | #endif |
---|
811 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseId ); |
---|
812 | TComPicYuv* pcBasePdm = pcBasePic->getPredDepthMap(); |
---|
813 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
---|
814 | Int iDisparity = xGetDisparityFromVirtDepth( uiBaseId, iPrdDepth ); |
---|
815 | Int iShiftX = m_uiSubSampExpX + 2; |
---|
816 | Int iAddX = ( 1 << iShiftX ) >> 1; |
---|
817 | Int iBasePosX = Clip3( 0, pcBasePdm->getWidth () - 1, iCurrPosX + ( ( iDisparity + iAddX ) >> iShiftX ) ); |
---|
818 | Int iBasePosY = Clip3( 0, pcBasePdm->getHeight() - 1, iCurrPosY ); |
---|
819 | Int iBaseCUAddr; |
---|
820 | Int iBaseAbsPartIdx; |
---|
821 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX << m_uiSubSampExpX, iBasePosY << m_uiSubSampExpY, iBaseCUAddr, iBaseAbsPartIdx ); |
---|
822 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
823 | if( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_INTER && pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_SKIP ) |
---|
824 | { |
---|
825 | continue; |
---|
826 | } |
---|
827 | |
---|
828 | for( UInt uiBaseRefListId = 0; uiBaseRefListId < 2; uiBaseRefListId++ ) |
---|
829 | { |
---|
830 | RefPicList eBaseRefPicList = RefPicList( uiBaseRefListId ); |
---|
831 | TComMvField cBaseMvField; |
---|
832 | pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); |
---|
833 | Int iBaseRefIdx = cBaseMvField.getRefIdx(); |
---|
834 | Int iBaseRefPoc = ( iBaseRefIdx >= 0 ? pcBaseCU->getSlice()->getRefPic( eBaseRefPicList, iBaseRefIdx )->getPOC() : -(1<<30) ); |
---|
835 | if( iBaseRefIdx >= 0 && iBaseRefPoc == iRefPoc ) |
---|
836 | { |
---|
837 | rcMv.set( cBaseMvField.getHor(), cBaseMvField.getVer() ); |
---|
838 | return true; |
---|
839 | } |
---|
840 | } |
---|
841 | } |
---|
842 | return false; |
---|
843 | } |
---|
844 | #endif |
---|
845 | |
---|
846 | |
---|
847 | Bool // first version |
---|
848 | TComDepthMapGenerator::getIViewOrgDepthMvPred( TComDataCU* pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv ) |
---|
849 | { |
---|
850 | AOF ( m_bCreated && m_bInit ); |
---|
851 | AOF ( iRefIdx >= 0 ); |
---|
852 | AOF ( pcCU ); |
---|
853 | |
---|
854 | TComSlice* pcSlice = pcCU->getSlice (); |
---|
855 | TComPic* pcPic = pcCU->getPic (); |
---|
856 | TComSPS* pcSPS = pcSlice->getSPS(); |
---|
857 | AOF ( pcSPS->getViewId() == m_uiCurrViewId ); |
---|
858 | ROFRS( pcPic->getOrgDepthMap(), false ); |
---|
859 | |
---|
860 | TComPic* pcRefPic = pcSlice->getRefPic( eRefPicList, iRefIdx ); |
---|
861 | UInt uiRefViewId = pcRefPic->getSPS()->getViewId(); |
---|
862 | Int iRefPoc = pcRefPic->getPOC(); |
---|
863 | ROFRS( uiRefViewId < m_uiCurrViewId, false ); |
---|
864 | AOF ( iRefPoc == pcSlice->getPOC() ); |
---|
865 | |
---|
866 | //===== get predicted depth for middle position of current PU (first version) ===== |
---|
867 | UInt uiPartAddr; |
---|
868 | Int iWidth; |
---|
869 | Int iHeight; |
---|
870 | pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
871 | TComPicYuv* pcOrgDepthMap = pcPic->getOrgDepthMap(); |
---|
872 | Pel* piOrgDepthMap = pcOrgDepthMap->getLumaAddr ( 0 ); |
---|
873 | Int iCurrStride = pcOrgDepthMap->getStride (); |
---|
874 | Int iCurrPosX; |
---|
875 | Int iCurrPosY; |
---|
876 | pcOrgDepthMap->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
877 | iCurrPosX += ( iWidth - 1 ) >> 1; |
---|
878 | iCurrPosY += ( iHeight - 1 ) >> 1; |
---|
879 | Int iPrdDepth = piOrgDepthMap[ iCurrPosX + iCurrPosY * iCurrStride ]; |
---|
880 | |
---|
881 | //===== get disparity vector ===== |
---|
882 | Int iDisparity = xGetDisparityFromVirtDepth( uiRefViewId, iPrdDepth ); |
---|
883 | rcMv.set ( iDisparity, 0 ); |
---|
884 | return true; |
---|
885 | } |
---|
886 | #endif |
---|
887 | |
---|
888 | |
---|
889 | |
---|
890 | |
---|
891 | |
---|
892 | #if !QC_MULTI_DIS_CAN |
---|
893 | /*=======================================================* |
---|
894 | *===== =====* |
---|
895 | *===== p i c t u r e o p e r a t i o n s =====* |
---|
896 | *===== =====* |
---|
897 | *=======================================================*/ |
---|
898 | |
---|
899 | Bool |
---|
900 | TComDepthMapGenerator::xConvertDepthMapCurr2Ref( TComPic* pcRef, TComPic* pcCur ) |
---|
901 | { |
---|
902 | AOF( pcCur->getSPS()->getViewId() == m_uiCurrViewId ); |
---|
903 | AOF( pcCur->getSPS()->getViewId() > pcRef->getSPS()->getViewId() ); |
---|
904 | AOF( pcCur->getPredDepthMap() ); |
---|
905 | AOF( pcRef->getPredDepthMap() ); |
---|
906 | AOF( pcRef->getPredDepthMap()->getWidth () == pcCur->getPredDepthMap()->getWidth () ); |
---|
907 | AOF( pcRef->getPredDepthMap()->getHeight() == pcCur->getPredDepthMap()->getHeight() ); |
---|
908 | #if PDM_REMOVE_DEPENDENCE |
---|
909 | if( pcCur->getViewId() == 1) |
---|
910 | xClearDepthMap( pcRef ); |
---|
911 | else if (pcCur->getViewId() == 2) |
---|
912 | xClearDepthMap( pcRef, PDM_UNDEFINED_DEPTH, 1 ); |
---|
913 | #else |
---|
914 | xClearDepthMap( pcRef ); |
---|
915 | #endif |
---|
916 | TComPicYuv* pcCurDepthMap = pcCur->getPredDepthMap (); |
---|
917 | TComPicYuv* pcRefDepthMap = pcRef->getPredDepthMap (); |
---|
918 | Int iWidth = pcCurDepthMap->getWidth (); |
---|
919 | Int iHeight = pcCurDepthMap->getHeight (); |
---|
920 | Int iCurStride = pcCurDepthMap->getStride (); |
---|
921 | Int iRefStride = pcRefDepthMap->getStride (); |
---|
922 | Pel* pCurSamples = pcCurDepthMap->getLumaAddr( 0 ); |
---|
923 | Pel* pRefSamples = pcRefDepthMap->getLumaAddr( 0 ); |
---|
924 | Int iRefViewIdx = pcRef->getViewId(); |
---|
925 | #if PDM_REMOVE_DEPENDENCE |
---|
926 | if( pcCur->getViewId() == 2) |
---|
927 | { |
---|
928 | pcRefDepthMap = pcRef->getPredDepthMapTemp(); |
---|
929 | pRefSamples = pcRefDepthMap->getLumaAddr( 0 ); |
---|
930 | } |
---|
931 | #endif |
---|
932 | Int iShiftX = m_uiSubSampExpX + 2; |
---|
933 | Int iAddX = ( 1 << iShiftX ) >> 1; |
---|
934 | for( Int iY = 0; iY < iHeight; iY++, pCurSamples += iCurStride, pRefSamples += iRefStride ) |
---|
935 | { |
---|
936 | for( Int iXCur = 0; iXCur < iWidth; iXCur++ ) |
---|
937 | { |
---|
938 | Int iDepth = pCurSamples[ iXCur ]; |
---|
939 | Int iDisp = xGetDisparityFromVirtDepth( iRefViewIdx, iDepth ); |
---|
940 | Int iXRef = iXCur + ( ( iDisp + iAddX ) >> iShiftX ); |
---|
941 | if( iXRef >= 0 && iXRef < iWidth && iDepth > pRefSamples[ iXRef ] ) |
---|
942 | { |
---|
943 | pRefSamples[ iXRef ] = iDepth; |
---|
944 | } |
---|
945 | } |
---|
946 | } |
---|
947 | Bool bUndefined = xFillDepthMapHoles( pcRef ); |
---|
948 | pcRefDepthMap->setBorderExtension( false ); |
---|
949 | pcRefDepthMap->extendPicBorder (); |
---|
950 | return bUndefined; |
---|
951 | } |
---|
952 | |
---|
953 | |
---|
954 | Bool |
---|
955 | TComDepthMapGenerator::xConvertDepthMapRef2Curr( TComPic* pcCur, TComPic* pcRef ) |
---|
956 | { |
---|
957 | AOF( pcCur->getSPS()->getViewId() == m_uiCurrViewId ); |
---|
958 | AOF( pcCur->getSPS()->getViewId() > pcRef->getSPS()->getViewId() ); |
---|
959 | AOF( pcCur->getPredDepthMap() ); |
---|
960 | #if PDM_REMOVE_DEPENDENCE |
---|
961 | if(pcCur->getViewId() == 1) |
---|
962 | { |
---|
963 | AOF( pcRef->getPredDepthMap() ); |
---|
964 | }else |
---|
965 | { |
---|
966 | AOF( pcRef->getPredDepthMapTemp() ); |
---|
967 | } |
---|
968 | #else |
---|
969 | AOF( pcRef->getPredDepthMap() ); |
---|
970 | #endif |
---|
971 | AOF( pcRef->getPredDepthMap()->getWidth () == pcCur->getPredDepthMap()->getWidth () ); |
---|
972 | AOF( pcRef->getPredDepthMap()->getHeight() == pcCur->getPredDepthMap()->getHeight() ); |
---|
973 | |
---|
974 | xClearDepthMap( pcCur ); |
---|
975 | TComPicYuv* pcRefDepthMap = pcRef->getPredDepthMap (); |
---|
976 | #if PDM_REMOVE_DEPENDENCE |
---|
977 | if(pcCur->getViewId() == 2) |
---|
978 | pcRefDepthMap = pcRef->getPredDepthMapTemp (); |
---|
979 | #endif |
---|
980 | TComPicYuv* pcCurDepthMap = pcCur->getPredDepthMap (); |
---|
981 | Int iWidth = pcRefDepthMap->getWidth (); |
---|
982 | Int iHeight = pcRefDepthMap->getHeight (); |
---|
983 | Int iRefStride = pcRefDepthMap->getStride (); |
---|
984 | Int iCurStride = pcCurDepthMap->getStride (); |
---|
985 | Pel* pRefSamples = pcRefDepthMap->getLumaAddr( 0 ); |
---|
986 | Pel* pCurSamples = pcCurDepthMap->getLumaAddr( 0 ); |
---|
987 | Int iRefViewIdx = pcRef->getViewId(); |
---|
988 | Int iShiftX = m_uiSubSampExpX + 2; |
---|
989 | Int iAddX = ( 1 << iShiftX ) >> 1; |
---|
990 | for( Int iY = 0; iY < iHeight; iY++, pRefSamples += iRefStride, pCurSamples += iCurStride ) |
---|
991 | { |
---|
992 | for( Int iXRef = 0; iXRef < iWidth; iXRef++ ) |
---|
993 | { |
---|
994 | Int iDepth = pRefSamples[ iXRef ]; |
---|
995 | Int iDisp = xGetDisparityFromVirtDepth( iRefViewIdx, iDepth ); |
---|
996 | Int iXCur = iXRef - ( ( iDisp + iAddX ) >> iShiftX ); |
---|
997 | if( iXCur >= 0 && iXCur < iWidth && iDepth > pCurSamples[ iXCur ] ) |
---|
998 | { |
---|
999 | pCurSamples[ iXCur ] = iDepth; |
---|
1000 | } |
---|
1001 | } |
---|
1002 | } |
---|
1003 | Bool bUndefined = xFillDepthMapHoles( pcCur ); |
---|
1004 | pcCurDepthMap->setBorderExtension( false ); |
---|
1005 | pcCurDepthMap->extendPicBorder (); |
---|
1006 | return bUndefined; |
---|
1007 | } |
---|
1008 | |
---|
1009 | |
---|
1010 | Bool |
---|
1011 | TComDepthMapGenerator::xPredictDepthMap( TComPic* pcPic ) |
---|
1012 | { |
---|
1013 | for( UInt uiCUAddr = 0; uiCUAddr < pcPic->getPicSym()->getNumberOfCUsInFrame(); uiCUAddr++ ) |
---|
1014 | { |
---|
1015 | TComDataCU* pcCU = pcPic->getCU( uiCUAddr ); |
---|
1016 | xPredictCUDepthMap( pcCU, 0, 0 ); |
---|
1017 | } |
---|
1018 | Bool bUndefined = xFillDepthMapHoles( pcPic ); |
---|
1019 | #if PDM_REMOVE_DEPENDENCE |
---|
1020 | if(pcPic->getStoredPDMforV2() == 1){ |
---|
1021 | pcPic->getPredDepthMapTemp()->setBorderExtension( false ); |
---|
1022 | pcPic->getPredDepthMapTemp()->extendPicBorder (); |
---|
1023 | }else{ |
---|
1024 | #endif |
---|
1025 | pcPic->getPredDepthMap()->setBorderExtension( false ); |
---|
1026 | pcPic->getPredDepthMap()->extendPicBorder (); |
---|
1027 | #if PDM_REMOVE_DEPENDENCE |
---|
1028 | } |
---|
1029 | #endif |
---|
1030 | return bUndefined; |
---|
1031 | } |
---|
1032 | |
---|
1033 | |
---|
1034 | Bool |
---|
1035 | TComDepthMapGenerator::xFillDepthMapHoles( TComPic* pcPic ) |
---|
1036 | { |
---|
1037 | Bool bUndefined = false; |
---|
1038 | TComPicYuv* pcDepthMap = pcPic->getPredDepthMap (); |
---|
1039 | #if PDM_REMOVE_DEPENDENCE |
---|
1040 | if(pcPic->getViewId()==0 && pcPic->getStoredPDMforV2()==1) |
---|
1041 | pcDepthMap = pcPic->getPredDepthMapTemp (); |
---|
1042 | #endif |
---|
1043 | Int iWidth = pcDepthMap->getWidth (); |
---|
1044 | Int iHeight = pcDepthMap->getHeight (); |
---|
1045 | Int iStride = pcDepthMap->getStride (); |
---|
1046 | Pel* pDMSamples = pcDepthMap->getLumaAddr ( 0 ); |
---|
1047 | // horizontal |
---|
1048 | for( Int iY = 0; iY < iHeight && !bUndefined; iY++, pDMSamples += iStride ) |
---|
1049 | { |
---|
1050 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
1051 | { |
---|
1052 | if( pDMSamples[ iX ] == PDM_UNDEFINED_DEPTH ) |
---|
1053 | { |
---|
1054 | Int iE; |
---|
1055 | for( iE = iX + 1; iE < iWidth; iE++ ) |
---|
1056 | { |
---|
1057 | if( pDMSamples[ iE ] != PDM_UNDEFINED_DEPTH ) |
---|
1058 | { |
---|
1059 | break; |
---|
1060 | } |
---|
1061 | } |
---|
1062 | if( iX > 0 || iE < iWidth ) |
---|
1063 | { |
---|
1064 | Int iDepth; |
---|
1065 | if ( iX > 0 && iE < iWidth ) iDepth = ( pDMSamples[ iX-1 ] < pDMSamples[ iE ] ? pDMSamples[ iX-1 ] : pDMSamples[ iE ] ); |
---|
1066 | else if( iX > 0 ) iDepth = pDMSamples[ iX-1 ]; |
---|
1067 | else /*( iE < iWidth )*/ iDepth = pDMSamples[ iE ]; |
---|
1068 | for( Int iZ = iX; iZ < iE; iZ++ ) |
---|
1069 | { |
---|
1070 | pDMSamples[ iZ ] = iDepth; |
---|
1071 | } |
---|
1072 | } |
---|
1073 | else |
---|
1074 | { |
---|
1075 | bUndefined = true; |
---|
1076 | break; |
---|
1077 | } |
---|
1078 | iX = iE - 1; |
---|
1079 | } |
---|
1080 | } |
---|
1081 | } |
---|
1082 | |
---|
1083 | if( bUndefined && m_uiCurrViewId ) |
---|
1084 | { |
---|
1085 | pDMSamples = pcDepthMap->getLumaAddr( 0 ); |
---|
1086 | Int iMiddleOrgDpth = ( 1 << m_uiOrgDepthBitDepth ) >> 1; |
---|
1087 | Int iMiddleDepth = xGetVirtDepthFromOrigDepth( m_uiCurrViewId, iMiddleOrgDpth ); |
---|
1088 | for( Int iY = 0; iY < iHeight; iY++, pDMSamples += iStride ) |
---|
1089 | { |
---|
1090 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
1091 | { |
---|
1092 | pDMSamples[ iX ] = iMiddleDepth; |
---|
1093 | } |
---|
1094 | } |
---|
1095 | } |
---|
1096 | return bUndefined; |
---|
1097 | } |
---|
1098 | |
---|
1099 | |
---|
1100 | Void |
---|
1101 | TComDepthMapGenerator::xClearDepthMap( TComPic* pcPic, Int iVal |
---|
1102 | #if PDM_REMOVE_DEPENDENCE |
---|
1103 | , |
---|
1104 | Int forFirstNonBaseView |
---|
1105 | #endif |
---|
1106 | ) |
---|
1107 | { |
---|
1108 | TComPicYuv* pcDepthMap = pcPic->getPredDepthMap (); |
---|
1109 | Int iWidth = pcDepthMap->getWidth (); |
---|
1110 | Int iHeight = pcDepthMap->getHeight (); |
---|
1111 | Int iStride = pcDepthMap->getStride (); |
---|
1112 | Pel* pDMSamples = pcDepthMap->getLumaAddr ( 0 ); |
---|
1113 | #if PDM_REMOVE_DEPENDENCE |
---|
1114 | if( forFirstNonBaseView == 1) |
---|
1115 | { |
---|
1116 | pcDepthMap = pcPic->getPredDepthMapTemp (); |
---|
1117 | pDMSamples = pcDepthMap->getLumaAddr ( 0 ); |
---|
1118 | } |
---|
1119 | #endif |
---|
1120 | for( Int iY = 0; iY < iHeight; iY++, pDMSamples += iStride ) |
---|
1121 | { |
---|
1122 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
1123 | { |
---|
1124 | pDMSamples[ iX ] = iVal; |
---|
1125 | } |
---|
1126 | } |
---|
1127 | pcDepthMap->setBorderExtension( false ); |
---|
1128 | pcDepthMap->extendPicBorder (); |
---|
1129 | } |
---|
1130 | |
---|
1131 | Void |
---|
1132 | TComDepthMapGenerator::xSetChroma( TComPicYuv* pcPic, Int iVal ) |
---|
1133 | { |
---|
1134 | Int iWidth = pcPic->getWidth () >> 1; |
---|
1135 | Int iHeight = pcPic->getHeight () >> 1; |
---|
1136 | Int iStride = pcPic->getCStride (); |
---|
1137 | Pel* pCbSamples = pcPic->getCbAddr ( 0 ); |
---|
1138 | Pel* pCrSamples = pcPic->getCrAddr ( 0 ); |
---|
1139 | for( Int iY = 0; iY < iHeight; iY++, pCbSamples += iStride, pCrSamples += iStride ) |
---|
1140 | { |
---|
1141 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
1142 | { |
---|
1143 | pCbSamples[ iX ] = pCrSamples[ iX ] = iVal; |
---|
1144 | } |
---|
1145 | } |
---|
1146 | } |
---|
1147 | |
---|
1148 | |
---|
1149 | |
---|
1150 | |
---|
1151 | |
---|
1152 | |
---|
1153 | |
---|
1154 | /*===============================================* |
---|
1155 | *===== =====* |
---|
1156 | *===== C U p r e d i c t i o n s =====* |
---|
1157 | *===== =====* |
---|
1158 | *===============================================*/ |
---|
1159 | |
---|
1160 | Void |
---|
1161 | TComDepthMapGenerator::xPredictCUDepthMap( TComDataCU* pcCU, UInt uiDepth, UInt uiAbsPartIdx ) |
---|
1162 | { |
---|
1163 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
1164 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
1165 | UInt uiRPelX = uiLPelX + ( g_uiMaxCUWidth >> uiDepth ) - 1; |
---|
1166 | UInt uiBPelY = uiTPelY + ( g_uiMaxCUHeight >> uiDepth ) - 1; |
---|
1167 | Bool bBoundary = ( uiRPelX >= pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() || uiBPelY >= pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); |
---|
1168 | Bool bSplit = ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) && uiDepth < ( g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ); |
---|
1169 | if( bSplit ) |
---|
1170 | { |
---|
1171 | UInt uiQNumParts = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
1172 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx += uiQNumParts ) |
---|
1173 | { |
---|
1174 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
1175 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
1176 | Bool bInside = ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() && uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); |
---|
1177 | if( bInside ) |
---|
1178 | { |
---|
1179 | xPredictCUDepthMap( pcCU, uiDepth + 1, uiAbsPartIdx ); |
---|
1180 | } |
---|
1181 | } |
---|
1182 | return; |
---|
1183 | } |
---|
1184 | |
---|
1185 | //--- set sub-CU and sub-depth-map --- |
---|
1186 | TComDataCU* pcSubCU = m_ppcCU [ uiDepth ]; |
---|
1187 | TComYuv* pcSubDM = m_ppcYuv[ uiDepth ]; |
---|
1188 | TComPicYuv* pcPicDM = pcCU->getPic()->getPredDepthMap(); |
---|
1189 | #if PDM_REMOVE_DEPENDENCE |
---|
1190 | if( pcCU->getPic()->getStoredPDMforV2() == 1) |
---|
1191 | pcPicDM = pcCU->getPic()->getPredDepthMapTemp(); |
---|
1192 | #endif |
---|
1193 | UInt uiCUAddr = pcCU->getAddr(); |
---|
1194 | pcSubCU->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
1195 | |
---|
1196 | //--- update depth map --- |
---|
1197 | switch( pcSubCU->getPredictionMode( 0 ) ) |
---|
1198 | { |
---|
1199 | case MODE_INTRA: |
---|
1200 | xIntraPredictCUDepthMap( pcSubCU, pcSubDM ); |
---|
1201 | break; |
---|
1202 | case MODE_SKIP: |
---|
1203 | case MODE_INTER: |
---|
1204 | xInterPredictCUDepthMap( pcSubCU, pcSubDM ); |
---|
1205 | break; |
---|
1206 | default: |
---|
1207 | AOT( true ); |
---|
1208 | break; |
---|
1209 | } |
---|
1210 | |
---|
1211 | //--- copy sub-depth-map --- |
---|
1212 | pcSubDM->copyToPicYuv( pcPicDM, uiCUAddr, uiAbsPartIdx ); |
---|
1213 | } |
---|
1214 | |
---|
1215 | |
---|
1216 | Void |
---|
1217 | TComDepthMapGenerator::xIntraPredictCUDepthMap( TComDataCU* pcCU, TComYuv* pcCUDepthMap ) |
---|
1218 | { |
---|
1219 | UInt uiInitTrDepth = ( pcCU->getPartitionSize( 0 ) == SIZE_2Nx2N ? 0 : 1 ); |
---|
1220 | UInt uiNumPart = pcCU->getNumPartInter (); |
---|
1221 | UInt uiNumQParts = pcCU->getTotalNumPart () >> 2; |
---|
1222 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
1223 | { |
---|
1224 | xIntraPredictBlkDepthMap( pcCU, pcCUDepthMap, uiPU * uiNumQParts, uiInitTrDepth ); |
---|
1225 | } |
---|
1226 | } |
---|
1227 | |
---|
1228 | |
---|
1229 | Void |
---|
1230 | TComDepthMapGenerator::xInterPredictCUDepthMap( TComDataCU* pcCU, TComYuv* pcCUDepthMap ) |
---|
1231 | { |
---|
1232 | for( UInt uiPartIdx = 0; uiPartIdx < pcCU->getNumPartInter(); uiPartIdx++ ) |
---|
1233 | { |
---|
1234 | xInterPredictPUDepthMap( pcCU, pcCUDepthMap, uiPartIdx ); |
---|
1235 | } |
---|
1236 | } |
---|
1237 | |
---|
1238 | |
---|
1239 | |
---|
1240 | |
---|
1241 | |
---|
1242 | |
---|
1243 | |
---|
1244 | /*=====================================================================* |
---|
1245 | *===== =====* |
---|
1246 | *===== P U - a n d B l o c k p r e d i c t i o n s =====* |
---|
1247 | *===== =====* |
---|
1248 | *=====================================================================*/ |
---|
1249 | |
---|
1250 | Void |
---|
1251 | TComDepthMapGenerator::xIntraPredictBlkDepthMap( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiAbsPartIdx, UInt uiTrDepth ) |
---|
1252 | { |
---|
1253 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
1254 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1255 | if( uiTrMode == uiTrDepth ) |
---|
1256 | { |
---|
1257 | UInt uiWidth = pcCU->getWidth ( 0 ) >> ( uiTrDepth + m_uiSubSampExpX ); |
---|
1258 | UInt uiHeight = pcCU->getHeight( 0 ) >> ( uiTrDepth + m_uiSubSampExpY ); |
---|
1259 | UInt uiStride = pcCUDepthMap->getStride (); |
---|
1260 | UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpX; |
---|
1261 | UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpY; |
---|
1262 | Pel* pDepthMap = pcCUDepthMap->getLumaAddr() + uiBlkY * pcCUDepthMap->getStride() + uiBlkX; |
---|
1263 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
1264 | Bool bAboveAvail = false; |
---|
1265 | Bool bLeftAvail = false; |
---|
1266 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx, true ); |
---|
1267 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
1268 | m_pcPrediction->getPredicBuf (), |
---|
1269 | m_pcPrediction->getPredicBufWidth (), |
---|
1270 | m_pcPrediction->getPredicBufHeight (), |
---|
1271 | bAboveAvail, bLeftAvail, false, true, m_uiSubSampExpX, m_uiSubSampExpY ); |
---|
1272 | m_pcPrediction->predIntraDepthAng ( pcCU->getPattern(), uiLumaPredMode, pDepthMap, uiStride, uiWidth, uiHeight ); // could be replaced with directional intra prediction |
---|
1273 | // using "predIntraLumaAng", but note: |
---|
1274 | // - need to take care of neighbours with undefined depth |
---|
1275 | // - special case for wedgelet mode (if available in normal views) |
---|
1276 | // copy to picture array (for next intra prediction block) |
---|
1277 | UInt uiZOrderIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
1278 | Pel* pPicDepthMap = pcCU->getPic()->getPredDepthMap()->getLumaAddr( pcCU->getAddr(), uiZOrderIdx ); |
---|
1279 | #if PDM_REMOVE_DEPENDENCE |
---|
1280 | if(pcCU->getPic()->getStoredPDMforV2()==1) |
---|
1281 | pPicDepthMap = pcCU->getPic()->getPredDepthMapTemp()->getLumaAddr( pcCU->getAddr(), uiZOrderIdx ); |
---|
1282 | #endif |
---|
1283 | Int iPicStride = pcCU->getPic()->getPredDepthMap()->getStride (); |
---|
1284 | for( UInt uiY = 0; uiY < uiHeight; uiY++, pDepthMap += uiStride, pPicDepthMap += iPicStride ) |
---|
1285 | { |
---|
1286 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1287 | { |
---|
1288 | pPicDepthMap[ uiX ] = pDepthMap[ uiX ]; |
---|
1289 | } |
---|
1290 | } |
---|
1291 | } |
---|
1292 | else |
---|
1293 | { |
---|
1294 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
1295 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
1296 | { |
---|
1297 | xIntraPredictBlkDepthMap( pcCU, pcCUDepthMap, uiAbsPartIdx + uiPart * uiNumQPart, uiTrDepth + 1 ); |
---|
1298 | } |
---|
1299 | } |
---|
1300 | } |
---|
1301 | |
---|
1302 | |
---|
1303 | Void |
---|
1304 | TComDepthMapGenerator::xInterPredictPUDepthMap( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx ) |
---|
1305 | { |
---|
1306 | if ( pcCU->getSlice()->getSPS()->getViewId() ) |
---|
1307 | { |
---|
1308 | AOF( m_uiCurrViewId == pcCU->getSlice()->getSPS()->getViewId() ); |
---|
1309 | // check for interview prediction |
---|
1310 | Int iWidth; |
---|
1311 | Int iHeight; |
---|
1312 | UInt uiAbsPartIdx; |
---|
1313 | pcCU->getPartIndexAndSize( uiPartIdx, uiAbsPartIdx, iWidth, iHeight ); |
---|
1314 | TComCUMvField* aiCurrMvField[2] = { pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getCUMvField( REF_PIC_LIST_1 ) }; |
---|
1315 | Int aiCurrRefIdx [2] = { aiCurrMvField[0]->getRefIdx( uiAbsPartIdx ), aiCurrMvField[1]->getRefIdx( uiAbsPartIdx ) }; |
---|
1316 | Bool abCurrIntView[2] = { aiCurrRefIdx[0] >= 0 && pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, aiCurrRefIdx[0] )->getSPS()->getViewId() != m_uiCurrViewId, |
---|
1317 | aiCurrRefIdx[1] >= 0 && pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, aiCurrRefIdx[1] )->getSPS()->getViewId() != m_uiCurrViewId }; |
---|
1318 | Bool bUsesInterViewPrd = ( abCurrIntView[0] || abCurrIntView[1] ); |
---|
1319 | if( bUsesInterViewPrd ) |
---|
1320 | { |
---|
1321 | xIViewPUDepthMapUpdate ( pcCU, pcCUDepthMap, uiPartIdx ); |
---|
1322 | } |
---|
1323 | else |
---|
1324 | { |
---|
1325 | #if PDM_NO_INTER_UPDATE |
---|
1326 | xInterPUDepthMapPrediction( pcCU, pcCUDepthMap, uiPartIdx ); |
---|
1327 | #else |
---|
1328 | xInterPUDepthMapUpdate ( pcCU, pcCUDepthMap, uiPartIdx ); |
---|
1329 | #endif |
---|
1330 | } |
---|
1331 | } |
---|
1332 | else |
---|
1333 | { |
---|
1334 | xInterPUDepthMapPrediction( pcCU, pcCUDepthMap, uiPartIdx ); |
---|
1335 | } |
---|
1336 | } |
---|
1337 | |
---|
1338 | |
---|
1339 | Void |
---|
1340 | TComDepthMapGenerator::xIViewPUDepthMapUpdate( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx ) |
---|
1341 | { |
---|
1342 | // get width, height, and part address |
---|
1343 | Int iWidth; |
---|
1344 | Int iHeight; |
---|
1345 | UInt uiAbsPartIdx; |
---|
1346 | pcCU->getPartIndexAndSize( uiPartIdx, uiAbsPartIdx, iWidth, iHeight ); |
---|
1347 | iWidth >>= m_uiSubSampExpX; |
---|
1348 | iHeight >>= m_uiSubSampExpY; |
---|
1349 | |
---|
1350 | // get depth values |
---|
1351 | Int iDepthValue = PDM_UNDEFINED_DEPTH; |
---|
1352 | Int aiPrdDepth[2] = { PDM_UNDEFINED_DEPTH, PDM_UNDEFINED_DEPTH }; |
---|
1353 | for( Int iRefListId = 0; iRefListId < 2; iRefListId++ ) |
---|
1354 | { |
---|
1355 | RefPicList eRefPicList = RefPicList( iRefListId ); |
---|
1356 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
1357 | Int iRefIdx = pcCUMvField->getRefIdx( uiAbsPartIdx ); |
---|
1358 | UInt uiBaseId = ( iRefIdx >= 0 ? pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getSPS()->getViewId() : MAX_VIEW_NUM ); |
---|
1359 | Bool bInterview = ( iRefIdx >= 0 && uiBaseId < m_uiCurrViewId ); |
---|
1360 | if( bInterview ) |
---|
1361 | { |
---|
1362 | Int iMvX = pcCUMvField->getMv( uiAbsPartIdx ).getHor(); |
---|
1363 | aiPrdDepth[ iRefListId ] = xGetVirtDepthFromDisparity( uiBaseId, iMvX ); |
---|
1364 | } |
---|
1365 | } |
---|
1366 | if( aiPrdDepth[ 0 ] != PDM_UNDEFINED_DEPTH && aiPrdDepth[ 1 ] != PDM_UNDEFINED_DEPTH ) |
---|
1367 | { |
---|
1368 | iDepthValue = ( aiPrdDepth[ 0 ] + aiPrdDepth[ 1 ] + 1 ) >> 1; |
---|
1369 | } |
---|
1370 | else |
---|
1371 | { |
---|
1372 | iDepthValue = ( aiPrdDepth[ 0 ] != PDM_UNDEFINED_DEPTH ? aiPrdDepth[ 0 ] : aiPrdDepth[ 1 ] ); |
---|
1373 | AOT( iDepthValue == PDM_UNDEFINED_DEPTH ); |
---|
1374 | } |
---|
1375 | iDepthValue = Max( 0, Min( PDM_MAX_ABS_VIRT_DEPTH, iDepthValue ) ); |
---|
1376 | |
---|
1377 | // set depth map for PU |
---|
1378 | UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpX; |
---|
1379 | UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpY; |
---|
1380 | Pel* pDMSamples = pcCUDepthMap->getLumaAddr() + uiBlkY * pcCUDepthMap->getStride() + uiBlkX; |
---|
1381 | Int iStride = pcCUDepthMap->getStride (); |
---|
1382 | for( Int iY = 0; iY < iHeight; iY++, pDMSamples += iStride ) |
---|
1383 | { |
---|
1384 | for( Int iX = 0; iX < iWidth; iX++) |
---|
1385 | { |
---|
1386 | pDMSamples[ iX ] = (Pel)iDepthValue; |
---|
1387 | } |
---|
1388 | } |
---|
1389 | } |
---|
1390 | |
---|
1391 | |
---|
1392 | Void |
---|
1393 | TComDepthMapGenerator::xInterPUDepthMapUpdate( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx ) |
---|
1394 | { |
---|
1395 | const Int iMaxAbsDeltaMvY = 8 << 2; |
---|
1396 | |
---|
1397 | //===== determine block parameters for current access unit and current view ===== |
---|
1398 | Int iWidth; |
---|
1399 | Int iHeight; |
---|
1400 | UInt uiAbsPartIdx; |
---|
1401 | pcCU->getPartIndexAndSize ( uiPartIdx, uiAbsPartIdx, iWidth, iHeight ); |
---|
1402 | UInt uiCurrViewId = pcCU->getSlice()->getSPS()->getViewId(); |
---|
1403 | Int iNum4x4BlksY = iHeight >> 2; |
---|
1404 | Int iNum4x4BlksX = iWidth >> 2; |
---|
1405 | iWidth >>= m_uiSubSampExpX; |
---|
1406 | iHeight >>= m_uiSubSampExpY; |
---|
1407 | |
---|
1408 | TComPicYuv* pcCurrDepthMap = pcCU->getPic()->getPredDepthMap(); |
---|
1409 | Pel* piCurrDepthMap = pcCurrDepthMap->getLumaAddr(); |
---|
1410 | Int iCurrStride = pcCurrDepthMap->getStride(); |
---|
1411 | TComCUMvField* aiCurrMvField[2] = { pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getCUMvField( REF_PIC_LIST_1 ) }; |
---|
1412 | Int aiCurrRefIdx [2] = { aiCurrMvField[0]->getRefIdx( uiAbsPartIdx ), aiCurrMvField[1]->getRefIdx( uiAbsPartIdx ) }; |
---|
1413 | Int iMinCurrListId = ( aiCurrRefIdx [0] < 0 ? 1 : 0 ); |
---|
1414 | Int iMaxCurrListId = ( aiCurrRefIdx [1] < 0 ? 0 : 1 ); |
---|
1415 | Int iCurrPUPosX; |
---|
1416 | Int iCurrPUPosY; |
---|
1417 | pcCurrDepthMap->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx, iCurrPUPosX, iCurrPUPosY ); |
---|
1418 | AOT( uiCurrViewId != m_uiCurrViewId ); |
---|
1419 | AOT( iMinCurrListId > iMaxCurrListId ); |
---|
1420 | AOT( aiCurrRefIdx[0] >= 0 && pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, aiCurrRefIdx[0] )->getSPS()->getViewId() != uiCurrViewId ); |
---|
1421 | AOT( aiCurrRefIdx[1] >= 0 && pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, aiCurrRefIdx[1] )->getSPS()->getViewId() != uiCurrViewId ); |
---|
1422 | |
---|
1423 | //===== determine parameters for current access unit and base view ===== |
---|
1424 | AOF( m_auiBaseIdList.size() ); |
---|
1425 | UInt uiBaseId = m_auiBaseIdList[ 0 ]; |
---|
1426 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseId ); |
---|
1427 | AOF( pcBasePic ); |
---|
1428 | TComPicYuv* pcBaseDepthMap = pcBasePic->getPredDepthMap(); |
---|
1429 | TComPicYuv* pcBaseRecPic = pcBasePic->getPicYuvRec (); |
---|
1430 | Pel* piBaseDepthMap = pcBaseDepthMap->getLumaAddr(); |
---|
1431 | Int iBaseStride = pcBaseDepthMap->getStride(); |
---|
1432 | Int iShiftX = m_uiSubSampExpX + 2; |
---|
1433 | Int iShiftY = m_uiSubSampExpY + 2; |
---|
1434 | Int iAddX = ( 1 << iShiftX ) >> 1; |
---|
1435 | Int iAddY = ( 1 << iShiftY ) >> 1; |
---|
1436 | |
---|
1437 | //===== initialize 4x4 block arrays ===== |
---|
1438 | for( Int i4x4BlkY = 0; i4x4BlkY < iNum4x4BlksY; i4x4BlkY++ ) |
---|
1439 | { |
---|
1440 | for( Int i4x4BlkX = 0; i4x4BlkX < iNum4x4BlksX; i4x4BlkX++ ) |
---|
1441 | { |
---|
1442 | m_aabDepthSet[ i4x4BlkY ][ i4x4BlkX ] = false; |
---|
1443 | m_aai4x4Depth[ i4x4BlkY ][ i4x4BlkX ] = PDM_UNDEFINED_DEPTH; |
---|
1444 | } |
---|
1445 | } |
---|
1446 | Int iNum4x4Set = 0; |
---|
1447 | |
---|
1448 | //===== determine depth based on 4x4 blocks ===== |
---|
1449 | for( Int i4x4BlkY = 0; i4x4BlkY < iNum4x4BlksY; i4x4BlkY++ ) |
---|
1450 | { |
---|
1451 | for( Int i4x4BlkX = 0; i4x4BlkX < iNum4x4BlksX; i4x4BlkX++ ) |
---|
1452 | { |
---|
1453 | // position parameters |
---|
1454 | Int iCurrBlkPosX = iCurrPUPosX + ( ( i4x4BlkX << 2 ) >> m_uiSubSampExpX ); |
---|
1455 | Int iCurrBlkPosY = iCurrPUPosY + ( ( i4x4BlkY << 2 ) >> m_uiSubSampExpY ); |
---|
1456 | Int iCurrSamplePosX = iCurrBlkPosX + ( 1 >> m_uiSubSampExpX ); |
---|
1457 | Int iCurrSamplePosY = iCurrBlkPosY + ( 1 >> m_uiSubSampExpY ); |
---|
1458 | Int iCurrPredDepth = piCurrDepthMap[ iCurrSamplePosY * iCurrStride + iCurrSamplePosX ]; |
---|
1459 | Int iCurrPredDisp = xGetDisparityFromVirtDepth( uiBaseId, iCurrPredDepth ); |
---|
1460 | Int iBaseSamplePosX = iCurrSamplePosX + ( ( iCurrPredDisp + iAddX ) >> iShiftX ); |
---|
1461 | Int iBaseSamplePosY = iCurrSamplePosY; |
---|
1462 | iBaseSamplePosX = Clip3( 0, pcBaseDepthMap->getWidth () - 1, iBaseSamplePosX ); |
---|
1463 | iBaseSamplePosY = Clip3( 0, pcBaseDepthMap->getHeight() - 1, iBaseSamplePosY ); |
---|
1464 | |
---|
1465 | // check for occlusion |
---|
1466 | if( piBaseDepthMap[ iBaseSamplePosY * iBaseStride + iBaseSamplePosX ] != iCurrPredDepth ) |
---|
1467 | { |
---|
1468 | continue; |
---|
1469 | } |
---|
1470 | |
---|
1471 | // determine base motion data and check prediction mode |
---|
1472 | Int iBaseCUAddr; |
---|
1473 | Int iBaseAbsPartIdx; |
---|
1474 | pcBaseRecPic->getCUAddrAndPartIdx( iBaseSamplePosX << m_uiSubSampExpX, iBaseSamplePosY << m_uiSubSampExpY, iBaseCUAddr, iBaseAbsPartIdx ); |
---|
1475 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
---|
1476 | if( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_INTER && pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) != MODE_SKIP ) |
---|
1477 | { |
---|
1478 | continue; |
---|
1479 | } |
---|
1480 | |
---|
1481 | // check whether base was inter-view predicted |
---|
1482 | TComCUMvField* aiBaseMvField[2] = { pcBaseCU->getCUMvField( REF_PIC_LIST_0 ), pcBaseCU->getCUMvField( REF_PIC_LIST_1 ) }; |
---|
1483 | Int aiBaseRefIdx [2] = { aiBaseMvField[0]->getRefIdx( iBaseAbsPartIdx ), aiBaseMvField[1]->getRefIdx( iBaseAbsPartIdx ) }; |
---|
1484 | Bool abBaseIntView[2] = { aiBaseRefIdx[0] >= 0 && pcBaseCU->getSlice()->getRefPic( REF_PIC_LIST_0, aiBaseRefIdx[0] )->getSPS()->getViewId() != uiBaseId, |
---|
1485 | aiBaseRefIdx[1] >= 0 && pcBaseCU->getSlice()->getRefPic( REF_PIC_LIST_1, aiBaseRefIdx[1] )->getSPS()->getViewId() != uiBaseId }; |
---|
1486 | if( abBaseIntView[0] || abBaseIntView[1] ) |
---|
1487 | { // current depth is reliable |
---|
1488 | m_aai4x4Depth[i4x4BlkY][i4x4BlkX] = iCurrPredDepth; |
---|
1489 | m_aabDepthSet[i4x4BlkY][i4x4BlkX] = true; |
---|
1490 | iNum4x4Set++; |
---|
1491 | continue; |
---|
1492 | } |
---|
1493 | |
---|
1494 | // determine depth candidates using an approximate 4-point relationship (if appropriate) |
---|
1495 | std::vector<Int> aiDepthCand; |
---|
1496 | Int iMinBaseListId = ( aiBaseRefIdx [0] < 0 ? 1 : 0 ); |
---|
1497 | Int iMaxBaseListId = ( aiBaseRefIdx [1] < 0 ? 0 : 1 ); |
---|
1498 | AOT( iMinBaseListId > iMaxBaseListId ); |
---|
1499 | for( Int iCurrRefListId = iMinCurrListId; iCurrRefListId <= iMaxCurrListId; iCurrRefListId++ ) |
---|
1500 | { |
---|
1501 | RefPicList eCurrRefPicList = RefPicList( iCurrRefListId ); |
---|
1502 | Int iCurrRefPoc = pcCU->getSlice()->getRefPOC( eCurrRefPicList, aiCurrRefIdx[ iCurrRefListId ] ); |
---|
1503 | TComPic* pcCurrRefPic = pcCU->getSlice()->getRefPic( eCurrRefPicList, aiCurrRefIdx[ iCurrRefListId ] ); |
---|
1504 | TComPicYuv* pcCurrRefDMap = pcCurrRefPic->getPredDepthMap(); |
---|
1505 | Pel* piCurrRefDMap = pcCurrRefDMap->getLumaAddr(); |
---|
1506 | Int iCurrRefStride = pcCurrRefDMap->getStride(); |
---|
1507 | TComMv rcCurrMv = aiCurrMvField[ iCurrRefListId ]->getMv( uiAbsPartIdx ); |
---|
1508 | Int iCurrRefSamplePosX = iCurrSamplePosX + ( ( rcCurrMv.getHor() + iAddX ) >> iShiftX ); |
---|
1509 | Int iCurrRefSamplePosY = iCurrSamplePosY + ( ( rcCurrMv.getVer() + iAddY ) >> iShiftY ); |
---|
1510 | Int iCurrRefSamplePosXC = Clip3( 0, pcCurrRefDMap->getWidth () - 1, iCurrRefSamplePosX ); |
---|
1511 | Int iCurrRefSamplePosYC = Clip3( 0, pcCurrRefDMap->getHeight() - 1, iCurrRefSamplePosY ); |
---|
1512 | Int iCurrRefDepth = piCurrRefDMap[ iCurrRefSamplePosYC * iCurrRefStride + iCurrRefSamplePosXC ]; |
---|
1513 | |
---|
1514 | for( Int iBaseRefListId = iMinBaseListId; iBaseRefListId <= iMaxBaseListId; iBaseRefListId++ ) |
---|
1515 | { |
---|
1516 | RefPicList eBaseRefPicList = RefPicList( iBaseRefListId ); |
---|
1517 | Int iBaseRefPoc = pcBaseCU->getSlice()->getRefPOC( eBaseRefPicList, aiBaseRefIdx[ iBaseRefListId ] ); |
---|
1518 | |
---|
1519 | if( iCurrRefPoc == iBaseRefPoc ) |
---|
1520 | { |
---|
1521 | // location and depth for path currView/currAU -> currView/refAU -> baseView/refAU |
---|
1522 | Int iCurrRefDisp = xGetDisparityFromVirtDepth( uiBaseId, iCurrRefDepth ); |
---|
1523 | Int iBaseRefSamplePosX = iCurrRefSamplePosX + ( ( iCurrRefDisp + iAddX ) >> iShiftX ); |
---|
1524 | Int iBaseRefSamplePosY = iCurrRefSamplePosY; |
---|
1525 | TComPic* pcBaseRefPic = pcBaseCU->getSlice()->getRefPic( eBaseRefPicList, aiBaseRefIdx[ iBaseRefListId ] ); |
---|
1526 | TComPicYuv* pcBaseRefDMap = pcBaseRefPic->getPredDepthMap(); |
---|
1527 | Pel* piBaseRefDMap = pcBaseRefDMap->getLumaAddr(); |
---|
1528 | Int iBaseRefStride = pcBaseRefDMap->getStride(); |
---|
1529 | iBaseRefSamplePosX = Clip3( 0, pcBaseRefDMap->getWidth () - 1, iBaseRefSamplePosX ); |
---|
1530 | iBaseRefSamplePosY = Clip3( 0, pcBaseRefDMap->getHeight() - 1, iBaseRefSamplePosY ); |
---|
1531 | Int iBaseRefDepth = piBaseRefDMap[ iBaseRefSamplePosY * iBaseRefStride + iBaseRefSamplePosX ]; |
---|
1532 | |
---|
1533 | // location and depth for path currView/currAU ->baseView/currAU -> baseView/refAU |
---|
1534 | TComMv rcBaseMv = aiBaseMvField[ iBaseRefListId ]->getMv( iBaseAbsPartIdx ); |
---|
1535 | Int iAbsDeltaMvY = ( rcBaseMv.getAbsVer() > rcCurrMv.getVer() ? rcBaseMv.getAbsVer() - rcCurrMv.getVer() : rcCurrMv.getVer() - rcBaseMv.getAbsVer() ); |
---|
1536 | |
---|
1537 | // check reliability (occlusion in reference access unit / vertical motion vector difference) |
---|
1538 | if( iBaseRefDepth != iCurrRefDepth || iAbsDeltaMvY > iMaxAbsDeltaMvY ) |
---|
1539 | { |
---|
1540 | continue; |
---|
1541 | } |
---|
1542 | |
---|
1543 | // determine new depth |
---|
1544 | Int iCurrCandDisp = iCurrRefDisp + rcCurrMv.getHor() - rcBaseMv.getHor(); |
---|
1545 | Int iCurrCandDepth = xGetVirtDepthFromDisparity( uiBaseId, iCurrCandDisp ); |
---|
1546 | aiDepthCand.push_back( iCurrCandDepth ); |
---|
1547 | } // iCurrRefPoc == iBaseRefPoc |
---|
1548 | } // iBaseRefListId |
---|
1549 | } // iCurrRefListId |
---|
1550 | |
---|
1551 | // set depth for 4x4 block |
---|
1552 | if( aiDepthCand.size() ) |
---|
1553 | { // get depth with minimum change (probably most reliable) |
---|
1554 | Int iMinAbsDepthChange = (1<<30); |
---|
1555 | Int iDepthForMinChange = (1<<30); |
---|
1556 | for( UInt uiCandId = 0; uiCandId < (UInt)aiDepthCand.size(); uiCandId++ ) |
---|
1557 | { |
---|
1558 | Int iAbsDeltaDepth = ( aiDepthCand[uiCandId] > iCurrPredDepth ? aiDepthCand[uiCandId] > iCurrPredDepth : iCurrPredDepth - aiDepthCand[uiCandId] ); |
---|
1559 | if( iAbsDeltaDepth < iMinAbsDepthChange ) |
---|
1560 | { |
---|
1561 | iMinAbsDepthChange = iAbsDeltaDepth; |
---|
1562 | iDepthForMinChange = aiDepthCand[uiCandId]; |
---|
1563 | } |
---|
1564 | } |
---|
1565 | m_aai4x4Depth[i4x4BlkY][i4x4BlkX] = Min( Max( 0, iDepthForMinChange ), PDM_MAX_ABS_VIRT_DEPTH ); |
---|
1566 | m_aabDepthSet[i4x4BlkY][i4x4BlkX] = true; |
---|
1567 | iNum4x4Set++; |
---|
1568 | } |
---|
1569 | } // i4x4BlkX |
---|
1570 | } // i4x4BlkY |
---|
1571 | |
---|
1572 | //===== fall back (take original depth for 4x4 blocks) ==== |
---|
1573 | if( iNum4x4Set < Max( 1, ( iNum4x4BlksY * iNum4x4BlksX ) >> 2 ) ) |
---|
1574 | { |
---|
1575 | iNum4x4Set = 0; |
---|
1576 | for( Int i4x4BlkY = 0; i4x4BlkY < iNum4x4BlksY; i4x4BlkY++ ) |
---|
1577 | { |
---|
1578 | for( Int i4x4BlkX = 0; i4x4BlkX < iNum4x4BlksX; i4x4BlkX++ ) |
---|
1579 | { |
---|
1580 | Int iCurrSamplePosX = iCurrPUPosX + ( ( ( i4x4BlkX << 2 ) + 1 ) >> m_uiSubSampExpX ); |
---|
1581 | Int iCurrSamplePosY = iCurrPUPosY + ( ( ( i4x4BlkY << 2 ) + 1 ) >> m_uiSubSampExpY ); |
---|
1582 | m_aai4x4Depth[i4x4BlkY][i4x4BlkX] = piCurrDepthMap[ iCurrSamplePosY * iCurrStride + iCurrSamplePosX ]; |
---|
1583 | m_aabDepthSet[i4x4BlkY][i4x4BlkX] = true; |
---|
1584 | iNum4x4Set++; |
---|
1585 | } |
---|
1586 | } |
---|
1587 | } |
---|
1588 | |
---|
1589 | #if PDM_ONE_DEPTH_PER_PU |
---|
1590 | //===== set average in 4x4 depth array ===== |
---|
1591 | Int iSum = 0; |
---|
1592 | for( Int i4x4BlkY = 0; i4x4BlkY < iNum4x4BlksY; i4x4BlkY++ ) |
---|
1593 | { |
---|
1594 | for( Int i4x4BlkX = 0; i4x4BlkX < iNum4x4BlksX; i4x4BlkX++ ) |
---|
1595 | { |
---|
1596 | if( m_aabDepthSet[ i4x4BlkY ][ i4x4BlkX ] ) |
---|
1597 | { |
---|
1598 | iSum += m_aai4x4Depth[ i4x4BlkY ][ i4x4BlkX ]; |
---|
1599 | } |
---|
1600 | } |
---|
1601 | } |
---|
1602 | Int iDepth = ( iSum + ( iNum4x4Set >> 1 ) ) / iNum4x4Set; |
---|
1603 | iNum4x4Set = iNum4x4BlksY * iNum4x4BlksX; |
---|
1604 | for( Int i4x4BlkY = 0; i4x4BlkY < iNum4x4BlksY; i4x4BlkY++ ) |
---|
1605 | { |
---|
1606 | for( Int i4x4BlkX = 0; i4x4BlkX < iNum4x4BlksX; i4x4BlkX++ ) |
---|
1607 | { |
---|
1608 | m_aai4x4Depth[ i4x4BlkY ][ i4x4BlkX ] = iDepth; |
---|
1609 | m_aabDepthSet[ i4x4BlkY ][ i4x4BlkX ] = true; |
---|
1610 | } |
---|
1611 | } |
---|
1612 | #endif |
---|
1613 | |
---|
1614 | //===== complete depth arrays ===== |
---|
1615 | while( iNum4x4BlksY * iNum4x4BlksX - iNum4x4Set ) |
---|
1616 | { |
---|
1617 | for( Int i4x4BlkY = 0; i4x4BlkY < iNum4x4BlksY; i4x4BlkY++ ) |
---|
1618 | { |
---|
1619 | for( Int i4x4BlkX = 0; i4x4BlkX < iNum4x4BlksX; i4x4BlkX++ ) |
---|
1620 | { |
---|
1621 | if( !m_aabDepthSet[ i4x4BlkY ][ i4x4BlkX ] ) |
---|
1622 | { // could also use minimum of neighbours (occlusions) |
---|
1623 | Int iNumNeighbours = 0; |
---|
1624 | Int iSumNeighbours = 0; |
---|
1625 | if( i4x4BlkY > 0 && m_aabDepthSet[ i4x4BlkY-1 ][ i4x4BlkX ] ) { iSumNeighbours += m_aai4x4Depth[ i4x4BlkY-1 ][ i4x4BlkX ]; iNumNeighbours++; } |
---|
1626 | if( i4x4BlkY < iNum4x4BlksY-1 && m_aabDepthSet[ i4x4BlkY+1 ][ i4x4BlkX ] ) { iSumNeighbours += m_aai4x4Depth[ i4x4BlkY+1 ][ i4x4BlkX ]; iNumNeighbours++; } |
---|
1627 | if( i4x4BlkX > 0 && m_aabDepthSet[ i4x4BlkY ][ i4x4BlkX-1 ] ) { iSumNeighbours += m_aai4x4Depth[ i4x4BlkY ][ i4x4BlkX-1 ]; iNumNeighbours++; } |
---|
1628 | if( i4x4BlkX < iNum4x4BlksX-1 && m_aabDepthSet[ i4x4BlkY ][ i4x4BlkX+1 ] ) { iSumNeighbours += m_aai4x4Depth[ i4x4BlkY ][ i4x4BlkX+1 ]; iNumNeighbours++; } |
---|
1629 | if( iNumNeighbours ) |
---|
1630 | { |
---|
1631 | m_aai4x4Depth[ i4x4BlkY ][ i4x4BlkX ] = ( iSumNeighbours + ( iNumNeighbours >> 1 ) ) / iNumNeighbours; |
---|
1632 | m_aabDepthSet[ i4x4BlkY ][ i4x4BlkX ] = true; |
---|
1633 | iNum4x4Set++; |
---|
1634 | } |
---|
1635 | } |
---|
1636 | } |
---|
1637 | } |
---|
1638 | } |
---|
1639 | |
---|
1640 | //===== set depth values ===== |
---|
1641 | UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpX; |
---|
1642 | UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ] >> m_uiSubSampExpY; |
---|
1643 | Pel* piDepthMap = pcCUDepthMap->getLumaAddr() + uiBlkY * pcCUDepthMap->getStride() + uiBlkX; |
---|
1644 | Int iCUStride = pcCUDepthMap->getStride (); |
---|
1645 | for( Int iRow = 0; iRow < iHeight; iRow++, piDepthMap += iCUStride ) |
---|
1646 | { |
---|
1647 | for( Int iCol = 0; iCol < iWidth; iCol++ ) |
---|
1648 | { |
---|
1649 | piDepthMap[ iCol ] = m_aai4x4Depth[ (iRow << m_uiSubSampExpY) >> 2 ][ (iCol << m_uiSubSampExpX) >> 2 ]; |
---|
1650 | } |
---|
1651 | } |
---|
1652 | } |
---|
1653 | |
---|
1654 | |
---|
1655 | Void |
---|
1656 | TComDepthMapGenerator::xInterPUDepthMapPrediction( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx ) |
---|
1657 | { |
---|
1658 | m_pcPrediction->motionCompensation( pcCU, pcCUDepthMap, REF_PIC_LIST_X, (Int)uiPartIdx, true, m_uiSubSampExpX, m_uiSubSampExpY ); |
---|
1659 | } |
---|
1660 | |
---|
1661 | |
---|
1662 | Bool |
---|
1663 | TComDepthMapGenerator::xGetPredDepth( TComDataCU* pcCU, UInt uiPartIdx, Int& riPrdDepth, Int* piPosX, Int* piPosY ) |
---|
1664 | { |
---|
1665 | AOF ( m_bCreated && m_bInit ); |
---|
1666 | AOF ( pcCU ); |
---|
1667 | ROFRS( m_bPDMAvailable, false ); |
---|
1668 | |
---|
1669 | TComSlice* pcSlice = pcCU->getSlice (); |
---|
1670 | TComPic* pcPic = pcCU->getPic (); |
---|
1671 | TComSPS* pcSPS = pcSlice->getSPS(); |
---|
1672 | AOF ( pcPic->getPredDepthMap() ); |
---|
1673 | AOF ( pcSPS->getViewId() == m_uiCurrViewId ); |
---|
1674 | |
---|
1675 | //===== get predicted depth and disprity for middle position of current PU ===== |
---|
1676 | UInt uiPartAddr; |
---|
1677 | Int iWidth; |
---|
1678 | Int iHeight; |
---|
1679 | pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
---|
1680 | TComPicYuv* pcPredDepthMap = pcPic->getPredDepthMap(); |
---|
1681 | Pel* piPredDepthMap = pcPredDepthMap->getLumaAddr ( 0 ); |
---|
1682 | Int iCurrStride = pcPredDepthMap->getStride (); |
---|
1683 | Int iCurrPosX; |
---|
1684 | Int iCurrPosY; |
---|
1685 | pcPredDepthMap->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
---|
1686 | #if SAIT_IMPROV_MOTION_PRED_M24829 // max disparity within PU |
---|
1687 | Int DiWidth = iCurrPosX+(iWidth >> m_uiSubSampExpX); |
---|
1688 | Int DiHeight = iCurrPosY+(iHeight >> m_uiSubSampExpY); |
---|
1689 | Int maxDepth = MIN_INT; |
---|
1690 | |
---|
1691 | for(Int y=iCurrPosY; y<DiHeight ;y++) |
---|
1692 | { |
---|
1693 | for(Int x=iCurrPosX; x<DiWidth; x++) |
---|
1694 | { |
---|
1695 | if(piPredDepthMap[ x + y * iCurrStride ] > maxDepth) |
---|
1696 | { |
---|
1697 | maxDepth = piPredDepthMap[ x + y * iCurrStride ]; |
---|
1698 | } |
---|
1699 | } |
---|
1700 | } |
---|
1701 | iCurrPosX += ( ( iWidth >> m_uiSubSampExpX ) - 1 ) >> 1; |
---|
1702 | iCurrPosY += ( ( iHeight >> m_uiSubSampExpY ) - 1 ) >> 1; |
---|
1703 | riPrdDepth = maxDepth; |
---|
1704 | #else |
---|
1705 | iCurrPosX += ( ( iWidth >> m_uiSubSampExpX ) - 1 ) >> 1; |
---|
1706 | iCurrPosY += ( ( iHeight >> m_uiSubSampExpY ) - 1 ) >> 1; |
---|
1707 | riPrdDepth = piPredDepthMap[ iCurrPosX + iCurrPosY * iCurrStride ]; |
---|
1708 | #endif |
---|
1709 | if( piPosX ) |
---|
1710 | { |
---|
1711 | *piPosX = iCurrPosX; |
---|
1712 | } |
---|
1713 | if( piPosY ) |
---|
1714 | { |
---|
1715 | *piPosY = iCurrPosY; |
---|
1716 | } |
---|
1717 | return true; |
---|
1718 | } |
---|
1719 | #endif |
---|
1720 | |
---|
1721 | #endif // DEPTH_MAP_GENERATION |
---|
1722 | |
---|