| 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-2013, ITU/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 ITU/ISO/IEC nor the names of its contributors may |
|---|
| 18 | * be used to endorse or promote products derived from this software without |
|---|
| 19 | * specific prior written permission. |
|---|
| 20 | * |
|---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
|---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | /** \file TComDataCU.cpp |
|---|
| 35 | \brief CU data structure |
|---|
| 36 | \todo not all entities are documented |
|---|
| 37 | */ |
|---|
| 38 | |
|---|
| 39 | #include "TComDataCU.h" |
|---|
| 40 | #include "TComPic.h" |
|---|
| 41 | |
|---|
| 42 | //! \ingroup TLibCommon |
|---|
| 43 | //! \{ |
|---|
| 44 | |
|---|
| 45 | #if ADAPTIVE_QP_SELECTION |
|---|
| 46 | Int * TComDataCU::m_pcGlbArlCoeffY = NULL; |
|---|
| 47 | Int * TComDataCU::m_pcGlbArlCoeffCb = NULL; |
|---|
| 48 | Int * TComDataCU::m_pcGlbArlCoeffCr = NULL; |
|---|
| 49 | #endif |
|---|
| 50 | |
|---|
| 51 | // ==================================================================================================================== |
|---|
| 52 | // Constructor / destructor / create / destroy |
|---|
| 53 | // ==================================================================================================================== |
|---|
| 54 | |
|---|
| 55 | TComDataCU::TComDataCU() |
|---|
| 56 | { |
|---|
| 57 | m_pcPic = NULL; |
|---|
| 58 | m_pcSlice = NULL; |
|---|
| 59 | m_puhDepth = NULL; |
|---|
| 60 | |
|---|
| 61 | m_skipFlag = NULL; |
|---|
| 62 | |
|---|
| 63 | m_pePartSize = NULL; |
|---|
| 64 | m_pePredMode = NULL; |
|---|
| 65 | m_CUTransquantBypass = NULL; |
|---|
| 66 | m_puhWidth = NULL; |
|---|
| 67 | m_puhHeight = NULL; |
|---|
| 68 | m_phQP = NULL; |
|---|
| 69 | m_pbMergeFlag = NULL; |
|---|
| 70 | m_puhMergeIndex = NULL; |
|---|
| 71 | m_puhLumaIntraDir = NULL; |
|---|
| 72 | m_puhChromaIntraDir = NULL; |
|---|
| 73 | m_puhInterDir = NULL; |
|---|
| 74 | m_puhTrIdx = NULL; |
|---|
| 75 | m_puhTransformSkip[0] = NULL; |
|---|
| 76 | m_puhTransformSkip[1] = NULL; |
|---|
| 77 | m_puhTransformSkip[2] = NULL; |
|---|
| 78 | m_puhCbf[0] = NULL; |
|---|
| 79 | m_puhCbf[1] = NULL; |
|---|
| 80 | m_puhCbf[2] = NULL; |
|---|
| 81 | m_pcTrCoeffY = NULL; |
|---|
| 82 | m_pcTrCoeffCb = NULL; |
|---|
| 83 | m_pcTrCoeffCr = NULL; |
|---|
| 84 | #if ADAPTIVE_QP_SELECTION |
|---|
| 85 | m_ArlCoeffIsAliasedAllocation = false; |
|---|
| 86 | m_pcArlCoeffY = NULL; |
|---|
| 87 | m_pcArlCoeffCb = NULL; |
|---|
| 88 | m_pcArlCoeffCr = NULL; |
|---|
| 89 | #endif |
|---|
| 90 | |
|---|
| 91 | m_pbIPCMFlag = NULL; |
|---|
| 92 | m_pcIPCMSampleY = NULL; |
|---|
| 93 | m_pcIPCMSampleCb = NULL; |
|---|
| 94 | m_pcIPCMSampleCr = NULL; |
|---|
| 95 | |
|---|
| 96 | m_pcPattern = NULL; |
|---|
| 97 | |
|---|
| 98 | m_pcCUAboveLeft = NULL; |
|---|
| 99 | m_pcCUAboveRight = NULL; |
|---|
| 100 | m_pcCUAbove = NULL; |
|---|
| 101 | m_pcCULeft = NULL; |
|---|
| 102 | |
|---|
| 103 | m_apcCUColocated[0] = NULL; |
|---|
| 104 | m_apcCUColocated[1] = NULL; |
|---|
| 105 | |
|---|
| 106 | m_apiMVPIdx[0] = NULL; |
|---|
| 107 | m_apiMVPIdx[1] = NULL; |
|---|
| 108 | m_apiMVPNum[0] = NULL; |
|---|
| 109 | m_apiMVPNum[1] = NULL; |
|---|
| 110 | |
|---|
| 111 | m_bDecSubCu = false; |
|---|
| 112 | m_sliceStartCU = 0; |
|---|
| 113 | m_sliceSegmentStartCU = 0; |
|---|
| 114 | #if H_3D_NBDV |
|---|
| 115 | m_pDvInfo = NULL; |
|---|
| 116 | #endif |
|---|
| 117 | |
|---|
| 118 | #if H_3D_VSP |
|---|
| 119 | m_piVSPFlag = NULL; |
|---|
| 120 | #endif |
|---|
| 121 | |
|---|
| 122 | #if H_3D_ARP |
|---|
| 123 | m_puhARPW = NULL; |
|---|
| 124 | #endif |
|---|
| 125 | |
|---|
| 126 | #if H_3D_IC |
|---|
| 127 | m_pbICFlag = NULL; |
|---|
| 128 | #endif |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | TComDataCU::~TComDataCU() |
|---|
| 132 | { |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | Void TComDataCU::create(UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
|---|
| 136 | #if ADAPTIVE_QP_SELECTION |
|---|
| 137 | , Bool bGlobalRMARLBuffer |
|---|
| 138 | #endif |
|---|
| 139 | ) |
|---|
| 140 | { |
|---|
| 141 | m_bDecSubCu = bDecSubCu; |
|---|
| 142 | |
|---|
| 143 | m_pcPic = NULL; |
|---|
| 144 | m_pcSlice = NULL; |
|---|
| 145 | m_uiNumPartition = uiNumPartition; |
|---|
| 146 | m_unitSize = unitSize; |
|---|
| 147 | |
|---|
| 148 | if ( !bDecSubCu ) |
|---|
| 149 | { |
|---|
| 150 | m_phQP = (Char* )xMalloc(Char, uiNumPartition); |
|---|
| 151 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 152 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 153 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 154 | |
|---|
| 155 | m_skipFlag = new Bool[ uiNumPartition ]; |
|---|
| 156 | |
|---|
| 157 | m_pePartSize = new Char[ uiNumPartition ]; |
|---|
| 158 | memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) ); |
|---|
| 159 | m_pePredMode = new Char[ uiNumPartition ]; |
|---|
| 160 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
|---|
| 161 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
|---|
| 162 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 163 | #if H_3D_VSP |
|---|
| 164 | m_piVSPFlag = (Char* )xMalloc(Char, uiNumPartition); |
|---|
| 165 | #endif |
|---|
| 166 | m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 167 | m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 168 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 169 | |
|---|
| 170 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 171 | m_puhTransformSkip[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 172 | m_puhTransformSkip[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 173 | m_puhTransformSkip[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 174 | |
|---|
| 175 | m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 176 | m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 177 | m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 178 | |
|---|
| 179 | m_apiMVPIdx[0] = new Char[ uiNumPartition ]; |
|---|
| 180 | m_apiMVPIdx[1] = new Char[ uiNumPartition ]; |
|---|
| 181 | m_apiMVPNum[0] = new Char[ uiNumPartition ]; |
|---|
| 182 | m_apiMVPNum[1] = new Char[ uiNumPartition ]; |
|---|
| 183 | memset( m_apiMVPIdx[0], -1,uiNumPartition * sizeof( Char ) ); |
|---|
| 184 | memset( m_apiMVPIdx[1], -1,uiNumPartition * sizeof( Char ) ); |
|---|
| 185 | |
|---|
| 186 | m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); |
|---|
| 187 | m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
|---|
| 188 | m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
|---|
| 189 | #if H_3D_NBDV |
|---|
| 190 | m_pDvInfo = (DisInfo* )xMalloc(DisInfo, uiNumPartition); |
|---|
| 191 | #endif |
|---|
| 192 | memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) ); |
|---|
| 193 | memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
|---|
| 194 | memset( m_pcTrCoeffCr, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
|---|
| 195 | #if ADAPTIVE_QP_SELECTION |
|---|
| 196 | if( bGlobalRMARLBuffer ) |
|---|
| 197 | { |
|---|
| 198 | if( m_pcGlbArlCoeffY == NULL ) |
|---|
| 199 | { |
|---|
| 200 | m_pcGlbArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
|---|
| 201 | m_pcGlbArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
|---|
| 202 | m_pcGlbArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
|---|
| 203 | } |
|---|
| 204 | m_pcArlCoeffY = m_pcGlbArlCoeffY; |
|---|
| 205 | m_pcArlCoeffCb = m_pcGlbArlCoeffCb; |
|---|
| 206 | m_pcArlCoeffCr = m_pcGlbArlCoeffCr; |
|---|
| 207 | m_ArlCoeffIsAliasedAllocation = true; |
|---|
| 208 | } |
|---|
| 209 | else |
|---|
| 210 | { |
|---|
| 211 | m_pcArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
|---|
| 212 | m_pcArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
|---|
| 213 | m_pcArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
|---|
| 214 | } |
|---|
| 215 | #endif |
|---|
| 216 | |
|---|
| 217 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
|---|
| 218 | m_pcIPCMSampleY = (Pel* )xMalloc(Pel , uiWidth*uiHeight); |
|---|
| 219 | m_pcIPCMSampleCb = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
|---|
| 220 | m_pcIPCMSampleCr = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
|---|
| 221 | |
|---|
| 222 | m_acCUMvField[0].create( uiNumPartition ); |
|---|
| 223 | m_acCUMvField[1].create( uiNumPartition ); |
|---|
| 224 | |
|---|
| 225 | #if H_3D_ARP |
|---|
| 226 | m_puhARPW = new UChar[ uiNumPartition]; |
|---|
| 227 | #endif |
|---|
| 228 | #if H_3D_IC |
|---|
| 229 | m_pbICFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
|---|
| 230 | #endif |
|---|
| 231 | } |
|---|
| 232 | else |
|---|
| 233 | { |
|---|
| 234 | m_acCUMvField[0].setNumPartition(uiNumPartition ); |
|---|
| 235 | m_acCUMvField[1].setNumPartition(uiNumPartition ); |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | m_sliceStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
|---|
| 239 | m_sliceSegmentStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
|---|
| 240 | |
|---|
| 241 | // create pattern memory |
|---|
| 242 | m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); |
|---|
| 243 | |
|---|
| 244 | // create motion vector fields |
|---|
| 245 | |
|---|
| 246 | m_pcCUAboveLeft = NULL; |
|---|
| 247 | m_pcCUAboveRight = NULL; |
|---|
| 248 | m_pcCUAbove = NULL; |
|---|
| 249 | m_pcCULeft = NULL; |
|---|
| 250 | |
|---|
| 251 | m_apcCUColocated[0] = NULL; |
|---|
| 252 | m_apcCUColocated[1] = NULL; |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | Void TComDataCU::destroy() |
|---|
| 256 | { |
|---|
| 257 | m_pcPic = NULL; |
|---|
| 258 | m_pcSlice = NULL; |
|---|
| 259 | |
|---|
| 260 | if ( m_pcPattern ) |
|---|
| 261 | { |
|---|
| 262 | xFree(m_pcPattern); |
|---|
| 263 | m_pcPattern = NULL; |
|---|
| 264 | } |
|---|
| 265 | |
|---|
| 266 | // encoder-side buffer free |
|---|
| 267 | if ( !m_bDecSubCu ) |
|---|
| 268 | { |
|---|
| 269 | if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } |
|---|
| 270 | if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } |
|---|
| 271 | if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } |
|---|
| 272 | if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } |
|---|
| 273 | |
|---|
| 274 | if ( m_skipFlag ) { delete[] m_skipFlag; m_skipFlag = NULL; } |
|---|
| 275 | |
|---|
| 276 | if ( m_pePartSize ) { delete[] m_pePartSize; m_pePartSize = NULL; } |
|---|
| 277 | if ( m_pePredMode ) { delete[] m_pePredMode; m_pePredMode = NULL; } |
|---|
| 278 | if ( m_CUTransquantBypass ) { delete[] m_CUTransquantBypass;m_CUTransquantBypass = NULL; } |
|---|
| 279 | if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } |
|---|
| 280 | if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } |
|---|
| 281 | if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } |
|---|
| 282 | if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } |
|---|
| 283 | if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } |
|---|
| 284 | if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } |
|---|
| 285 | #if H_3D_VSP |
|---|
| 286 | if ( m_piVSPFlag ) { xFree(m_piVSPFlag); m_piVSPFlag = NULL; } |
|---|
| 287 | #endif |
|---|
| 288 | if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } |
|---|
| 289 | if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } |
|---|
| 290 | if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } |
|---|
| 291 | if ( m_puhTransformSkip[0]) { xFree(m_puhTransformSkip[0]); m_puhTransformSkip[0] = NULL; } |
|---|
| 292 | if ( m_puhTransformSkip[1]) { xFree(m_puhTransformSkip[1]); m_puhTransformSkip[1] = NULL; } |
|---|
| 293 | if ( m_puhTransformSkip[2]) { xFree(m_puhTransformSkip[2]); m_puhTransformSkip[2] = NULL; } |
|---|
| 294 | if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } |
|---|
| 295 | if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } |
|---|
| 296 | if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } |
|---|
| 297 | #if ADAPTIVE_QP_SELECTION |
|---|
| 298 | if (!m_ArlCoeffIsAliasedAllocation) |
|---|
| 299 | { |
|---|
| 300 | xFree(m_pcArlCoeffY); m_pcArlCoeffY = 0; |
|---|
| 301 | xFree(m_pcArlCoeffCb); m_pcArlCoeffCb = 0; |
|---|
| 302 | xFree(m_pcArlCoeffCr); m_pcArlCoeffCr = 0; |
|---|
| 303 | } |
|---|
| 304 | if ( m_pcGlbArlCoeffY ) { xFree(m_pcGlbArlCoeffY); m_pcGlbArlCoeffY = NULL; } |
|---|
| 305 | if ( m_pcGlbArlCoeffCb ) { xFree(m_pcGlbArlCoeffCb); m_pcGlbArlCoeffCb = NULL; } |
|---|
| 306 | if ( m_pcGlbArlCoeffCr ) { xFree(m_pcGlbArlCoeffCr); m_pcGlbArlCoeffCr = NULL; } |
|---|
| 307 | #endif |
|---|
| 308 | if ( m_pbIPCMFlag ) { xFree(m_pbIPCMFlag ); m_pbIPCMFlag = NULL; } |
|---|
| 309 | if ( m_pcIPCMSampleY ) { xFree(m_pcIPCMSampleY); m_pcIPCMSampleY = NULL; } |
|---|
| 310 | if ( m_pcIPCMSampleCb ) { xFree(m_pcIPCMSampleCb); m_pcIPCMSampleCb = NULL; } |
|---|
| 311 | if ( m_pcIPCMSampleCr ) { xFree(m_pcIPCMSampleCr); m_pcIPCMSampleCr = NULL; } |
|---|
| 312 | if ( m_apiMVPIdx[0] ) { delete[] m_apiMVPIdx[0]; m_apiMVPIdx[0] = NULL; } |
|---|
| 313 | if ( m_apiMVPIdx[1] ) { delete[] m_apiMVPIdx[1]; m_apiMVPIdx[1] = NULL; } |
|---|
| 314 | if ( m_apiMVPNum[0] ) { delete[] m_apiMVPNum[0]; m_apiMVPNum[0] = NULL; } |
|---|
| 315 | if ( m_apiMVPNum[1] ) { delete[] m_apiMVPNum[1]; m_apiMVPNum[1] = NULL; } |
|---|
| 316 | #if H_3D_NBDV |
|---|
| 317 | if ( m_pDvInfo ) { xFree(m_pDvInfo); m_pDvInfo = NULL; } |
|---|
| 318 | #endif |
|---|
| 319 | |
|---|
| 320 | #if H_3D_ARP |
|---|
| 321 | if ( m_puhARPW ) { delete[] m_puhARPW; m_puhARPW = NULL; } |
|---|
| 322 | #endif |
|---|
| 323 | #if H_3D_IC |
|---|
| 324 | if ( m_pbICFlag ) { xFree(m_pbICFlag); m_pbICFlag = NULL; } |
|---|
| 325 | #endif |
|---|
| 326 | m_acCUMvField[0].destroy(); |
|---|
| 327 | m_acCUMvField[1].destroy(); |
|---|
| 328 | |
|---|
| 329 | } |
|---|
| 330 | |
|---|
| 331 | m_pcCUAboveLeft = NULL; |
|---|
| 332 | m_pcCUAboveRight = NULL; |
|---|
| 333 | m_pcCUAbove = NULL; |
|---|
| 334 | m_pcCULeft = NULL; |
|---|
| 335 | |
|---|
| 336 | m_apcCUColocated[0] = NULL; |
|---|
| 337 | m_apcCUColocated[1] = NULL; |
|---|
| 338 | |
|---|
| 339 | if( m_sliceStartCU ) |
|---|
| 340 | { |
|---|
| 341 | xFree(m_sliceStartCU); |
|---|
| 342 | m_sliceStartCU=NULL; |
|---|
| 343 | } |
|---|
| 344 | if(m_sliceSegmentStartCU ) |
|---|
| 345 | { |
|---|
| 346 | xFree(m_sliceSegmentStartCU); |
|---|
| 347 | m_sliceSegmentStartCU=NULL; |
|---|
| 348 | } |
|---|
| 349 | } |
|---|
| 350 | |
|---|
| 351 | const NDBFBlockInfo& NDBFBlockInfo::operator= (const NDBFBlockInfo& src) |
|---|
| 352 | { |
|---|
| 353 | this->tileID = src.tileID; |
|---|
| 354 | this->sliceID= src.sliceID; |
|---|
| 355 | this->startSU= src.startSU; |
|---|
| 356 | this->endSU = src.endSU; |
|---|
| 357 | this->widthSU= src.widthSU; |
|---|
| 358 | this->heightSU=src.heightSU; |
|---|
| 359 | this->posX = src.posX; |
|---|
| 360 | this->posY = src.posY; |
|---|
| 361 | this->width = src.width; |
|---|
| 362 | this->height = src.height; |
|---|
| 363 | ::memcpy(this->isBorderAvailable, src.isBorderAvailable, sizeof(Bool)*((Int)NUM_SGU_BORDER)); |
|---|
| 364 | this->allBordersAvailable = src.allBordersAvailable; |
|---|
| 365 | |
|---|
| 366 | return *this; |
|---|
| 367 | } |
|---|
| 368 | |
|---|
| 369 | |
|---|
| 370 | // ==================================================================================================================== |
|---|
| 371 | // Public member functions |
|---|
| 372 | // ==================================================================================================================== |
|---|
| 373 | |
|---|
| 374 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 375 | // Initialization |
|---|
| 376 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 377 | |
|---|
| 378 | /** |
|---|
| 379 | - initialize top-level CU |
|---|
| 380 | - internal buffers are already created |
|---|
| 381 | - set values before encoding a CU |
|---|
| 382 | . |
|---|
| 383 | \param pcPic picture (TComPic) class pointer |
|---|
| 384 | \param iCUAddr CU address |
|---|
| 385 | */ |
|---|
| 386 | Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr ) |
|---|
| 387 | { |
|---|
| 388 | |
|---|
| 389 | m_pcPic = pcPic; |
|---|
| 390 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
|---|
| 391 | m_uiCUAddr = iCUAddr; |
|---|
| 392 | m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth; |
|---|
| 393 | m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight; |
|---|
| 394 | m_uiAbsIdxInLCU = 0; |
|---|
| 395 | m_dTotalCost = MAX_DOUBLE; |
|---|
| 396 | m_uiTotalDistortion = 0; |
|---|
| 397 | m_uiTotalBits = 0; |
|---|
| 398 | m_uiTotalBins = 0; |
|---|
| 399 | m_uiNumPartition = pcPic->getNumPartInCU(); |
|---|
| 400 | |
|---|
| 401 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
|---|
| 402 | { |
|---|
| 403 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceCurStartCUAddr()) |
|---|
| 404 | { |
|---|
| 405 | m_sliceStartCU[i]=getSlice()->getSliceCurStartCUAddr(); |
|---|
| 406 | } |
|---|
| 407 | else |
|---|
| 408 | { |
|---|
| 409 | m_sliceStartCU[i]=pcPic->getCU(getAddr())->m_sliceStartCU[i]; |
|---|
| 410 | } |
|---|
| 411 | } |
|---|
| 412 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
|---|
| 413 | { |
|---|
| 414 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceSegmentCurStartCUAddr()) |
|---|
| 415 | { |
|---|
| 416 | m_sliceSegmentStartCU[i]=getSlice()->getSliceSegmentCurStartCUAddr(); |
|---|
| 417 | } |
|---|
| 418 | else |
|---|
| 419 | { |
|---|
| 420 | m_sliceSegmentStartCU[i]=pcPic->getCU(getAddr())->m_sliceSegmentStartCU[i]; |
|---|
| 421 | } |
|---|
| 422 | } |
|---|
| 423 | |
|---|
| 424 | Int partStartIdx = getSlice()->getSliceSegmentCurStartCUAddr() - pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr) * pcPic->getNumPartInCU(); |
|---|
| 425 | |
|---|
| 426 | Int numElements = min<Int>( partStartIdx, m_uiNumPartition ); |
|---|
| 427 | for ( Int ui = 0; ui < numElements; ui++ ) |
|---|
| 428 | { |
|---|
| 429 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
|---|
| 430 | m_skipFlag[ui] = pcFrom->getSkipFlag(ui); |
|---|
| 431 | m_pePartSize[ui] = pcFrom->getPartitionSize(ui); |
|---|
| 432 | m_pePredMode[ui] = pcFrom->getPredictionMode(ui); |
|---|
| 433 | m_CUTransquantBypass[ui] = pcFrom->getCUTransquantBypass(ui); |
|---|
| 434 | m_puhDepth[ui] = pcFrom->getDepth(ui); |
|---|
| 435 | #if H_3D_ARP |
|---|
| 436 | m_puhARPW [ui] = pcFrom->getARPW( ui ); |
|---|
| 437 | #endif |
|---|
| 438 | #if H_3D_IC |
|---|
| 439 | m_pbICFlag[ui] = pcFrom->m_pbICFlag[ui]; |
|---|
| 440 | #endif |
|---|
| 441 | m_puhWidth [ui] = pcFrom->getWidth(ui); |
|---|
| 442 | m_puhHeight [ui] = pcFrom->getHeight(ui); |
|---|
| 443 | m_puhTrIdx [ui] = pcFrom->getTransformIdx(ui); |
|---|
| 444 | m_puhTransformSkip[0][ui] = pcFrom->getTransformSkip(ui,TEXT_LUMA); |
|---|
| 445 | m_puhTransformSkip[1][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_U); |
|---|
| 446 | m_puhTransformSkip[2][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_V); |
|---|
| 447 | m_apiMVPIdx[0][ui] = pcFrom->m_apiMVPIdx[0][ui];; |
|---|
| 448 | m_apiMVPIdx[1][ui] = pcFrom->m_apiMVPIdx[1][ui]; |
|---|
| 449 | m_apiMVPNum[0][ui] = pcFrom->m_apiMVPNum[0][ui]; |
|---|
| 450 | m_apiMVPNum[1][ui] = pcFrom->m_apiMVPNum[1][ui]; |
|---|
| 451 | m_phQP[ui]=pcFrom->m_phQP[ui]; |
|---|
| 452 | m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui]; |
|---|
| 453 | m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui]; |
|---|
| 454 | #if H_3D_VSP |
|---|
| 455 | m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui]; |
|---|
| 456 | #endif |
|---|
| 457 | m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui]; |
|---|
| 458 | m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui]; |
|---|
| 459 | m_puhInterDir[ui]=pcFrom->m_puhInterDir[ui]; |
|---|
| 460 | m_puhCbf[0][ui]=pcFrom->m_puhCbf[0][ui]; |
|---|
| 461 | m_puhCbf[1][ui]=pcFrom->m_puhCbf[1][ui]; |
|---|
| 462 | m_puhCbf[2][ui]=pcFrom->m_puhCbf[2][ui]; |
|---|
| 463 | m_pbIPCMFlag[ui] = pcFrom->m_pbIPCMFlag[ui]; |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | Int firstElement = max<Int>( partStartIdx, 0 ); |
|---|
| 467 | numElements = m_uiNumPartition - firstElement; |
|---|
| 468 | |
|---|
| 469 | if ( numElements > 0 ) |
|---|
| 470 | { |
|---|
| 471 | memset( m_skipFlag + firstElement, false, numElements * sizeof( *m_skipFlag ) ); |
|---|
| 472 | |
|---|
| 473 | memset( m_pePartSize + firstElement, SIZE_NONE, numElements * sizeof( *m_pePartSize ) ); |
|---|
| 474 | memset( m_pePredMode + firstElement, MODE_NONE, numElements * sizeof( *m_pePredMode ) ); |
|---|
| 475 | memset( m_CUTransquantBypass+ firstElement, false, numElements * sizeof( *m_CUTransquantBypass) ); |
|---|
| 476 | memset( m_puhDepth + firstElement, 0, numElements * sizeof( *m_puhDepth ) ); |
|---|
| 477 | memset( m_puhTrIdx + firstElement, 0, numElements * sizeof( *m_puhTrIdx ) ); |
|---|
| 478 | memset( m_puhTransformSkip[0] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[0]) ); |
|---|
| 479 | memset( m_puhTransformSkip[1] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[1]) ); |
|---|
| 480 | memset( m_puhTransformSkip[2] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[2]) ); |
|---|
| 481 | memset( m_puhWidth + firstElement, g_uiMaxCUWidth, numElements * sizeof( *m_puhWidth ) ); |
|---|
| 482 | memset( m_puhHeight + firstElement, g_uiMaxCUHeight, numElements * sizeof( *m_puhHeight ) ); |
|---|
| 483 | memset( m_apiMVPIdx[0] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[0] ) ); |
|---|
| 484 | memset( m_apiMVPIdx[1] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[1] ) ); |
|---|
| 485 | memset( m_apiMVPNum[0] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[0] ) ); |
|---|
| 486 | memset( m_apiMVPNum[1] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[1] ) ); |
|---|
| 487 | memset( m_phQP + firstElement, getSlice()->getSliceQp(), numElements * sizeof( *m_phQP ) ); |
|---|
| 488 | memset( m_pbMergeFlag + firstElement, false, numElements * sizeof( *m_pbMergeFlag ) ); |
|---|
| 489 | memset( m_puhMergeIndex + firstElement, 0, numElements * sizeof( *m_puhMergeIndex ) ); |
|---|
| 490 | #if H_3D_VSP |
|---|
| 491 | memset( m_piVSPFlag + firstElement, 0, numElements * sizeof( *m_piVSPFlag ) ); |
|---|
| 492 | #endif |
|---|
| 493 | memset( m_puhLumaIntraDir + firstElement, DC_IDX, numElements * sizeof( *m_puhLumaIntraDir ) ); |
|---|
| 494 | memset( m_puhChromaIntraDir + firstElement, 0, numElements * sizeof( *m_puhChromaIntraDir ) ); |
|---|
| 495 | memset( m_puhInterDir + firstElement, 0, numElements * sizeof( *m_puhInterDir ) ); |
|---|
| 496 | memset( m_puhCbf[0] + firstElement, 0, numElements * sizeof( *m_puhCbf[0] ) ); |
|---|
| 497 | memset( m_puhCbf[1] + firstElement, 0, numElements * sizeof( *m_puhCbf[1] ) ); |
|---|
| 498 | memset( m_puhCbf[2] + firstElement, 0, numElements * sizeof( *m_puhCbf[2] ) ); |
|---|
| 499 | memset( m_pbIPCMFlag + firstElement, false, numElements * sizeof( *m_pbIPCMFlag ) ); |
|---|
| 500 | #if H_3D_ARP |
|---|
| 501 | memset( m_puhARPW + firstElement, 0, numElements * sizeof( UChar ) ); |
|---|
| 502 | #endif |
|---|
| 503 | #if H_3D_IC |
|---|
| 504 | memset( m_pbICFlag + firstElement, false, numElements * sizeof( *m_pbICFlag ) ); |
|---|
| 505 | #endif |
|---|
| 506 | } |
|---|
| 507 | |
|---|
| 508 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight; |
|---|
| 509 | if ( 0 >= partStartIdx ) |
|---|
| 510 | { |
|---|
| 511 | m_acCUMvField[0].clearMvField(); |
|---|
| 512 | m_acCUMvField[1].clearMvField(); |
|---|
| 513 | memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); |
|---|
| 514 | #if ADAPTIVE_QP_SELECTION |
|---|
| 515 | memset( m_pcArlCoeffY , 0, sizeof( Int ) * uiTmp ); |
|---|
| 516 | #endif |
|---|
| 517 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 518 | uiTmp >>= 2; |
|---|
| 519 | memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); |
|---|
| 520 | memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); |
|---|
| 521 | #if ADAPTIVE_QP_SELECTION |
|---|
| 522 | memset( m_pcArlCoeffCb, 0, sizeof( Int ) * uiTmp ); |
|---|
| 523 | memset( m_pcArlCoeffCr, 0, sizeof( Int ) * uiTmp ); |
|---|
| 524 | #endif |
|---|
| 525 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 526 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 527 | } |
|---|
| 528 | else |
|---|
| 529 | { |
|---|
| 530 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
|---|
| 531 | m_acCUMvField[0].copyFrom(&pcFrom->m_acCUMvField[0],m_uiNumPartition,0); |
|---|
| 532 | m_acCUMvField[1].copyFrom(&pcFrom->m_acCUMvField[1],m_uiNumPartition,0); |
|---|
| 533 | for(Int i=0; i<uiTmp; i++) |
|---|
| 534 | { |
|---|
| 535 | m_pcTrCoeffY[i]=pcFrom->m_pcTrCoeffY[i]; |
|---|
| 536 | #if ADAPTIVE_QP_SELECTION |
|---|
| 537 | m_pcArlCoeffY[i]=pcFrom->m_pcArlCoeffY[i]; |
|---|
| 538 | #endif |
|---|
| 539 | m_pcIPCMSampleY[i]=pcFrom->m_pcIPCMSampleY[i]; |
|---|
| 540 | } |
|---|
| 541 | for(Int i=0; i<(uiTmp>>2); i++) |
|---|
| 542 | { |
|---|
| 543 | m_pcTrCoeffCb[i]=pcFrom->m_pcTrCoeffCb[i]; |
|---|
| 544 | m_pcTrCoeffCr[i]=pcFrom->m_pcTrCoeffCr[i]; |
|---|
| 545 | #if ADAPTIVE_QP_SELECTION |
|---|
| 546 | m_pcArlCoeffCb[i]=pcFrom->m_pcArlCoeffCb[i]; |
|---|
| 547 | m_pcArlCoeffCr[i]=pcFrom->m_pcArlCoeffCr[i]; |
|---|
| 548 | #endif |
|---|
| 549 | m_pcIPCMSampleCb[i]=pcFrom->m_pcIPCMSampleCb[i]; |
|---|
| 550 | m_pcIPCMSampleCr[i]=pcFrom->m_pcIPCMSampleCr[i]; |
|---|
| 551 | } |
|---|
| 552 | } |
|---|
| 553 | |
|---|
| 554 | // Setting neighbor CU |
|---|
| 555 | m_pcCULeft = NULL; |
|---|
| 556 | m_pcCUAbove = NULL; |
|---|
| 557 | m_pcCUAboveLeft = NULL; |
|---|
| 558 | m_pcCUAboveRight = NULL; |
|---|
| 559 | |
|---|
| 560 | m_apcCUColocated[0] = NULL; |
|---|
| 561 | m_apcCUColocated[1] = NULL; |
|---|
| 562 | |
|---|
| 563 | UInt uiWidthInCU = pcPic->getFrameWidthInCU(); |
|---|
| 564 | if ( m_uiCUAddr % uiWidthInCU ) |
|---|
| 565 | { |
|---|
| 566 | m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); |
|---|
| 567 | } |
|---|
| 568 | |
|---|
| 569 | if ( m_uiCUAddr / uiWidthInCU ) |
|---|
| 570 | { |
|---|
| 571 | m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); |
|---|
| 572 | } |
|---|
| 573 | |
|---|
| 574 | if ( m_pcCULeft && m_pcCUAbove ) |
|---|
| 575 | { |
|---|
| 576 | m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); |
|---|
| 577 | } |
|---|
| 578 | |
|---|
| 579 | if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) |
|---|
| 580 | { |
|---|
| 581 | m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); |
|---|
| 582 | } |
|---|
| 583 | |
|---|
| 584 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
|---|
| 585 | { |
|---|
| 586 | m_apcCUColocated[0] = getSlice()->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); |
|---|
| 587 | } |
|---|
| 588 | |
|---|
| 589 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
|---|
| 590 | { |
|---|
| 591 | m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); |
|---|
| 592 | } |
|---|
| 593 | } |
|---|
| 594 | |
|---|
| 595 | /** initialize prediction data with enabling sub-LCU-level delta QP |
|---|
| 596 | *\param uiDepth depth of the current CU |
|---|
| 597 | *\param qp qp for the current CU |
|---|
| 598 | *- set CU width and CU height according to depth |
|---|
| 599 | *- set qp value according to input qp |
|---|
| 600 | *- set last-coded qp value according to input last-coded qp |
|---|
| 601 | */ |
|---|
| 602 | Void TComDataCU::initEstData( UInt uiDepth, Int qp ) |
|---|
| 603 | { |
|---|
| 604 | m_dTotalCost = MAX_DOUBLE; |
|---|
| 605 | m_uiTotalDistortion = 0; |
|---|
| 606 | m_uiTotalBits = 0; |
|---|
| 607 | m_uiTotalBins = 0; |
|---|
| 608 | |
|---|
| 609 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
|---|
| 610 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
|---|
| 611 | |
|---|
| 612 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
|---|
| 613 | { |
|---|
| 614 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui >= getSlice()->getSliceSegmentCurStartCUAddr()) |
|---|
| 615 | { |
|---|
| 616 | m_apiMVPIdx[0][ui] = -1; |
|---|
| 617 | m_apiMVPIdx[1][ui] = -1; |
|---|
| 618 | m_apiMVPNum[0][ui] = -1; |
|---|
| 619 | m_apiMVPNum[1][ui] = -1; |
|---|
| 620 | m_puhDepth [ui] = uiDepth; |
|---|
| 621 | m_puhWidth [ui] = uhWidth; |
|---|
| 622 | m_puhHeight [ui] = uhHeight; |
|---|
| 623 | m_puhTrIdx [ui] = 0; |
|---|
| 624 | m_puhTransformSkip[0][ui] = 0; |
|---|
| 625 | m_puhTransformSkip[1][ui] = 0; |
|---|
| 626 | m_puhTransformSkip[2][ui] = 0; |
|---|
| 627 | m_skipFlag[ui] = false; |
|---|
| 628 | m_pePartSize[ui] = SIZE_NONE; |
|---|
| 629 | m_pePredMode[ui] = MODE_NONE; |
|---|
| 630 | m_CUTransquantBypass[ui] = false; |
|---|
| 631 | m_pbIPCMFlag[ui] = 0; |
|---|
| 632 | m_phQP[ui] = qp; |
|---|
| 633 | m_pbMergeFlag[ui] = 0; |
|---|
| 634 | m_puhMergeIndex[ui] = 0; |
|---|
| 635 | #if H_3D_VSP |
|---|
| 636 | m_piVSPFlag[ui] = 0; |
|---|
| 637 | #endif |
|---|
| 638 | m_puhLumaIntraDir[ui] = DC_IDX; |
|---|
| 639 | m_puhChromaIntraDir[ui] = 0; |
|---|
| 640 | m_puhInterDir[ui] = 0; |
|---|
| 641 | m_puhCbf[0][ui] = 0; |
|---|
| 642 | m_puhCbf[1][ui] = 0; |
|---|
| 643 | m_puhCbf[2][ui] = 0; |
|---|
| 644 | #if H_3D_ARP |
|---|
| 645 | m_puhARPW[ui] = 0; |
|---|
| 646 | #endif |
|---|
| 647 | #if H_3D_IC |
|---|
| 648 | m_pbICFlag[ui] = false; |
|---|
| 649 | #endif |
|---|
| 650 | } |
|---|
| 651 | } |
|---|
| 652 | |
|---|
| 653 | UInt uiTmp = uhWidth*uhHeight; |
|---|
| 654 | |
|---|
| 655 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU >= getSlice()->getSliceSegmentCurStartCUAddr()) |
|---|
| 656 | { |
|---|
| 657 | m_acCUMvField[0].clearMvField(); |
|---|
| 658 | m_acCUMvField[1].clearMvField(); |
|---|
| 659 | uiTmp = uhWidth*uhHeight; |
|---|
| 660 | |
|---|
| 661 | memset( m_pcTrCoeffY, 0, uiTmp * sizeof( *m_pcTrCoeffY ) ); |
|---|
| 662 | #if ADAPTIVE_QP_SELECTION |
|---|
| 663 | memset( m_pcArlCoeffY , 0, uiTmp * sizeof( *m_pcArlCoeffY ) ); |
|---|
| 664 | #endif |
|---|
| 665 | memset( m_pcIPCMSampleY, 0, uiTmp * sizeof( *m_pcIPCMSampleY ) ); |
|---|
| 666 | |
|---|
| 667 | uiTmp>>=2; |
|---|
| 668 | memset( m_pcTrCoeffCb, 0, uiTmp * sizeof( *m_pcTrCoeffCb ) ); |
|---|
| 669 | memset( m_pcTrCoeffCr, 0, uiTmp * sizeof( *m_pcTrCoeffCr ) ); |
|---|
| 670 | #if ADAPTIVE_QP_SELECTION |
|---|
| 671 | memset( m_pcArlCoeffCb, 0, uiTmp * sizeof( *m_pcArlCoeffCb ) ); |
|---|
| 672 | memset( m_pcArlCoeffCr, 0, uiTmp * sizeof( *m_pcArlCoeffCr ) ); |
|---|
| 673 | #endif |
|---|
| 674 | memset( m_pcIPCMSampleCb, 0, uiTmp * sizeof( *m_pcIPCMSampleCb ) ); |
|---|
| 675 | memset( m_pcIPCMSampleCr, 0, uiTmp * sizeof( *m_pcIPCMSampleCr ) ); |
|---|
| 676 | } |
|---|
| 677 | } |
|---|
| 678 | |
|---|
| 679 | |
|---|
| 680 | // initialize Sub partition |
|---|
| 681 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
|---|
| 682 | { |
|---|
| 683 | assert( uiPartUnitIdx<4 ); |
|---|
| 684 | |
|---|
| 685 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
|---|
| 686 | |
|---|
| 687 | m_pcPic = pcCU->getPic(); |
|---|
| 688 | m_pcSlice = m_pcPic->getSlice(m_pcPic->getCurrSliceIdx()); |
|---|
| 689 | m_uiCUAddr = pcCU->getAddr(); |
|---|
| 690 | m_uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset; |
|---|
| 691 | |
|---|
| 692 | m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth>>uiDepth )*( uiPartUnitIdx & 1 ); |
|---|
| 693 | m_uiCUPelY = pcCU->getCUPelY() + ( g_uiMaxCUHeight>>uiDepth )*( uiPartUnitIdx >> 1 ); |
|---|
| 694 | |
|---|
| 695 | m_dTotalCost = MAX_DOUBLE; |
|---|
| 696 | m_uiTotalDistortion = 0; |
|---|
| 697 | m_uiTotalBits = 0; |
|---|
| 698 | m_uiTotalBins = 0; |
|---|
| 699 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
|---|
| 700 | |
|---|
| 701 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
|---|
| 702 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
|---|
| 703 | |
|---|
| 704 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
|---|
| 705 | memset( m_phQP, qp, sizeInChar ); |
|---|
| 706 | |
|---|
| 707 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
|---|
| 708 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
|---|
| 709 | #if H_3D_VSP |
|---|
| 710 | memset( m_piVSPFlag, 0, sizeof( Char ) * m_uiNumPartition ); |
|---|
| 711 | #endif |
|---|
| 712 | memset( m_puhLumaIntraDir, DC_IDX, iSizeInUchar ); |
|---|
| 713 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
|---|
| 714 | memset( m_puhInterDir, 0, iSizeInUchar ); |
|---|
| 715 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
|---|
| 716 | memset( m_puhTransformSkip[0], 0, iSizeInUchar ); |
|---|
| 717 | memset( m_puhTransformSkip[1], 0, iSizeInUchar ); |
|---|
| 718 | memset( m_puhTransformSkip[2], 0, iSizeInUchar ); |
|---|
| 719 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
|---|
| 720 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
|---|
| 721 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
|---|
| 722 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
|---|
| 723 | #if H_3D_NBDV |
|---|
| 724 | m_pDvInfo->bDV = false; |
|---|
| 725 | #endif |
|---|
| 726 | #if H_3D_ARP |
|---|
| 727 | memset( m_puhARPW, 0, iSizeInUchar ); |
|---|
| 728 | #endif |
|---|
| 729 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
|---|
| 730 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
|---|
| 731 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
|---|
| 732 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
|---|
| 733 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
|---|
| 734 | #if H_3D_IC |
|---|
| 735 | memset( m_pbICFlag, 0, iSizeInBool ); |
|---|
| 736 | #endif |
|---|
| 737 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
|---|
| 738 | { |
|---|
| 739 | m_skipFlag[ui] = false; |
|---|
| 740 | m_pePartSize[ui] = SIZE_NONE; |
|---|
| 741 | m_pePredMode[ui] = MODE_NONE; |
|---|
| 742 | m_CUTransquantBypass[ui] = false; |
|---|
| 743 | m_apiMVPIdx[0][ui] = -1; |
|---|
| 744 | m_apiMVPIdx[1][ui] = -1; |
|---|
| 745 | m_apiMVPNum[0][ui] = -1; |
|---|
| 746 | m_apiMVPNum[1][ui] = -1; |
|---|
| 747 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui<getSlice()->getSliceSegmentCurStartCUAddr()) |
|---|
| 748 | { |
|---|
| 749 | m_apiMVPIdx[0][ui] = pcCU->m_apiMVPIdx[0][uiPartOffset+ui]; |
|---|
| 750 | m_apiMVPIdx[1][ui] = pcCU->m_apiMVPIdx[1][uiPartOffset+ui];; |
|---|
| 751 | m_apiMVPNum[0][ui] = pcCU->m_apiMVPNum[0][uiPartOffset+ui];; |
|---|
| 752 | m_apiMVPNum[1][ui] = pcCU->m_apiMVPNum[1][uiPartOffset+ui];; |
|---|
| 753 | m_puhDepth [ui] = pcCU->getDepth(uiPartOffset+ui); |
|---|
| 754 | m_puhWidth [ui] = pcCU->getWidth(uiPartOffset+ui); |
|---|
| 755 | m_puhHeight [ui] = pcCU->getHeight(uiPartOffset+ui); |
|---|
| 756 | m_puhTrIdx [ui] = pcCU->getTransformIdx(uiPartOffset+ui); |
|---|
| 757 | m_puhTransformSkip[0][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_LUMA); |
|---|
| 758 | m_puhTransformSkip[1][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_U); |
|---|
| 759 | m_puhTransformSkip[2][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_V); |
|---|
| 760 | m_skipFlag[ui] = pcCU->getSkipFlag(uiPartOffset+ui); |
|---|
| 761 | m_pePartSize[ui] = pcCU->getPartitionSize(uiPartOffset+ui); |
|---|
| 762 | m_pePredMode[ui] = pcCU->getPredictionMode(uiPartOffset+ui); |
|---|
| 763 | m_CUTransquantBypass[ui] = pcCU->getCUTransquantBypass(uiPartOffset+ui); |
|---|
| 764 | m_pbIPCMFlag[ui]=pcCU->m_pbIPCMFlag[uiPartOffset+ui]; |
|---|
| 765 | m_phQP[ui] = pcCU->m_phQP[uiPartOffset+ui]; |
|---|
| 766 | m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui]; |
|---|
| 767 | m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui]; |
|---|
| 768 | #if H_3D_VSP |
|---|
| 769 | m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui]; |
|---|
| 770 | #endif |
|---|
| 771 | m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui]; |
|---|
| 772 | m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui]; |
|---|
| 773 | m_puhInterDir[ui]=pcCU->m_puhInterDir[uiPartOffset+ui]; |
|---|
| 774 | m_puhCbf[0][ui]=pcCU->m_puhCbf[0][uiPartOffset+ui]; |
|---|
| 775 | m_puhCbf[1][ui]=pcCU->m_puhCbf[1][uiPartOffset+ui]; |
|---|
| 776 | m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui]; |
|---|
| 777 | |
|---|
| 778 | #if H_3D_ARP |
|---|
| 779 | m_puhARPW [ui] = pcCU->getARPW( uiPartOffset+ui ); |
|---|
| 780 | #endif |
|---|
| 781 | #if H_3D_IC |
|---|
| 782 | m_pbICFlag [ui] = pcCU->m_pbICFlag[uiPartOffset+ui]; |
|---|
| 783 | #endif |
|---|
| 784 | } |
|---|
| 785 | } |
|---|
| 786 | UInt uiTmp = uhWidth*uhHeight; |
|---|
| 787 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
|---|
| 788 | #if ADAPTIVE_QP_SELECTION |
|---|
| 789 | memset( m_pcArlCoeffY , 0, sizeof(Int)*uiTmp ); |
|---|
| 790 | #endif |
|---|
| 791 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 792 | uiTmp >>= 2; |
|---|
| 793 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
|---|
| 794 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
|---|
| 795 | #if ADAPTIVE_QP_SELECTION |
|---|
| 796 | memset( m_pcArlCoeffCb, 0, sizeof(Int)*uiTmp ); |
|---|
| 797 | memset( m_pcArlCoeffCr, 0, sizeof(Int)*uiTmp ); |
|---|
| 798 | #endif |
|---|
| 799 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 800 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 801 | m_acCUMvField[0].clearMvField(); |
|---|
| 802 | m_acCUMvField[1].clearMvField(); |
|---|
| 803 | |
|---|
| 804 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU<getSlice()->getSliceSegmentCurStartCUAddr()) |
|---|
| 805 | { |
|---|
| 806 | // Part of this CU contains data from an older slice. Now copy in that data. |
|---|
| 807 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
|---|
| 808 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
|---|
| 809 | TComDataCU * bigCU = getPic()->getCU(getAddr()); |
|---|
| 810 | Int minui = uiPartOffset; |
|---|
| 811 | minui = -minui; |
|---|
| 812 | pcCU->m_acCUMvField[0].copyTo(&m_acCUMvField[0],minui,uiPartOffset,m_uiNumPartition); |
|---|
| 813 | pcCU->m_acCUMvField[1].copyTo(&m_acCUMvField[1],minui,uiPartOffset,m_uiNumPartition); |
|---|
| 814 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*m_uiAbsIdxInLCU/pcCU->getPic()->getNumPartInCU(); |
|---|
| 815 | uiTmp = uhWidth*uhHeight; |
|---|
| 816 | for(Int i=0; i<uiTmp; i++) |
|---|
| 817 | { |
|---|
| 818 | m_pcTrCoeffY[i]=bigCU->m_pcTrCoeffY[uiCoffOffset+i]; |
|---|
| 819 | #if ADAPTIVE_QP_SELECTION |
|---|
| 820 | m_pcArlCoeffY[i]=bigCU->m_pcArlCoeffY[uiCoffOffset+i]; |
|---|
| 821 | #endif |
|---|
| 822 | m_pcIPCMSampleY[i]=bigCU->m_pcIPCMSampleY[uiCoffOffset+i]; |
|---|
| 823 | } |
|---|
| 824 | uiTmp>>=2; |
|---|
| 825 | uiCoffOffset>>=2; |
|---|
| 826 | for(Int i=0; i<uiTmp; i++) |
|---|
| 827 | { |
|---|
| 828 | m_pcTrCoeffCr[i]=bigCU->m_pcTrCoeffCr[uiCoffOffset+i]; |
|---|
| 829 | m_pcTrCoeffCb[i]=bigCU->m_pcTrCoeffCb[uiCoffOffset+i]; |
|---|
| 830 | #if ADAPTIVE_QP_SELECTION |
|---|
| 831 | m_pcArlCoeffCr[i]=bigCU->m_pcArlCoeffCr[uiCoffOffset+i]; |
|---|
| 832 | m_pcArlCoeffCb[i]=bigCU->m_pcArlCoeffCb[uiCoffOffset+i]; |
|---|
| 833 | #endif |
|---|
| 834 | m_pcIPCMSampleCb[i]=bigCU->m_pcIPCMSampleCb[uiCoffOffset+i]; |
|---|
| 835 | m_pcIPCMSampleCr[i]=bigCU->m_pcIPCMSampleCr[uiCoffOffset+i]; |
|---|
| 836 | } |
|---|
| 837 | } |
|---|
| 838 | |
|---|
| 839 | m_pcCULeft = pcCU->getCULeft(); |
|---|
| 840 | m_pcCUAbove = pcCU->getCUAbove(); |
|---|
| 841 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
|---|
| 842 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
|---|
| 843 | |
|---|
| 844 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
|---|
| 845 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
|---|
| 846 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
|---|
| 847 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
|---|
| 848 | } |
|---|
| 849 | |
|---|
| 850 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 851 | { |
|---|
| 852 | UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
|---|
| 853 | UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
|---|
| 854 | |
|---|
| 855 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
|---|
| 856 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
|---|
| 857 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
|---|
| 858 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
|---|
| 859 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
|---|
| 860 | } |
|---|
| 861 | |
|---|
| 862 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 863 | // Copy |
|---|
| 864 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 865 | |
|---|
| 866 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 867 | { |
|---|
| 868 | UInt uiPart = uiAbsPartIdx; |
|---|
| 869 | |
|---|
| 870 | m_pcPic = pcCU->getPic(); |
|---|
| 871 | m_pcSlice = pcCU->getSlice(); |
|---|
| 872 | m_uiCUAddr = pcCU->getAddr(); |
|---|
| 873 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
|---|
| 874 | |
|---|
| 875 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 876 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 877 | |
|---|
| 878 | UInt uiWidth = g_uiMaxCUWidth >> uiDepth; |
|---|
| 879 | UInt uiHeight = g_uiMaxCUHeight >> uiDepth; |
|---|
| 880 | |
|---|
| 881 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
|---|
| 882 | |
|---|
| 883 | m_phQP=pcCU->getQP() + uiPart; |
|---|
| 884 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
|---|
| 885 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
|---|
| 886 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
|---|
| 887 | |
|---|
| 888 | #if H_3D_NBDV |
|---|
| 889 | m_pDvInfo = pcCU->getDvInfo() + uiPart; |
|---|
| 890 | #endif |
|---|
| 891 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
|---|
| 892 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
|---|
| 893 | #if H_3D_VSP |
|---|
| 894 | m_piVSPFlag = pcCU->getVSPFlag() + uiPart; |
|---|
| 895 | #endif |
|---|
| 896 | |
|---|
| 897 | #if H_3D_ARP |
|---|
| 898 | m_puhARPW = pcCU->getARPW() + uiPart; |
|---|
| 899 | #endif |
|---|
| 900 | #if H_3D_IC |
|---|
| 901 | m_pbICFlag = pcCU->getICFlag() + uiPart; |
|---|
| 902 | #endif |
|---|
| 903 | |
|---|
| 904 | m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; |
|---|
| 905 | m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; |
|---|
| 906 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
|---|
| 907 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
|---|
| 908 | m_puhTransformSkip[0] = pcCU->getTransformSkip(TEXT_LUMA) + uiPart; |
|---|
| 909 | m_puhTransformSkip[1] = pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPart; |
|---|
| 910 | m_puhTransformSkip[2] = pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPart; |
|---|
| 911 | |
|---|
| 912 | m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; |
|---|
| 913 | m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; |
|---|
| 914 | m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; |
|---|
| 915 | |
|---|
| 916 | m_puhDepth=pcCU->getDepth() + uiPart; |
|---|
| 917 | m_puhWidth=pcCU->getWidth() + uiPart; |
|---|
| 918 | m_puhHeight=pcCU->getHeight() + uiPart; |
|---|
| 919 | |
|---|
| 920 | m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; |
|---|
| 921 | m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; |
|---|
| 922 | m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; |
|---|
| 923 | m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; |
|---|
| 924 | |
|---|
| 925 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
|---|
| 926 | |
|---|
| 927 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
|---|
| 928 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
|---|
| 929 | m_pcCUAbove = pcCU->getCUAbove(); |
|---|
| 930 | m_pcCULeft = pcCU->getCULeft(); |
|---|
| 931 | |
|---|
| 932 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
|---|
| 933 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
|---|
| 934 | |
|---|
| 935 | UInt uiTmp = uiWidth*uiHeight; |
|---|
| 936 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
|---|
| 937 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
|---|
| 938 | |
|---|
| 939 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); |
|---|
| 940 | |
|---|
| 941 | m_pcTrCoeffY = pcCU->getCoeffY() + uiCoffOffset; |
|---|
| 942 | #if ADAPTIVE_QP_SELECTION |
|---|
| 943 | m_pcArlCoeffY= pcCU->getArlCoeffY() + uiCoffOffset; |
|---|
| 944 | #endif |
|---|
| 945 | m_pcIPCMSampleY = pcCU->getPCMSampleY() + uiCoffOffset; |
|---|
| 946 | |
|---|
| 947 | uiTmp >>= 2; |
|---|
| 948 | uiCoffOffset >>=2; |
|---|
| 949 | m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; |
|---|
| 950 | m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; |
|---|
| 951 | #if ADAPTIVE_QP_SELECTION |
|---|
| 952 | m_pcArlCoeffCb=pcCU->getArlCoeffCb() + uiCoffOffset; |
|---|
| 953 | m_pcArlCoeffCr=pcCU->getArlCoeffCr() + uiCoffOffset; |
|---|
| 954 | #endif |
|---|
| 955 | m_pcIPCMSampleCb = pcCU->getPCMSampleCb() + uiCoffOffset; |
|---|
| 956 | m_pcIPCMSampleCr = pcCU->getPCMSampleCr() + uiCoffOffset; |
|---|
| 957 | |
|---|
| 958 | m_acCUMvField[0].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_0), uiPart ); |
|---|
| 959 | m_acCUMvField[1].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_1), uiPart ); |
|---|
| 960 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
|---|
| 961 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
|---|
| 962 | } |
|---|
| 963 | #if H_3D_NBDV |
|---|
| 964 | Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx) |
|---|
| 965 | { |
|---|
| 966 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
|---|
| 967 | } |
|---|
| 968 | #endif |
|---|
| 969 | // Copy inter prediction info from the biggest CU |
|---|
| 970 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList |
|---|
| 971 | #if H_3D_NBDV |
|---|
| 972 | , Bool bNBDV |
|---|
| 973 | #endif |
|---|
| 974 | ) |
|---|
| 975 | { |
|---|
| 976 | m_pcPic = pcCU->getPic(); |
|---|
| 977 | m_pcSlice = pcCU->getSlice(); |
|---|
| 978 | m_uiCUAddr = pcCU->getAddr(); |
|---|
| 979 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
|---|
| 980 | |
|---|
| 981 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
|---|
| 982 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); |
|---|
| 983 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); |
|---|
| 984 | |
|---|
| 985 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
|---|
| 986 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
|---|
| 987 | m_pcCUAbove = pcCU->getCUAbove(); |
|---|
| 988 | m_pcCULeft = pcCU->getCULeft(); |
|---|
| 989 | |
|---|
| 990 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
|---|
| 991 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
|---|
| 992 | |
|---|
| 993 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
|---|
| 994 | |
|---|
| 995 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
|---|
| 996 | #if H_3D_NBDV |
|---|
| 997 | if(bNBDV == true) |
|---|
| 998 | { |
|---|
| 999 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
|---|
| 1000 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
|---|
| 1001 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
|---|
| 1002 | } |
|---|
| 1003 | else |
|---|
| 1004 | { |
|---|
| 1005 | #endif |
|---|
| 1006 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
|---|
| 1007 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
|---|
| 1008 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
|---|
| 1009 | |
|---|
| 1010 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
|---|
| 1011 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
|---|
| 1012 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
|---|
| 1013 | |
|---|
| 1014 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
|---|
| 1015 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
|---|
| 1016 | #if H_3D_VSP |
|---|
| 1017 | m_piVSPFlag = pcCU->getVSPFlag() + uiAbsPartIdx; |
|---|
| 1018 | #endif |
|---|
| 1019 | |
|---|
| 1020 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
|---|
| 1021 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
|---|
| 1022 | |
|---|
| 1023 | #if H_3D_ARP |
|---|
| 1024 | m_puhARPW = pcCU->getARPW() + uiAbsPartIdx; |
|---|
| 1025 | #endif |
|---|
| 1026 | |
|---|
| 1027 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
|---|
| 1028 | |
|---|
| 1029 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
|---|
| 1030 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
|---|
| 1031 | #if H_3D_NBDV |
|---|
| 1032 | } |
|---|
| 1033 | #endif |
|---|
| 1034 | #if H_3D_IC |
|---|
| 1035 | m_pbICFlag = pcCU->getICFlag() + uiAbsPartIdx; |
|---|
| 1036 | #endif |
|---|
| 1037 | } |
|---|
| 1038 | |
|---|
| 1039 | // Copy small CU to bigger CU. |
|---|
| 1040 | // One of quarter parts overwritten by predicted sub part. |
|---|
| 1041 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
|---|
| 1042 | { |
|---|
| 1043 | assert( uiPartUnitIdx<4 ); |
|---|
| 1044 | |
|---|
| 1045 | m_dTotalCost += pcCU->getTotalCost(); |
|---|
| 1046 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
|---|
| 1047 | m_uiTotalBits += pcCU->getTotalBits(); |
|---|
| 1048 | |
|---|
| 1049 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
|---|
| 1050 | |
|---|
| 1051 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
|---|
| 1052 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
|---|
| 1053 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
|---|
| 1054 | |
|---|
| 1055 | Int sizeInChar = sizeof( Char ) * uiNumPartition; |
|---|
| 1056 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
|---|
| 1057 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
|---|
| 1058 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
|---|
| 1059 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
|---|
| 1060 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
|---|
| 1061 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
|---|
| 1062 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
|---|
| 1063 | #if H_3D_VSP |
|---|
| 1064 | memcpy( m_piVSPFlag + uiOffset, pcCU->getVSPFlag(), sizeof( Char ) * uiNumPartition ); |
|---|
| 1065 | #endif |
|---|
| 1066 | memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); |
|---|
| 1067 | memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); |
|---|
| 1068 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
|---|
| 1069 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
|---|
| 1070 | memcpy( m_puhTransformSkip[0] + uiOffset, pcCU->getTransformSkip(TEXT_LUMA), iSizeInUchar ); |
|---|
| 1071 | memcpy( m_puhTransformSkip[1] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_U), iSizeInUchar ); |
|---|
| 1072 | memcpy( m_puhTransformSkip[2] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_V), iSizeInUchar ); |
|---|
| 1073 | |
|---|
| 1074 | memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); |
|---|
| 1075 | memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); |
|---|
| 1076 | memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); |
|---|
| 1077 | |
|---|
| 1078 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
|---|
| 1079 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
|---|
| 1080 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
|---|
| 1081 | |
|---|
| 1082 | memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInUchar ); |
|---|
| 1083 | memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInUchar ); |
|---|
| 1084 | memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInUchar ); |
|---|
| 1085 | memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInUchar ); |
|---|
| 1086 | |
|---|
| 1087 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
|---|
| 1088 | |
|---|
| 1089 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
|---|
| 1090 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
|---|
| 1091 | m_pcCUAbove = pcCU->getCUAbove(); |
|---|
| 1092 | m_pcCULeft = pcCU->getCULeft(); |
|---|
| 1093 | |
|---|
| 1094 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
|---|
| 1095 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
|---|
| 1096 | |
|---|
| 1097 | m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); |
|---|
| 1098 | m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); |
|---|
| 1099 | |
|---|
| 1100 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); |
|---|
| 1101 | UInt uiTmp2 = uiPartUnitIdx*uiTmp; |
|---|
| 1102 | memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); |
|---|
| 1103 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1104 | memcpy( m_pcArlCoeffY + uiTmp2, pcCU->getArlCoeffY(), sizeof(Int)*uiTmp ); |
|---|
| 1105 | #endif |
|---|
| 1106 | memcpy( m_pcIPCMSampleY + uiTmp2 , pcCU->getPCMSampleY(), sizeof(Pel) * uiTmp ); |
|---|
| 1107 | |
|---|
| 1108 | uiTmp >>= 2; uiTmp2>>= 2; |
|---|
| 1109 | memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); |
|---|
| 1110 | memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); |
|---|
| 1111 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1112 | memcpy( m_pcArlCoeffCb + uiTmp2, pcCU->getArlCoeffCb(), sizeof(Int)*uiTmp ); |
|---|
| 1113 | memcpy( m_pcArlCoeffCr + uiTmp2, pcCU->getArlCoeffCr(), sizeof(Int)*uiTmp ); |
|---|
| 1114 | #endif |
|---|
| 1115 | memcpy( m_pcIPCMSampleCb + uiTmp2 , pcCU->getPCMSampleCb(), sizeof(Pel) * uiTmp ); |
|---|
| 1116 | memcpy( m_pcIPCMSampleCr + uiTmp2 , pcCU->getPCMSampleCr(), sizeof(Pel) * uiTmp ); |
|---|
| 1117 | m_uiTotalBins += pcCU->getTotalBins(); |
|---|
| 1118 | memcpy( m_sliceStartCU + uiOffset, pcCU->m_sliceStartCU, sizeof( UInt ) * uiNumPartition ); |
|---|
| 1119 | memcpy( m_sliceSegmentStartCU + uiOffset, pcCU->m_sliceSegmentStartCU, sizeof( UInt ) * uiNumPartition ); |
|---|
| 1120 | |
|---|
| 1121 | #if H_3D_ARP |
|---|
| 1122 | memcpy( m_puhARPW + uiOffset, pcCU->getARPW(), iSizeInUchar ); |
|---|
| 1123 | #endif |
|---|
| 1124 | #if H_3D_IC |
|---|
| 1125 | memcpy( m_pbICFlag + uiOffset, pcCU->getICFlag(), iSizeInBool ); |
|---|
| 1126 | #endif |
|---|
| 1127 | } |
|---|
| 1128 | |
|---|
| 1129 | // Copy current predicted part to a CU in picture. |
|---|
| 1130 | // It is used to predict for next part |
|---|
| 1131 | Void TComDataCU::copyToPic( UChar uhDepth ) |
|---|
| 1132 | { |
|---|
| 1133 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
|---|
| 1134 | |
|---|
| 1135 | rpcCU->getTotalCost() = m_dTotalCost; |
|---|
| 1136 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
|---|
| 1137 | rpcCU->getTotalBits() = m_uiTotalBits; |
|---|
| 1138 | |
|---|
| 1139 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
|---|
| 1140 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
|---|
| 1141 | |
|---|
| 1142 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
|---|
| 1143 | |
|---|
| 1144 | memcpy( rpcCU->getSkipFlag() + m_uiAbsIdxInLCU, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
|---|
| 1145 | |
|---|
| 1146 | memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar ); |
|---|
| 1147 | #if H_3D_NBDV |
|---|
| 1148 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition ); |
|---|
| 1149 | #endif |
|---|
| 1150 | |
|---|
| 1151 | memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
|---|
| 1152 | memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
|---|
| 1153 | memcpy( rpcCU->getCUTransquantBypass()+ m_uiAbsIdxInLCU, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
|---|
| 1154 | memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); |
|---|
| 1155 | memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); |
|---|
| 1156 | #if H_3D_VSP |
|---|
| 1157 | memcpy( rpcCU->getVSPFlag() + m_uiAbsIdxInLCU, m_piVSPFlag, sizeof( Char ) * m_uiNumPartition ); |
|---|
| 1158 | #endif |
|---|
| 1159 | memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); |
|---|
| 1160 | memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); |
|---|
| 1161 | memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); |
|---|
| 1162 | memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); |
|---|
| 1163 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhTransformSkip[0], iSizeInUchar ); |
|---|
| 1164 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhTransformSkip[1], iSizeInUchar ); |
|---|
| 1165 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhTransformSkip[2], iSizeInUchar ); |
|---|
| 1166 | |
|---|
| 1167 | memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); |
|---|
| 1168 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); |
|---|
| 1169 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); |
|---|
| 1170 | |
|---|
| 1171 | memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); |
|---|
| 1172 | memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); |
|---|
| 1173 | memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); |
|---|
| 1174 | |
|---|
| 1175 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInUchar ); |
|---|
| 1176 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInUchar ); |
|---|
| 1177 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInUchar ); |
|---|
| 1178 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInUchar ); |
|---|
| 1179 | |
|---|
| 1180 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); |
|---|
| 1181 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); |
|---|
| 1182 | |
|---|
| 1183 | memcpy( rpcCU->getIPCMFlag() + m_uiAbsIdxInLCU, m_pbIPCMFlag, iSizeInBool ); |
|---|
| 1184 | |
|---|
| 1185 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); |
|---|
| 1186 | UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
|---|
| 1187 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
|---|
| 1188 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1189 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
|---|
| 1190 | #endif |
|---|
| 1191 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof(Pel)*uiTmp ); |
|---|
| 1192 | |
|---|
| 1193 | uiTmp >>= 2; uiTmp2 >>= 2; |
|---|
| 1194 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
|---|
| 1195 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
|---|
| 1196 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1197 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
|---|
| 1198 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
|---|
| 1199 | #endif |
|---|
| 1200 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
|---|
| 1201 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
|---|
| 1202 | rpcCU->getTotalBins() = m_uiTotalBins; |
|---|
| 1203 | memcpy( rpcCU->m_sliceStartCU + m_uiAbsIdxInLCU, m_sliceStartCU, sizeof( UInt ) * m_uiNumPartition ); |
|---|
| 1204 | memcpy( rpcCU->m_sliceSegmentStartCU + m_uiAbsIdxInLCU, m_sliceSegmentStartCU, sizeof( UInt ) * m_uiNumPartition ); |
|---|
| 1205 | |
|---|
| 1206 | #if H_3D_ARP |
|---|
| 1207 | memcpy( rpcCU->getARPW() + m_uiAbsIdxInLCU, m_puhARPW, iSizeInUchar ); |
|---|
| 1208 | #endif |
|---|
| 1209 | #if H_3D_IC |
|---|
| 1210 | memcpy( rpcCU->getICFlag() + m_uiAbsIdxInLCU, m_pbICFlag, iSizeInBool ); |
|---|
| 1211 | #endif |
|---|
| 1212 | } |
|---|
| 1213 | |
|---|
| 1214 | Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) |
|---|
| 1215 | { |
|---|
| 1216 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
|---|
| 1217 | UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); |
|---|
| 1218 | |
|---|
| 1219 | UInt uiPartStart = uiPartIdx*uiQNumPart; |
|---|
| 1220 | UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; |
|---|
| 1221 | |
|---|
| 1222 | rpcCU->getTotalCost() = m_dTotalCost; |
|---|
| 1223 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
|---|
| 1224 | rpcCU->getTotalBits() = m_uiTotalBits; |
|---|
| 1225 | |
|---|
| 1226 | Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; |
|---|
| 1227 | Int iSizeInBool = sizeof( Bool ) * uiQNumPart; |
|---|
| 1228 | |
|---|
| 1229 | Int sizeInChar = sizeof( Char ) * uiQNumPart; |
|---|
| 1230 | memcpy( rpcCU->getSkipFlag() + uiPartOffset, m_skipFlag, sizeof( *m_skipFlag ) * uiQNumPart ); |
|---|
| 1231 | |
|---|
| 1232 | memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, sizeInChar ); |
|---|
| 1233 | memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart ); |
|---|
| 1234 | memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( *m_pePredMode ) * uiQNumPart ); |
|---|
| 1235 | memcpy( rpcCU->getCUTransquantBypass()+ uiPartOffset, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * uiQNumPart ); |
|---|
| 1236 | memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); |
|---|
| 1237 | memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); |
|---|
| 1238 | #if H_3D_VSP |
|---|
| 1239 | memcpy( rpcCU->getVSPFlag() + uiPartOffset, m_piVSPFlag, sizeof(Char) * uiQNumPart ); |
|---|
| 1240 | #endif |
|---|
| 1241 | memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); |
|---|
| 1242 | memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); |
|---|
| 1243 | memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); |
|---|
| 1244 | memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); |
|---|
| 1245 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + uiPartOffset, m_puhTransformSkip[0], iSizeInUchar ); |
|---|
| 1246 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhTransformSkip[1], iSizeInUchar ); |
|---|
| 1247 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhTransformSkip[2], iSizeInUchar ); |
|---|
| 1248 | memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); |
|---|
| 1249 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); |
|---|
| 1250 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); |
|---|
| 1251 | |
|---|
| 1252 | memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); |
|---|
| 1253 | memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); |
|---|
| 1254 | memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); |
|---|
| 1255 | |
|---|
| 1256 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInUchar ); |
|---|
| 1257 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInUchar ); |
|---|
| 1258 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInUchar ); |
|---|
| 1259 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInUchar ); |
|---|
| 1260 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
|---|
| 1261 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
|---|
| 1262 | |
|---|
| 1263 | memcpy( rpcCU->getIPCMFlag() + uiPartOffset, m_pbIPCMFlag, iSizeInBool ); |
|---|
| 1264 | |
|---|
| 1265 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); |
|---|
| 1266 | UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
|---|
| 1267 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
|---|
| 1268 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1269 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
|---|
| 1270 | #endif |
|---|
| 1271 | |
|---|
| 1272 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof( Pel ) * uiTmp ); |
|---|
| 1273 | |
|---|
| 1274 | uiTmp >>= 2; uiTmp2 >>= 2; |
|---|
| 1275 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
|---|
| 1276 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
|---|
| 1277 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1278 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
|---|
| 1279 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
|---|
| 1280 | #endif |
|---|
| 1281 | |
|---|
| 1282 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
|---|
| 1283 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
|---|
| 1284 | rpcCU->getTotalBins() = m_uiTotalBins; |
|---|
| 1285 | memcpy( rpcCU->m_sliceStartCU + uiPartOffset, m_sliceStartCU, sizeof( UInt ) * uiQNumPart ); |
|---|
| 1286 | memcpy( rpcCU->m_sliceSegmentStartCU + uiPartOffset, m_sliceSegmentStartCU, sizeof( UInt ) * uiQNumPart ); |
|---|
| 1287 | |
|---|
| 1288 | #if H_3D_ARP |
|---|
| 1289 | memcpy( rpcCU->getARPW() + uiPartOffset, m_puhARPW, iSizeInUchar ); |
|---|
| 1290 | #endif |
|---|
| 1291 | #if H_3D_IC |
|---|
| 1292 | memcpy( rpcCU->getICFlag() + uiPartOffset, m_pbICFlag, iSizeInBool ); |
|---|
| 1293 | #endif |
|---|
| 1294 | } |
|---|
| 1295 | |
|---|
| 1296 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 1297 | // Other public functions |
|---|
| 1298 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 1299 | |
|---|
| 1300 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
|---|
| 1301 | UInt uiCurrPartUnitIdx, |
|---|
| 1302 | Bool bEnforceSliceRestriction, |
|---|
| 1303 | Bool bEnforceTileRestriction ) |
|---|
| 1304 | { |
|---|
| 1305 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1306 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
|---|
| 1307 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1308 | |
|---|
| 1309 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
|---|
| 1310 | { |
|---|
| 1311 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
|---|
| 1312 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
|---|
| 1313 | { |
|---|
| 1314 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1315 | } |
|---|
| 1316 | else |
|---|
| 1317 | { |
|---|
| 1318 | uiLPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1319 | return this; |
|---|
| 1320 | } |
|---|
| 1321 | } |
|---|
| 1322 | |
|---|
| 1323 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; |
|---|
| 1324 | |
|---|
| 1325 | |
|---|
| 1326 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
|---|
| 1327 | || |
|---|
| 1328 | (bEnforceTileRestriction && ( m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) ) ) |
|---|
| 1329 | ) |
|---|
| 1330 | { |
|---|
| 1331 | return NULL; |
|---|
| 1332 | } |
|---|
| 1333 | return m_pcCULeft; |
|---|
| 1334 | } |
|---|
| 1335 | |
|---|
| 1336 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
|---|
| 1337 | UInt uiCurrPartUnitIdx, |
|---|
| 1338 | Bool bEnforceSliceRestriction, |
|---|
| 1339 | Bool planarAtLCUBoundary , |
|---|
| 1340 | Bool bEnforceTileRestriction ) |
|---|
| 1341 | { |
|---|
| 1342 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1343 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
|---|
| 1344 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1345 | |
|---|
| 1346 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
|---|
| 1347 | { |
|---|
| 1348 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ]; |
|---|
| 1349 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
|---|
| 1350 | { |
|---|
| 1351 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1352 | } |
|---|
| 1353 | else |
|---|
| 1354 | { |
|---|
| 1355 | uiAPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1356 | return this; |
|---|
| 1357 | } |
|---|
| 1358 | } |
|---|
| 1359 | |
|---|
| 1360 | if(planarAtLCUBoundary) |
|---|
| 1361 | { |
|---|
| 1362 | return NULL; |
|---|
| 1363 | } |
|---|
| 1364 | |
|---|
| 1365 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
|---|
| 1366 | |
|---|
| 1367 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
|---|
| 1368 | || |
|---|
| 1369 | (bEnforceTileRestriction &&(m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())))) |
|---|
| 1370 | ) |
|---|
| 1371 | { |
|---|
| 1372 | return NULL; |
|---|
| 1373 | } |
|---|
| 1374 | return m_pcCUAbove; |
|---|
| 1375 | } |
|---|
| 1376 | |
|---|
| 1377 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
|---|
| 1378 | { |
|---|
| 1379 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1380 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
|---|
| 1381 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1382 | |
|---|
| 1383 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
|---|
| 1384 | { |
|---|
| 1385 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
|---|
| 1386 | { |
|---|
| 1387 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ]; |
|---|
| 1388 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
|---|
| 1389 | { |
|---|
| 1390 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1391 | } |
|---|
| 1392 | else |
|---|
| 1393 | { |
|---|
| 1394 | uiALPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1395 | return this; |
|---|
| 1396 | } |
|---|
| 1397 | } |
|---|
| 1398 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; |
|---|
| 1399 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
|---|
| 1400 | m_pcCUAbove->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1401 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1402 | )) |
|---|
| 1403 | ) |
|---|
| 1404 | { |
|---|
| 1405 | return NULL; |
|---|
| 1406 | } |
|---|
| 1407 | return m_pcCUAbove; |
|---|
| 1408 | } |
|---|
| 1409 | |
|---|
| 1410 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
|---|
| 1411 | { |
|---|
| 1412 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
|---|
| 1413 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
|---|
| 1414 | m_pcCULeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1415 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1416 | )) |
|---|
| 1417 | ) |
|---|
| 1418 | { |
|---|
| 1419 | return NULL; |
|---|
| 1420 | } |
|---|
| 1421 | return m_pcCULeft; |
|---|
| 1422 | } |
|---|
| 1423 | |
|---|
| 1424 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; |
|---|
| 1425 | if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || |
|---|
| 1426 | m_pcCUAboveLeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1427 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveLeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1428 | )) |
|---|
| 1429 | ) |
|---|
| 1430 | { |
|---|
| 1431 | return NULL; |
|---|
| 1432 | } |
|---|
| 1433 | return m_pcCUAboveLeft; |
|---|
| 1434 | } |
|---|
| 1435 | |
|---|
| 1436 | TComDataCU* TComDataCU::getPUAboveRight( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
|---|
| 1437 | { |
|---|
| 1438 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1439 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1; |
|---|
| 1440 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1441 | |
|---|
| 1442 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
|---|
| 1443 | { |
|---|
| 1444 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 1445 | return NULL; |
|---|
| 1446 | } |
|---|
| 1447 | |
|---|
| 1448 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - 1, uiNumPartInCUWidth ) ) |
|---|
| 1449 | { |
|---|
| 1450 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
|---|
| 1451 | { |
|---|
| 1452 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
|---|
| 1453 | { |
|---|
| 1454 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
|---|
| 1455 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
|---|
| 1456 | { |
|---|
| 1457 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1458 | } |
|---|
| 1459 | else |
|---|
| 1460 | { |
|---|
| 1461 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1462 | return this; |
|---|
| 1463 | } |
|---|
| 1464 | } |
|---|
| 1465 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 1466 | return NULL; |
|---|
| 1467 | } |
|---|
| 1468 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
|---|
| 1469 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
|---|
| 1470 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1471 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1472 | )) |
|---|
| 1473 | ) |
|---|
| 1474 | { |
|---|
| 1475 | return NULL; |
|---|
| 1476 | } |
|---|
| 1477 | return m_pcCUAbove; |
|---|
| 1478 | } |
|---|
| 1479 | |
|---|
| 1480 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
|---|
| 1481 | { |
|---|
| 1482 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 1483 | return NULL; |
|---|
| 1484 | } |
|---|
| 1485 | |
|---|
| 1486 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
|---|
| 1487 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
|---|
| 1488 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
|---|
| 1489 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1490 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1491 | )) |
|---|
| 1492 | ) |
|---|
| 1493 | { |
|---|
| 1494 | return NULL; |
|---|
| 1495 | } |
|---|
| 1496 | return m_pcCUAboveRight; |
|---|
| 1497 | } |
|---|
| 1498 | |
|---|
| 1499 | TComDataCU* TComDataCU::getPUBelowLeft( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
|---|
| 1500 | { |
|---|
| 1501 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1502 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth(); |
|---|
| 1503 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1504 | |
|---|
| 1505 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
|---|
| 1506 | { |
|---|
| 1507 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 1508 | return NULL; |
|---|
| 1509 | } |
|---|
| 1510 | |
|---|
| 1511 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - 1, uiNumPartInCUWidth ) ) |
|---|
| 1512 | { |
|---|
| 1513 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
|---|
| 1514 | { |
|---|
| 1515 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
|---|
| 1516 | { |
|---|
| 1517 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
|---|
| 1518 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
|---|
| 1519 | { |
|---|
| 1520 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1521 | } |
|---|
| 1522 | else |
|---|
| 1523 | { |
|---|
| 1524 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1525 | return this; |
|---|
| 1526 | } |
|---|
| 1527 | } |
|---|
| 1528 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 1529 | return NULL; |
|---|
| 1530 | } |
|---|
| 1531 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
|---|
| 1532 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
|---|
| 1533 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1534 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1535 | )) |
|---|
| 1536 | ) |
|---|
| 1537 | { |
|---|
| 1538 | return NULL; |
|---|
| 1539 | } |
|---|
| 1540 | return m_pcCULeft; |
|---|
| 1541 | } |
|---|
| 1542 | |
|---|
| 1543 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 1544 | return NULL; |
|---|
| 1545 | } |
|---|
| 1546 | |
|---|
| 1547 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
|---|
| 1548 | { |
|---|
| 1549 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1550 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth(); |
|---|
| 1551 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1552 | |
|---|
| 1553 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
|---|
| 1554 | { |
|---|
| 1555 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 1556 | return NULL; |
|---|
| 1557 | } |
|---|
| 1558 | |
|---|
| 1559 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
|---|
| 1560 | { |
|---|
| 1561 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
|---|
| 1562 | { |
|---|
| 1563 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] ) |
|---|
| 1564 | { |
|---|
| 1565 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ]; |
|---|
| 1566 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
|---|
| 1567 | { |
|---|
| 1568 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1569 | } |
|---|
| 1570 | else |
|---|
| 1571 | { |
|---|
| 1572 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1573 | return this; |
|---|
| 1574 | } |
|---|
| 1575 | } |
|---|
| 1576 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 1577 | return NULL; |
|---|
| 1578 | } |
|---|
| 1579 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; |
|---|
| 1580 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
|---|
| 1581 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1582 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1583 | )) |
|---|
| 1584 | ) |
|---|
| 1585 | { |
|---|
| 1586 | return NULL; |
|---|
| 1587 | } |
|---|
| 1588 | return m_pcCULeft; |
|---|
| 1589 | } |
|---|
| 1590 | |
|---|
| 1591 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 1592 | return NULL; |
|---|
| 1593 | } |
|---|
| 1594 | |
|---|
| 1595 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
|---|
| 1596 | { |
|---|
| 1597 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1598 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
|---|
| 1599 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1600 | |
|---|
| 1601 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
|---|
| 1602 | { |
|---|
| 1603 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 1604 | return NULL; |
|---|
| 1605 | } |
|---|
| 1606 | |
|---|
| 1607 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
|---|
| 1608 | { |
|---|
| 1609 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
|---|
| 1610 | { |
|---|
| 1611 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] ) |
|---|
| 1612 | { |
|---|
| 1613 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ]; |
|---|
| 1614 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
|---|
| 1615 | { |
|---|
| 1616 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1617 | } |
|---|
| 1618 | else |
|---|
| 1619 | { |
|---|
| 1620 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1621 | return this; |
|---|
| 1622 | } |
|---|
| 1623 | } |
|---|
| 1624 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 1625 | return NULL; |
|---|
| 1626 | } |
|---|
| 1627 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; |
|---|
| 1628 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
|---|
| 1629 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1630 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1631 | )) |
|---|
| 1632 | ) |
|---|
| 1633 | { |
|---|
| 1634 | return NULL; |
|---|
| 1635 | } |
|---|
| 1636 | return m_pcCUAbove; |
|---|
| 1637 | } |
|---|
| 1638 | |
|---|
| 1639 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
|---|
| 1640 | { |
|---|
| 1641 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 1642 | return NULL; |
|---|
| 1643 | } |
|---|
| 1644 | |
|---|
| 1645 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; |
|---|
| 1646 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
|---|
| 1647 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
|---|
| 1648 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1649 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1650 | )) |
|---|
| 1651 | ) |
|---|
| 1652 | { |
|---|
| 1653 | return NULL; |
|---|
| 1654 | } |
|---|
| 1655 | return m_pcCUAboveRight; |
|---|
| 1656 | } |
|---|
| 1657 | |
|---|
| 1658 | /** Get left QpMinCu |
|---|
| 1659 | *\param uiLPartUnitIdx |
|---|
| 1660 | *\param uiCurrAbsIdxInLCU |
|---|
| 1661 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
|---|
| 1662 | */ |
|---|
| 1663 | TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInLCU) |
|---|
| 1664 | { |
|---|
| 1665 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1666 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth -getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
|---|
| 1667 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
|---|
| 1668 | |
|---|
| 1669 | // check for left LCU boundary |
|---|
| 1670 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCUWidth) ) |
|---|
| 1671 | { |
|---|
| 1672 | return NULL; |
|---|
| 1673 | } |
|---|
| 1674 | |
|---|
| 1675 | // get index of left-CU relative to top-left corner of current quantization group |
|---|
| 1676 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
|---|
| 1677 | |
|---|
| 1678 | // return pointer to current LCU |
|---|
| 1679 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1680 | } |
|---|
| 1681 | |
|---|
| 1682 | /** Get Above QpMinCu |
|---|
| 1683 | *\param aPartUnitIdx |
|---|
| 1684 | *\param currAbsIdxInLCU |
|---|
| 1685 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
|---|
| 1686 | */ |
|---|
| 1687 | TComDataCU* TComDataCU::getQpMinCuAbove( UInt& aPartUnitIdx, UInt currAbsIdxInLCU ) |
|---|
| 1688 | { |
|---|
| 1689 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1690 | UInt absZorderQpMinCUIdx = (currAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
|---|
| 1691 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
|---|
| 1692 | |
|---|
| 1693 | // check for top LCU boundary |
|---|
| 1694 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCUWidth) ) |
|---|
| 1695 | { |
|---|
| 1696 | return NULL; |
|---|
| 1697 | } |
|---|
| 1698 | |
|---|
| 1699 | // get index of top-CU relative to top-left corner of current quantization group |
|---|
| 1700 | aPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCUWidth]; |
|---|
| 1701 | |
|---|
| 1702 | // return pointer to current LCU |
|---|
| 1703 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1704 | } |
|---|
| 1705 | |
|---|
| 1706 | /** Get reference QP from left QpMinCu or latest coded QP |
|---|
| 1707 | *\param uiCurrAbsIdxInLCU |
|---|
| 1708 | *\returns Char reference QP value |
|---|
| 1709 | */ |
|---|
| 1710 | Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInLCU ) |
|---|
| 1711 | { |
|---|
| 1712 | UInt lPartIdx = 0, aPartIdx = 0; |
|---|
| 1713 | TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
|---|
| 1714 | TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
|---|
| 1715 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + 1) >> 1); |
|---|
| 1716 | } |
|---|
| 1717 | |
|---|
| 1718 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) |
|---|
| 1719 | { |
|---|
| 1720 | Int iLastValidPartIdx = iAbsPartIdx-1; |
|---|
| 1721 | while ( iLastValidPartIdx >= 0 |
|---|
| 1722 | && getPredictionMode( iLastValidPartIdx ) == MODE_NONE ) |
|---|
| 1723 | { |
|---|
| 1724 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
|---|
| 1725 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
|---|
| 1726 | } |
|---|
| 1727 | return iLastValidPartIdx; |
|---|
| 1728 | } |
|---|
| 1729 | |
|---|
| 1730 | Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) |
|---|
| 1731 | { |
|---|
| 1732 | UInt uiQUPartIdxMask = ~((1<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
|---|
| 1733 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); |
|---|
| 1734 | if ( uiAbsPartIdx < m_uiNumPartition |
|---|
| 1735 | && (getSCUAddr()+iLastValidPartIdx < getSliceStartCU(m_uiAbsIdxInLCU+uiAbsPartIdx))) |
|---|
| 1736 | { |
|---|
| 1737 | return getSlice()->getSliceQp(); |
|---|
| 1738 | } |
|---|
| 1739 | else |
|---|
| 1740 | if ( iLastValidPartIdx >= 0 ) |
|---|
| 1741 | { |
|---|
| 1742 | return getQP( iLastValidPartIdx ); |
|---|
| 1743 | } |
|---|
| 1744 | else |
|---|
| 1745 | { |
|---|
| 1746 | if ( getZorderIdxInCU() > 0 ) |
|---|
| 1747 | { |
|---|
| 1748 | return getPic()->getCU( getAddr() )->getLastCodedQP( getZorderIdxInCU() ); |
|---|
| 1749 | } |
|---|
| 1750 | else if ( getPic()->getPicSym()->getInverseCUOrderMap(getAddr()) > 0 |
|---|
| 1751 | && getPic()->getPicSym()->getTileIdxMap(getAddr()) == getPic()->getPicSym()->getTileIdxMap(getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1)) |
|---|
| 1752 | && !( getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() && getAddr() % getPic()->getFrameWidthInCU() == 0 ) ) |
|---|
| 1753 | { |
|---|
| 1754 | return getPic()->getCU( getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1) )->getLastCodedQP( getPic()->getNumPartInCU() ); |
|---|
| 1755 | } |
|---|
| 1756 | else |
|---|
| 1757 | { |
|---|
| 1758 | return getSlice()->getSliceQp(); |
|---|
| 1759 | } |
|---|
| 1760 | } |
|---|
| 1761 | } |
|---|
| 1762 | /** Check whether the CU is coded in lossless coding mode |
|---|
| 1763 | * \param uiAbsPartIdx |
|---|
| 1764 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
|---|
| 1765 | */ |
|---|
| 1766 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) |
|---|
| 1767 | { |
|---|
| 1768 | return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); |
|---|
| 1769 | } |
|---|
| 1770 | |
|---|
| 1771 | /** Get allowed chroma intra modes |
|---|
| 1772 | *\param uiAbsPartIdx |
|---|
| 1773 | *\param uiModeList pointer to chroma intra modes array |
|---|
| 1774 | *\returns |
|---|
| 1775 | *- fill uiModeList with chroma intra modes |
|---|
| 1776 | */ |
|---|
| 1777 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt* uiModeList ) |
|---|
| 1778 | { |
|---|
| 1779 | uiModeList[0] = PLANAR_IDX; |
|---|
| 1780 | uiModeList[1] = VER_IDX; |
|---|
| 1781 | uiModeList[2] = HOR_IDX; |
|---|
| 1782 | uiModeList[3] = DC_IDX; |
|---|
| 1783 | uiModeList[4] = DM_CHROMA_IDX; |
|---|
| 1784 | |
|---|
| 1785 | UInt uiLumaMode = getLumaIntraDir( uiAbsPartIdx ); |
|---|
| 1786 | |
|---|
| 1787 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
|---|
| 1788 | { |
|---|
| 1789 | if( uiLumaMode == uiModeList[i] ) |
|---|
| 1790 | { |
|---|
| 1791 | uiModeList[i] = 34; // VER+8 mode |
|---|
| 1792 | break; |
|---|
| 1793 | } |
|---|
| 1794 | } |
|---|
| 1795 | } |
|---|
| 1796 | |
|---|
| 1797 | /** Get most probable intra modes |
|---|
| 1798 | *\param uiAbsPartIdx |
|---|
| 1799 | *\param uiIntraDirPred pointer to the array for MPM storage |
|---|
| 1800 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
|---|
| 1801 | *\returns Number of MPM |
|---|
| 1802 | */ |
|---|
| 1803 | Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode ) |
|---|
| 1804 | { |
|---|
| 1805 | TComDataCU* pcTempCU; |
|---|
| 1806 | UInt uiTempPartIdx; |
|---|
| 1807 | Int iLeftIntraDir, iAboveIntraDir; |
|---|
| 1808 | Int uiPredNum = 0; |
|---|
| 1809 | |
|---|
| 1810 | // Get intra direction of left PU |
|---|
| 1811 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 1812 | |
|---|
| 1813 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
|---|
| 1814 | |
|---|
| 1815 | // Get intra direction of above PU |
|---|
| 1816 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true ); |
|---|
| 1817 | |
|---|
| 1818 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
|---|
| 1819 | |
|---|
| 1820 | uiPredNum = 3; |
|---|
| 1821 | if(iLeftIntraDir == iAboveIntraDir) |
|---|
| 1822 | { |
|---|
| 1823 | if( piMode ) |
|---|
| 1824 | { |
|---|
| 1825 | *piMode = 1; |
|---|
| 1826 | } |
|---|
| 1827 | |
|---|
| 1828 | if (iLeftIntraDir > 1) // angular modes |
|---|
| 1829 | { |
|---|
| 1830 | uiIntraDirPred[0] = iLeftIntraDir; |
|---|
| 1831 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
|---|
| 1832 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
|---|
| 1833 | } |
|---|
| 1834 | else //non-angular |
|---|
| 1835 | { |
|---|
| 1836 | uiIntraDirPred[0] = PLANAR_IDX; |
|---|
| 1837 | uiIntraDirPred[1] = DC_IDX; |
|---|
| 1838 | uiIntraDirPred[2] = VER_IDX; |
|---|
| 1839 | } |
|---|
| 1840 | } |
|---|
| 1841 | else |
|---|
| 1842 | { |
|---|
| 1843 | if( piMode ) |
|---|
| 1844 | { |
|---|
| 1845 | *piMode = 2; |
|---|
| 1846 | } |
|---|
| 1847 | uiIntraDirPred[0] = iLeftIntraDir; |
|---|
| 1848 | uiIntraDirPred[1] = iAboveIntraDir; |
|---|
| 1849 | |
|---|
| 1850 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
|---|
| 1851 | { |
|---|
| 1852 | uiIntraDirPred[2] = PLANAR_IDX; |
|---|
| 1853 | } |
|---|
| 1854 | else |
|---|
| 1855 | { |
|---|
| 1856 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
|---|
| 1857 | } |
|---|
| 1858 | } |
|---|
| 1859 | |
|---|
| 1860 | return uiPredNum; |
|---|
| 1861 | } |
|---|
| 1862 | |
|---|
| 1863 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 1864 | { |
|---|
| 1865 | TComDataCU* pcTempCU; |
|---|
| 1866 | UInt uiTempPartIdx; |
|---|
| 1867 | UInt uiCtx; |
|---|
| 1868 | // Get left split flag |
|---|
| 1869 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 1870 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
|---|
| 1871 | |
|---|
| 1872 | // Get above split flag |
|---|
| 1873 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 1874 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
|---|
| 1875 | |
|---|
| 1876 | return uiCtx; |
|---|
| 1877 | } |
|---|
| 1878 | |
|---|
| 1879 | UInt TComDataCU::getCtxQtCbf( TextType eType, UInt uiTrDepth ) |
|---|
| 1880 | { |
|---|
| 1881 | if( eType ) |
|---|
| 1882 | { |
|---|
| 1883 | return uiTrDepth; |
|---|
| 1884 | } |
|---|
| 1885 | else |
|---|
| 1886 | { |
|---|
| 1887 | const UInt uiCtx = ( uiTrDepth == 0 ? 1 : 0 ); |
|---|
| 1888 | return uiCtx; |
|---|
| 1889 | } |
|---|
| 1890 | } |
|---|
| 1891 | |
|---|
| 1892 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) |
|---|
| 1893 | { |
|---|
| 1894 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
|---|
| 1895 | PartSize partSize = getPartitionSize( absPartIdx ); |
|---|
| 1896 | UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
|---|
| 1897 | Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0; |
|---|
| 1898 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) ); |
|---|
| 1899 | |
|---|
| 1900 | UInt log2MinTUSizeInCU = 0; |
|---|
| 1901 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
|---|
| 1902 | { |
|---|
| 1903 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
|---|
| 1904 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
|---|
| 1905 | } |
|---|
| 1906 | else |
|---|
| 1907 | { |
|---|
| 1908 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
|---|
| 1909 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
|---|
| 1910 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
|---|
| 1911 | { |
|---|
| 1912 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
|---|
| 1913 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
|---|
| 1914 | } |
|---|
| 1915 | } |
|---|
| 1916 | return log2MinTUSizeInCU; |
|---|
| 1917 | } |
|---|
| 1918 | |
|---|
| 1919 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
|---|
| 1920 | { |
|---|
| 1921 | TComDataCU* pcTempCU; |
|---|
| 1922 | UInt uiTempPartIdx; |
|---|
| 1923 | UInt uiCtx = 0; |
|---|
| 1924 | |
|---|
| 1925 | // Get BCBP of left PU |
|---|
| 1926 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 1927 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
|---|
| 1928 | |
|---|
| 1929 | // Get BCBP of above PU |
|---|
| 1930 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 1931 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
|---|
| 1932 | |
|---|
| 1933 | return uiCtx; |
|---|
| 1934 | } |
|---|
| 1935 | |
|---|
| 1936 | #if H_3D_ARP |
|---|
| 1937 | UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx ) |
|---|
| 1938 | { |
|---|
| 1939 | TComDataCU* pcTempCU; |
|---|
| 1940 | UInt uiTempPartIdx; |
|---|
| 1941 | UInt uiCtx = 0; |
|---|
| 1942 | |
|---|
| 1943 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 1944 | uiCtx = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0; |
|---|
| 1945 | |
|---|
| 1946 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 1947 | uiCtx += ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1): 0; |
|---|
| 1948 | |
|---|
| 1949 | return uiCtx; |
|---|
| 1950 | } |
|---|
| 1951 | #endif |
|---|
| 1952 | |
|---|
| 1953 | #if H_3D_IC |
|---|
| 1954 | UInt TComDataCU::getCtxICFlag( UInt uiAbsPartIdx ) |
|---|
| 1955 | { |
|---|
| 1956 | UInt uiCtx = 0; |
|---|
| 1957 | |
|---|
| 1958 | return uiCtx; |
|---|
| 1959 | } |
|---|
| 1960 | #endif |
|---|
| 1961 | |
|---|
| 1962 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
|---|
| 1963 | { |
|---|
| 1964 | return getDepth( uiAbsPartIdx ); |
|---|
| 1965 | } |
|---|
| 1966 | |
|---|
| 1967 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 1968 | { |
|---|
| 1969 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 1970 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 1971 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 1972 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 1973 | } |
|---|
| 1974 | |
|---|
| 1975 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 1976 | { |
|---|
| 1977 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 1978 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 1979 | } |
|---|
| 1980 | |
|---|
| 1981 | /** Sets a coded block flag for all sub-partitions of a partition |
|---|
| 1982 | * \param uiCbf The value of the coded block flag to be set |
|---|
| 1983 | * \param eTType |
|---|
| 1984 | * \param uiAbsPartIdx |
|---|
| 1985 | * \param uiPartIdx |
|---|
| 1986 | * \param uiDepth |
|---|
| 1987 | * \returns Void |
|---|
| 1988 | */ |
|---|
| 1989 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 1990 | { |
|---|
| 1991 | setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 1992 | } |
|---|
| 1993 | |
|---|
| 1994 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
|---|
| 1995 | { |
|---|
| 1996 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 1997 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 1998 | } |
|---|
| 1999 | |
|---|
| 2000 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
|---|
| 2001 | { |
|---|
| 2002 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2003 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
|---|
| 2004 | } |
|---|
| 2005 | |
|---|
| 2006 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2007 | { |
|---|
| 2008 | assert( sizeof( *m_pePartSize) == 1 ); |
|---|
| 2009 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
|---|
| 2010 | } |
|---|
| 2011 | |
|---|
| 2012 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2013 | { |
|---|
| 2014 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
|---|
| 2015 | } |
|---|
| 2016 | |
|---|
| 2017 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
|---|
| 2018 | { |
|---|
| 2019 | assert( sizeof( *m_skipFlag) == 1 ); |
|---|
| 2020 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); |
|---|
| 2021 | } |
|---|
| 2022 | |
|---|
| 2023 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2024 | { |
|---|
| 2025 | assert( sizeof( *m_pePredMode) == 1 ); |
|---|
| 2026 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
|---|
| 2027 | } |
|---|
| 2028 | |
|---|
| 2029 | Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
|---|
| 2030 | { |
|---|
| 2031 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
|---|
| 2032 | UInt currPartNumQ = currPartNumb >> 2; |
|---|
| 2033 | |
|---|
| 2034 | if(!foundNonZeroCbf) |
|---|
| 2035 | { |
|---|
| 2036 | if(pcCU->getDepth(absPartIdx) > depth) |
|---|
| 2037 | { |
|---|
| 2038 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
|---|
| 2039 | { |
|---|
| 2040 | pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
|---|
| 2041 | } |
|---|
| 2042 | } |
|---|
| 2043 | else |
|---|
| 2044 | { |
|---|
| 2045 | if(pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V ) ) |
|---|
| 2046 | { |
|---|
| 2047 | foundNonZeroCbf = true; |
|---|
| 2048 | } |
|---|
| 2049 | else |
|---|
| 2050 | { |
|---|
| 2051 | setQPSubParts(qp, absPartIdx, depth); |
|---|
| 2052 | } |
|---|
| 2053 | } |
|---|
| 2054 | } |
|---|
| 2055 | } |
|---|
| 2056 | |
|---|
| 2057 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2058 | { |
|---|
| 2059 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2060 | TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); |
|---|
| 2061 | |
|---|
| 2062 | for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) |
|---|
| 2063 | { |
|---|
| 2064 | if( m_pcPic->getCU( getAddr() )->getSliceSegmentStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr() ) |
|---|
| 2065 | { |
|---|
| 2066 | m_phQP[uiSCUIdx] = qp; |
|---|
| 2067 | } |
|---|
| 2068 | } |
|---|
| 2069 | } |
|---|
| 2070 | |
|---|
| 2071 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2072 | { |
|---|
| 2073 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2074 | |
|---|
| 2075 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2076 | } |
|---|
| 2077 | |
|---|
| 2078 | template<typename T> |
|---|
| 2079 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
|---|
| 2080 | { |
|---|
| 2081 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
|---|
| 2082 | |
|---|
| 2083 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
|---|
| 2084 | switch ( m_pePartSize[ uiCUAddr ] ) |
|---|
| 2085 | { |
|---|
| 2086 | case SIZE_2Nx2N: |
|---|
| 2087 | memset( puhBaseLCU + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
|---|
| 2088 | break; |
|---|
| 2089 | case SIZE_2NxN: |
|---|
| 2090 | memset( puhBaseLCU + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
|---|
| 2091 | break; |
|---|
| 2092 | case SIZE_Nx2N: |
|---|
| 2093 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
|---|
| 2094 | memset( puhBaseLCU + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
|---|
| 2095 | break; |
|---|
| 2096 | case SIZE_NxN: |
|---|
| 2097 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
|---|
| 2098 | break; |
|---|
| 2099 | case SIZE_2NxnU: |
|---|
| 2100 | if ( uiPUIdx == 0 ) |
|---|
| 2101 | { |
|---|
| 2102 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2103 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2104 | } |
|---|
| 2105 | else if ( uiPUIdx == 1 ) |
|---|
| 2106 | { |
|---|
| 2107 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2108 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
|---|
| 2109 | } |
|---|
| 2110 | else |
|---|
| 2111 | { |
|---|
| 2112 | assert(0); |
|---|
| 2113 | } |
|---|
| 2114 | break; |
|---|
| 2115 | case SIZE_2NxnD: |
|---|
| 2116 | if ( uiPUIdx == 0 ) |
|---|
| 2117 | { |
|---|
| 2118 | memset( puhBaseLCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
|---|
| 2119 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2120 | } |
|---|
| 2121 | else if ( uiPUIdx == 1 ) |
|---|
| 2122 | { |
|---|
| 2123 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2124 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2125 | } |
|---|
| 2126 | else |
|---|
| 2127 | { |
|---|
| 2128 | assert(0); |
|---|
| 2129 | } |
|---|
| 2130 | break; |
|---|
| 2131 | case SIZE_nLx2N: |
|---|
| 2132 | if ( uiPUIdx == 0 ) |
|---|
| 2133 | { |
|---|
| 2134 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2135 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2136 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2137 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2138 | } |
|---|
| 2139 | else if ( uiPUIdx == 1 ) |
|---|
| 2140 | { |
|---|
| 2141 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2142 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
|---|
| 2143 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2144 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
|---|
| 2145 | } |
|---|
| 2146 | else |
|---|
| 2147 | { |
|---|
| 2148 | assert(0); |
|---|
| 2149 | } |
|---|
| 2150 | break; |
|---|
| 2151 | case SIZE_nRx2N: |
|---|
| 2152 | if ( uiPUIdx == 0 ) |
|---|
| 2153 | { |
|---|
| 2154 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
|---|
| 2155 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2156 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
|---|
| 2157 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2158 | } |
|---|
| 2159 | else if ( uiPUIdx == 1 ) |
|---|
| 2160 | { |
|---|
| 2161 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2162 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2163 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2164 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2165 | } |
|---|
| 2166 | else |
|---|
| 2167 | { |
|---|
| 2168 | assert(0); |
|---|
| 2169 | } |
|---|
| 2170 | break; |
|---|
| 2171 | default: |
|---|
| 2172 | assert( 0 ); |
|---|
| 2173 | } |
|---|
| 2174 | } |
|---|
| 2175 | |
|---|
| 2176 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2177 | { |
|---|
| 2178 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2179 | } |
|---|
| 2180 | |
|---|
| 2181 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2182 | { |
|---|
| 2183 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2184 | } |
|---|
| 2185 | |
|---|
| 2186 | #if H_3D_VSP |
|---|
| 2187 | Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2188 | { |
|---|
| 2189 | setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2190 | } |
|---|
| 2191 | #endif |
|---|
| 2192 | |
|---|
| 2193 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2194 | { |
|---|
| 2195 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2196 | |
|---|
| 2197 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2198 | } |
|---|
| 2199 | |
|---|
| 2200 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2201 | { |
|---|
| 2202 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2203 | } |
|---|
| 2204 | |
|---|
| 2205 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2206 | { |
|---|
| 2207 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2208 | } |
|---|
| 2209 | |
|---|
| 2210 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2211 | { |
|---|
| 2212 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2213 | } |
|---|
| 2214 | |
|---|
| 2215 | |
|---|
| 2216 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2217 | { |
|---|
| 2218 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2219 | |
|---|
| 2220 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2221 | } |
|---|
| 2222 | |
|---|
| 2223 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2224 | { |
|---|
| 2225 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2226 | |
|---|
| 2227 | memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2228 | memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2229 | memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2230 | } |
|---|
| 2231 | |
|---|
| 2232 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) |
|---|
| 2233 | { |
|---|
| 2234 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2235 | |
|---|
| 2236 | memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2237 | } |
|---|
| 2238 | |
|---|
| 2239 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2240 | { |
|---|
| 2241 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2242 | |
|---|
| 2243 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2244 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2245 | } |
|---|
| 2246 | |
|---|
| 2247 | UChar TComDataCU::getNumPartInter() |
|---|
| 2248 | { |
|---|
| 2249 | UChar iNumPart = 0; |
|---|
| 2250 | |
|---|
| 2251 | switch ( m_pePartSize[0] ) |
|---|
| 2252 | { |
|---|
| 2253 | case SIZE_2Nx2N: iNumPart = 1; break; |
|---|
| 2254 | case SIZE_2NxN: iNumPart = 2; break; |
|---|
| 2255 | case SIZE_Nx2N: iNumPart = 2; break; |
|---|
| 2256 | case SIZE_NxN: iNumPart = 4; break; |
|---|
| 2257 | case SIZE_2NxnU: iNumPart = 2; break; |
|---|
| 2258 | case SIZE_2NxnD: iNumPart = 2; break; |
|---|
| 2259 | case SIZE_nLx2N: iNumPart = 2; break; |
|---|
| 2260 | case SIZE_nRx2N: iNumPart = 2; break; |
|---|
| 2261 | default: assert (0); break; |
|---|
| 2262 | } |
|---|
| 2263 | |
|---|
| 2264 | return iNumPart; |
|---|
| 2265 | } |
|---|
| 2266 | |
|---|
| 2267 | #if H_3D_IC |
|---|
| 2268 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) |
|---|
| 2269 | { |
|---|
| 2270 | UInt uiNumPartition = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition; |
|---|
| 2271 | UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0; |
|---|
| 2272 | |
|---|
| 2273 | switch ( m_pePartSize[uiTmpAbsPartIdx] ) |
|---|
| 2274 | { |
|---|
| 2275 | case SIZE_2NxN: |
|---|
| 2276 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1; |
|---|
| 2277 | break; |
|---|
| 2278 | case SIZE_Nx2N: |
|---|
| 2279 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2; |
|---|
| 2280 | break; |
|---|
| 2281 | case SIZE_NxN: |
|---|
| 2282 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx; |
|---|
| 2283 | break; |
|---|
| 2284 | case SIZE_2NxnU: |
|---|
| 2285 | riWidth = getWidth( uiTmpAbsPartIdx ); |
|---|
| 2286 | riHeight = ( uiPartIdx == 0 ) ? getHeight( uiTmpAbsPartIdx ) >> 2 : ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ); |
|---|
| 2287 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3; |
|---|
| 2288 | break; |
|---|
| 2289 | case SIZE_2NxnD: |
|---|
| 2290 | riWidth = getWidth( uiTmpAbsPartIdx ); |
|---|
| 2291 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ) : getHeight( uiTmpAbsPartIdx ) >> 2; |
|---|
| 2292 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3); |
|---|
| 2293 | break; |
|---|
| 2294 | case SIZE_nLx2N: |
|---|
| 2295 | riWidth = ( uiPartIdx == 0 ) ? getWidth( uiTmpAbsPartIdx ) >> 2 : ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ); |
|---|
| 2296 | riHeight = getHeight( uiTmpAbsPartIdx ); |
|---|
| 2297 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4; |
|---|
| 2298 | break; |
|---|
| 2299 | case SIZE_nRx2N: |
|---|
| 2300 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ) : getWidth( uiTmpAbsPartIdx ) >> 2; |
|---|
| 2301 | riHeight = getHeight( uiTmpAbsPartIdx ); |
|---|
| 2302 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4); |
|---|
| 2303 | break; |
|---|
| 2304 | default: |
|---|
| 2305 | assert ( m_pePartSize[uiTmpAbsPartIdx] == SIZE_2Nx2N ); |
|---|
| 2306 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = 0; |
|---|
| 2307 | break; |
|---|
| 2308 | } |
|---|
| 2309 | } |
|---|
| 2310 | #else |
|---|
| 2311 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
|---|
| 2312 | { |
|---|
| 2313 | switch ( m_pePartSize[0] ) |
|---|
| 2314 | { |
|---|
| 2315 | case SIZE_2NxN: |
|---|
| 2316 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
|---|
| 2317 | break; |
|---|
| 2318 | case SIZE_Nx2N: |
|---|
| 2319 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
|---|
| 2320 | break; |
|---|
| 2321 | case SIZE_NxN: |
|---|
| 2322 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
|---|
| 2323 | break; |
|---|
| 2324 | case SIZE_2NxnU: |
|---|
| 2325 | riWidth = getWidth(0); |
|---|
| 2326 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
|---|
| 2327 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
|---|
| 2328 | break; |
|---|
| 2329 | case SIZE_2NxnD: |
|---|
| 2330 | riWidth = getWidth(0); |
|---|
| 2331 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
|---|
| 2332 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
|---|
| 2333 | break; |
|---|
| 2334 | case SIZE_nLx2N: |
|---|
| 2335 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
|---|
| 2336 | riHeight = getHeight(0); |
|---|
| 2337 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
|---|
| 2338 | break; |
|---|
| 2339 | case SIZE_nRx2N: |
|---|
| 2340 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
|---|
| 2341 | riHeight = getHeight(0); |
|---|
| 2342 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
|---|
| 2343 | break; |
|---|
| 2344 | default: |
|---|
| 2345 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
|---|
| 2346 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
|---|
| 2347 | break; |
|---|
| 2348 | } |
|---|
| 2349 | } |
|---|
| 2350 | #endif |
|---|
| 2351 | |
|---|
| 2352 | |
|---|
| 2353 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
|---|
| 2354 | { |
|---|
| 2355 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
|---|
| 2356 | { |
|---|
| 2357 | TComMv cZeroMv; |
|---|
| 2358 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
|---|
| 2359 | return; |
|---|
| 2360 | } |
|---|
| 2361 | |
|---|
| 2362 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
|---|
| 2363 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
|---|
| 2364 | } |
|---|
| 2365 | |
|---|
| 2366 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
|---|
| 2367 | { |
|---|
| 2368 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
|---|
| 2369 | UInt uiPUWidth = 0; |
|---|
| 2370 | |
|---|
| 2371 | switch ( m_pePartSize[uiAbsPartIdx] ) |
|---|
| 2372 | { |
|---|
| 2373 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
|---|
| 2374 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
|---|
| 2375 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
|---|
| 2376 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
|---|
| 2377 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
|---|
| 2378 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
|---|
| 2379 | case SIZE_nLx2N: |
|---|
| 2380 | if ( uiPartIdx == 0 ) |
|---|
| 2381 | { |
|---|
| 2382 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
|---|
| 2383 | } |
|---|
| 2384 | else if ( uiPartIdx == 1 ) |
|---|
| 2385 | { |
|---|
| 2386 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
|---|
| 2387 | } |
|---|
| 2388 | else |
|---|
| 2389 | { |
|---|
| 2390 | assert(0); |
|---|
| 2391 | } |
|---|
| 2392 | break; |
|---|
| 2393 | case SIZE_nRx2N: |
|---|
| 2394 | if ( uiPartIdx == 0 ) |
|---|
| 2395 | { |
|---|
| 2396 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
|---|
| 2397 | } |
|---|
| 2398 | else if ( uiPartIdx == 1 ) |
|---|
| 2399 | { |
|---|
| 2400 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
|---|
| 2401 | } |
|---|
| 2402 | else |
|---|
| 2403 | { |
|---|
| 2404 | assert(0); |
|---|
| 2405 | } |
|---|
| 2406 | break; |
|---|
| 2407 | default: |
|---|
| 2408 | assert (0); |
|---|
| 2409 | break; |
|---|
| 2410 | } |
|---|
| 2411 | |
|---|
| 2412 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
|---|
| 2413 | } |
|---|
| 2414 | |
|---|
| 2415 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
|---|
| 2416 | { |
|---|
| 2417 | UInt uiPUHeight = 0; |
|---|
| 2418 | switch ( m_pePartSize[uiAbsPartIdx] ) |
|---|
| 2419 | { |
|---|
| 2420 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
|---|
| 2421 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
|---|
| 2422 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
|---|
| 2423 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
|---|
| 2424 | case SIZE_2NxnU: |
|---|
| 2425 | if ( uiPartIdx == 0 ) |
|---|
| 2426 | { |
|---|
| 2427 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
|---|
| 2428 | } |
|---|
| 2429 | else if ( uiPartIdx == 1 ) |
|---|
| 2430 | { |
|---|
| 2431 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
|---|
| 2432 | } |
|---|
| 2433 | else |
|---|
| 2434 | { |
|---|
| 2435 | assert(0); |
|---|
| 2436 | } |
|---|
| 2437 | break; |
|---|
| 2438 | case SIZE_2NxnD: |
|---|
| 2439 | if ( uiPartIdx == 0 ) |
|---|
| 2440 | { |
|---|
| 2441 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
|---|
| 2442 | } |
|---|
| 2443 | else if ( uiPartIdx == 1 ) |
|---|
| 2444 | { |
|---|
| 2445 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
|---|
| 2446 | } |
|---|
| 2447 | else |
|---|
| 2448 | { |
|---|
| 2449 | assert(0); |
|---|
| 2450 | } |
|---|
| 2451 | break; |
|---|
| 2452 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
|---|
| 2453 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
|---|
| 2454 | default: |
|---|
| 2455 | assert (0); |
|---|
| 2456 | break; |
|---|
| 2457 | } |
|---|
| 2458 | |
|---|
| 2459 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
|---|
| 2460 | } |
|---|
| 2461 | |
|---|
| 2462 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
|---|
| 2463 | { |
|---|
| 2464 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
|---|
| 2465 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
|---|
| 2466 | |
|---|
| 2467 | switch ( m_pePartSize[0] ) |
|---|
| 2468 | { |
|---|
| 2469 | case SIZE_2Nx2N: break; |
|---|
| 2470 | case SIZE_2NxN: |
|---|
| 2471 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
|---|
| 2472 | break; |
|---|
| 2473 | case SIZE_Nx2N: |
|---|
| 2474 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
|---|
| 2475 | break; |
|---|
| 2476 | case SIZE_NxN: |
|---|
| 2477 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
|---|
| 2478 | break; |
|---|
| 2479 | case SIZE_2NxnU: |
|---|
| 2480 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
|---|
| 2481 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
|---|
| 2482 | break; |
|---|
| 2483 | case SIZE_2NxnD: |
|---|
| 2484 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
|---|
| 2485 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
|---|
| 2486 | break; |
|---|
| 2487 | case SIZE_nLx2N: |
|---|
| 2488 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
|---|
| 2489 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
|---|
| 2490 | break; |
|---|
| 2491 | case SIZE_nRx2N: |
|---|
| 2492 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
|---|
| 2493 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
|---|
| 2494 | break; |
|---|
| 2495 | default: |
|---|
| 2496 | assert (0); |
|---|
| 2497 | break; |
|---|
| 2498 | } |
|---|
| 2499 | |
|---|
| 2500 | } |
|---|
| 2501 | |
|---|
| 2502 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) |
|---|
| 2503 | { |
|---|
| 2504 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
|---|
| 2505 | |
|---|
| 2506 | switch ( m_pePartSize[0] ) |
|---|
| 2507 | { |
|---|
| 2508 | case SIZE_2Nx2N: |
|---|
| 2509 | ruiPartIdxLB += m_uiNumPartition >> 1; |
|---|
| 2510 | break; |
|---|
| 2511 | case SIZE_2NxN: |
|---|
| 2512 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
|---|
| 2513 | break; |
|---|
| 2514 | case SIZE_Nx2N: |
|---|
| 2515 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
|---|
| 2516 | break; |
|---|
| 2517 | case SIZE_NxN: |
|---|
| 2518 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
|---|
| 2519 | break; |
|---|
| 2520 | case SIZE_2NxnU: |
|---|
| 2521 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
|---|
| 2522 | break; |
|---|
| 2523 | case SIZE_2NxnD: |
|---|
| 2524 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
|---|
| 2525 | break; |
|---|
| 2526 | case SIZE_nLx2N: |
|---|
| 2527 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
|---|
| 2528 | break; |
|---|
| 2529 | case SIZE_nRx2N: |
|---|
| 2530 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
|---|
| 2531 | break; |
|---|
| 2532 | default: |
|---|
| 2533 | assert (0); |
|---|
| 2534 | break; |
|---|
| 2535 | } |
|---|
| 2536 | } |
|---|
| 2537 | |
|---|
| 2538 | /** Derives the partition index of neighbouring bottom right block |
|---|
| 2539 | * \param [in] eCUMode |
|---|
| 2540 | * \param [in] uiPartIdx |
|---|
| 2541 | * \param [out] ruiPartIdxRB |
|---|
| 2542 | */ |
|---|
| 2543 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxRB ) |
|---|
| 2544 | { |
|---|
| 2545 | ruiPartIdxRB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth() + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1]; |
|---|
| 2546 | |
|---|
| 2547 | switch ( m_pePartSize[0] ) |
|---|
| 2548 | { |
|---|
| 2549 | case SIZE_2Nx2N: |
|---|
| 2550 | ruiPartIdxRB += m_uiNumPartition >> 1; |
|---|
| 2551 | break; |
|---|
| 2552 | case SIZE_2NxN: |
|---|
| 2553 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
|---|
| 2554 | break; |
|---|
| 2555 | case SIZE_Nx2N: |
|---|
| 2556 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
|---|
| 2557 | break; |
|---|
| 2558 | case SIZE_NxN: |
|---|
| 2559 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
|---|
| 2560 | break; |
|---|
| 2561 | case SIZE_2NxnU: |
|---|
| 2562 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
|---|
| 2563 | break; |
|---|
| 2564 | case SIZE_2NxnD: |
|---|
| 2565 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
|---|
| 2566 | break; |
|---|
| 2567 | case SIZE_nLx2N: |
|---|
| 2568 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
|---|
| 2569 | break; |
|---|
| 2570 | case SIZE_nRx2N: |
|---|
| 2571 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
|---|
| 2572 | break; |
|---|
| 2573 | default: |
|---|
| 2574 | assert (0); |
|---|
| 2575 | break; |
|---|
| 2576 | } |
|---|
| 2577 | } |
|---|
| 2578 | |
|---|
| 2579 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
|---|
| 2580 | { |
|---|
| 2581 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
|---|
| 2582 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
|---|
| 2583 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
|---|
| 2584 | } |
|---|
| 2585 | |
|---|
| 2586 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
|---|
| 2587 | { |
|---|
| 2588 | UInt uiAbsIdx; |
|---|
| 2589 | UInt uiMinCuWidth, uiWidthInMinCus; |
|---|
| 2590 | |
|---|
| 2591 | uiMinCuWidth = getPic()->getMinCUWidth(); |
|---|
| 2592 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
|---|
| 2593 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
|---|
| 2594 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
|---|
| 2595 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
|---|
| 2596 | } |
|---|
| 2597 | |
|---|
| 2598 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
|---|
| 2599 | { |
|---|
| 2600 | |
|---|
| 2601 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
|---|
| 2602 | { |
|---|
| 2603 | return false; |
|---|
| 2604 | } |
|---|
| 2605 | |
|---|
| 2606 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 2607 | { |
|---|
| 2608 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
|---|
| 2609 | { |
|---|
| 2610 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
|---|
| 2611 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
|---|
| 2612 | { |
|---|
| 2613 | return false; |
|---|
| 2614 | } |
|---|
| 2615 | } |
|---|
| 2616 | } |
|---|
| 2617 | |
|---|
| 2618 | return true; |
|---|
| 2619 | } |
|---|
| 2620 | |
|---|
| 2621 | #if H_3D_VSP |
|---|
| 2622 | |
|---|
| 2623 | /** Add a VSP merging candidate |
|---|
| 2624 | * \Inputs |
|---|
| 2625 | * \param uiPUIdx: PU index within a CU |
|---|
| 2626 | * \param ucVspMergePos: Specify the VSP merge candidate position |
|---|
| 2627 | * \param mrgCandIdx: Target merge candidate index. At encoder, it is set equal to -1, such that the whole merge candidate list will be constructed. |
|---|
| 2628 | * \param pDinfo: The "disparity information" derived from neighboring blocks. Type 1 MV. |
|---|
| 2629 | * \param uiCount: The next position to add VSP merge candidate |
|---|
| 2630 | * |
|---|
| 2631 | * \Outputs |
|---|
| 2632 | * \param uiCount: The next position to add merge candidate. Will be updated if VSP is successfully added |
|---|
| 2633 | * \param abCandIsInter: abCandIsInter[iCount] tells that VSP candidate is an Inter candidate, if VSP is successfully added |
|---|
| 2634 | * \param pcMvFieldNeighbours: Return the "disparity vector". Type 1 MV. To be used to fetch a depth block. A "global" variable |
|---|
| 2635 | * \param puhInterDirNeighbours: Tells the VSP prediction direction. TODO: The value does NOT matter for VSP, as the direction will be determined based on availability later |
|---|
| 2636 | * Having it as output is mainly for coding beauty |
|---|
| 2637 | * \param vspFlag: vspFlag[iCount] will be set (equal to 1), if VSP is successfully added. To be used to indicate the actual position of the VSP candidate |
|---|
| 2638 | * |
|---|
| 2639 | * \Return |
|---|
| 2640 | * true: if the VSP candidate is added at the target position |
|---|
| 2641 | * false: otherwise |
|---|
| 2642 | */ |
|---|
| 2643 | inline Bool TComDataCU::xAddVspCand( UChar ucVspMergePos, Int mrgCandIdx, DisInfo* pDInfo, Int& iCount, |
|---|
| 2644 | Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag ) |
|---|
| 2645 | { |
|---|
| 2646 | if( !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) ) // Not to add the candidate if VSP is turned off |
|---|
| 2647 | return false; |
|---|
| 2648 | if( m_pcSlice->getIsDepth() ) // VSP is turned off for depth layers |
|---|
| 2649 | return false; |
|---|
| 2650 | |
|---|
| 2651 | Int refViewIdx = pDInfo->m_aVIdxCan; |
|---|
| 2652 | TComPic* picDepth = NULL; |
|---|
| 2653 | //assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC()); |
|---|
| 2654 | picDepth = getSlice()->getIvPic( true, refViewIdx ); |
|---|
| 2655 | |
|---|
| 2656 | ////////// |
|---|
| 2657 | // Code if simply re-writing |
|---|
| 2658 | // if(ucVspMergePos == H_3D_VSPPOSITION && picDepth != NULL && 0 != m_pcSlice->getViewIndex() ) // VSP can be used only when depth is used as input |
|---|
| 2659 | // { |
|---|
| 2660 | // abCandIsInter[iCount] = true; |
|---|
| 2661 | // puhInterDirNeighbours[iCount] = 1; |
|---|
| 2662 | // vspFlag[iCount] = 1; |
|---|
| 2663 | // vspDirTrue[iCount] = 0; // TODO: Check if this is really useful!!!! |
|---|
| 2664 | // |
|---|
| 2665 | // Int iRefIdxList0 = getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC() == getSlice()->getPOC() ? 0 : |
|---|
| 2666 | // (getSlice()->getAlterRefIdx(REF_PIC_LIST_0) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_0)); |
|---|
| 2667 | // pcMvFieldNeighbours[iCount<<1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList0 ); |
|---|
| 2668 | // if (getSlice()->isInterB()) |
|---|
| 2669 | // { |
|---|
| 2670 | // puhInterDirNeighbours[iCount] = xGetVspDirection(uiPUIdx); |
|---|
| 2671 | // Int iRefIdxList1 = getSlice()->getRefPic(REF_PIC_LIST_1, 0)->getPOC() == getSlice()->getPOC() ? 0 : |
|---|
| 2672 | // (getSlice()->getAlterRefIdx(REF_PIC_LIST_1) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_1)); |
|---|
| 2673 | // pcMvFieldNeighbours[(iCount<<1)+1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList1 ); |
|---|
| 2674 | // } |
|---|
| 2675 | // |
|---|
| 2676 | // if ( mrgCandIdx == iCount ) |
|---|
| 2677 | // return true; |
|---|
| 2678 | // |
|---|
| 2679 | // iCount++; |
|---|
| 2680 | // } |
|---|
| 2681 | ///////////// |
|---|
| 2682 | |
|---|
| 2683 | if(ucVspMergePos == H_3D_VSP_POSITION && picDepth != NULL && 0 != m_pcSlice->getViewIndex() ) // VSP can be used only when depth is used as input |
|---|
| 2684 | { |
|---|
| 2685 | Bool refViewAvailFlag = false; |
|---|
| 2686 | UChar predFlag[2] = {0, 0}; |
|---|
| 2687 | Int iRefListIdX = 0; |
|---|
| 2688 | Int iRefListIdY = 0; |
|---|
| 2689 | |
|---|
| 2690 | for( iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ ) |
|---|
| 2691 | { |
|---|
| 2692 | RefPicList eRefPicList = RefPicList( iRefListIdX ); |
|---|
| 2693 | for (Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicList) && !refViewAvailFlag; i++) |
|---|
| 2694 | { |
|---|
| 2695 | Int viewIdxRefInList = m_pcSlice->getRefPic(eRefPicList, i)->getViewIndex(); |
|---|
| 2696 | if (refViewIdx == viewIdxRefInList) |
|---|
| 2697 | { |
|---|
| 2698 | Int iRefIdxList0 = getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC() == getSlice()->getPOC() ? 0 : |
|---|
| 2699 | (getSlice()->getAlterRefIdx(REF_PIC_LIST_0) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_0)); |
|---|
| 2700 | |
|---|
| 2701 | refViewAvailFlag = true; |
|---|
| 2702 | predFlag[iRefListIdX] = 1; |
|---|
| 2703 | iRefListIdY = 1 - iRefListIdX; |
|---|
| 2704 | pcMvFieldNeighbours[iCount<<1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList0 ); |
|---|
| 2705 | // pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acDoNBDV, i ); // Buggy code |
|---|
| 2706 | } |
|---|
| 2707 | } |
|---|
| 2708 | } |
|---|
| 2709 | |
|---|
| 2710 | if (m_pcSlice->isInterB() && refViewAvailFlag) |
|---|
| 2711 | { |
|---|
| 2712 | RefPicList eRefPicList = RefPicList( iRefListIdY ); |
|---|
| 2713 | refViewAvailFlag = false; |
|---|
| 2714 | for (Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicList) && !refViewAvailFlag; i++) |
|---|
| 2715 | { |
|---|
| 2716 | Int viewIdxRefInList = m_pcSlice->getRefPic(eRefPicList, i)->getViewIndex(); |
|---|
| 2717 | if (refViewIdx != viewIdxRefInList) |
|---|
| 2718 | { |
|---|
| 2719 | Int iRefIdxList1 = getSlice()->getRefPic(REF_PIC_LIST_1, 0)->getPOC() == getSlice()->getPOC() ? 0 : |
|---|
| 2720 | (getSlice()->getAlterRefIdx(REF_PIC_LIST_1) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_1)); |
|---|
| 2721 | |
|---|
| 2722 | refViewAvailFlag = true; |
|---|
| 2723 | predFlag[iRefListIdY] = 1; |
|---|
| 2724 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList1 ); |
|---|
| 2725 | //pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].setMvField( pDInfo->m_acDoNBDV, i ); // Buggy code |
|---|
| 2726 | } |
|---|
| 2727 | } |
|---|
| 2728 | } |
|---|
| 2729 | |
|---|
| 2730 | abCandIsInter[iCount] = true; |
|---|
| 2731 | puhInterDirNeighbours[iCount] = (predFlag[0] | (predFlag[1] << 1)); |
|---|
| 2732 | vspFlag[iCount] = 1; |
|---|
| 2733 | |
|---|
| 2734 | if ( mrgCandIdx == iCount ) |
|---|
| 2735 | return true; |
|---|
| 2736 | |
|---|
| 2737 | iCount++; |
|---|
| 2738 | } |
|---|
| 2739 | |
|---|
| 2740 | return false; |
|---|
| 2741 | } |
|---|
| 2742 | #endif |
|---|
| 2743 | |
|---|
| 2744 | /** Constructs a list of merging candidates |
|---|
| 2745 | * \param uiAbsPartIdx |
|---|
| 2746 | * \param uiPUIdx |
|---|
| 2747 | * \param uiDepth |
|---|
| 2748 | * \param pcMvFieldNeighbours |
|---|
| 2749 | * \param puhInterDirNeighbours |
|---|
| 2750 | * \param numValidMergeCand |
|---|
| 2751 | */ |
|---|
| 2752 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
|---|
| 2753 | #if H_3D_VSP |
|---|
| 2754 | , Int* vspFlag |
|---|
| 2755 | #endif |
|---|
| 2756 | , Int& numValidMergeCand |
|---|
| 2757 | , Int mrgCandIdx |
|---|
| 2758 | ) |
|---|
| 2759 | { |
|---|
| 2760 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
|---|
| 2761 | #if H_3D_IV_MERGE |
|---|
| 2762 | TComMv cZeroMv; |
|---|
| 2763 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ]; |
|---|
| 2764 | #else |
|---|
| 2765 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
|---|
| 2766 | #endif |
|---|
| 2767 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
|---|
| 2768 | { |
|---|
| 2769 | abCandIsInter[ui] = false; |
|---|
| 2770 | #if H_3D_IV_MERGE |
|---|
| 2771 | pcMvFieldNeighbours[ ( ui << 1 ) ].setMvField(cZeroMv, NOT_VALID); |
|---|
| 2772 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID); |
|---|
| 2773 | #else |
|---|
| 2774 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
|---|
| 2775 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
|---|
| 2776 | #endif |
|---|
| 2777 | } |
|---|
| 2778 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
|---|
| 2779 | // compute the location of the current PU |
|---|
| 2780 | Int xP, yP, nPSW, nPSH; |
|---|
| 2781 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
|---|
| 2782 | |
|---|
| 2783 | Int iCount = 0; |
|---|
| 2784 | |
|---|
| 2785 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
|---|
| 2786 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
|---|
| 2787 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
|---|
| 2788 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
|---|
| 2789 | #if H_3D_IV_MERGE |
|---|
| 2790 | Bool ivMvPredFlag = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() ); |
|---|
| 2791 | |
|---|
| 2792 | //===== add merge with predicted depth maps ===== |
|---|
| 2793 | TComMv acPdmMv [4]; |
|---|
| 2794 | Int aiPdmRefIdx [4] = {-1, -1, -1, -1}; |
|---|
| 2795 | Bool bLeftAvai = false; |
|---|
| 2796 | Int iPosLeftAbove[2] = {-1, -1}; |
|---|
| 2797 | |
|---|
| 2798 | |
|---|
| 2799 | DisInfo cDisInfo; |
|---|
| 2800 | |
|---|
| 2801 | cDisInfo.bDV = getDvInfo(uiAbsPartIdx).bDV; |
|---|
| 2802 | #if H_3D_NBDV_REF |
|---|
| 2803 | cDisInfo.m_acDoNBDV = getDvInfo(uiAbsPartIdx).m_acDoNBDV; |
|---|
| 2804 | #endif //H_3D_NBDV_REF |
|---|
| 2805 | cDisInfo.m_acNBDV = getDvInfo(uiAbsPartIdx).m_acNBDV; |
|---|
| 2806 | cDisInfo.m_aVIdxCan = getDvInfo(uiAbsPartIdx).m_aVIdxCan; |
|---|
| 2807 | |
|---|
| 2808 | if( m_pcSlice->getIsDepth()) |
|---|
| 2809 | { |
|---|
| 2810 | UInt uiPartIdxCenter; |
|---|
| 2811 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
|---|
| 2812 | TComDataCU *pcTextureCU = m_pcSlice->getTexturePic()->getCU( getAddr() ); |
|---|
| 2813 | |
|---|
| 2814 | if ( pcTextureCU && !pcTextureCU->isIntra( uiPartIdxCenter ) ) |
|---|
| 2815 | { |
|---|
| 2816 | abCandIsInter[iCount] = true; |
|---|
| 2817 | puhInterDirNeighbours[iCount] = pcTextureCU->getInterDir( uiPartIdxCenter ); |
|---|
| 2818 | if( ( puhInterDirNeighbours[iCount] & 1 ) == 1 ) |
|---|
| 2819 | { |
|---|
| 2820 | pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 2821 | |
|---|
| 2822 | TComMv cMvPred = pcMvFieldNeighbours[iCount<<1].getMv(); |
|---|
| 2823 | |
|---|
| 2824 | #if H_3D_IC |
|---|
| 2825 | const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
|---|
| 2826 | cMvPred+=cAdd; |
|---|
| 2827 | cMvPred>>=2; |
|---|
| 2828 | clipMv(cMvPred); |
|---|
| 2829 | #endif |
|---|
| 2830 | //pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,pcMvFieldNeighbours[iCount<<1].getRefIdx()); |
|---|
| 2831 | #if H_3D_CLEANUPS //Notes from QC: for BVSP coded blocks, the reference index shall not be equal to -1 due to the adoption of JCT3V-D0191 |
|---|
| 2832 | pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,pcMvFieldNeighbours[iCount<<1].getRefIdx()); |
|---|
| 2833 | #else |
|---|
| 2834 | if (pcMvFieldNeighbours[iCount<<1].getRefIdx()<0) |
|---|
| 2835 | { |
|---|
| 2836 | for (Int i=0; i<getSlice()->getNumRefIdx(REF_PIC_LIST_0); i++) |
|---|
| 2837 | { |
|---|
| 2838 | if (getSlice()->getRefPOC(REF_PIC_LIST_0, i) == getSlice()->getPOC()) |
|---|
| 2839 | { |
|---|
| 2840 | pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,i); |
|---|
| 2841 | break; |
|---|
| 2842 | } |
|---|
| 2843 | } |
|---|
| 2844 | } |
|---|
| 2845 | #endif |
|---|
| 2846 | } |
|---|
| 2847 | |
|---|
| 2848 | if ( getSlice()->isInterB() ) |
|---|
| 2849 | { |
|---|
| 2850 | if( ( puhInterDirNeighbours[iCount] & 2 ) == 2 ) |
|---|
| 2851 | { |
|---|
| 2852 | pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 2853 | TComMv cMvPred = pcMvFieldNeighbours[(iCount<<1)+1].getMv(); |
|---|
| 2854 | |
|---|
| 2855 | #if H_3D_IC |
|---|
| 2856 | const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
|---|
| 2857 | cMvPred+=cAdd; |
|---|
| 2858 | cMvPred>>=2; |
|---|
| 2859 | clipMv(cMvPred); |
|---|
| 2860 | #endif |
|---|
| 2861 | //pcMvFieldNeighbours[(iCount<<1)+1].setMvField(cMvPred,pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()); |
|---|
| 2862 | #if H_3D_CLEANUPS |
|---|
| 2863 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField(cMvPred,pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()); |
|---|
| 2864 | #else |
|---|
| 2865 | if (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()<0) |
|---|
| 2866 | { |
|---|
| 2867 | for (Int i=0; i<getSlice()->getNumRefIdx(REF_PIC_LIST_1); i++) |
|---|
| 2868 | { |
|---|
| 2869 | if (getSlice()->getRefPOC(REF_PIC_LIST_1, i) == getSlice()->getPOC()) |
|---|
| 2870 | { |
|---|
| 2871 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField(cMvPred,i); |
|---|
| 2872 | break; |
|---|
| 2873 | } |
|---|
| 2874 | } |
|---|
| 2875 | } |
|---|
| 2876 | #endif |
|---|
| 2877 | } |
|---|
| 2878 | } |
|---|
| 2879 | #if !H_3D_CLEANUPS |
|---|
| 2880 | if (!((pcMvFieldNeighbours[iCount<<1].getRefIdx()<0 && !getSlice()->isInterB()) |
|---|
| 2881 | || (pcMvFieldNeighbours[iCount<<1].getRefIdx()<0 && pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()<0 && getSlice()->isInterB()))) |
|---|
| 2882 | { |
|---|
| 2883 | #endif |
|---|
| 2884 | #if H_3D_NBDV |
|---|
| 2885 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 2886 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 2887 | #endif |
|---|
| 2888 | if ( mrgCandIdx == iCount ) |
|---|
| 2889 | { |
|---|
| 2890 | return; |
|---|
| 2891 | } |
|---|
| 2892 | iCount ++; |
|---|
| 2893 | #if !H_3D_CLEANUPS |
|---|
| 2894 | } |
|---|
| 2895 | else |
|---|
| 2896 | { |
|---|
| 2897 | assert(0); |
|---|
| 2898 | } |
|---|
| 2899 | #endif |
|---|
| 2900 | } |
|---|
| 2901 | } |
|---|
| 2902 | |
|---|
| 2903 | Int iPdmDir[2] = {0, 0}; |
|---|
| 2904 | |
|---|
| 2905 | if ( ivMvPredFlag ) |
|---|
| 2906 | { |
|---|
| 2907 | getInterViewMergeCands(uiPUIdx, aiPdmRefIdx, acPdmMv, &cDisInfo, iPdmDir ); |
|---|
| 2908 | } |
|---|
| 2909 | |
|---|
| 2910 | Int iPdmInterDir; |
|---|
| 2911 | #if H_3D_CLEANUPS |
|---|
| 2912 | if( iPdmDir[0] ) |
|---|
| 2913 | #else |
|---|
| 2914 | if( iPdmDir[0] && ivMvPredFlag ) |
|---|
| 2915 | #endif |
|---|
| 2916 | { |
|---|
| 2917 | abCandIsInter [ iCount ] = true; |
|---|
| 2918 | puhInterDirNeighbours[ iCount ] = iPdmDir[0]; |
|---|
| 2919 | iPdmInterDir = iPdmDir[0]; |
|---|
| 2920 | |
|---|
| 2921 | if( ( iPdmInterDir & 1 ) == 1 ) |
|---|
| 2922 | { |
|---|
| 2923 | pcMvFieldNeighbours[ iCount<<1 ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] ); |
|---|
| 2924 | } |
|---|
| 2925 | if( ( iPdmInterDir & 2 ) == 2 ) |
|---|
| 2926 | { |
|---|
| 2927 | pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 1 ], aiPdmRefIdx[ 1 ] ); |
|---|
| 2928 | } |
|---|
| 2929 | |
|---|
| 2930 | if ( mrgCandIdx == iCount ) |
|---|
| 2931 | { |
|---|
| 2932 | return; |
|---|
| 2933 | } |
|---|
| 2934 | iCount ++; |
|---|
| 2935 | } |
|---|
| 2936 | #if H_3D_CLEANUPS |
|---|
| 2937 | // early termination |
|---|
| 2938 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 2939 | { |
|---|
| 2940 | return; |
|---|
| 2941 | } |
|---|
| 2942 | #endif |
|---|
| 2943 | #endif |
|---|
| 2944 | |
|---|
| 2945 | #if !H_3D_IV_MERGE |
|---|
| 2946 | #if H_3D_NBDV //Notes from QC: DvMCP related variables. |
|---|
| 2947 | //acPdmMv[0].m_bDvMcp = acPdmMv[1].m_bDvMcp = acPdmMv[2].m_bDvMcp = acPdmMv[3].m_bDvMcp = false; |
|---|
| 2948 | #endif |
|---|
| 2949 | |
|---|
| 2950 | #if H_3D_NBDV //Notes from QC: Some examples to show how to use the NBDV and DoNBDV variables. Remove this comment once it is done |
|---|
| 2951 | DisInfo cDisInfo; |
|---|
| 2952 | cDisInfo.bDV = false; |
|---|
| 2953 | //if(!bNoPdmMerge) |
|---|
| 2954 | //{ |
|---|
| 2955 | //cDisInfo.bDV = getDvInfo(uiAbsPartIdx).bDV; |
|---|
| 2956 | //cDisInfo.m_aVIdxCan = getDvInfo(uiAbsPartIdx).m_aVIdxCan; |
|---|
| 2957 | //cDisInfo.m_acNBDV = getDvInfo(uiAbsPartIdx).m_acNBDV; |
|---|
| 2958 | //#if H_3D_NBDV_REF |
|---|
| 2959 | //cDisInfo.m_acDoNBDV = getDvInfo(uiAbsPartIdx).m_acDoNBDV; |
|---|
| 2960 | //#endif |
|---|
| 2961 | //} |
|---|
| 2962 | #endif |
|---|
| 2963 | #endif |
|---|
| 2964 | //left |
|---|
| 2965 | UInt uiLeftPartIdx = 0; |
|---|
| 2966 | TComDataCU* pcCULeft = 0; |
|---|
| 2967 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
|---|
| 2968 | Bool isAvailableA1 = pcCULeft && |
|---|
| 2969 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
|---|
| 2970 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
|---|
| 2971 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
|---|
| 2972 | if ( isAvailableA1 ) |
|---|
| 2973 | { |
|---|
| 2974 | abCandIsInter[iCount] = true; |
|---|
| 2975 | // get Inter Dir |
|---|
| 2976 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
|---|
| 2977 | // get Mv from Left |
|---|
| 2978 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 2979 | if ( getSlice()->isInterB() ) |
|---|
| 2980 | { |
|---|
| 2981 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 2982 | } |
|---|
| 2983 | #if H_3D_IV_MERGE |
|---|
| 2984 | Bool bRemoveSpa = false; //pruning to inter-view candidates |
|---|
| 2985 | Int iCnloop = iCount - 1; |
|---|
| 2986 | for(; iCnloop >= 0; iCnloop --) |
|---|
| 2987 | { |
|---|
| 2988 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
|---|
| 2989 | { |
|---|
| 2990 | bRemoveSpa = true; |
|---|
| 2991 | abCandIsInter [ iCount ] = false; |
|---|
| 2992 | |
|---|
| 2993 | //reset to the default value for MC |
|---|
| 2994 | puhInterDirNeighbours[iCount] = 0; |
|---|
| 2995 | pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 2996 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 2997 | break; |
|---|
| 2998 | } |
|---|
| 2999 | } |
|---|
| 3000 | if(!bRemoveSpa) |
|---|
| 3001 | { |
|---|
| 3002 | bLeftAvai = true; |
|---|
| 3003 | iPosLeftAbove[0] = iCount; |
|---|
| 3004 | #if H_3D_NBDV |
|---|
| 3005 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3006 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3007 | #endif |
|---|
| 3008 | #if H_3D_VSP |
|---|
| 3009 | if (pcCULeft->getVSPFlag(uiLeftPartIdx) == 1) |
|---|
| 3010 | vspFlag[iCount] = 1; |
|---|
| 3011 | #endif |
|---|
| 3012 | if ( mrgCandIdx == iCount ) |
|---|
| 3013 | { |
|---|
| 3014 | return; |
|---|
| 3015 | } |
|---|
| 3016 | iCount ++; |
|---|
| 3017 | } |
|---|
| 3018 | #else |
|---|
| 3019 | if ( mrgCandIdx == iCount ) |
|---|
| 3020 | { |
|---|
| 3021 | return; |
|---|
| 3022 | } |
|---|
| 3023 | iCount ++; |
|---|
| 3024 | #endif |
|---|
| 3025 | } |
|---|
| 3026 | |
|---|
| 3027 | // early termination |
|---|
| 3028 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3029 | { |
|---|
| 3030 | return; |
|---|
| 3031 | } |
|---|
| 3032 | // above |
|---|
| 3033 | UInt uiAbovePartIdx = 0; |
|---|
| 3034 | TComDataCU* pcCUAbove = 0; |
|---|
| 3035 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
|---|
| 3036 | Bool isAvailableB1 = pcCUAbove && |
|---|
| 3037 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
|---|
| 3038 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
|---|
| 3039 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
|---|
| 3040 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
|---|
| 3041 | { |
|---|
| 3042 | abCandIsInter[iCount] = true; |
|---|
| 3043 | // get Inter Dir |
|---|
| 3044 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
|---|
| 3045 | // get Mv from Left |
|---|
| 3046 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 3047 | if ( getSlice()->isInterB() ) |
|---|
| 3048 | { |
|---|
| 3049 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 3050 | } |
|---|
| 3051 | #if H_3D_IV_MERGE |
|---|
| 3052 | Bool bRemoveSpa = false; //pruning to inter-view candidates |
|---|
| 3053 | Int iCnloop = bLeftAvai? (iCount-2): (iCount-1); |
|---|
| 3054 | for(; iCnloop >= 0; iCnloop --) |
|---|
| 3055 | { |
|---|
| 3056 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
|---|
| 3057 | { |
|---|
| 3058 | bRemoveSpa = true; |
|---|
| 3059 | abCandIsInter [ iCount ] = false; |
|---|
| 3060 | |
|---|
| 3061 | //reset to the default value for MC |
|---|
| 3062 | puhInterDirNeighbours[iCount] = 0; |
|---|
| 3063 | |
|---|
| 3064 | pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3065 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3066 | break; |
|---|
| 3067 | } |
|---|
| 3068 | } |
|---|
| 3069 | if(!bRemoveSpa) |
|---|
| 3070 | { |
|---|
| 3071 | iPosLeftAbove[1] = iCount; |
|---|
| 3072 | #if H_3D_NBDV |
|---|
| 3073 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3074 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3075 | #endif |
|---|
| 3076 | #if H_3D_VSP |
|---|
| 3077 | if (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1) |
|---|
| 3078 | vspFlag[iCount] = 1; |
|---|
| 3079 | #endif |
|---|
| 3080 | if ( mrgCandIdx == iCount ) |
|---|
| 3081 | { |
|---|
| 3082 | return; |
|---|
| 3083 | } |
|---|
| 3084 | iCount ++; |
|---|
| 3085 | } |
|---|
| 3086 | #else |
|---|
| 3087 | if ( mrgCandIdx == iCount ) |
|---|
| 3088 | { |
|---|
| 3089 | return; |
|---|
| 3090 | } |
|---|
| 3091 | iCount ++; |
|---|
| 3092 | #endif |
|---|
| 3093 | } |
|---|
| 3094 | // early termination |
|---|
| 3095 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3096 | { |
|---|
| 3097 | return; |
|---|
| 3098 | } |
|---|
| 3099 | |
|---|
| 3100 | // above right |
|---|
| 3101 | UInt uiAboveRightPartIdx = 0; |
|---|
| 3102 | TComDataCU* pcCUAboveRight = 0; |
|---|
| 3103 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
|---|
| 3104 | Bool isAvailableB0 = pcCUAboveRight && |
|---|
| 3105 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
|---|
| 3106 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
|---|
| 3107 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
|---|
| 3108 | { |
|---|
| 3109 | abCandIsInter[iCount] = true; |
|---|
| 3110 | // get Inter Dir |
|---|
| 3111 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
|---|
| 3112 | // get Mv from Left |
|---|
| 3113 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 3114 | if ( getSlice()->isInterB() ) |
|---|
| 3115 | { |
|---|
| 3116 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 3117 | } |
|---|
| 3118 | #if H_3D_NBDV |
|---|
| 3119 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3120 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3121 | #endif |
|---|
| 3122 | #if H_3D_VSP |
|---|
| 3123 | if (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1) |
|---|
| 3124 | vspFlag[iCount] = 1; |
|---|
| 3125 | #endif |
|---|
| 3126 | if ( mrgCandIdx == iCount ) |
|---|
| 3127 | { |
|---|
| 3128 | return; |
|---|
| 3129 | } |
|---|
| 3130 | iCount ++; |
|---|
| 3131 | } |
|---|
| 3132 | // early termination |
|---|
| 3133 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3134 | { |
|---|
| 3135 | return; |
|---|
| 3136 | } |
|---|
| 3137 | |
|---|
| 3138 | #if H_3D_IV_MERGE |
|---|
| 3139 | #if H_3D_CLEANUPS |
|---|
| 3140 | if( iPdmDir[1] ) |
|---|
| 3141 | #else |
|---|
| 3142 | if(ivMvPredFlag && iPdmDir[1] ) |
|---|
| 3143 | #endif |
|---|
| 3144 | { |
|---|
| 3145 | assert(iCount < getSlice()->getMaxNumMergeCand()); |
|---|
| 3146 | abCandIsInter [ iCount ] = true; |
|---|
| 3147 | puhInterDirNeighbours[ iCount ] = iPdmDir[1]; |
|---|
| 3148 | if( ( iPdmDir[1] & 1 ) == 1 ) |
|---|
| 3149 | { |
|---|
| 3150 | pcMvFieldNeighbours[ iCount<<1 ].setMvField( acPdmMv[ 2 ], aiPdmRefIdx[ 2 ] ); |
|---|
| 3151 | } |
|---|
| 3152 | if( ( iPdmDir[1] & 2 ) == 2 ) |
|---|
| 3153 | { |
|---|
| 3154 | pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 3 ], aiPdmRefIdx[ 3 ] ); |
|---|
| 3155 | } |
|---|
| 3156 | |
|---|
| 3157 | Bool bRemoveSpa = false; //pruning to A1, B1 |
|---|
| 3158 | for(Int i = 0; i < 2; i ++) |
|---|
| 3159 | { |
|---|
| 3160 | Int iCnloop = iPosLeftAbove[i]; |
|---|
| 3161 | if(iCnloop == -1) |
|---|
| 3162 | continue; |
|---|
| 3163 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
|---|
| 3164 | { |
|---|
| 3165 | bRemoveSpa = true; |
|---|
| 3166 | abCandIsInter [ iCount ] = false; |
|---|
| 3167 | //reset to the default value for MC |
|---|
| 3168 | puhInterDirNeighbours[iCount] = 0; |
|---|
| 3169 | pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3170 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3171 | break; |
|---|
| 3172 | } |
|---|
| 3173 | } |
|---|
| 3174 | if(!bRemoveSpa) |
|---|
| 3175 | { |
|---|
| 3176 | #if H_3D_NBDV |
|---|
| 3177 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3178 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3179 | #endif |
|---|
| 3180 | if ( mrgCandIdx == iCount ) |
|---|
| 3181 | return; |
|---|
| 3182 | iCount ++; |
|---|
| 3183 | |
|---|
| 3184 | // early termination |
|---|
| 3185 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3186 | { |
|---|
| 3187 | return; |
|---|
| 3188 | } |
|---|
| 3189 | } |
|---|
| 3190 | } |
|---|
| 3191 | #endif |
|---|
| 3192 | |
|---|
| 3193 | #if H_3D_VSP |
|---|
| 3194 | if ( xAddVspCand( 3, mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag ) ) |
|---|
| 3195 | return; |
|---|
| 3196 | // early termination |
|---|
| 3197 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3198 | return; |
|---|
| 3199 | #endif |
|---|
| 3200 | |
|---|
| 3201 | //left bottom |
|---|
| 3202 | UInt uiLeftBottomPartIdx = 0; |
|---|
| 3203 | TComDataCU* pcCULeftBottom = 0; |
|---|
| 3204 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
|---|
| 3205 | Bool isAvailableA0 = pcCULeftBottom && |
|---|
| 3206 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
|---|
| 3207 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
|---|
| 3208 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
|---|
| 3209 | { |
|---|
| 3210 | abCandIsInter[iCount] = true; |
|---|
| 3211 | // get Inter Dir |
|---|
| 3212 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
|---|
| 3213 | // get Mv from Left |
|---|
| 3214 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 3215 | if ( getSlice()->isInterB() ) |
|---|
| 3216 | { |
|---|
| 3217 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 3218 | } |
|---|
| 3219 | #if H_3D_NBDV |
|---|
| 3220 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3221 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3222 | #endif |
|---|
| 3223 | #if H_3D_VSP |
|---|
| 3224 | if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) == 1) |
|---|
| 3225 | vspFlag[iCount] = 1; |
|---|
| 3226 | #endif |
|---|
| 3227 | if ( mrgCandIdx == iCount ) |
|---|
| 3228 | { |
|---|
| 3229 | return; |
|---|
| 3230 | } |
|---|
| 3231 | iCount ++; |
|---|
| 3232 | } |
|---|
| 3233 | // early termination |
|---|
| 3234 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3235 | { |
|---|
| 3236 | return; |
|---|
| 3237 | } |
|---|
| 3238 | // above left |
|---|
| 3239 | if( iCount < 4 ) |
|---|
| 3240 | { |
|---|
| 3241 | UInt uiAboveLeftPartIdx = 0; |
|---|
| 3242 | TComDataCU* pcCUAboveLeft = 0; |
|---|
| 3243 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
|---|
| 3244 | Bool isAvailableB2 = pcCUAboveLeft && |
|---|
| 3245 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
|---|
| 3246 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
|---|
| 3247 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
|---|
| 3248 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
|---|
| 3249 | { |
|---|
| 3250 | abCandIsInter[iCount] = true; |
|---|
| 3251 | // get Inter Dir |
|---|
| 3252 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
|---|
| 3253 | // get Mv from Left |
|---|
| 3254 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 3255 | if ( getSlice()->isInterB() ) |
|---|
| 3256 | { |
|---|
| 3257 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 3258 | } |
|---|
| 3259 | #if H_3D_NBDV |
|---|
| 3260 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3261 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3262 | #endif |
|---|
| 3263 | #if H_3D_VSP |
|---|
| 3264 | if (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1) |
|---|
| 3265 | vspFlag[iCount] = 1; |
|---|
| 3266 | #endif |
|---|
| 3267 | if ( mrgCandIdx == iCount ) |
|---|
| 3268 | { |
|---|
| 3269 | return; |
|---|
| 3270 | } |
|---|
| 3271 | iCount ++; |
|---|
| 3272 | } |
|---|
| 3273 | } |
|---|
| 3274 | // early termination |
|---|
| 3275 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3276 | { |
|---|
| 3277 | return; |
|---|
| 3278 | } |
|---|
| 3279 | if ( getSlice()->getEnableTMVPFlag()) |
|---|
| 3280 | { |
|---|
| 3281 | //>> MTK colocated-RightBottom |
|---|
| 3282 | UInt uiPartIdxRB; |
|---|
| 3283 | Int uiLCUIdx = getAddr(); |
|---|
| 3284 | |
|---|
| 3285 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
|---|
| 3286 | |
|---|
| 3287 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
|---|
| 3288 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 3289 | |
|---|
| 3290 | TComMv cColMv; |
|---|
| 3291 | Int iRefIdx; |
|---|
| 3292 | |
|---|
| 3293 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
|---|
| 3294 | { |
|---|
| 3295 | uiLCUIdx = -1; |
|---|
| 3296 | } |
|---|
| 3297 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
|---|
| 3298 | { |
|---|
| 3299 | uiLCUIdx = -1; |
|---|
| 3300 | } |
|---|
| 3301 | else |
|---|
| 3302 | { |
|---|
| 3303 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
|---|
| 3304 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
|---|
| 3305 | { |
|---|
| 3306 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
|---|
| 3307 | uiLCUIdx = getAddr(); |
|---|
| 3308 | } |
|---|
| 3309 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
|---|
| 3310 | { |
|---|
| 3311 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
|---|
| 3312 | uiLCUIdx = -1 ; |
|---|
| 3313 | } |
|---|
| 3314 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
|---|
| 3315 | { |
|---|
| 3316 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
|---|
| 3317 | uiLCUIdx = getAddr() + 1; |
|---|
| 3318 | } |
|---|
| 3319 | else //is the right bottom corner of LCU |
|---|
| 3320 | { |
|---|
| 3321 | uiAbsPartAddr = 0; |
|---|
| 3322 | uiLCUIdx = -1 ; |
|---|
| 3323 | } |
|---|
| 3324 | } |
|---|
| 3325 | |
|---|
| 3326 | |
|---|
| 3327 | iRefIdx = 0; |
|---|
| 3328 | Bool bExistMV = false; |
|---|
| 3329 | UInt uiPartIdxCenter; |
|---|
| 3330 | UInt uiCurLCUIdx = getAddr(); |
|---|
| 3331 | Int dir = 0; |
|---|
| 3332 | UInt uiArrayAddr = iCount; |
|---|
| 3333 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
|---|
| 3334 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
|---|
| 3335 | if( bExistMV == false ) |
|---|
| 3336 | { |
|---|
| 3337 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
|---|
| 3338 | } |
|---|
| 3339 | if( bExistMV ) |
|---|
| 3340 | { |
|---|
| 3341 | dir |= 1; |
|---|
| 3342 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
|---|
| 3343 | } |
|---|
| 3344 | |
|---|
| 3345 | if ( getSlice()->isInterB() ) |
|---|
| 3346 | { |
|---|
| 3347 | #if H_3D_TMVP |
|---|
| 3348 | iRefIdx = 0; |
|---|
| 3349 | #endif |
|---|
| 3350 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
|---|
| 3351 | if( bExistMV == false ) |
|---|
| 3352 | { |
|---|
| 3353 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
|---|
| 3354 | } |
|---|
| 3355 | if( bExistMV ) |
|---|
| 3356 | { |
|---|
| 3357 | dir |= 2; |
|---|
| 3358 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
|---|
| 3359 | } |
|---|
| 3360 | } |
|---|
| 3361 | |
|---|
| 3362 | if (dir != 0) |
|---|
| 3363 | { |
|---|
| 3364 | puhInterDirNeighbours[uiArrayAddr] = dir; |
|---|
| 3365 | abCandIsInter[uiArrayAddr] = true; |
|---|
| 3366 | #if H_3D_NBDV |
|---|
| 3367 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3368 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3369 | #endif |
|---|
| 3370 | if ( mrgCandIdx == iCount ) |
|---|
| 3371 | { |
|---|
| 3372 | return; |
|---|
| 3373 | } |
|---|
| 3374 | iCount++; |
|---|
| 3375 | } |
|---|
| 3376 | } |
|---|
| 3377 | // early termination |
|---|
| 3378 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3379 | { |
|---|
| 3380 | return; |
|---|
| 3381 | } |
|---|
| 3382 | UInt uiArrayAddr = iCount; |
|---|
| 3383 | UInt uiCutoff = uiArrayAddr; |
|---|
| 3384 | |
|---|
| 3385 | if ( getSlice()->isInterB()) |
|---|
| 3386 | { |
|---|
| 3387 | #if H_3D_IV_MERGE |
|---|
| 3388 | UInt uiPriorityList0[20] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4, 2, 4, 3, 4 }; |
|---|
| 3389 | UInt uiPriorityList1[20] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2, 4, 0, 4, 1, 4, 2, 4, 3 }; |
|---|
| 3390 | #else |
|---|
| 3391 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
|---|
| 3392 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
|---|
| 3393 | #endif |
|---|
| 3394 | |
|---|
| 3395 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
|---|
| 3396 | { |
|---|
| 3397 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
|---|
| 3398 | #if H_3D_VSP |
|---|
| 3399 | Bool bValid = true; |
|---|
| 3400 | if ( vspFlag[i] == 1 || vspFlag[j] == 1 ) |
|---|
| 3401 | bValid = false; |
|---|
| 3402 | if( !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) ) |
|---|
| 3403 | assert(bValid == true); |
|---|
| 3404 | #endif |
|---|
| 3405 | #if H_3D_VSP |
|---|
| 3406 | if (abCandIsInter[i] && abCandIsInter[j] && (puhInterDirNeighbours[i]&0x1) && (puhInterDirNeighbours[j]&0x2) && bValid) |
|---|
| 3407 | #else |
|---|
| 3408 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
|---|
| 3409 | #endif |
|---|
| 3410 | { |
|---|
| 3411 | abCandIsInter[uiArrayAddr] = true; |
|---|
| 3412 | puhInterDirNeighbours[uiArrayAddr] = 3; |
|---|
| 3413 | |
|---|
| 3414 | // get Mv from cand[i] and cand[j] |
|---|
| 3415 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
|---|
| 3416 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
|---|
| 3417 | |
|---|
| 3418 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
|---|
| 3419 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
|---|
| 3420 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
|---|
| 3421 | { |
|---|
| 3422 | abCandIsInter[uiArrayAddr] = false; |
|---|
| 3423 | } |
|---|
| 3424 | else |
|---|
| 3425 | { |
|---|
| 3426 | uiArrayAddr++; |
|---|
| 3427 | } |
|---|
| 3428 | } |
|---|
| 3429 | } |
|---|
| 3430 | } |
|---|
| 3431 | // early termination |
|---|
| 3432 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
|---|
| 3433 | { |
|---|
| 3434 | return; |
|---|
| 3435 | } |
|---|
| 3436 | Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
|---|
| 3437 | Int r = 0; |
|---|
| 3438 | Int refcnt = 0; |
|---|
| 3439 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
|---|
| 3440 | { |
|---|
| 3441 | abCandIsInter[uiArrayAddr] = true; |
|---|
| 3442 | puhInterDirNeighbours[uiArrayAddr] = 1; |
|---|
| 3443 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
|---|
| 3444 | |
|---|
| 3445 | if ( getSlice()->isInterB() ) |
|---|
| 3446 | { |
|---|
| 3447 | puhInterDirNeighbours[uiArrayAddr] = 3; |
|---|
| 3448 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
|---|
| 3449 | } |
|---|
| 3450 | uiArrayAddr++; |
|---|
| 3451 | if ( refcnt == iNumRefIdx - 1 ) |
|---|
| 3452 | { |
|---|
| 3453 | r = 0; |
|---|
| 3454 | } |
|---|
| 3455 | else |
|---|
| 3456 | { |
|---|
| 3457 | ++r; |
|---|
| 3458 | ++refcnt; |
|---|
| 3459 | } |
|---|
| 3460 | } |
|---|
| 3461 | |
|---|
| 3462 | numValidMergeCand = uiArrayAddr; |
|---|
| 3463 | } |
|---|
| 3464 | |
|---|
| 3465 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
|---|
| 3466 | * \param xN, xN location of the upper-left corner pixel of a neighboring PU |
|---|
| 3467 | * \param xP, yP location of the upper-left corner pixel of the current PU |
|---|
| 3468 | * \returns Bool |
|---|
| 3469 | */ |
|---|
| 3470 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
|---|
| 3471 | { |
|---|
| 3472 | |
|---|
| 3473 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
|---|
| 3474 | if ((xN>>plevel)!= (xP>>plevel)) |
|---|
| 3475 | { |
|---|
| 3476 | return true; |
|---|
| 3477 | } |
|---|
| 3478 | if ((yN>>plevel)!= (yP>>plevel)) |
|---|
| 3479 | { |
|---|
| 3480 | return true; |
|---|
| 3481 | } |
|---|
| 3482 | return false; |
|---|
| 3483 | } |
|---|
| 3484 | /** calculate the location of upper-left corner pixel and size of the current PU. |
|---|
| 3485 | * \param partIdx PU index within a CU |
|---|
| 3486 | * \param xP, yP location of the upper-left corner pixel of the current PU |
|---|
| 3487 | * \param PSW, nPSH size of the curren PU |
|---|
| 3488 | * \returns Void |
|---|
| 3489 | */ |
|---|
| 3490 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
|---|
| 3491 | { |
|---|
| 3492 | UInt col = m_uiCUPelX; |
|---|
| 3493 | UInt row = m_uiCUPelY; |
|---|
| 3494 | |
|---|
| 3495 | switch ( m_pePartSize[0] ) |
|---|
| 3496 | { |
|---|
| 3497 | case SIZE_2NxN: |
|---|
| 3498 | nPSW = getWidth(0); |
|---|
| 3499 | nPSH = getHeight(0) >> 1; |
|---|
| 3500 | xP = col; |
|---|
| 3501 | yP = (partIdx ==0)? row: row + nPSH; |
|---|
| 3502 | break; |
|---|
| 3503 | case SIZE_Nx2N: |
|---|
| 3504 | nPSW = getWidth(0) >> 1; |
|---|
| 3505 | nPSH = getHeight(0); |
|---|
| 3506 | xP = (partIdx ==0)? col: col + nPSW; |
|---|
| 3507 | yP = row; |
|---|
| 3508 | break; |
|---|
| 3509 | case SIZE_NxN: |
|---|
| 3510 | nPSW = getWidth(0) >> 1; |
|---|
| 3511 | nPSH = getHeight(0) >> 1; |
|---|
| 3512 | xP = col + (partIdx&0x1)*nPSW; |
|---|
| 3513 | yP = row + (partIdx>>1)*nPSH; |
|---|
| 3514 | break; |
|---|
| 3515 | case SIZE_2NxnU: |
|---|
| 3516 | nPSW = getWidth(0); |
|---|
| 3517 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
|---|
| 3518 | xP = col; |
|---|
| 3519 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
|---|
| 3520 | |
|---|
| 3521 | break; |
|---|
| 3522 | case SIZE_2NxnD: |
|---|
| 3523 | nPSW = getWidth(0); |
|---|
| 3524 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
|---|
| 3525 | xP = col; |
|---|
| 3526 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
|---|
| 3527 | break; |
|---|
| 3528 | case SIZE_nLx2N: |
|---|
| 3529 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
|---|
| 3530 | nPSH = getHeight(0); |
|---|
| 3531 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
|---|
| 3532 | yP = row; |
|---|
| 3533 | break; |
|---|
| 3534 | case SIZE_nRx2N: |
|---|
| 3535 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
|---|
| 3536 | nPSH = getHeight(0); |
|---|
| 3537 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
|---|
| 3538 | yP = row; |
|---|
| 3539 | break; |
|---|
| 3540 | default: |
|---|
| 3541 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
|---|
| 3542 | nPSW = getWidth(0); |
|---|
| 3543 | nPSH = getHeight(0); |
|---|
| 3544 | xP = col ; |
|---|
| 3545 | yP = row ; |
|---|
| 3546 | |
|---|
| 3547 | break; |
|---|
| 3548 | } |
|---|
| 3549 | } |
|---|
| 3550 | |
|---|
| 3551 | /** Constructs a list of candidates for AMVP |
|---|
| 3552 | * \param uiPartIdx |
|---|
| 3553 | * \param uiPartAddr |
|---|
| 3554 | * \param eRefPicList |
|---|
| 3555 | * \param iRefIdx |
|---|
| 3556 | * \param pInfo |
|---|
| 3557 | */ |
|---|
| 3558 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
|---|
| 3559 | { |
|---|
| 3560 | TComMv cMvPred; |
|---|
| 3561 | Bool bAddedSmvp = false; |
|---|
| 3562 | |
|---|
| 3563 | pInfo->iN = 0; |
|---|
| 3564 | if (iRefIdx < 0) |
|---|
| 3565 | { |
|---|
| 3566 | return; |
|---|
| 3567 | } |
|---|
| 3568 | |
|---|
| 3569 | //-- Get Spatial MV |
|---|
| 3570 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
|---|
| 3571 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 3572 | Bool bAdded = false; |
|---|
| 3573 | |
|---|
| 3574 | deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
|---|
| 3575 | deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); |
|---|
| 3576 | |
|---|
| 3577 | TComDataCU* tmpCU = NULL; |
|---|
| 3578 | UInt idx; |
|---|
| 3579 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB); |
|---|
| 3580 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
|---|
| 3581 | |
|---|
| 3582 | if (!bAddedSmvp) |
|---|
| 3583 | { |
|---|
| 3584 | tmpCU = getPULeft(idx, uiPartIdxLB); |
|---|
| 3585 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
|---|
| 3586 | } |
|---|
| 3587 | |
|---|
| 3588 | // Left predictor search |
|---|
| 3589 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
|---|
| 3590 | if (!bAdded) |
|---|
| 3591 | { |
|---|
| 3592 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
|---|
| 3593 | } |
|---|
| 3594 | |
|---|
| 3595 | if(!bAdded) |
|---|
| 3596 | { |
|---|
| 3597 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
|---|
| 3598 | if (!bAdded) |
|---|
| 3599 | { |
|---|
| 3600 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
|---|
| 3601 | } |
|---|
| 3602 | } |
|---|
| 3603 | // Above predictor search |
|---|
| 3604 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
|---|
| 3605 | |
|---|
| 3606 | if (!bAdded) |
|---|
| 3607 | { |
|---|
| 3608 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
|---|
| 3609 | } |
|---|
| 3610 | |
|---|
| 3611 | if(!bAdded) |
|---|
| 3612 | { |
|---|
| 3613 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
|---|
| 3614 | } |
|---|
| 3615 | bAdded = bAddedSmvp; |
|---|
| 3616 | if (pInfo->iN==2) bAdded = true; |
|---|
| 3617 | |
|---|
| 3618 | if(!bAdded) |
|---|
| 3619 | { |
|---|
| 3620 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
|---|
| 3621 | if (!bAdded) |
|---|
| 3622 | { |
|---|
| 3623 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
|---|
| 3624 | } |
|---|
| 3625 | |
|---|
| 3626 | if(!bAdded) |
|---|
| 3627 | { |
|---|
| 3628 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
|---|
| 3629 | } |
|---|
| 3630 | } |
|---|
| 3631 | |
|---|
| 3632 | if ( pInfo->iN == 2 ) |
|---|
| 3633 | { |
|---|
| 3634 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
|---|
| 3635 | { |
|---|
| 3636 | pInfo->iN = 1; |
|---|
| 3637 | } |
|---|
| 3638 | } |
|---|
| 3639 | |
|---|
| 3640 | if ( getSlice()->getEnableTMVPFlag() ) |
|---|
| 3641 | { |
|---|
| 3642 | // Get Temporal Motion Predictor |
|---|
| 3643 | Int iRefIdx_Col = iRefIdx; |
|---|
| 3644 | TComMv cColMv; |
|---|
| 3645 | UInt uiPartIdxRB; |
|---|
| 3646 | UInt uiAbsPartIdx; |
|---|
| 3647 | UInt uiAbsPartAddr; |
|---|
| 3648 | Int uiLCUIdx = getAddr(); |
|---|
| 3649 | |
|---|
| 3650 | deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); |
|---|
| 3651 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
|---|
| 3652 | |
|---|
| 3653 | //---- co-located RightBottom Temporal Predictor (H) ---// |
|---|
| 3654 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
|---|
| 3655 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
|---|
| 3656 | { |
|---|
| 3657 | uiLCUIdx = -1; |
|---|
| 3658 | } |
|---|
| 3659 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
|---|
| 3660 | { |
|---|
| 3661 | uiLCUIdx = -1; |
|---|
| 3662 | } |
|---|
| 3663 | else |
|---|
| 3664 | { |
|---|
| 3665 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
|---|
| 3666 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
|---|
| 3667 | { |
|---|
| 3668 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
|---|
| 3669 | uiLCUIdx = getAddr(); |
|---|
| 3670 | } |
|---|
| 3671 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
|---|
| 3672 | { |
|---|
| 3673 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
|---|
| 3674 | uiLCUIdx = -1 ; |
|---|
| 3675 | } |
|---|
| 3676 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
|---|
| 3677 | { |
|---|
| 3678 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
|---|
| 3679 | uiLCUIdx = getAddr() + 1; |
|---|
| 3680 | } |
|---|
| 3681 | else //is the right bottom corner of LCU |
|---|
| 3682 | { |
|---|
| 3683 | uiAbsPartAddr = 0; |
|---|
| 3684 | uiLCUIdx = -1 ; |
|---|
| 3685 | } |
|---|
| 3686 | } |
|---|
| 3687 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col |
|---|
| 3688 | #if H_3D_TMVP |
|---|
| 3689 | , 0 |
|---|
| 3690 | #endif |
|---|
| 3691 | ) ) |
|---|
| 3692 | { |
|---|
| 3693 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
|---|
| 3694 | } |
|---|
| 3695 | else |
|---|
| 3696 | { |
|---|
| 3697 | UInt uiPartIdxCenter; |
|---|
| 3698 | UInt uiCurLCUIdx = getAddr(); |
|---|
| 3699 | xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); |
|---|
| 3700 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col |
|---|
| 3701 | #if H_3D_TMVP |
|---|
| 3702 | , 0 |
|---|
| 3703 | #endif |
|---|
| 3704 | )) |
|---|
| 3705 | { |
|---|
| 3706 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
|---|
| 3707 | } |
|---|
| 3708 | } |
|---|
| 3709 | //---- co-located RightBottom Temporal Predictor ---// |
|---|
| 3710 | } |
|---|
| 3711 | |
|---|
| 3712 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
|---|
| 3713 | { |
|---|
| 3714 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
|---|
| 3715 | } |
|---|
| 3716 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
|---|
| 3717 | { |
|---|
| 3718 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
|---|
| 3719 | pInfo->iN++; |
|---|
| 3720 | } |
|---|
| 3721 | return ; |
|---|
| 3722 | } |
|---|
| 3723 | |
|---|
| 3724 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
|---|
| 3725 | { |
|---|
| 3726 | Int width = 0; |
|---|
| 3727 | Int height = 0; |
|---|
| 3728 | UInt partAddr; |
|---|
| 3729 | |
|---|
| 3730 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
|---|
| 3731 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
|---|
| 3732 | { |
|---|
| 3733 | return true; |
|---|
| 3734 | } |
|---|
| 3735 | return false; |
|---|
| 3736 | } |
|---|
| 3737 | |
|---|
| 3738 | Void TComDataCU::clipMv (TComMv& rcMv) |
|---|
| 3739 | { |
|---|
| 3740 | Int iMvShift = 2; |
|---|
| 3741 | #if H_3D_IC |
|---|
| 3742 | if( getSlice()->getIsDepth() ) |
|---|
| 3743 | iMvShift = 0; |
|---|
| 3744 | #endif |
|---|
| 3745 | Int iOffset = 8; |
|---|
| 3746 | Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset - m_uiCUPelX - 1 ) << iMvShift; |
|---|
| 3747 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
|---|
| 3748 | |
|---|
| 3749 | Int iVerMax = ( m_pcSlice->getSPS()->getPicHeightInLumaSamples() + iOffset - m_uiCUPelY - 1 ) << iMvShift; |
|---|
| 3750 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
|---|
| 3751 | |
|---|
| 3752 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
|---|
| 3753 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
|---|
| 3754 | } |
|---|
| 3755 | |
|---|
| 3756 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
|---|
| 3757 | { |
|---|
| 3758 | UInt uiShift = ( (m_puhTrIdx[uiAbsPartIdx]==0) && (m_pePartSize[uiAbsPartIdx]==SIZE_NxN) ) ? m_puhTrIdx[uiAbsPartIdx]+1 : m_puhTrIdx[uiAbsPartIdx]; |
|---|
| 3759 | uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
|---|
| 3760 | |
|---|
| 3761 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
|---|
| 3762 | UInt uiCnt = 0; |
|---|
| 3763 | while( uiWidth ) |
|---|
| 3764 | { |
|---|
| 3765 | uiCnt++; |
|---|
| 3766 | uiWidth>>=1; |
|---|
| 3767 | } |
|---|
| 3768 | uiCnt-=2; |
|---|
| 3769 | return uiCnt > 6 ? 6 : uiCnt; |
|---|
| 3770 | } |
|---|
| 3771 | |
|---|
| 3772 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
|---|
| 3773 | { |
|---|
| 3774 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
|---|
| 3775 | } |
|---|
| 3776 | |
|---|
| 3777 | /** Set a I_PCM flag for all sub-partitions of a partition. |
|---|
| 3778 | * \param bIpcmFlag I_PCM flag |
|---|
| 3779 | * \param uiAbsPartIdx patition index |
|---|
| 3780 | * \param uiDepth CU depth |
|---|
| 3781 | * \returns Void |
|---|
| 3782 | */ |
|---|
| 3783 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
|---|
| 3784 | { |
|---|
| 3785 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 3786 | |
|---|
| 3787 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
|---|
| 3788 | } |
|---|
| 3789 | |
|---|
| 3790 | /** Test whether the current block is skipped |
|---|
| 3791 | * \param uiPartIdx Block index |
|---|
| 3792 | * \returns Flag indicating whether the block is skipped |
|---|
| 3793 | */ |
|---|
| 3794 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
|---|
| 3795 | { |
|---|
| 3796 | return ( getSkipFlag( uiPartIdx ) ); |
|---|
| 3797 | } |
|---|
| 3798 | |
|---|
| 3799 | // ==================================================================================================================== |
|---|
| 3800 | // Protected member functions |
|---|
| 3801 | // ==================================================================================================================== |
|---|
| 3802 | |
|---|
| 3803 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
|---|
| 3804 | { |
|---|
| 3805 | TComDataCU* pcTmpCU = NULL; |
|---|
| 3806 | UInt uiIdx; |
|---|
| 3807 | switch( eDir ) |
|---|
| 3808 | { |
|---|
| 3809 | case MD_LEFT: |
|---|
| 3810 | { |
|---|
| 3811 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
|---|
| 3812 | break; |
|---|
| 3813 | } |
|---|
| 3814 | case MD_ABOVE: |
|---|
| 3815 | { |
|---|
| 3816 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx ); |
|---|
| 3817 | break; |
|---|
| 3818 | } |
|---|
| 3819 | case MD_ABOVE_RIGHT: |
|---|
| 3820 | { |
|---|
| 3821 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
|---|
| 3822 | break; |
|---|
| 3823 | } |
|---|
| 3824 | case MD_BELOW_LEFT: |
|---|
| 3825 | { |
|---|
| 3826 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
|---|
| 3827 | break; |
|---|
| 3828 | } |
|---|
| 3829 | case MD_ABOVE_LEFT: |
|---|
| 3830 | { |
|---|
| 3831 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
|---|
| 3832 | break; |
|---|
| 3833 | } |
|---|
| 3834 | default: |
|---|
| 3835 | { |
|---|
| 3836 | break; |
|---|
| 3837 | } |
|---|
| 3838 | } |
|---|
| 3839 | |
|---|
| 3840 | if ( pcTmpCU == NULL ) |
|---|
| 3841 | { |
|---|
| 3842 | return false; |
|---|
| 3843 | } |
|---|
| 3844 | |
|---|
| 3845 | #if L0363_MVP_POC |
|---|
| 3846 | if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) |
|---|
| 3847 | #else |
|---|
| 3848 | if ( m_pcSlice->isEqualRef(eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx), iRefIdx) ) |
|---|
| 3849 | #endif |
|---|
| 3850 | { |
|---|
| 3851 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
|---|
| 3852 | |
|---|
| 3853 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
|---|
| 3854 | return true; |
|---|
| 3855 | } |
|---|
| 3856 | |
|---|
| 3857 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
|---|
| 3858 | if( eRefPicList == REF_PIC_LIST_0 ) |
|---|
| 3859 | { |
|---|
| 3860 | eRefPicList2nd = REF_PIC_LIST_1; |
|---|
| 3861 | } |
|---|
| 3862 | else if ( eRefPicList == REF_PIC_LIST_1) |
|---|
| 3863 | { |
|---|
| 3864 | eRefPicList2nd = REF_PIC_LIST_0; |
|---|
| 3865 | } |
|---|
| 3866 | |
|---|
| 3867 | |
|---|
| 3868 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
|---|
| 3869 | Int iNeibRefPOC; |
|---|
| 3870 | |
|---|
| 3871 | |
|---|
| 3872 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
|---|
| 3873 | { |
|---|
| 3874 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
|---|
| 3875 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
|---|
| 3876 | { |
|---|
| 3877 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
|---|
| 3878 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
|---|
| 3879 | return true; |
|---|
| 3880 | } |
|---|
| 3881 | } |
|---|
| 3882 | return false; |
|---|
| 3883 | } |
|---|
| 3884 | |
|---|
| 3885 | /** |
|---|
| 3886 | * \param pInfo |
|---|
| 3887 | * \param eRefPicList |
|---|
| 3888 | * \param iRefIdx |
|---|
| 3889 | * \param uiPartUnitIdx |
|---|
| 3890 | * \param eDir |
|---|
| 3891 | * \returns Bool |
|---|
| 3892 | */ |
|---|
| 3893 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
|---|
| 3894 | { |
|---|
| 3895 | TComDataCU* pcTmpCU = NULL; |
|---|
| 3896 | UInt uiIdx; |
|---|
| 3897 | switch( eDir ) |
|---|
| 3898 | { |
|---|
| 3899 | case MD_LEFT: |
|---|
| 3900 | { |
|---|
| 3901 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
|---|
| 3902 | break; |
|---|
| 3903 | } |
|---|
| 3904 | case MD_ABOVE: |
|---|
| 3905 | { |
|---|
| 3906 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
|---|
| 3907 | break; |
|---|
| 3908 | } |
|---|
| 3909 | case MD_ABOVE_RIGHT: |
|---|
| 3910 | { |
|---|
| 3911 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
|---|
| 3912 | break; |
|---|
| 3913 | } |
|---|
| 3914 | case MD_BELOW_LEFT: |
|---|
| 3915 | { |
|---|
| 3916 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
|---|
| 3917 | break; |
|---|
| 3918 | } |
|---|
| 3919 | case MD_ABOVE_LEFT: |
|---|
| 3920 | { |
|---|
| 3921 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
|---|
| 3922 | break; |
|---|
| 3923 | } |
|---|
| 3924 | default: |
|---|
| 3925 | { |
|---|
| 3926 | break; |
|---|
| 3927 | } |
|---|
| 3928 | } |
|---|
| 3929 | |
|---|
| 3930 | if ( pcTmpCU == NULL ) |
|---|
| 3931 | { |
|---|
| 3932 | return false; |
|---|
| 3933 | } |
|---|
| 3934 | |
|---|
| 3935 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
|---|
| 3936 | if( eRefPicList == REF_PIC_LIST_0 ) |
|---|
| 3937 | { |
|---|
| 3938 | eRefPicList2nd = REF_PIC_LIST_1; |
|---|
| 3939 | } |
|---|
| 3940 | else if ( eRefPicList == REF_PIC_LIST_1) |
|---|
| 3941 | { |
|---|
| 3942 | eRefPicList2nd = REF_PIC_LIST_0; |
|---|
| 3943 | } |
|---|
| 3944 | |
|---|
| 3945 | Int iCurrPOC = m_pcSlice->getPOC(); |
|---|
| 3946 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
|---|
| 3947 | Int iNeibPOC = iCurrPOC; |
|---|
| 3948 | Int iNeibRefPOC; |
|---|
| 3949 | |
|---|
| 3950 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
|---|
| 3951 | Bool bIsNeibRefLongTerm = false; |
|---|
| 3952 | //--------------- V1 (END) ------------------// |
|---|
| 3953 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
|---|
| 3954 | { |
|---|
| 3955 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
|---|
| 3956 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
|---|
| 3957 | TComMv rcMv; |
|---|
| 3958 | |
|---|
| 3959 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
|---|
| 3960 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
|---|
| 3961 | { |
|---|
| 3962 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
|---|
| 3963 | { |
|---|
| 3964 | rcMv = cMvPred; |
|---|
| 3965 | } |
|---|
| 3966 | else |
|---|
| 3967 | { |
|---|
| 3968 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
|---|
| 3969 | if ( iScale == 4096 ) |
|---|
| 3970 | { |
|---|
| 3971 | rcMv = cMvPred; |
|---|
| 3972 | } |
|---|
| 3973 | else |
|---|
| 3974 | { |
|---|
| 3975 | rcMv = cMvPred.scaleMv( iScale ); |
|---|
| 3976 | } |
|---|
| 3977 | } |
|---|
| 3978 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
|---|
| 3979 | return true; |
|---|
| 3980 | } |
|---|
| 3981 | } |
|---|
| 3982 | //---------------------- V2(END) --------------------// |
|---|
| 3983 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
|---|
| 3984 | { |
|---|
| 3985 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
|---|
| 3986 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
|---|
| 3987 | TComMv rcMv; |
|---|
| 3988 | |
|---|
| 3989 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); |
|---|
| 3990 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
|---|
| 3991 | { |
|---|
| 3992 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
|---|
| 3993 | { |
|---|
| 3994 | rcMv = cMvPred; |
|---|
| 3995 | } |
|---|
| 3996 | else |
|---|
| 3997 | { |
|---|
| 3998 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
|---|
| 3999 | if ( iScale == 4096 ) |
|---|
| 4000 | { |
|---|
| 4001 | rcMv = cMvPred; |
|---|
| 4002 | } |
|---|
| 4003 | else |
|---|
| 4004 | { |
|---|
| 4005 | rcMv = cMvPred.scaleMv( iScale ); |
|---|
| 4006 | } |
|---|
| 4007 | } |
|---|
| 4008 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
|---|
| 4009 | return true; |
|---|
| 4010 | } |
|---|
| 4011 | } |
|---|
| 4012 | //---------------------- V3(END) --------------------// |
|---|
| 4013 | return false; |
|---|
| 4014 | } |
|---|
| 4015 | |
|---|
| 4016 | /** |
|---|
| 4017 | * \param eRefPicList |
|---|
| 4018 | * \param uiCUAddr |
|---|
| 4019 | * \param uiPartUnitIdx |
|---|
| 4020 | * \param riRefIdx |
|---|
| 4021 | * \returns Bool |
|---|
| 4022 | */ |
|---|
| 4023 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx |
|---|
| 4024 | #if H_3D_TMVP |
|---|
| 4025 | , Bool bMRG |
|---|
| 4026 | #endif |
|---|
| 4027 | ) |
|---|
| 4028 | { |
|---|
| 4029 | UInt uiAbsPartAddr = uiPartUnitIdx; |
|---|
| 4030 | |
|---|
| 4031 | RefPicList eColRefPicList; |
|---|
| 4032 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
|---|
| 4033 | TComMv cColMv; |
|---|
| 4034 | |
|---|
| 4035 | // use coldir. |
|---|
| 4036 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
|---|
| 4037 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
|---|
| 4038 | if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE) |
|---|
| 4039 | { |
|---|
| 4040 | return false; |
|---|
| 4041 | } |
|---|
| 4042 | iCurrPOC = m_pcSlice->getPOC(); |
|---|
| 4043 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
|---|
| 4044 | iColPOC = pColCU->getSlice()->getPOC(); |
|---|
| 4045 | |
|---|
| 4046 | if (pColCU->isIntra(uiAbsPartAddr)) |
|---|
| 4047 | { |
|---|
| 4048 | return false; |
|---|
| 4049 | } |
|---|
| 4050 | eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
|---|
| 4051 | |
|---|
| 4052 | Int iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
|---|
| 4053 | |
|---|
| 4054 | if (iColRefIdx < 0 ) |
|---|
| 4055 | { |
|---|
| 4056 | eColRefPicList = RefPicList(1 - eColRefPicList); |
|---|
| 4057 | iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
|---|
| 4058 | |
|---|
| 4059 | if (iColRefIdx < 0 ) |
|---|
| 4060 | { |
|---|
| 4061 | return false; |
|---|
| 4062 | } |
|---|
| 4063 | } |
|---|
| 4064 | |
|---|
| 4065 | // Scale the vector. |
|---|
| 4066 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
|---|
| 4067 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
|---|
| 4068 | |
|---|
| 4069 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
|---|
| 4070 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
|---|
| 4071 | Bool bIsColRefLongTerm = pColCU->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
|---|
| 4072 | |
|---|
| 4073 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
|---|
| 4074 | { |
|---|
| 4075 | #if H_3D_TMVP |
|---|
| 4076 | Int iAlterRefIdx = m_pcSlice->getAlterRefIdx(eRefPicList); |
|---|
| 4077 | if(bMRG && iAlterRefIdx > 0) |
|---|
| 4078 | { |
|---|
| 4079 | riRefIdx = iAlterRefIdx; |
|---|
| 4080 | bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
|---|
| 4081 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
|---|
| 4082 | assert(bIsCurrRefLongTerm == bIsColRefLongTerm); |
|---|
| 4083 | } |
|---|
| 4084 | else |
|---|
| 4085 | { |
|---|
| 4086 | #endif |
|---|
| 4087 | return false; |
|---|
| 4088 | #if H_3D_TMVP |
|---|
| 4089 | } |
|---|
| 4090 | #endif |
|---|
| 4091 | } |
|---|
| 4092 | |
|---|
| 4093 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
|---|
| 4094 | { |
|---|
| 4095 | #if H_3D_TMVP |
|---|
| 4096 | Int iCurrViewId = m_pcSlice->getViewIndex (); |
|---|
| 4097 | Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewIndex (); |
|---|
| 4098 | Int iColViewId = pColCU->getSlice()->getViewIndex(); |
|---|
| 4099 | Int iColRefViewId = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewIndex(); |
|---|
| 4100 | iScale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId ); |
|---|
| 4101 | if ( iScale != 4096 ) |
|---|
| 4102 | { |
|---|
| 4103 | rcMv = cColMv.scaleMv( iScale ); |
|---|
| 4104 | } |
|---|
| 4105 | else |
|---|
| 4106 | { |
|---|
| 4107 | #endif |
|---|
| 4108 | rcMv = cColMv; |
|---|
| 4109 | #if H_3D_TMVP |
|---|
| 4110 | } |
|---|
| 4111 | #endif |
|---|
| 4112 | } |
|---|
| 4113 | else |
|---|
| 4114 | { |
|---|
| 4115 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
|---|
| 4116 | if ( iScale == 4096 ) |
|---|
| 4117 | { |
|---|
| 4118 | rcMv = cColMv; |
|---|
| 4119 | } |
|---|
| 4120 | else |
|---|
| 4121 | { |
|---|
| 4122 | rcMv = cColMv.scaleMv( iScale ); |
|---|
| 4123 | } |
|---|
| 4124 | } |
|---|
| 4125 | return true; |
|---|
| 4126 | } |
|---|
| 4127 | |
|---|
| 4128 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
|---|
| 4129 | { |
|---|
| 4130 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
|---|
| 4131 | } |
|---|
| 4132 | |
|---|
| 4133 | UInt TComDataCU::xGetComponentBits(Int iVal) |
|---|
| 4134 | { |
|---|
| 4135 | UInt uiLength = 1; |
|---|
| 4136 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
|---|
| 4137 | |
|---|
| 4138 | assert ( uiTemp ); |
|---|
| 4139 | |
|---|
| 4140 | while ( 1 != uiTemp ) |
|---|
| 4141 | { |
|---|
| 4142 | uiTemp >>= 1; |
|---|
| 4143 | uiLength += 2; |
|---|
| 4144 | } |
|---|
| 4145 | |
|---|
| 4146 | return uiLength; |
|---|
| 4147 | } |
|---|
| 4148 | |
|---|
| 4149 | |
|---|
| 4150 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
|---|
| 4151 | { |
|---|
| 4152 | Int iDiffPocD = iColPOC - iColRefPOC; |
|---|
| 4153 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
|---|
| 4154 | |
|---|
| 4155 | if( iDiffPocD == iDiffPocB ) |
|---|
| 4156 | { |
|---|
| 4157 | return 4096; |
|---|
| 4158 | } |
|---|
| 4159 | else |
|---|
| 4160 | { |
|---|
| 4161 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
|---|
| 4162 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
|---|
| 4163 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
|---|
| 4164 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
|---|
| 4165 | return iScale; |
|---|
| 4166 | } |
|---|
| 4167 | } |
|---|
| 4168 | |
|---|
| 4169 | /** |
|---|
| 4170 | * \param eCUMode |
|---|
| 4171 | * \param uiPartIdx |
|---|
| 4172 | * \param ruiPartIdxCenter |
|---|
| 4173 | * \returns Void |
|---|
| 4174 | */ |
|---|
| 4175 | Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
|---|
| 4176 | { |
|---|
| 4177 | UInt uiPartAddr; |
|---|
| 4178 | Int iPartWidth; |
|---|
| 4179 | Int iPartHeight; |
|---|
| 4180 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
|---|
| 4181 | |
|---|
| 4182 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
|---|
| 4183 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
|---|
| 4184 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInWidth() |
|---|
| 4185 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
|---|
| 4186 | } |
|---|
| 4187 | |
|---|
| 4188 | Void TComDataCU::compressMV() |
|---|
| 4189 | { |
|---|
| 4190 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
|---|
| 4191 | if (scaleFactor > 0) |
|---|
| 4192 | { |
|---|
| 4193 | m_acCUMvField[0].compress(m_pePredMode, scaleFactor); |
|---|
| 4194 | m_acCUMvField[1].compress(m_pePredMode, scaleFactor); |
|---|
| 4195 | } |
|---|
| 4196 | } |
|---|
| 4197 | |
|---|
| 4198 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
|---|
| 4199 | { |
|---|
| 4200 | UInt uiCTXIdx; |
|---|
| 4201 | UInt uiScanIdx; |
|---|
| 4202 | UInt uiDirMode; |
|---|
| 4203 | |
|---|
| 4204 | if ( !bIsIntra ) |
|---|
| 4205 | { |
|---|
| 4206 | uiScanIdx = SCAN_DIAG; |
|---|
| 4207 | return uiScanIdx; |
|---|
| 4208 | } |
|---|
| 4209 | |
|---|
| 4210 | switch(uiWidth) |
|---|
| 4211 | { |
|---|
| 4212 | case 2: uiCTXIdx = 6; break; |
|---|
| 4213 | case 4: uiCTXIdx = 5; break; |
|---|
| 4214 | case 8: uiCTXIdx = 4; break; |
|---|
| 4215 | case 16: uiCTXIdx = 3; break; |
|---|
| 4216 | case 32: uiCTXIdx = 2; break; |
|---|
| 4217 | case 64: uiCTXIdx = 1; break; |
|---|
| 4218 | default: uiCTXIdx = 0; break; |
|---|
| 4219 | } |
|---|
| 4220 | |
|---|
| 4221 | if ( bIsLuma ) |
|---|
| 4222 | { |
|---|
| 4223 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
|---|
| 4224 | uiScanIdx = SCAN_DIAG; |
|---|
| 4225 | if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size |
|---|
| 4226 | { |
|---|
| 4227 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
|---|
| 4228 | } |
|---|
| 4229 | } |
|---|
| 4230 | else |
|---|
| 4231 | { |
|---|
| 4232 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
|---|
| 4233 | if( uiDirMode == DM_CHROMA_IDX ) |
|---|
| 4234 | { |
|---|
| 4235 | // get number of partitions in current CU |
|---|
| 4236 | UInt depth = getDepth(uiAbsPartIdx); |
|---|
| 4237 | UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); |
|---|
| 4238 | |
|---|
| 4239 | // get luma mode from upper-left corner of current CU |
|---|
| 4240 | uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); |
|---|
| 4241 | } |
|---|
| 4242 | uiScanIdx = SCAN_DIAG; |
|---|
| 4243 | if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size |
|---|
| 4244 | { |
|---|
| 4245 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
|---|
| 4246 | } |
|---|
| 4247 | } |
|---|
| 4248 | |
|---|
| 4249 | return uiScanIdx; |
|---|
| 4250 | } |
|---|
| 4251 | |
|---|
| 4252 | UInt TComDataCU::getSCUAddr() |
|---|
| 4253 | { |
|---|
| 4254 | return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; |
|---|
| 4255 | } |
|---|
| 4256 | |
|---|
| 4257 | /** Set neighboring blocks availabilities for non-deblocked filtering |
|---|
| 4258 | * \param numLCUInPicWidth number of LCUs in picture width |
|---|
| 4259 | * \param numLCUInPicHeight number of LCUs in picture height |
|---|
| 4260 | * \param numSUInLCUWidth number of SUs in LCU width |
|---|
| 4261 | * \param numSUInLCUHeight number of SUs in LCU height |
|---|
| 4262 | * \param picWidth picture width |
|---|
| 4263 | * \param picHeight picture height |
|---|
| 4264 | * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled |
|---|
| 4265 | * \param bTopTileBoundary true means that top boundary coincides tile boundary |
|---|
| 4266 | * \param bDownTileBoundary true means that bottom boundary coincides tile boundary |
|---|
| 4267 | * \param bLeftTileBoundary true means that left boundary coincides tile boundary |
|---|
| 4268 | * \param bRightTileBoundary true means that right boundary coincides tile boundary |
|---|
| 4269 | * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled |
|---|
| 4270 | */ |
|---|
| 4271 | Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt /*numLCUInPicHeight*/, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight |
|---|
| 4272 | ,std::vector<Bool>& LFCrossSliceBoundary |
|---|
| 4273 | ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary |
|---|
| 4274 | ,Bool bIndependentTileBoundaryEnabled) |
|---|
| 4275 | { |
|---|
| 4276 | UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight; |
|---|
| 4277 | Int* pSliceIDMapLCU = m_piSliceSUMap; |
|---|
| 4278 | Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1); |
|---|
| 4279 | UInt uiLPelX, uiTPelY; |
|---|
| 4280 | UInt width, height; |
|---|
| 4281 | Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary; |
|---|
| 4282 | Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false; |
|---|
| 4283 | Bool* pbAvailBorder; |
|---|
| 4284 | Bool* pbAvail; |
|---|
| 4285 | UInt rTLSU, rBRSU, widthSU, heightSU; |
|---|
| 4286 | UInt zRefSU; |
|---|
| 4287 | Int* pRefID; |
|---|
| 4288 | Int* pRefMapLCU; |
|---|
| 4289 | UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0; |
|---|
| 4290 | Int* pRRefMapLCU= NULL; |
|---|
| 4291 | Int* pLRefMapLCU= NULL; |
|---|
| 4292 | Int* pTRefMapLCU= NULL; |
|---|
| 4293 | Int* pBRefMapLCU= NULL; |
|---|
| 4294 | Int sliceID; |
|---|
| 4295 | UInt numSGU = (UInt)m_vNDFBlock.size(); |
|---|
| 4296 | |
|---|
| 4297 | for(Int i=0; i< numSGU; i++) |
|---|
| 4298 | { |
|---|
| 4299 | NDBFBlockInfo& rSGU = m_vNDFBlock[i]; |
|---|
| 4300 | |
|---|
| 4301 | sliceID = rSGU.sliceID; |
|---|
| 4302 | uiLPelX = rSGU.posX; |
|---|
| 4303 | uiTPelY = rSGU.posY; |
|---|
| 4304 | width = rSGU.width; |
|---|
| 4305 | height = rSGU.height; |
|---|
| 4306 | rTLSU = g_auiZscanToRaster[ rSGU.startSU ]; |
|---|
| 4307 | rBRSU = g_auiZscanToRaster[ rSGU.endSU ]; |
|---|
| 4308 | widthSU = rSGU.widthSU; |
|---|
| 4309 | heightSU = rSGU.heightSU; |
|---|
| 4310 | |
|---|
| 4311 | pbAvailBorder = rSGU.isBorderAvailable; |
|---|
| 4312 | |
|---|
| 4313 | bPicTBoundary= (uiTPelY == 0 )?(true):(false); |
|---|
| 4314 | bPicLBoundary= (uiLPelX == 0 )?(true):(false); |
|---|
| 4315 | bPicRBoundary= (!(uiLPelX+ width < picWidth ) )?(true):(false); |
|---|
| 4316 | bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false); |
|---|
| 4317 | |
|---|
| 4318 | bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false); |
|---|
| 4319 | bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false); |
|---|
| 4320 | bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false); |
|---|
| 4321 | bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false); |
|---|
| 4322 | |
|---|
| 4323 | // SGU_L |
|---|
| 4324 | pbAvail = &(pbAvailBorder[SGU_L]); |
|---|
| 4325 | if(bPicLBoundary) |
|---|
| 4326 | { |
|---|
| 4327 | *pbAvail = false; |
|---|
| 4328 | } |
|---|
| 4329 | else if (onlyOneSliceInPic) |
|---|
| 4330 | { |
|---|
| 4331 | *pbAvail = true; |
|---|
| 4332 | } |
|---|
| 4333 | else |
|---|
| 4334 | { |
|---|
| 4335 | // bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false); |
|---|
| 4336 | if(bLCULBoundary) |
|---|
| 4337 | { |
|---|
| 4338 | rLRefSU = rTLSU + numSUInLCUWidth -1; |
|---|
| 4339 | zRefSU = g_auiRasterToZscan[rLRefSU]; |
|---|
| 4340 | pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU); |
|---|
| 4341 | } |
|---|
| 4342 | else |
|---|
| 4343 | { |
|---|
| 4344 | zRefSU = g_auiRasterToZscan[rTLSU - 1]; |
|---|
| 4345 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 4346 | } |
|---|
| 4347 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 4348 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 4349 | } |
|---|
| 4350 | |
|---|
| 4351 | // SGU_R |
|---|
| 4352 | pbAvail = &(pbAvailBorder[SGU_R]); |
|---|
| 4353 | if(bPicRBoundary) |
|---|
| 4354 | { |
|---|
| 4355 | *pbAvail = false; |
|---|
| 4356 | } |
|---|
| 4357 | else if (onlyOneSliceInPic) |
|---|
| 4358 | { |
|---|
| 4359 | *pbAvail = true; |
|---|
| 4360 | } |
|---|
| 4361 | else |
|---|
| 4362 | { |
|---|
| 4363 | // bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false); |
|---|
| 4364 | if(bLCURBoundary) |
|---|
| 4365 | { |
|---|
| 4366 | rRRefSU = rTLSU + widthSU - numSUInLCUWidth; |
|---|
| 4367 | zRefSU = g_auiRasterToZscan[rRRefSU]; |
|---|
| 4368 | pRefMapLCU = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU); |
|---|
| 4369 | } |
|---|
| 4370 | else |
|---|
| 4371 | { |
|---|
| 4372 | zRefSU = g_auiRasterToZscan[rTLSU + widthSU]; |
|---|
| 4373 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 4374 | } |
|---|
| 4375 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 4376 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 4377 | } |
|---|
| 4378 | |
|---|
| 4379 | // SGU_T |
|---|
| 4380 | pbAvail = &(pbAvailBorder[SGU_T]); |
|---|
| 4381 | if(bPicTBoundary) |
|---|
| 4382 | { |
|---|
| 4383 | *pbAvail = false; |
|---|
| 4384 | } |
|---|
| 4385 | else if (onlyOneSliceInPic) |
|---|
| 4386 | { |
|---|
| 4387 | *pbAvail = true; |
|---|
| 4388 | } |
|---|
| 4389 | else |
|---|
| 4390 | { |
|---|
| 4391 | // bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false); |
|---|
| 4392 | if(bLCUTBoundary) |
|---|
| 4393 | { |
|---|
| 4394 | rTRefSU = numSUInLCU - (numSUInLCUWidth - rTLSU); |
|---|
| 4395 | zRefSU = g_auiRasterToZscan[rTRefSU]; |
|---|
| 4396 | pRefMapLCU = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU)); |
|---|
| 4397 | } |
|---|
| 4398 | else |
|---|
| 4399 | { |
|---|
| 4400 | zRefSU = g_auiRasterToZscan[rTLSU - numSUInLCUWidth]; |
|---|
| 4401 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 4402 | } |
|---|
| 4403 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 4404 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 4405 | } |
|---|
| 4406 | |
|---|
| 4407 | // SGU_B |
|---|
| 4408 | pbAvail = &(pbAvailBorder[SGU_B]); |
|---|
| 4409 | if(bPicBBoundary) |
|---|
| 4410 | { |
|---|
| 4411 | *pbAvail = false; |
|---|
| 4412 | } |
|---|
| 4413 | else if (onlyOneSliceInPic) |
|---|
| 4414 | { |
|---|
| 4415 | *pbAvail = true; |
|---|
| 4416 | } |
|---|
| 4417 | else |
|---|
| 4418 | { |
|---|
| 4419 | // bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false); |
|---|
| 4420 | if(bLCUBBoundary) |
|---|
| 4421 | { |
|---|
| 4422 | rBRefSU = rTLSU % numSUInLCUWidth; |
|---|
| 4423 | zRefSU = g_auiRasterToZscan[rBRefSU]; |
|---|
| 4424 | pRefMapLCU = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU)); |
|---|
| 4425 | } |
|---|
| 4426 | else |
|---|
| 4427 | { |
|---|
| 4428 | zRefSU = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)]; |
|---|
| 4429 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 4430 | } |
|---|
| 4431 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 4432 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 4433 | } |
|---|
| 4434 | |
|---|
| 4435 | // SGU_TL |
|---|
| 4436 | pbAvail = &(pbAvailBorder[SGU_TL]); |
|---|
| 4437 | if(bPicTBoundary || bPicLBoundary) |
|---|
| 4438 | { |
|---|
| 4439 | *pbAvail = false; |
|---|
| 4440 | } |
|---|
| 4441 | else if (onlyOneSliceInPic) |
|---|
| 4442 | { |
|---|
| 4443 | *pbAvail = true; |
|---|
| 4444 | } |
|---|
| 4445 | else |
|---|
| 4446 | { |
|---|
| 4447 | if(bLCUTBoundary && bLCULBoundary) |
|---|
| 4448 | { |
|---|
| 4449 | zRefSU = numSUInLCU -1; |
|---|
| 4450 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU); |
|---|
| 4451 | } |
|---|
| 4452 | else if(bLCUTBoundary) |
|---|
| 4453 | { |
|---|
| 4454 | zRefSU = g_auiRasterToZscan[ rTRefSU- 1]; |
|---|
| 4455 | pRefMapLCU = pTRefMapLCU; |
|---|
| 4456 | } |
|---|
| 4457 | else if(bLCULBoundary) |
|---|
| 4458 | { |
|---|
| 4459 | zRefSU = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ]; |
|---|
| 4460 | pRefMapLCU = pLRefMapLCU; |
|---|
| 4461 | } |
|---|
| 4462 | else //inside LCU |
|---|
| 4463 | { |
|---|
| 4464 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1]; |
|---|
| 4465 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 4466 | } |
|---|
| 4467 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 4468 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 4469 | } |
|---|
| 4470 | |
|---|
| 4471 | // SGU_TR |
|---|
| 4472 | pbAvail = &(pbAvailBorder[SGU_TR]); |
|---|
| 4473 | if(bPicTBoundary || bPicRBoundary) |
|---|
| 4474 | { |
|---|
| 4475 | *pbAvail = false; |
|---|
| 4476 | } |
|---|
| 4477 | else if (onlyOneSliceInPic) |
|---|
| 4478 | { |
|---|
| 4479 | *pbAvail = true; |
|---|
| 4480 | } |
|---|
| 4481 | else |
|---|
| 4482 | { |
|---|
| 4483 | if(bLCUTBoundary && bLCURBoundary) |
|---|
| 4484 | { |
|---|
| 4485 | zRefSU = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth]; |
|---|
| 4486 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU); |
|---|
| 4487 | } |
|---|
| 4488 | else if(bLCUTBoundary) |
|---|
| 4489 | { |
|---|
| 4490 | zRefSU = g_auiRasterToZscan[ rTRefSU+ widthSU]; |
|---|
| 4491 | pRefMapLCU = pTRefMapLCU; |
|---|
| 4492 | } |
|---|
| 4493 | else if(bLCURBoundary) |
|---|
| 4494 | { |
|---|
| 4495 | zRefSU = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ]; |
|---|
| 4496 | pRefMapLCU = pRRefMapLCU; |
|---|
| 4497 | } |
|---|
| 4498 | else //inside LCU |
|---|
| 4499 | { |
|---|
| 4500 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU]; |
|---|
| 4501 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 4502 | } |
|---|
| 4503 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 4504 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 4505 | } |
|---|
| 4506 | |
|---|
| 4507 | // SGU_BL |
|---|
| 4508 | pbAvail = &(pbAvailBorder[SGU_BL]); |
|---|
| 4509 | if(bPicBBoundary || bPicLBoundary) |
|---|
| 4510 | { |
|---|
| 4511 | *pbAvail = false; |
|---|
| 4512 | } |
|---|
| 4513 | else if (onlyOneSliceInPic) |
|---|
| 4514 | { |
|---|
| 4515 | *pbAvail = true; |
|---|
| 4516 | } |
|---|
| 4517 | else |
|---|
| 4518 | { |
|---|
| 4519 | if(bLCUBBoundary && bLCULBoundary) |
|---|
| 4520 | { |
|---|
| 4521 | zRefSU = g_auiRasterToZscan[numSUInLCUWidth - 1]; |
|---|
| 4522 | pRefMapLCU = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU); |
|---|
| 4523 | } |
|---|
| 4524 | else if(bLCUBBoundary) |
|---|
| 4525 | { |
|---|
| 4526 | zRefSU = g_auiRasterToZscan[ rBRefSU - 1]; |
|---|
| 4527 | pRefMapLCU = pBRefMapLCU; |
|---|
| 4528 | } |
|---|
| 4529 | else if(bLCULBoundary) |
|---|
| 4530 | { |
|---|
| 4531 | zRefSU = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ]; |
|---|
| 4532 | pRefMapLCU = pLRefMapLCU; |
|---|
| 4533 | } |
|---|
| 4534 | else //inside LCU |
|---|
| 4535 | { |
|---|
| 4536 | zRefSU = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1]; |
|---|
| 4537 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 4538 | } |
|---|
| 4539 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 4540 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 4541 | } |
|---|
| 4542 | |
|---|
| 4543 | // SGU_BR |
|---|
| 4544 | pbAvail = &(pbAvailBorder[SGU_BR]); |
|---|
| 4545 | if(bPicBBoundary || bPicRBoundary) |
|---|
| 4546 | { |
|---|
| 4547 | *pbAvail = false; |
|---|
| 4548 | } |
|---|
| 4549 | else if (onlyOneSliceInPic) |
|---|
| 4550 | { |
|---|
| 4551 | *pbAvail = true; |
|---|
| 4552 | } |
|---|
| 4553 | else |
|---|
| 4554 | { |
|---|
| 4555 | if(bLCUBBoundary && bLCURBoundary) |
|---|
| 4556 | { |
|---|
| 4557 | zRefSU = 0; |
|---|
| 4558 | pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU); |
|---|
| 4559 | } |
|---|
| 4560 | else if(bLCUBBoundary) |
|---|
| 4561 | { |
|---|
| 4562 | zRefSU = g_auiRasterToZscan[ rBRefSU + widthSU]; |
|---|
| 4563 | pRefMapLCU = pBRefMapLCU; |
|---|
| 4564 | } |
|---|
| 4565 | else if(bLCURBoundary) |
|---|
| 4566 | { |
|---|
| 4567 | zRefSU = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)]; |
|---|
| 4568 | pRefMapLCU = pRRefMapLCU; |
|---|
| 4569 | } |
|---|
| 4570 | else //inside LCU |
|---|
| 4571 | { |
|---|
| 4572 | zRefSU = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU]; |
|---|
| 4573 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 4574 | } |
|---|
| 4575 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 4576 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 4577 | } |
|---|
| 4578 | |
|---|
| 4579 | if(bIndependentTileBoundaryEnabled) |
|---|
| 4580 | { |
|---|
| 4581 | //left LCU boundary |
|---|
| 4582 | if(!bPicLBoundary && bLCULBoundary) |
|---|
| 4583 | { |
|---|
| 4584 | if(bLeftTileBoundary) |
|---|
| 4585 | { |
|---|
| 4586 | pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false; |
|---|
| 4587 | } |
|---|
| 4588 | } |
|---|
| 4589 | //right LCU boundary |
|---|
| 4590 | if(!bPicRBoundary && bLCURBoundary) |
|---|
| 4591 | { |
|---|
| 4592 | if(bRightTileBoundary) |
|---|
| 4593 | { |
|---|
| 4594 | pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false; |
|---|
| 4595 | } |
|---|
| 4596 | } |
|---|
| 4597 | //top LCU boundary |
|---|
| 4598 | if(!bPicTBoundary && bLCUTBoundary) |
|---|
| 4599 | { |
|---|
| 4600 | if(bTopTileBoundary) |
|---|
| 4601 | { |
|---|
| 4602 | pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false; |
|---|
| 4603 | } |
|---|
| 4604 | } |
|---|
| 4605 | //down LCU boundary |
|---|
| 4606 | if(!bPicBBoundary && bLCUBBoundary) |
|---|
| 4607 | { |
|---|
| 4608 | if(bDownTileBoundary) |
|---|
| 4609 | { |
|---|
| 4610 | pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false; |
|---|
| 4611 | } |
|---|
| 4612 | } |
|---|
| 4613 | } |
|---|
| 4614 | rSGU.allBordersAvailable = true; |
|---|
| 4615 | for(Int b=0; b< NUM_SGU_BORDER; b++) |
|---|
| 4616 | { |
|---|
| 4617 | if(pbAvailBorder[b] == false) |
|---|
| 4618 | { |
|---|
| 4619 | rSGU.allBordersAvailable = false; |
|---|
| 4620 | break; |
|---|
| 4621 | } |
|---|
| 4622 | } |
|---|
| 4623 | } |
|---|
| 4624 | } |
|---|
| 4625 | |
|---|
| 4626 | #if H_3D |
|---|
| 4627 | Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) |
|---|
| 4628 | { |
|---|
| 4629 | riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX(); |
|---|
| 4630 | riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); |
|---|
| 4631 | } |
|---|
| 4632 | #endif |
|---|
| 4633 | #if H_3D_NBDV |
|---|
| 4634 | //Notes from QC: |
|---|
| 4635 | //TBD#1: DoNBDV related contributions are just partially integrated under the marco of H_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done |
|---|
| 4636 | //TBD#2: set of DvMCP values need to be done as part of inter-view motion prediction process. Remove this comment once merge related integration is done |
|---|
| 4637 | //To be checked: Parallel Merge features for NBDV, related to DV_DERIVATION_PARALLEL_B0096 and LGE_IVMP_PARALLEL_MERGE_B0136 are not integrated. The need of these features due to the adoption of CU-based NBDV is not clear. We need confirmation on this, especially by proponents |
|---|
| 4638 | Bool TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo |
|---|
| 4639 | #if H_3D_NBDV_REF |
|---|
| 4640 | , Bool bDepthRefine |
|---|
| 4641 | #endif |
|---|
| 4642 | ) |
|---|
| 4643 | { |
|---|
| 4644 | //// ******* Init variables ******* ///// |
|---|
| 4645 | // Init disparity struct for results |
|---|
| 4646 | pDInfo->bDV = false; |
|---|
| 4647 | // Init struct for disparities from MCP neighboring blocks |
|---|
| 4648 | IDVInfo cIDVInfo; |
|---|
| 4649 | cIDVInfo.m_bFound = false; |
|---|
| 4650 | UInt uiPartIdx = 0; |
|---|
| 4651 | UInt uiPartAddr = 0; |
|---|
| 4652 | for (UInt iCurDvMcpCand = 0; iCurDvMcpCand < IDV_CANDS; iCurDvMcpCand++) |
|---|
| 4653 | { |
|---|
| 4654 | for (UInt iList = 0; iList < 2; iList++) |
|---|
| 4655 | { |
|---|
| 4656 | cIDVInfo.m_acMvCand[iList][iCurDvMcpCand].setZero(); |
|---|
| 4657 | cIDVInfo.m_aVIdxCan[iList][iCurDvMcpCand] = 0; |
|---|
| 4658 | cIDVInfo.m_bAvailab[iList][iCurDvMcpCand] = false; |
|---|
| 4659 | } |
|---|
| 4660 | } |
|---|
| 4661 | #if H_3D_NBDV_REF |
|---|
| 4662 | if( !m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ) ) |
|---|
| 4663 | { |
|---|
| 4664 | bDepthRefine = false; |
|---|
| 4665 | } |
|---|
| 4666 | #endif |
|---|
| 4667 | // Get Positions |
|---|
| 4668 | PartSize eCUMode = getPartitionSize( uiPartAddr ); |
|---|
| 4669 | assert(eCUMode == SIZE_2Nx2N); |
|---|
| 4670 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
|---|
| 4671 | |
|---|
| 4672 | deriveLeftRightTopIdxGeneral(uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
|---|
| 4673 | deriveLeftBottomIdxGeneral (uiPartAddr, uiPartIdx, uiPartIdxLB ); |
|---|
| 4674 | |
|---|
| 4675 | //// ******* Get disparity from temporal neighboring blocks ******* ///// |
|---|
| 4676 | if ( getSlice()->getEnableTMVPFlag() ) |
|---|
| 4677 | { |
|---|
| 4678 | TComMv cColMv; |
|---|
| 4679 | Int iTargetViewIdx = 0; |
|---|
| 4680 | Int iTStartViewIdx = 0; |
|---|
| 4681 | |
|---|
| 4682 | ///*** Derive center position *** |
|---|
| 4683 | UInt uiPartIdxCenter; |
|---|
| 4684 | Int uiLCUIdx = getAddr(); |
|---|
| 4685 | xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter ); |
|---|
| 4686 | |
|---|
| 4687 | ///*** Derive bottom right neighbour position *** |
|---|
| 4688 | Int iLCUIdxRBNb = -1; |
|---|
| 4689 | Int iPartIdxRBNb = -1; |
|---|
| 4690 | xDeriveRightBottomNbIdx(iLCUIdxRBNb, iPartIdxRBNb ); |
|---|
| 4691 | |
|---|
| 4692 | ///*** Search temporal candidate pictures for disparity vector *** |
|---|
| 4693 | const Int iNumCandPics = getPic()->getNumDdvCandPics(); |
|---|
| 4694 | for(Int curCandPic = 0; curCandPic < iNumCandPics; curCandPic++) |
|---|
| 4695 | { |
|---|
| 4696 | RefPicList eCurRefPicList = REF_PIC_LIST_0 ; |
|---|
| 4697 | Int curCandPicRefIdx = 0; |
|---|
| 4698 | if( curCandPic == 0 ) |
|---|
| 4699 | { |
|---|
| 4700 | eCurRefPicList = RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0); |
|---|
| 4701 | curCandPicRefIdx = getSlice()->getColRefIdx(); |
|---|
| 4702 | } |
|---|
| 4703 | else |
|---|
| 4704 | { |
|---|
| 4705 | eCurRefPicList = getPic()->getRapRefList(); |
|---|
| 4706 | curCandPicRefIdx = getPic()->getRapRefIdx(); |
|---|
| 4707 | } |
|---|
| 4708 | |
|---|
| 4709 | // Check BR and Center |
|---|
| 4710 | for(Int curPosition = 0; curPosition < 2; curPosition++) |
|---|
| 4711 | { |
|---|
| 4712 | Bool bCheck = false; |
|---|
| 4713 | if ( curPosition == 0 && iLCUIdxRBNb >= 0 ) |
|---|
| 4714 | bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, iLCUIdxRBNb, iPartIdxRBNb, cColMv, iTargetViewIdx, iTStartViewIdx); |
|---|
| 4715 | |
|---|
| 4716 | if (curPosition == 1 ) |
|---|
| 4717 | bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, uiLCUIdx, uiPartIdxCenter, cColMv, iTargetViewIdx, iTStartViewIdx ); |
|---|
| 4718 | |
|---|
| 4719 | if( bCheck ) |
|---|
| 4720 | { |
|---|
| 4721 | clipMv(cColMv); |
|---|
| 4722 | pDInfo->m_acNBDV = cColMv; |
|---|
| 4723 | pDInfo->m_aVIdxCan = iTargetViewIdx; |
|---|
| 4724 | |
|---|
| 4725 | #if H_3D_NBDV_REF |
|---|
| 4726 | TComPic* picDepth = NULL; |
|---|
| 4727 | picDepth = getSlice()->getIvPic( true, iTargetViewIdx ); |
|---|
| 4728 | assert(picDepth != NULL); |
|---|
| 4729 | if (picDepth && bDepthRefine) |
|---|
| 4730 | estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv ); |
|---|
| 4731 | |
|---|
| 4732 | #if 0 // H_3D_VSP |
|---|
| 4733 | Int refFrmIdx = 0; |
|---|
| 4734 | RefPicList privateRefPicList = REF_PIC_LIST_0; |
|---|
| 4735 | //getRefListAndRefFrmIdx(iTargetViewIdx, privateRefPicList, refFrmIdx); |
|---|
| 4736 | |
|---|
| 4737 | //pDInfo->m_aListIdx[ pDInfo->iN ] = privateRefPicList; |
|---|
| 4738 | //pDInfo->m_aRefIdx [ pDInfo->iN ] = -1-refFrmIdx; |
|---|
| 4739 | assert(pDInfo->m_aRefIdx [ pDInfo->iN ] < 0); |
|---|
| 4740 | #endif //H_3D_VSP |
|---|
| 4741 | pDInfo->m_acDoNBDV = cColMv; |
|---|
| 4742 | #endif //H_3D_NBDV_REF |
|---|
| 4743 | return true; |
|---|
| 4744 | } |
|---|
| 4745 | } |
|---|
| 4746 | } |
|---|
| 4747 | } |
|---|
| 4748 | |
|---|
| 4749 | UInt uiIdx = 0; |
|---|
| 4750 | Bool bCheckMcpDv = false; |
|---|
| 4751 | TComDataCU* pcTmpCU = NULL; |
|---|
| 4752 | |
|---|
| 4753 | //// ******* Get disparity from left block ******* ///// |
|---|
| 4754 | pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false); |
|---|
| 4755 | bCheckMcpDv = true; |
|---|
| 4756 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT |
|---|
| 4757 | #if H_3D_NBDV_REF |
|---|
| 4758 | , bDepthRefine |
|---|
| 4759 | #endif |
|---|
| 4760 | ) ) |
|---|
| 4761 | return true; |
|---|
| 4762 | |
|---|
| 4763 | //// ******* Get disparity from above block ******* ///// |
|---|
| 4764 | pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true); |
|---|
| 4765 | if(pcTmpCU != NULL ) |
|---|
| 4766 | { |
|---|
| 4767 | bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0); |
|---|
| 4768 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE |
|---|
| 4769 | #if H_3D_NBDV_REF |
|---|
| 4770 | , bDepthRefine |
|---|
| 4771 | #endif |
|---|
| 4772 | ) ) |
|---|
| 4773 | return true; |
|---|
| 4774 | } |
|---|
| 4775 | |
|---|
| 4776 | //// ******* Get disparity from above right block ******* ///// |
|---|
| 4777 | pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true); |
|---|
| 4778 | if(pcTmpCU != NULL ) |
|---|
| 4779 | { |
|---|
| 4780 | bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0); |
|---|
| 4781 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVERIGHT |
|---|
| 4782 | #if H_3D_NBDV_REF |
|---|
| 4783 | , bDepthRefine |
|---|
| 4784 | #endif |
|---|
| 4785 | ) ) |
|---|
| 4786 | return true; |
|---|
| 4787 | } |
|---|
| 4788 | |
|---|
| 4789 | //// ******* Get disparity from below left block ******* ///// |
|---|
| 4790 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true); |
|---|
| 4791 | if( pcTmpCU != NULL ) |
|---|
| 4792 | { |
|---|
| 4793 | bCheckMcpDv = true; |
|---|
| 4794 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFTBELOW |
|---|
| 4795 | #if H_3D_NBDV_REF |
|---|
| 4796 | , bDepthRefine |
|---|
| 4797 | #endif |
|---|
| 4798 | ) ) |
|---|
| 4799 | return true; |
|---|
| 4800 | } |
|---|
| 4801 | |
|---|
| 4802 | //// ******* Get disparity from above left block ******* ///// |
|---|
| 4803 | pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true); |
|---|
| 4804 | assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr)); |
|---|
| 4805 | |
|---|
| 4806 | if( pcTmpCU != NULL ) |
|---|
| 4807 | { |
|---|
| 4808 | bCheckMcpDv = (( getAddr() - pcTmpCU->getAddr() ) <= 1); |
|---|
| 4809 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVELEFT |
|---|
| 4810 | #if H_3D_NBDV_REF |
|---|
| 4811 | , bDepthRefine |
|---|
| 4812 | #endif |
|---|
| 4813 | ) ) |
|---|
| 4814 | return true; |
|---|
| 4815 | } |
|---|
| 4816 | |
|---|
| 4817 | //// ******* Search MCP blocks ******* ///// |
|---|
| 4818 | if( cIDVInfo.m_bFound ) |
|---|
| 4819 | { |
|---|
| 4820 | for( Int curPos = 0 ; curPos < IDV_CANDS ; curPos++ ) |
|---|
| 4821 | { |
|---|
| 4822 | for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) |
|---|
| 4823 | { |
|---|
| 4824 | if( cIDVInfo.m_bAvailab[iList][curPos] ) |
|---|
| 4825 | { |
|---|
| 4826 | TComMv cDispVec = cIDVInfo.m_acMvCand[iList][ curPos ]; |
|---|
| 4827 | clipMv( cDispVec ); |
|---|
| 4828 | pDInfo->m_acNBDV = cDispVec; |
|---|
| 4829 | #if H_3D_CLEANUPS |
|---|
| 4830 | pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ]; |
|---|
| 4831 | assert(pDInfo->m_aVIdxCan == 0); //Notes from QC: only works for CTC |
|---|
| 4832 | #else |
|---|
| 4833 | pDInfo->m_aVIdxCan = 0; |
|---|
| 4834 | #endif |
|---|
| 4835 | #if H_3D_NBDV_REF |
|---|
| 4836 | #if H_3D_CLEANUPS |
|---|
| 4837 | TComPic* picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan ); |
|---|
| 4838 | #else |
|---|
| 4839 | TComPic* picDepth = getSlice()->getIvPic( true, 0 ); |
|---|
| 4840 | #endif |
|---|
| 4841 | assert(picDepth!=NULL); |
|---|
| 4842 | |
|---|
| 4843 | if (picDepth && bDepthRefine) |
|---|
| 4844 | #if H_3D_CLEANUPS |
|---|
| 4845 | estimateDVFromDM (pDInfo->m_aVIdxCan, uiPartIdx, picDepth, uiPartAddr, &cDispVec); |
|---|
| 4846 | #else |
|---|
| 4847 | estimateDVFromDM(0, uiPartIdx, picDepth, uiPartAddr, &cDispVec ); // from base view |
|---|
| 4848 | #endif |
|---|
| 4849 | pDInfo->m_acDoNBDV = cDispVec; |
|---|
| 4850 | |
|---|
| 4851 | #if 0 // H_3D_VSP |
|---|
| 4852 | Int refFrmIdx = 0; |
|---|
| 4853 | RefPicList privateRefPicList = REF_PIC_LIST_0 ; |
|---|
| 4854 | getRefListAndRefFrmIdx(0, privateRefPicList, refFrmIdx); // find the reference picture from base view |
|---|
| 4855 | |
|---|
| 4856 | pDInfo->m_aListIdx[ pDInfo->iN ] = privateRefPicList; |
|---|
| 4857 | pDInfo->m_aRefIdx [ pDInfo->iN ] = -1-refFrmIdx; |
|---|
| 4858 | assert(pDInfo->m_aRefIdx [ pDInfo->iN ] < 0); |
|---|
| 4859 | #endif //H_3D_VSP |
|---|
| 4860 | |
|---|
| 4861 | #endif |
|---|
| 4862 | return true; |
|---|
| 4863 | } |
|---|
| 4864 | } |
|---|
| 4865 | } |
|---|
| 4866 | } |
|---|
| 4867 | |
|---|
| 4868 | TComMv defaultDV(0, 0); |
|---|
| 4869 | pDInfo->m_acNBDV = defaultDV; |
|---|
| 4870 | pDInfo->m_aVIdxCan = 0; |
|---|
| 4871 | #if H_3D_NBDV_REF |
|---|
| 4872 | TComPic* picDepth = NULL; |
|---|
| 4873 | picDepth = getSlice()->getIvPic( true, 0 ); |
|---|
| 4874 | assert(picDepth!=NULL); |
|---|
| 4875 | |
|---|
| 4876 | if (picDepth && bDepthRefine) |
|---|
| 4877 | { |
|---|
| 4878 | estimateDVFromDM(0, uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view |
|---|
| 4879 | } |
|---|
| 4880 | pDInfo->m_acDoNBDV = defaultDV; |
|---|
| 4881 | |
|---|
| 4882 | #if 0 // H_3D_VSP |
|---|
| 4883 | Int refFrmIdx = 0; |
|---|
| 4884 | RefPicList privateRefPicList = REF_PIC_LIST_0 ; |
|---|
| 4885 | getRefListAndRefFrmIdx(0, privateRefPicList, refFrmIdx); // find the reference picture from base view |
|---|
| 4886 | |
|---|
| 4887 | pDInfo->m_aListIdx[ pDInfo->iN ] = privateRefPicList; |
|---|
| 4888 | pDInfo->m_aRefIdx [ pDInfo->iN ] = -1-refFrmIdx; |
|---|
| 4889 | assert(pDInfo->m_aRefIdx [ pDInfo->iN ] < 0); |
|---|
| 4890 | #endif |
|---|
| 4891 | #endif |
|---|
| 4892 | return false; |
|---|
| 4893 | } |
|---|
| 4894 | |
|---|
| 4895 | #if H_3D_NBDV_REF |
|---|
| 4896 | Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT ) |
|---|
| 4897 | { |
|---|
| 4898 | Int iPictureWidth = pcBaseViewDepthPicYuv->getWidth(); |
|---|
| 4899 | Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(); |
|---|
| 4900 | |
|---|
| 4901 | Int depthStartPosX = Clip3(0, iPictureWidth - iBlkWidth, iBlkX + ((mv->getHor()+2)>>2)); |
|---|
| 4902 | Int depthStartPosY = Clip3(0, iPictureHeight- iBlkHeight, iBlkY + ((mv->getVer()+2)>>2)); |
|---|
| 4903 | Int depthEndPosX = Clip3(0, iPictureWidth - 1, iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2)); |
|---|
| 4904 | Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2)); |
|---|
| 4905 | |
|---|
| 4906 | Pel* depthTL = pcBaseViewDepthPicYuv->getLumaAddr(); |
|---|
| 4907 | Int depStride = pcBaseViewDepthPicYuv->getStride(); |
|---|
| 4908 | |
|---|
| 4909 | Pel maxDepthVal = 0; |
|---|
| 4910 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthStartPosX ]); // Left Top |
|---|
| 4911 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthStartPosX ]); // Left Bottom |
|---|
| 4912 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthEndPosX ]); // Right Top |
|---|
| 4913 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthEndPosX ]); // Right Bottom |
|---|
| 4914 | |
|---|
| 4915 | return aiShiftLUT[ maxDepthVal ]; |
|---|
| 4916 | } |
|---|
| 4917 | |
|---|
| 4918 | Void TComDataCU::estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred ) |
|---|
| 4919 | { |
|---|
| 4920 | if (picDepth) |
|---|
| 4921 | { |
|---|
| 4922 | UInt uiAbsPartAddrCurrCU = m_uiAbsIdxInLCU + uiPartAddr; |
|---|
| 4923 | Int iWidth, iHeight; |
|---|
| 4924 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more |
|---|
| 4925 | |
|---|
| 4926 | TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec(); |
|---|
| 4927 | Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; |
|---|
| 4928 | Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; |
|---|
| 4929 | |
|---|
| 4930 | Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx ); |
|---|
| 4931 | |
|---|
| 4932 | Pel iDisp = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT ); |
|---|
| 4933 | cMvPred->setHor( iDisp ); |
|---|
| 4934 | clipMv(*cMvPred); |
|---|
| 4935 | } |
|---|
| 4936 | } |
|---|
| 4937 | #endif //H_3D_NBDV_REF |
|---|
| 4938 | |
|---|
| 4939 | |
|---|
| 4940 | Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos |
|---|
| 4941 | #if H_3D_NBDV_REF |
|---|
| 4942 | , Bool bDepthRefine |
|---|
| 4943 | #endif |
|---|
| 4944 | ) |
|---|
| 4945 | { |
|---|
| 4946 | if( pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) ) |
|---|
| 4947 | { |
|---|
| 4948 | Bool bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); |
|---|
| 4949 | for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) |
|---|
| 4950 | { |
|---|
| 4951 | RefPicList eRefPicList = RefPicList(iList); |
|---|
| 4952 | Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; |
|---|
| 4953 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
|---|
| 4954 | |
|---|
| 4955 | if( refId >= 0) |
|---|
| 4956 | { |
|---|
| 4957 | Int refViewIdx = pcTmpCU->getSlice()->getRefPic(eRefPicList, refId)->getViewIndex(); |
|---|
| 4958 | if (refViewIdx != m_pcSlice->getViewIndex()) |
|---|
| 4959 | { |
|---|
| 4960 | clipMv(cMvPred); |
|---|
| 4961 | pNbDvInfo->m_acNBDV = cMvPred; |
|---|
| 4962 | pNbDvInfo->m_aVIdxCan = refViewIdx; |
|---|
| 4963 | #if H_3D_NBDV_REF |
|---|
| 4964 | TComPic* picDepth = NULL; |
|---|
| 4965 | assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC()); |
|---|
| 4966 | picDepth = getSlice()->getIvPic (true, refViewIdx ); |
|---|
| 4967 | assert(picDepth != NULL); |
|---|
| 4968 | |
|---|
| 4969 | UInt uiPartIdx = 0; //Notes from MTK: Please confirm that using 0 as partition index and partition address is correct for CU-level DoNBDV |
|---|
| 4970 | UInt uiPartAddr = 0; //QC: confirmed |
|---|
| 4971 | |
|---|
| 4972 | if (picDepth && bDepthRefine) |
|---|
| 4973 | estimateDVFromDM(refViewIdx, uiPartIdx, picDepth, uiPartAddr, &cMvPred ); |
|---|
| 4974 | |
|---|
| 4975 | #if 0 // H_3D_VSP |
|---|
| 4976 | pNbDvInfo->m_aListIdx[ pNbDvInfo->iN ] = eRefPicList; |
|---|
| 4977 | pNbDvInfo->m_aRefIdx [ pNbDvInfo->iN ] = -1-refId; |
|---|
| 4978 | assert(pNbDvInfo->m_aRefIdx [ pNbDvInfo->iN ] < 0); |
|---|
| 4979 | #endif |
|---|
| 4980 | |
|---|
| 4981 | pNbDvInfo->m_acDoNBDV = cMvPred; |
|---|
| 4982 | #endif |
|---|
| 4983 | return true; |
|---|
| 4984 | } |
|---|
| 4985 | else if ( bSearchForMvpDv && cMvPred.getIDVFlag() && bTmpIsSkipped ) |
|---|
| 4986 | { |
|---|
| 4987 | assert( uiMvpDvPos < IDV_CANDS ); |
|---|
| 4988 | paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() ); |
|---|
| 4989 | //Notes from QC: DvMCP is implemented in a way that doesn�t carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design. |
|---|
| 4990 | paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = 0; |
|---|
| 4991 | paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true; |
|---|
| 4992 | paIDVInfo->m_bFound = true; |
|---|
| 4993 | } |
|---|
| 4994 | } |
|---|
| 4995 | } |
|---|
| 4996 | } |
|---|
| 4997 | return false; |
|---|
| 4998 | } |
|---|
| 4999 | |
|---|
| 5000 | Void TComDataCU::xDeriveRightBottomNbIdx(Int &riLCUIdxRBNb, Int &riPartIdxRBNb ) |
|---|
| 5001 | { |
|---|
| 5002 | UInt uiPartIdx = 0; |
|---|
| 5003 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 5004 | Int uiLCUIdx = getAddr(); |
|---|
| 5005 | |
|---|
| 5006 | UInt uiPartIdxRB; |
|---|
| 5007 | deriveRightBottomIdx(uiPartIdx, uiPartIdxRB ); |
|---|
| 5008 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
|---|
| 5009 | |
|---|
| 5010 | if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
|---|
| 5011 | { |
|---|
| 5012 | riLCUIdxRBNb = -1; |
|---|
| 5013 | riPartIdxRBNb = -1; |
|---|
| 5014 | } |
|---|
| 5015 | else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
|---|
| 5016 | { |
|---|
| 5017 | riLCUIdxRBNb = -1; |
|---|
| 5018 | riPartIdxRBNb = -1; |
|---|
| 5019 | } |
|---|
| 5020 | else |
|---|
| 5021 | { |
|---|
| 5022 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
|---|
| 5023 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
|---|
| 5024 | { |
|---|
| 5025 | riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
|---|
| 5026 | riLCUIdxRBNb = uiLCUIdx; |
|---|
| 5027 | } |
|---|
| 5028 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
|---|
| 5029 | { |
|---|
| 5030 | riPartIdxRBNb = -1; |
|---|
| 5031 | riLCUIdxRBNb = -1; |
|---|
| 5032 | } |
|---|
| 5033 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
|---|
| 5034 | { |
|---|
| 5035 | riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
|---|
| 5036 | riLCUIdxRBNb = uiLCUIdx + 1; |
|---|
| 5037 | } |
|---|
| 5038 | else //is the right bottom corner of LCU |
|---|
| 5039 | { |
|---|
| 5040 | riPartIdxRBNb = -1; |
|---|
| 5041 | riLCUIdxRBNb = -1; |
|---|
| 5042 | } |
|---|
| 5043 | } |
|---|
| 5044 | } |
|---|
| 5045 | |
|---|
| 5046 | |
|---|
| 5047 | Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 5048 | { |
|---|
| 5049 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 5050 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
|---|
| 5051 | { |
|---|
| 5052 | m_pDvInfo[uiAbsPartIdx + ui] = cDvInfo; |
|---|
| 5053 | } |
|---|
| 5054 | } |
|---|
| 5055 | |
|---|
| 5056 | Bool TComDataCU::xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx ) |
|---|
| 5057 | { |
|---|
| 5058 | |
|---|
| 5059 | RefPicList eColRefPicList = REF_PIC_LIST_0; |
|---|
| 5060 | Int iColViewIdx, iColRefViewIdx; |
|---|
| 5061 | TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx); |
|---|
| 5062 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
|---|
| 5063 | iColViewIdx = pColCU->getSlice()->getViewIndex(); |
|---|
| 5064 | if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiPartUnitIdx)) |
|---|
| 5065 | { |
|---|
| 5066 | return false; |
|---|
| 5067 | } |
|---|
| 5068 | for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++) |
|---|
| 5069 | { |
|---|
| 5070 | if(pColCU->getSlice()->isInterB()) |
|---|
| 5071 | { |
|---|
| 5072 | eColRefPicList = RefPicList(ilist); |
|---|
| 5073 | } |
|---|
| 5074 | |
|---|
| 5075 | Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartUnitIdx); |
|---|
| 5076 | |
|---|
| 5077 | if (iColRefIdx < 0) |
|---|
| 5078 | { |
|---|
| 5079 | continue; |
|---|
| 5080 | } |
|---|
| 5081 | |
|---|
| 5082 | iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewIndex(); |
|---|
| 5083 | |
|---|
| 5084 | if ( iColViewIdx == iColRefViewIdx ) // temporal vector |
|---|
| 5085 | { |
|---|
| 5086 | continue; |
|---|
| 5087 | } |
|---|
| 5088 | else |
|---|
| 5089 | { |
|---|
| 5090 | rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx); |
|---|
| 5091 | rcMv.setIDVFlag(0); |
|---|
| 5092 | iTargetViewIdx = iColRefViewIdx ; |
|---|
| 5093 | iStartViewIdx = iColViewIdx ; |
|---|
| 5094 | return true; |
|---|
| 5095 | } |
|---|
| 5096 | } |
|---|
| 5097 | |
|---|
| 5098 | return false; |
|---|
| 5099 | } |
|---|
| 5100 | #endif |
|---|
| 5101 | #if H_3D_IV_MERGE |
|---|
| 5102 | Bool |
|---|
| 5103 | TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc ) |
|---|
| 5104 | { |
|---|
| 5105 | TComSlice* pcSlice = getSlice (); |
|---|
| 5106 | #if H_3D_CLEANUPS //Notes from QC: to be aligned with the spec. |
|---|
| 5107 | Int iViewIndex = pDInfo->m_aVIdxCan; |
|---|
| 5108 | #else |
|---|
| 5109 | Bool valid = false; |
|---|
| 5110 | |
|---|
| 5111 | Int iViewIndex = 0; |
|---|
| 5112 | |
|---|
| 5113 | for( UInt uiBIndex = 0; uiBIndex < pcSlice->getViewIndex( ) && !valid; uiBIndex++ ) |
|---|
| 5114 | { |
|---|
| 5115 | UInt uiBaseIndex = uiBIndex; |
|---|
| 5116 | TComPic* pcBasePic = pcSlice->getIvPic( false, uiBaseIndex ); |
|---|
| 5117 | for( Int iRefListId = 0; iRefListId < 2 && !valid; iRefListId++ ) |
|---|
| 5118 | { |
|---|
| 5119 | RefPicList eRefPicListTest = RefPicList( iRefListId ); |
|---|
| 5120 | Int iNumRefPics = pcSlice->getNumRefIdx( eRefPicListTest ) ; |
|---|
| 5121 | for( Int iRefIndex = 0; iRefIndex < iNumRefPics; iRefIndex++ ) |
|---|
| 5122 | { |
|---|
| 5123 | if(pcBasePic->getPOC() == pcSlice->getRefPic( eRefPicListTest, iRefIndex )->getPOC() |
|---|
| 5124 | && pcBasePic->getViewIndex() == pcSlice->getRefPic( eRefPicListTest, iRefIndex )->getViewIndex()) |
|---|
| 5125 | { |
|---|
| 5126 | valid = true; |
|---|
| 5127 | iViewIndex = uiBaseIndex; |
|---|
| 5128 | break; |
|---|
| 5129 | } |
|---|
| 5130 | } |
|---|
| 5131 | } |
|---|
| 5132 | } |
|---|
| 5133 | |
|---|
| 5134 | if (!valid) |
|---|
| 5135 | return false; |
|---|
| 5136 | #endif |
|---|
| 5137 | //--- get base CU/PU and check prediction mode --- |
|---|
| 5138 | TComPic* pcBasePic = pcSlice->getIvPic( false, iViewIndex ); |
|---|
| 5139 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
|---|
| 5140 | |
|---|
| 5141 | UInt uiPartAddr; |
|---|
| 5142 | Int iWidth; |
|---|
| 5143 | Int iHeight; |
|---|
| 5144 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
|---|
| 5145 | |
|---|
| 5146 | Int iCurrPosX, iCurrPosY; |
|---|
| 5147 | pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
|---|
| 5148 | |
|---|
| 5149 | iCurrPosX += ( ( iWidth - 1 ) >> 1 ); |
|---|
| 5150 | iCurrPosY += ( ( iHeight - 1 ) >> 1 ); |
|---|
| 5151 | |
|---|
| 5152 | Bool depthRefineFlag = false; |
|---|
| 5153 | #if H_3D_NBDV_REF |
|---|
| 5154 | depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ); |
|---|
| 5155 | #endif // H_3D_NBDV_REF |
|---|
| 5156 | |
|---|
| 5157 | TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
|---|
| 5158 | |
|---|
| 5159 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
|---|
| 5160 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
|---|
| 5161 | |
|---|
| 5162 | Int iBaseCUAddr; |
|---|
| 5163 | Int iBaseAbsPartIdx; |
|---|
| 5164 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
|---|
| 5165 | |
|---|
| 5166 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
|---|
| 5167 | |
|---|
| 5168 | Bool abPdmAvailable[4] = {false, false, false, false}; |
|---|
| 5169 | #if H_3D_NBDV |
|---|
| 5170 | for( Int i = 0; i < 4; i++) |
|---|
| 5171 | { |
|---|
| 5172 | pacPdmMv[i].setIDVFlag (false); |
|---|
| 5173 | } |
|---|
| 5174 | #endif |
|---|
| 5175 | if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) |
|---|
| 5176 | { |
|---|
| 5177 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
|---|
| 5178 | { |
|---|
| 5179 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
|---|
| 5180 | |
|---|
| 5181 | Bool stopLoop = false; |
|---|
| 5182 | for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop) |
|---|
| 5183 | { |
|---|
| 5184 | RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); |
|---|
| 5185 | TComMvField cBaseMvField; |
|---|
| 5186 | pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); |
|---|
| 5187 | Int iBaseRefIdx = cBaseMvField.getRefIdx(); |
|---|
| 5188 | if (iBaseRefIdx >= 0) |
|---|
| 5189 | { |
|---|
| 5190 | Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx); |
|---|
| 5191 | if (iBaseRefPOC != pcSlice->getPOC()) |
|---|
| 5192 | { |
|---|
| 5193 | for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) |
|---|
| 5194 | { |
|---|
| 5195 | if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) |
|---|
| 5196 | { |
|---|
| 5197 | abPdmAvailable[ uiCurrRefListId ] = true; |
|---|
| 5198 | TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); |
|---|
| 5199 | #if H_3D_NBDV |
|---|
| 5200 | cMv.setIDVFlag (true); |
|---|
| 5201 | cMv.setIDVHor (cDv.getHor()); |
|---|
| 5202 | cMv.setIDVVer (cDv.getVer()); |
|---|
| 5203 | #endif |
|---|
| 5204 | clipMv( cMv ); |
|---|
| 5205 | paiPdmRefIdx [ uiCurrRefListId ] = iPdmRefIdx; |
|---|
| 5206 | pacPdmMv [ uiCurrRefListId ] = cMv; |
|---|
| 5207 | stopLoop = true; |
|---|
| 5208 | break; |
|---|
| 5209 | } |
|---|
| 5210 | } |
|---|
| 5211 | } |
|---|
| 5212 | } |
|---|
| 5213 | } |
|---|
| 5214 | } |
|---|
| 5215 | } |
|---|
| 5216 | availableMcDc[0] = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 ); |
|---|
| 5217 | for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ ) |
|---|
| 5218 | { |
|---|
| 5219 | RefPicList eRefPicListDMV = RefPicList( iRefListId ); |
|---|
| 5220 | Int iNumRefPics = pcSlice->getNumRefIdx( eRefPicListDMV ); |
|---|
| 5221 | for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ ) |
|---|
| 5222 | { |
|---|
| 5223 | if( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC()) |
|---|
| 5224 | { |
|---|
| 5225 | abPdmAvailable[ iRefListId+2 ] = true; |
|---|
| 5226 | paiPdmRefIdx [ iRefListId+2 ] = iPdmRefIdx; |
|---|
| 5227 | |
|---|
| 5228 | #if H_3D_NBDV_REF |
|---|
| 5229 | TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
|---|
| 5230 | #endif // H_3D_NBDV_REF |
|---|
| 5231 | cMv.setVer(0); |
|---|
| 5232 | clipMv( cMv ); |
|---|
| 5233 | pacPdmMv [ iRefListId + 2] = cMv; |
|---|
| 5234 | break; |
|---|
| 5235 | } |
|---|
| 5236 | } |
|---|
| 5237 | } |
|---|
| 5238 | availableMcDc[1] = ( abPdmAvailable[2] ? 1 : 0 ) + ( abPdmAvailable[3] ? 2 : 0 ); |
|---|
| 5239 | return false; |
|---|
| 5240 | } |
|---|
| 5241 | #endif |
|---|
| 5242 | #if H_3D_ARP |
|---|
| 5243 | Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 5244 | { |
|---|
| 5245 | assert( sizeof( *m_puhARPW) == 1 ); |
|---|
| 5246 | memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
|---|
| 5247 | } |
|---|
| 5248 | #endif |
|---|
| 5249 | |
|---|
| 5250 | #if H_3D_IC |
|---|
| 5251 | Void TComDataCU::setICFlagSubParts( Bool bICFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 5252 | { |
|---|
| 5253 | memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ))*sizeof(Bool) ); |
|---|
| 5254 | } |
|---|
| 5255 | |
|---|
| 5256 | Bool TComDataCU::isICFlagRequired( UInt uiAbsPartIdx ) |
|---|
| 5257 | { |
|---|
| 5258 | UInt uiPartAddr; |
|---|
| 5259 | UInt iNumbPart; |
|---|
| 5260 | |
|---|
| 5261 | if( !( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ) |
|---|
| 5262 | { |
|---|
| 5263 | return false; |
|---|
| 5264 | } |
|---|
| 5265 | |
|---|
| 5266 | if( getSlice()->getIcSkipParseFlag() ) |
|---|
| 5267 | { |
|---|
| 5268 | if( getMergeFlag( uiAbsPartIdx ) && getMergeIndex( uiAbsPartIdx ) == 0 ) |
|---|
| 5269 | { |
|---|
| 5270 | return false; |
|---|
| 5271 | } |
|---|
| 5272 | } |
|---|
| 5273 | |
|---|
| 5274 | if( getMergeFlag( uiAbsPartIdx ) ) |
|---|
| 5275 | { |
|---|
| 5276 | return true; |
|---|
| 5277 | } |
|---|
| 5278 | |
|---|
| 5279 | |
|---|
| 5280 | Int iWidth, iHeight; |
|---|
| 5281 | |
|---|
| 5282 | iNumbPart = ( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ? 1 : ( getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 ) ); |
|---|
| 5283 | |
|---|
| 5284 | for(UInt i = 0; i < iNumbPart; i++) |
|---|
| 5285 | { |
|---|
| 5286 | getPartIndexAndSize( i, uiPartAddr, iWidth, iHeight, uiAbsPartIdx, true ); |
|---|
| 5287 | uiPartAddr += uiAbsPartIdx; |
|---|
| 5288 | |
|---|
| 5289 | for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++) |
|---|
| 5290 | { |
|---|
| 5291 | RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
|---|
| 5292 | Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr); |
|---|
| 5293 | |
|---|
| 5294 | if( ( getInterDir( uiPartAddr ) & ( uiRefIdx+1 ) ) && iBestRefIdx >= 0 && getSlice()->getViewIndex() != getSlice()->getRefPic( eRefList, iBestRefIdx )->getViewIndex() ) |
|---|
| 5295 | { |
|---|
| 5296 | return true; |
|---|
| 5297 | } |
|---|
| 5298 | } |
|---|
| 5299 | } |
|---|
| 5300 | |
|---|
| 5301 | return false; |
|---|
| 5302 | } |
|---|
| 5303 | #endif |
|---|
| 5304 | //! \} |
|---|