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