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