[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[872] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
[2] | 33 | |
---|
[56] | 34 | /** \file TEncCu.cpp |
---|
| 35 | \brief Coding Unit (CU) encoder class |
---|
[2] | 36 | */ |
---|
| 37 | |
---|
| 38 | #include <stdio.h> |
---|
| 39 | #include "TEncTop.h" |
---|
| 40 | #include "TEncCu.h" |
---|
| 41 | #include "TEncAnalyze.h" |
---|
| 42 | |
---|
[56] | 43 | #include <cmath> |
---|
| 44 | #include <algorithm> |
---|
| 45 | using namespace std; |
---|
| 46 | |
---|
| 47 | //! \ingroup TLibEncoder |
---|
| 48 | //! \{ |
---|
| 49 | |
---|
[2] | 50 | // ==================================================================================================================== |
---|
| 51 | // Constructor / destructor / create / destroy |
---|
| 52 | // ==================================================================================================================== |
---|
| 53 | |
---|
| 54 | /** |
---|
| 55 | \param uiTotalDepth total number of allowable depth |
---|
| 56 | \param uiMaxWidth largest CU width |
---|
| 57 | \param uiMaxHeight largest CU height |
---|
| 58 | */ |
---|
| 59 | Void TEncCu::create(UChar uhTotalDepth, UInt uiMaxWidth, UInt uiMaxHeight) |
---|
| 60 | { |
---|
| 61 | Int i; |
---|
[56] | 62 | |
---|
[2] | 63 | m_uhTotalDepth = uhTotalDepth + 1; |
---|
| 64 | m_ppcBestCU = new TComDataCU*[m_uhTotalDepth-1]; |
---|
| 65 | m_ppcTempCU = new TComDataCU*[m_uhTotalDepth-1]; |
---|
[608] | 66 | |
---|
| 67 | #if H_3D_ARP |
---|
[443] | 68 | m_ppcWeightedTempCU = new TComDataCU*[m_uhTotalDepth-1]; |
---|
| 69 | #endif |
---|
[608] | 70 | |
---|
[2] | 71 | m_ppcPredYuvBest = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 72 | m_ppcResiYuvBest = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 73 | m_ppcRecoYuvBest = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 74 | m_ppcPredYuvTemp = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 75 | m_ppcResiYuvTemp = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 76 | m_ppcRecoYuvTemp = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 77 | m_ppcOrigYuv = new TComYuv*[m_uhTotalDepth-1]; |
---|
[833] | 78 | #if H_3D_DBBP |
---|
| 79 | m_ppcOrigYuvDBBP = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 80 | #endif |
---|
[56] | 81 | |
---|
[2] | 82 | UInt uiNumPartitions; |
---|
| 83 | for( i=0 ; i<m_uhTotalDepth-1 ; i++) |
---|
| 84 | { |
---|
| 85 | uiNumPartitions = 1<<( ( m_uhTotalDepth - i - 1 )<<1 ); |
---|
| 86 | UInt uiWidth = uiMaxWidth >> i; |
---|
| 87 | UInt uiHeight = uiMaxHeight >> i; |
---|
[56] | 88 | |
---|
| 89 | m_ppcBestCU[i] = new TComDataCU; m_ppcBestCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); |
---|
| 90 | m_ppcTempCU[i] = new TComDataCU; m_ppcTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); |
---|
[608] | 91 | |
---|
| 92 | #if H_3D_ARP |
---|
[443] | 93 | m_ppcWeightedTempCU[i] = new TComDataCU; m_ppcWeightedTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); |
---|
[608] | 94 | #endif |
---|
| 95 | |
---|
[2] | 96 | m_ppcPredYuvBest[i] = new TComYuv; m_ppcPredYuvBest[i]->create(uiWidth, uiHeight); |
---|
| 97 | m_ppcResiYuvBest[i] = new TComYuv; m_ppcResiYuvBest[i]->create(uiWidth, uiHeight); |
---|
| 98 | m_ppcRecoYuvBest[i] = new TComYuv; m_ppcRecoYuvBest[i]->create(uiWidth, uiHeight); |
---|
[56] | 99 | |
---|
[2] | 100 | m_ppcPredYuvTemp[i] = new TComYuv; m_ppcPredYuvTemp[i]->create(uiWidth, uiHeight); |
---|
| 101 | m_ppcResiYuvTemp[i] = new TComYuv; m_ppcResiYuvTemp[i]->create(uiWidth, uiHeight); |
---|
| 102 | m_ppcRecoYuvTemp[i] = new TComYuv; m_ppcRecoYuvTemp[i]->create(uiWidth, uiHeight); |
---|
[56] | 103 | |
---|
[2] | 104 | m_ppcOrigYuv [i] = new TComYuv; m_ppcOrigYuv [i]->create(uiWidth, uiHeight); |
---|
[833] | 105 | #if H_3D_DBBP |
---|
| 106 | m_ppcOrigYuvDBBP[i] = new TComYuv; m_ppcOrigYuvDBBP[i]->create(uiWidth, uiHeight); |
---|
| 107 | #endif |
---|
[2] | 108 | } |
---|
[56] | 109 | |
---|
| 110 | m_bEncodeDQP = false; |
---|
[872] | 111 | #if KWU_RC_MADPRED_E0227 |
---|
[608] | 112 | m_LCUPredictionSAD = 0; |
---|
| 113 | m_addSADDepth = 0; |
---|
| 114 | m_temporalSAD = 0; |
---|
[655] | 115 | m_spatialSAD = 0; |
---|
| 116 | #endif |
---|
[2] | 117 | |
---|
| 118 | // initialize partition order. |
---|
| 119 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
| 120 | initZscanToRaster( m_uhTotalDepth, 1, 0, piTmp); |
---|
| 121 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); |
---|
[56] | 122 | |
---|
[2] | 123 | // initialize conversion matrix from partition index to pel |
---|
| 124 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | Void TEncCu::destroy() |
---|
| 128 | { |
---|
| 129 | Int i; |
---|
[56] | 130 | |
---|
[2] | 131 | for( i=0 ; i<m_uhTotalDepth-1 ; i++) |
---|
| 132 | { |
---|
| 133 | if(m_ppcBestCU[i]) |
---|
| 134 | { |
---|
| 135 | m_ppcBestCU[i]->destroy(); delete m_ppcBestCU[i]; m_ppcBestCU[i] = NULL; |
---|
| 136 | } |
---|
| 137 | if(m_ppcTempCU[i]) |
---|
| 138 | { |
---|
| 139 | m_ppcTempCU[i]->destroy(); delete m_ppcTempCU[i]; m_ppcTempCU[i] = NULL; |
---|
| 140 | } |
---|
[608] | 141 | #if H_3D_ARP |
---|
| 142 | if(m_ppcWeightedTempCU[i]) |
---|
| 143 | { |
---|
| 144 | m_ppcWeightedTempCU[i]->destroy(); delete m_ppcWeightedTempCU[i]; m_ppcWeightedTempCU[i] = NULL; |
---|
| 145 | } |
---|
| 146 | #endif |
---|
[2] | 147 | if(m_ppcPredYuvBest[i]) |
---|
| 148 | { |
---|
| 149 | m_ppcPredYuvBest[i]->destroy(); delete m_ppcPredYuvBest[i]; m_ppcPredYuvBest[i] = NULL; |
---|
| 150 | } |
---|
| 151 | if(m_ppcResiYuvBest[i]) |
---|
| 152 | { |
---|
| 153 | m_ppcResiYuvBest[i]->destroy(); delete m_ppcResiYuvBest[i]; m_ppcResiYuvBest[i] = NULL; |
---|
| 154 | } |
---|
| 155 | if(m_ppcRecoYuvBest[i]) |
---|
| 156 | { |
---|
| 157 | m_ppcRecoYuvBest[i]->destroy(); delete m_ppcRecoYuvBest[i]; m_ppcRecoYuvBest[i] = NULL; |
---|
| 158 | } |
---|
| 159 | if(m_ppcPredYuvTemp[i]) |
---|
| 160 | { |
---|
| 161 | m_ppcPredYuvTemp[i]->destroy(); delete m_ppcPredYuvTemp[i]; m_ppcPredYuvTemp[i] = NULL; |
---|
| 162 | } |
---|
| 163 | if(m_ppcResiYuvTemp[i]) |
---|
| 164 | { |
---|
| 165 | m_ppcResiYuvTemp[i]->destroy(); delete m_ppcResiYuvTemp[i]; m_ppcResiYuvTemp[i] = NULL; |
---|
| 166 | } |
---|
| 167 | if(m_ppcRecoYuvTemp[i]) |
---|
| 168 | { |
---|
| 169 | m_ppcRecoYuvTemp[i]->destroy(); delete m_ppcRecoYuvTemp[i]; m_ppcRecoYuvTemp[i] = NULL; |
---|
| 170 | } |
---|
| 171 | if(m_ppcOrigYuv[i]) |
---|
| 172 | { |
---|
| 173 | m_ppcOrigYuv[i]->destroy(); delete m_ppcOrigYuv[i]; m_ppcOrigYuv[i] = NULL; |
---|
| 174 | } |
---|
[833] | 175 | #if H_3D_DBBP |
---|
| 176 | if(m_ppcOrigYuvDBBP[i]) |
---|
| 177 | { |
---|
| 178 | m_ppcOrigYuvDBBP[i]->destroy(); delete m_ppcOrigYuvDBBP[i]; m_ppcOrigYuvDBBP[i] = NULL; |
---|
| 179 | } |
---|
| 180 | #endif |
---|
[2] | 181 | } |
---|
| 182 | if(m_ppcBestCU) |
---|
| 183 | { |
---|
| 184 | delete [] m_ppcBestCU; |
---|
| 185 | m_ppcBestCU = NULL; |
---|
| 186 | } |
---|
| 187 | if(m_ppcTempCU) |
---|
| 188 | { |
---|
| 189 | delete [] m_ppcTempCU; |
---|
| 190 | m_ppcTempCU = NULL; |
---|
| 191 | } |
---|
[608] | 192 | |
---|
| 193 | #if H_3D_ARP |
---|
| 194 | if(m_ppcWeightedTempCU) |
---|
| 195 | { |
---|
| 196 | delete [] m_ppcWeightedTempCU; |
---|
| 197 | m_ppcWeightedTempCU = NULL; |
---|
| 198 | } |
---|
| 199 | #endif |
---|
[2] | 200 | if(m_ppcPredYuvBest) |
---|
| 201 | { |
---|
| 202 | delete [] m_ppcPredYuvBest; |
---|
| 203 | m_ppcPredYuvBest = NULL; |
---|
| 204 | } |
---|
| 205 | if(m_ppcResiYuvBest) |
---|
| 206 | { |
---|
| 207 | delete [] m_ppcResiYuvBest; |
---|
| 208 | m_ppcResiYuvBest = NULL; |
---|
| 209 | } |
---|
| 210 | if(m_ppcRecoYuvBest) |
---|
| 211 | { |
---|
| 212 | delete [] m_ppcRecoYuvBest; |
---|
| 213 | m_ppcRecoYuvBest = NULL; |
---|
| 214 | } |
---|
| 215 | if(m_ppcPredYuvTemp) |
---|
| 216 | { |
---|
| 217 | delete [] m_ppcPredYuvTemp; |
---|
| 218 | m_ppcPredYuvTemp = NULL; |
---|
| 219 | } |
---|
| 220 | if(m_ppcResiYuvTemp) |
---|
| 221 | { |
---|
| 222 | delete [] m_ppcResiYuvTemp; |
---|
| 223 | m_ppcResiYuvTemp = NULL; |
---|
| 224 | } |
---|
| 225 | if(m_ppcRecoYuvTemp) |
---|
| 226 | { |
---|
| 227 | delete [] m_ppcRecoYuvTemp; |
---|
| 228 | m_ppcRecoYuvTemp = NULL; |
---|
| 229 | } |
---|
| 230 | if(m_ppcOrigYuv) |
---|
| 231 | { |
---|
| 232 | delete [] m_ppcOrigYuv; |
---|
| 233 | m_ppcOrigYuv = NULL; |
---|
| 234 | } |
---|
[833] | 235 | #if H_3D_DBBP |
---|
| 236 | if(m_ppcOrigYuvDBBP) |
---|
| 237 | { |
---|
| 238 | delete [] m_ppcOrigYuvDBBP; |
---|
| 239 | m_ppcOrigYuvDBBP = NULL; |
---|
| 240 | } |
---|
| 241 | #endif |
---|
[2] | 242 | } |
---|
| 243 | |
---|
| 244 | /** \param pcEncTop pointer of encoder class |
---|
| 245 | */ |
---|
| 246 | Void TEncCu::init( TEncTop* pcEncTop ) |
---|
| 247 | { |
---|
| 248 | m_pcEncCfg = pcEncTop; |
---|
| 249 | m_pcPredSearch = pcEncTop->getPredSearch(); |
---|
| 250 | m_pcTrQuant = pcEncTop->getTrQuant(); |
---|
| 251 | m_pcBitCounter = pcEncTop->getBitCounter(); |
---|
| 252 | m_pcRdCost = pcEncTop->getRdCost(); |
---|
[56] | 253 | |
---|
[2] | 254 | m_pcEntropyCoder = pcEncTop->getEntropyCoder(); |
---|
| 255 | m_pcCavlcCoder = pcEncTop->getCavlcCoder(); |
---|
| 256 | m_pcSbacCoder = pcEncTop->getSbacCoder(); |
---|
| 257 | m_pcBinCABAC = pcEncTop->getBinCABAC(); |
---|
[56] | 258 | |
---|
[2] | 259 | m_pppcRDSbacCoder = pcEncTop->getRDSbacCoder(); |
---|
| 260 | m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder(); |
---|
[56] | 261 | |
---|
[608] | 262 | m_pcRateCtrl = pcEncTop->getRateCtrl(); |
---|
[2] | 263 | } |
---|
| 264 | |
---|
| 265 | // ==================================================================================================================== |
---|
| 266 | // Public member functions |
---|
| 267 | // ==================================================================================================================== |
---|
| 268 | |
---|
| 269 | /** \param rpcCU pointer of CU data class |
---|
| 270 | */ |
---|
| 271 | Void TEncCu::compressCU( TComDataCU*& rpcCU ) |
---|
| 272 | { |
---|
[56] | 273 | // initialize CU data |
---|
| 274 | m_ppcBestCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() ); |
---|
| 275 | m_ppcTempCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() ); |
---|
| 276 | |
---|
[655] | 277 | #if KWU_RC_MADPRED_E0227 |
---|
| 278 | m_LCUPredictionSAD = 0; |
---|
| 279 | m_addSADDepth = 0; |
---|
| 280 | m_temporalSAD = 0; |
---|
| 281 | m_spatialSAD = 0; |
---|
| 282 | #endif |
---|
[608] | 283 | |
---|
[56] | 284 | // analysis of CU |
---|
| 285 | xCompressCU( m_ppcBestCU[0], m_ppcTempCU[0], 0 ); |
---|
| 286 | |
---|
| 287 | #if ADAPTIVE_QP_SELECTION |
---|
| 288 | if( m_pcEncCfg->getUseAdaptQpSelect() ) |
---|
[2] | 289 | { |
---|
[56] | 290 | if(rpcCU->getSlice()->getSliceType()!=I_SLICE) //IIII |
---|
| 291 | { |
---|
| 292 | xLcuCollectARLStats( rpcCU); |
---|
| 293 | } |
---|
[2] | 294 | } |
---|
[56] | 295 | #endif |
---|
| 296 | } |
---|
[608] | 297 | /** \param pcCU pointer of CU data class |
---|
[56] | 298 | */ |
---|
[608] | 299 | Void TEncCu::encodeCU ( TComDataCU* pcCU ) |
---|
[56] | 300 | { |
---|
| 301 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 302 | { |
---|
[56] | 303 | setdQPFlag(true); |
---|
| 304 | } |
---|
[2] | 305 | |
---|
[56] | 306 | // Encode CU data |
---|
| 307 | xEncodeCU( pcCU, 0, 0 ); |
---|
[2] | 308 | } |
---|
| 309 | |
---|
[56] | 310 | // ==================================================================================================================== |
---|
| 311 | // Protected member functions |
---|
| 312 | // ==================================================================================================================== |
---|
| 313 | /** Derive small set of test modes for AMP encoder speed-up |
---|
| 314 | *\param rpcBestCU |
---|
| 315 | *\param eParentPartSize |
---|
| 316 | *\param bTestAMP_Hor |
---|
| 317 | *\param bTestAMP_Ver |
---|
| 318 | *\param bTestMergeAMP_Hor |
---|
| 319 | *\param bTestMergeAMP_Ver |
---|
| 320 | *\returns Void |
---|
| 321 | */ |
---|
| 322 | #if AMP_ENC_SPEEDUP |
---|
| 323 | #if AMP_MRG |
---|
| 324 | Void TEncCu::deriveTestModeAMP (TComDataCU *&rpcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver) |
---|
| 325 | #else |
---|
| 326 | Void TEncCu::deriveTestModeAMP (TComDataCU *&rpcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver) |
---|
| 327 | #endif |
---|
[2] | 328 | { |
---|
[56] | 329 | if ( rpcBestCU->getPartitionSize(0) == SIZE_2NxN ) |
---|
[2] | 330 | { |
---|
[56] | 331 | bTestAMP_Hor = true; |
---|
[2] | 332 | } |
---|
[56] | 333 | else if ( rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) |
---|
[2] | 334 | { |
---|
[56] | 335 | bTestAMP_Ver = true; |
---|
| 336 | } |
---|
| 337 | else if ( rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N && rpcBestCU->getMergeFlag(0) == false && rpcBestCU->isSkipped(0) == false ) |
---|
| 338 | { |
---|
| 339 | bTestAMP_Hor = true; |
---|
| 340 | bTestAMP_Ver = true; |
---|
| 341 | } |
---|
[2] | 342 | |
---|
[56] | 343 | #if AMP_MRG |
---|
| 344 | //! Utilizing the partition size of parent PU |
---|
| 345 | if ( eParentPartSize >= SIZE_2NxnU && eParentPartSize <= SIZE_nRx2N ) |
---|
| 346 | { |
---|
| 347 | bTestMergeAMP_Hor = true; |
---|
| 348 | bTestMergeAMP_Ver = true; |
---|
[2] | 349 | } |
---|
[56] | 350 | |
---|
| 351 | if ( eParentPartSize == SIZE_NONE ) //! if parent is intra |
---|
[2] | 352 | { |
---|
[56] | 353 | if ( rpcBestCU->getPartitionSize(0) == SIZE_2NxN ) |
---|
[2] | 354 | { |
---|
[56] | 355 | bTestMergeAMP_Hor = true; |
---|
[2] | 356 | } |
---|
[56] | 357 | else if ( rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) |
---|
[2] | 358 | { |
---|
[56] | 359 | bTestMergeAMP_Ver = true; |
---|
[2] | 360 | } |
---|
| 361 | } |
---|
| 362 | |
---|
[56] | 363 | if ( rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N && rpcBestCU->isSkipped(0) == false ) |
---|
| 364 | { |
---|
| 365 | bTestMergeAMP_Hor = true; |
---|
| 366 | bTestMergeAMP_Ver = true; |
---|
| 367 | } |
---|
[2] | 368 | |
---|
[56] | 369 | if ( rpcBestCU->getWidth(0) == 64 ) |
---|
| 370 | { |
---|
| 371 | bTestAMP_Hor = false; |
---|
| 372 | bTestAMP_Ver = false; |
---|
| 373 | } |
---|
| 374 | #else |
---|
| 375 | //! Utilizing the partition size of parent PU |
---|
| 376 | if ( eParentPartSize >= SIZE_2NxnU && eParentPartSize <= SIZE_nRx2N ) |
---|
| 377 | { |
---|
| 378 | bTestAMP_Hor = true; |
---|
| 379 | bTestAMP_Ver = true; |
---|
| 380 | } |
---|
[2] | 381 | |
---|
[56] | 382 | if ( eParentPartSize == SIZE_2Nx2N ) |
---|
| 383 | { |
---|
| 384 | bTestAMP_Hor = false; |
---|
| 385 | bTestAMP_Ver = false; |
---|
| 386 | } |
---|
| 387 | #endif |
---|
[2] | 388 | } |
---|
[56] | 389 | #endif |
---|
[2] | 390 | |
---|
| 391 | // ==================================================================================================================== |
---|
| 392 | // Protected member functions |
---|
| 393 | // ==================================================================================================================== |
---|
[56] | 394 | /** Compress a CU block recursively with enabling sub-LCU-level delta QP |
---|
| 395 | *\param rpcBestCU |
---|
| 396 | *\param rpcTempCU |
---|
| 397 | *\param uiDepth |
---|
| 398 | *\returns Void |
---|
| 399 | * |
---|
| 400 | *- for loop of QP value to compress the current CU with all possible QP |
---|
| 401 | */ |
---|
| 402 | #if AMP_ENC_SPEEDUP |
---|
| 403 | Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth, PartSize eParentPartSize ) |
---|
| 404 | #else |
---|
[2] | 405 | Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth ) |
---|
[56] | 406 | #endif |
---|
[2] | 407 | { |
---|
| 408 | TComPic* pcPic = rpcBestCU->getPic(); |
---|
| 409 | |
---|
[608] | 410 | #if H_3D_QTLPC |
---|
[1039] | 411 | TComVPS *vps = pcPic->getSlice(0)->getVPS(); |
---|
| 412 | Bool bLimQtPredFalg = vps->getLimQtPredFlag(pcPic->getSlice(0)->getLayerId()); |
---|
[608] | 413 | TComPic *pcTexture = rpcBestCU->getSlice()->getTexturePic(); |
---|
[189] | 414 | |
---|
| 415 | Bool depthMapDetect = (pcTexture != NULL); |
---|
| 416 | Bool bIntraSliceDetect = (rpcBestCU->getSlice()->getSliceType() == I_SLICE); |
---|
| 417 | |
---|
[608] | 418 | Bool rapPic = (rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || rpcBestCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA); |
---|
[296] | 419 | |
---|
[608] | 420 | Bool bTry2NxN = true; |
---|
| 421 | Bool bTryNx2N = true; |
---|
[115] | 422 | #endif |
---|
[2] | 423 | // get Original YUV data from picture |
---|
| 424 | m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); |
---|
| 425 | |
---|
[655] | 426 | #if H_3D_QTLPC |
---|
| 427 | Bool bTrySplit = true; |
---|
| 428 | Bool bTrySplitDQP = true; |
---|
| 429 | #endif |
---|
[2] | 430 | |
---|
[56] | 431 | // variable for Early CU determination |
---|
| 432 | Bool bSubBranch = true; |
---|
| 433 | |
---|
| 434 | // variable for Cbf fast mode PU decision |
---|
| 435 | Bool doNotBlockPu = true; |
---|
[608] | 436 | Bool earlyDetectionSkipMode = false; |
---|
[56] | 437 | |
---|
[622] | 438 | #if H_3D_VSP |
---|
[608] | 439 | DisInfo DvInfo; |
---|
| 440 | DvInfo.bDV = false; |
---|
| 441 | DvInfo.m_acNBDV.setZero(); |
---|
| 442 | DvInfo.m_aVIdxCan = 0; |
---|
| 443 | #if H_3D_NBDV_REF |
---|
| 444 | DvInfo.m_acDoNBDV.setZero(); |
---|
| 445 | #endif |
---|
| 446 | #endif |
---|
[2] | 447 | Bool bBoundary = false; |
---|
| 448 | UInt uiLPelX = rpcBestCU->getCUPelX(); |
---|
| 449 | UInt uiRPelX = uiLPelX + rpcBestCU->getWidth(0) - 1; |
---|
| 450 | UInt uiTPelY = rpcBestCU->getCUPelY(); |
---|
| 451 | UInt uiBPelY = uiTPelY + rpcBestCU->getHeight(0) - 1; |
---|
| 452 | |
---|
[872] | 453 | #if H_MV_ENC_DEC_TRAC |
---|
| 454 | #if ENC_DEC_TRACE |
---|
| 455 | stopAtPos ( rpcBestCU->getSlice()->getPOC(), |
---|
| 456 | rpcBestCU->getSlice()->getLayerId(), |
---|
| 457 | rpcBestCU->getCUPelX(), |
---|
| 458 | rpcBestCU->getCUPelY(), |
---|
| 459 | rpcBestCU->getWidth(0), |
---|
| 460 | rpcBestCU->getHeight(0) ); |
---|
| 461 | #endif |
---|
| 462 | #endif |
---|
| 463 | |
---|
[56] | 464 | Int iBaseQP = xComputeQP( rpcBestCU, uiDepth ); |
---|
| 465 | Int iMinQP; |
---|
| 466 | Int iMaxQP; |
---|
| 467 | Bool isAddLowestQP = false; |
---|
| 468 | |
---|
| 469 | if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
[2] | 470 | { |
---|
[56] | 471 | Int idQP = m_pcEncCfg->getMaxDeltaQP(); |
---|
| 472 | iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); |
---|
| 473 | iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); |
---|
| 474 | } |
---|
| 475 | else |
---|
| 476 | { |
---|
| 477 | iMinQP = rpcTempCU->getQP(0); |
---|
| 478 | iMaxQP = rpcTempCU->getQP(0); |
---|
| 479 | } |
---|
| 480 | |
---|
[608] | 481 | if ( m_pcEncCfg->getUseRateCtrl() ) |
---|
| 482 | { |
---|
| 483 | iMinQP = m_pcRateCtrl->getRCQP(); |
---|
| 484 | iMaxQP = m_pcRateCtrl->getRCQP(); |
---|
| 485 | } |
---|
[872] | 486 | // transquant-bypass (TQB) processing loop variable initialisation --- |
---|
| 487 | |
---|
| 488 | const Int lowestQP = iMinQP; // For TQB, use this QP which is the lowest non TQB QP tested (rather than QP'=0) - that way delta QPs are smaller, and TQB can be tested at all CU levels. |
---|
| 489 | |
---|
| 490 | if ( (rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) ) |
---|
[608] | 491 | { |
---|
[872] | 492 | isAddLowestQP = true; // mark that the first iteration is to cost TQB mode. |
---|
| 493 | iMinQP = iMinQP - 1; // increase loop variable range by 1, to allow testing of TQB mode along with other QPs |
---|
| 494 | if ( m_pcEncCfg->getCUTransquantBypassFlagForceValue() ) |
---|
| 495 | { |
---|
| 496 | iMaxQP = iMinQP; |
---|
| 497 | } |
---|
[608] | 498 | } |
---|
[872] | 499 | |
---|
[608] | 500 | #if H_3D_IC |
---|
[724] | 501 | Bool bICEnabled = rpcTempCU->getSlice()->getViewIndex() && ( rpcTempCU->getSlice()->getSliceType() == P_SLICE || rpcTempCU->getSlice()->getSliceType() == B_SLICE ) && !rpcTempCU->getSlice()->getIsDepth(); |
---|
[608] | 502 | bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC(); |
---|
| 503 | #endif |
---|
[56] | 504 | // If slice start or slice end is within this cu... |
---|
| 505 | TComSlice * pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx()); |
---|
[608] | 506 | Bool bSliceStart = pcSlice->getSliceSegmentCurStartCUAddr()>rpcTempCU->getSCUAddr()&&pcSlice->getSliceSegmentCurStartCUAddr()<rpcTempCU->getSCUAddr()+rpcTempCU->getTotalNumPart(); |
---|
| 507 | Bool bSliceEnd = (pcSlice->getSliceSegmentCurEndCUAddr()>rpcTempCU->getSCUAddr()&&pcSlice->getSliceSegmentCurEndCUAddr()<rpcTempCU->getSCUAddr()+rpcTempCU->getTotalNumPart()); |
---|
[56] | 508 | Bool bInsidePicture = ( uiRPelX < rpcBestCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < rpcBestCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); |
---|
| 509 | // We need to split, so don't try these modes. |
---|
| 510 | if(!bSliceEnd && !bSliceStart && bInsidePicture ) |
---|
| 511 | { |
---|
[655] | 512 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 513 | Bool bIVFMerge = false; |
---|
| 514 | Int iIVFMaxD = 0; |
---|
| 515 | Bool bFMD = false; |
---|
| 516 | #endif |
---|
[56] | 517 | for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) |
---|
| 518 | { |
---|
[872] | 519 | const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP); |
---|
| 520 | |
---|
| 521 | if (bIsLosslessMode) |
---|
[2] | 522 | { |
---|
[56] | 523 | iQP = lowestQP; |
---|
[2] | 524 | } |
---|
[872] | 525 | |
---|
[655] | 526 | #if H_3D_QTLPC |
---|
[608] | 527 | bTrySplit = true; |
---|
[655] | 528 | #endif |
---|
[2] | 529 | |
---|
[872] | 530 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[608] | 531 | #if H_3D_QTLPC |
---|
[116] | 532 | //logic for setting bTrySplit using the partition information that is stored of the texture colocated CU |
---|
[1084] | 533 | #if H_3D_FCO |
---|
[1066] | 534 | if(depthMapDetect && !bIntraSliceDetect && !rapPic && ( m_pcEncCfg->getUseQTL() || bLimQtPredFalg ) && pcTexture->getReconMark()) |
---|
| 535 | #else |
---|
[1039] | 536 | if(depthMapDetect && !bIntraSliceDetect && !rapPic && ( m_pcEncCfg->getUseQTL() || bLimQtPredFalg )) |
---|
[1066] | 537 | #endif |
---|
[116] | 538 | { |
---|
[189] | 539 | TComDataCU* pcTextureCU = pcTexture->getCU( rpcBestCU->getAddr() ); //Corresponding texture LCU |
---|
| 540 | UInt uiCUIdx = rpcBestCU->getZorderIdxInCU(); |
---|
| 541 | assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); //Depth cannot be more partitionned than the texture. |
---|
| 542 | if (pcTextureCU->getDepth(uiCUIdx) > uiDepth || pcTextureCU->getPartitionSize(uiCUIdx) == SIZE_NxN) //Texture was split. |
---|
[116] | 543 | { |
---|
| 544 | bTrySplit = true; |
---|
[189] | 545 | bTryNx2N = true; |
---|
| 546 | bTry2NxN = true; |
---|
[116] | 547 | } |
---|
[189] | 548 | else |
---|
[116] | 549 | { |
---|
| 550 | bTrySplit = false; |
---|
[189] | 551 | bTryNx2N = false; |
---|
| 552 | bTry2NxN = false; |
---|
[833] | 553 | if( pcTextureCU->getDepth(uiCUIdx) == uiDepth && pcTextureCU->getPartitionSize(uiCUIdx) != SIZE_2Nx2N) |
---|
| 554 | { |
---|
| 555 | if(pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxN || pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxnU|| pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxnD) |
---|
| 556 | bTry2NxN = true; |
---|
| 557 | else |
---|
| 558 | bTryNx2N = true; |
---|
| 559 | } |
---|
[116] | 560 | } |
---|
| 561 | } |
---|
[115] | 562 | #endif |
---|
[608] | 563 | |
---|
| 564 | #if H_3D_NBDV |
---|
[443] | 565 | if( rpcTempCU->getSlice()->getSliceType() != I_SLICE ) |
---|
| 566 | { |
---|
[608] | 567 | #if H_3D_ARP && H_3D_IV_MERGE |
---|
| 568 | if( rpcTempCU->getSlice()->getVPS()->getUseAdvRP(rpcTempCU->getSlice()->getLayerId()) || rpcTempCU->getSlice()->getVPS()->getIvMvPredFlag(rpcTempCU->getSlice()->getLayerId()) ) |
---|
| 569 | #else |
---|
| 570 | #if H_3D_ARP |
---|
| 571 | if( rpcTempCU->getSlice()->getVPS()->getUseAdvRP(rpcTempCU->getSlice()->getLayerId()) ) |
---|
[443] | 572 | #else |
---|
[608] | 573 | #if H_3D_IV_MERGE |
---|
| 574 | if( rpcTempCU->getSlice()->getVPS()->getIvMvPredFlag(rpcTempCU->getSlice()->getLayerId()) ) |
---|
| 575 | #else |
---|
| 576 | if (0) |
---|
[443] | 577 | #endif |
---|
[608] | 578 | #endif |
---|
| 579 | #endif |
---|
| 580 | { |
---|
[443] | 581 | PartSize ePartTemp = rpcTempCU->getPartitionSize(0); |
---|
| 582 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
[773] | 583 | #if H_3D_IV_MERGE |
---|
[724] | 584 | if (rpcTempCU->getSlice()->getIsDepth() ) |
---|
| 585 | { |
---|
[833] | 586 | DvInfo.bDV = rpcTempCU->getDispforDepth(0, 0, &DvInfo); |
---|
[724] | 587 | } |
---|
| 588 | else |
---|
| 589 | { |
---|
| 590 | #endif |
---|
[608] | 591 | #if H_3D_NBDV_REF |
---|
| 592 | if(rpcTempCU->getSlice()->getVPS()->getDepthRefinementFlag( rpcTempCU->getSlice()->getLayerIdInVps())) |
---|
| 593 | DvInfo.bDV = rpcTempCU->getDisMvpCandNBDV(&DvInfo, true); |
---|
| 594 | else |
---|
| 595 | #endif |
---|
| 596 | DvInfo.bDV = rpcTempCU->getDisMvpCandNBDV(&DvInfo); |
---|
| 597 | |
---|
[773] | 598 | #if H_3D_IV_MERGE |
---|
[724] | 599 | } |
---|
| 600 | #endif |
---|
[443] | 601 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 602 | rpcBestCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 603 | rpcTempCU->setPartSizeSubParts( ePartTemp, 0, uiDepth ); |
---|
| 604 | } |
---|
[608] | 605 | } |
---|
[655] | 606 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 607 | if(rpcTempCU->getSlice()->getViewIndex() && !rpcTempCU->getSlice()->getIsDepth()) |
---|
| 608 | { |
---|
| 609 | PartSize ePartTemp = rpcTempCU->getPartitionSize(0); |
---|
| 610 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 611 | rpcTempCU->getIVNStatus( 0, &DvInfo, bIVFMerge, iIVFMaxD); |
---|
| 612 | rpcTempCU->setPartSizeSubParts( ePartTemp, 0, uiDepth ); |
---|
| 613 | } |
---|
[443] | 614 | #endif |
---|
| 615 | #endif |
---|
[56] | 616 | // do inter modes, SKIP and 2Nx2N |
---|
| 617 | if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) |
---|
[2] | 618 | { |
---|
[608] | 619 | #if H_3D_IC |
---|
| 620 | for( UInt uiICId = 0; uiICId < ( bICEnabled ? 2 : 1 ); uiICId++ ) |
---|
[443] | 621 | { |
---|
[608] | 622 | Bool bICFlag = uiICId ? true : false; |
---|
[443] | 623 | #endif |
---|
[608] | 624 | // 2Nx2N |
---|
| 625 | if(m_pcEncCfg->getUseEarlySkipDetection()) |
---|
[56] | 626 | { |
---|
[608] | 627 | #if H_3D_IC |
---|
| 628 | rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); |
---|
[56] | 629 | #endif |
---|
[655] | 630 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[872] | 631 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD ); rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N |
---|
[608] | 632 | #else |
---|
[872] | 633 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); |
---|
| 634 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N |
---|
[189] | 635 | #endif |
---|
[622] | 636 | #if H_3D_VSP |
---|
[608] | 637 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
[5] | 638 | #endif |
---|
[608] | 639 | } |
---|
| 640 | // SKIP |
---|
| 641 | #if H_3D_IC |
---|
| 642 | rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); |
---|
[2] | 643 | #endif |
---|
[608] | 644 | xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N |
---|
[655] | 645 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 646 | bFMD = bIVFMerge && rpcBestCU->isSkipped(0); |
---|
| 647 | #endif |
---|
[872] | 648 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 649 | #if H_3D_VSP |
---|
[608] | 650 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 651 | #endif |
---|
| 652 | |
---|
| 653 | if(!m_pcEncCfg->getUseEarlySkipDetection()) |
---|
| 654 | { |
---|
[116] | 655 | // 2Nx2N, NxN |
---|
[608] | 656 | #if H_3D_IC |
---|
[296] | 657 | rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); |
---|
| 658 | #endif |
---|
[655] | 659 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[872] | 660 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD ); rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[2] | 661 | #else |
---|
[872] | 662 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); |
---|
| 663 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[2] | 664 | #endif |
---|
[622] | 665 | #if H_3D_VSP |
---|
[608] | 666 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 667 | #endif |
---|
[833] | 668 | |
---|
| 669 | #if H_3D_DBBP |
---|
| 670 | if( m_pcEncCfg->getUseDBBP() ) |
---|
| 671 | { |
---|
| 672 | xCheckRDCostInterDBBP( rpcBestCU, rpcTempCU, false ); |
---|
[872] | 673 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[833] | 674 | #if H_3D_VSP |
---|
| 675 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 676 | #endif |
---|
| 677 | } |
---|
| 678 | #endif |
---|
| 679 | |
---|
[116] | 680 | if(m_pcEncCfg->getUseCbfFastMode()) |
---|
| 681 | { |
---|
| 682 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 683 | } |
---|
[608] | 684 | } |
---|
| 685 | #if H_3D_IC |
---|
| 686 | } |
---|
[189] | 687 | #endif |
---|
[608] | 688 | } |
---|
[56] | 689 | |
---|
[655] | 690 | #if H_3D_QTLPC |
---|
[1039] | 691 | if(depthMapDetect && !bIntraSliceDetect && !rapPic && ( m_pcEncCfg->getUseQTL() || bLimQtPredFalg )) |
---|
[116] | 692 | { |
---|
| 693 | bTrySplitDQP = bTrySplit; |
---|
| 694 | } |
---|
[189] | 695 | #endif |
---|
[872] | 696 | if ( bIsLosslessMode ) |
---|
[56] | 697 | { |
---|
| 698 | iQP = iMinQP; |
---|
| 699 | } |
---|
[608] | 700 | } |
---|
| 701 | |
---|
[872] | 702 | #if KWU_RC_MADPRED_E0227 |
---|
[608] | 703 | if ( uiDepth <= m_addSADDepth ) |
---|
| 704 | { |
---|
| 705 | m_LCUPredictionSAD += m_temporalSAD; |
---|
| 706 | m_addSADDepth = uiDepth; |
---|
| 707 | } |
---|
[5] | 708 | #endif |
---|
[608] | 709 | #if H_3D_DIM_ENC |
---|
| 710 | if( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() ) |
---|
[56] | 711 | { |
---|
[608] | 712 | earlyDetectionSkipMode = false; |
---|
| 713 | } |
---|
[56] | 714 | #endif |
---|
[1084] | 715 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 716 | rpcTempCU->initEstData( uiDepth, iMinQP, isAddLowestQP ); |
---|
| 717 | if(rpcBestCU->getSlice()->getApplySingleDepthMode()) |
---|
| 718 | { |
---|
| 719 | xCheckRDCostSingleDepth( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); |
---|
| 720 | rpcTempCU->initEstData( uiDepth, iMinQP, isAddLowestQP ); |
---|
| 721 | } |
---|
| 722 | #endif |
---|
[608] | 723 | if(!earlyDetectionSkipMode) |
---|
| 724 | { |
---|
| 725 | for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) |
---|
[2] | 726 | { |
---|
[872] | 727 | const Bool bIsLosslessMode = isAddLowestQP && (iQP == iMinQP); |
---|
| 728 | |
---|
| 729 | if (bIsLosslessMode) |
---|
[443] | 730 | { |
---|
[608] | 731 | iQP = lowestQP; |
---|
[443] | 732 | } |
---|
[872] | 733 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[608] | 734 | |
---|
| 735 | // do inter modes, NxN, 2NxN, and Nx2N |
---|
| 736 | if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) |
---|
[2] | 737 | { |
---|
[116] | 738 | // 2Nx2N, NxN |
---|
[608] | 739 | if(!( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) )) |
---|
[116] | 740 | { |
---|
[608] | 741 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu |
---|
| 742 | #if H_3D_QTLPC |
---|
| 743 | && bTrySplit |
---|
| 744 | #endif |
---|
| 745 | ) |
---|
[116] | 746 | { |
---|
[655] | 747 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 748 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN, bFMD ); |
---|
[115] | 749 | #else |
---|
[608] | 750 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); |
---|
[115] | 751 | #endif |
---|
[872] | 752 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 753 | #if H_3D_VSP |
---|
[608] | 754 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
[116] | 755 | #endif |
---|
[608] | 756 | } |
---|
[116] | 757 | } |
---|
[56] | 758 | |
---|
[608] | 759 | // 2NxN, Nx2N |
---|
| 760 | if(doNotBlockPu |
---|
| 761 | #if H_3D_QTLPC |
---|
| 762 | && bTryNx2N |
---|
[115] | 763 | #endif |
---|
[608] | 764 | ) |
---|
| 765 | { |
---|
[655] | 766 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 767 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N, bFMD ); |
---|
[115] | 768 | #else |
---|
[608] | 769 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N ); |
---|
[115] | 770 | #endif |
---|
[872] | 771 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 772 | #if H_3D_VSP |
---|
[608] | 773 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
[115] | 774 | #endif |
---|
[608] | 775 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) |
---|
[116] | 776 | { |
---|
[608] | 777 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 778 | } |
---|
| 779 | } |
---|
| 780 | if(doNotBlockPu |
---|
| 781 | #if H_3D_QTLPC |
---|
| 782 | && bTry2NxN |
---|
[115] | 783 | #endif |
---|
[608] | 784 | ) |
---|
| 785 | { |
---|
[655] | 786 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 787 | xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN, bFMD ); |
---|
| 788 | #else |
---|
| 789 | xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN ); |
---|
[115] | 790 | #endif |
---|
[872] | 791 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 792 | #if H_3D_VSP |
---|
[608] | 793 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
[296] | 794 | #endif |
---|
[608] | 795 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN) |
---|
| 796 | { |
---|
| 797 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
[115] | 798 | } |
---|
| 799 | } |
---|
[56] | 800 | |
---|
| 801 | #if 1 |
---|
[116] | 802 | //! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N) |
---|
| 803 | if( pcPic->getSlice(0)->getSPS()->getAMPAcc(uiDepth) ) |
---|
| 804 | { |
---|
[56] | 805 | #if AMP_ENC_SPEEDUP |
---|
[116] | 806 | Bool bTestAMP_Hor = false, bTestAMP_Ver = false; |
---|
[56] | 807 | |
---|
| 808 | #if AMP_MRG |
---|
[116] | 809 | Bool bTestMergeAMP_Hor = false, bTestMergeAMP_Ver = false; |
---|
[56] | 810 | |
---|
[116] | 811 | deriveTestModeAMP (rpcBestCU, eParentPartSize, bTestAMP_Hor, bTestAMP_Ver, bTestMergeAMP_Hor, bTestMergeAMP_Ver); |
---|
[2] | 812 | #else |
---|
[116] | 813 | deriveTestModeAMP (rpcBestCU, eParentPartSize, bTestAMP_Hor, bTestAMP_Ver); |
---|
[56] | 814 | #endif |
---|
| 815 | |
---|
[116] | 816 | //! Do horizontal AMP |
---|
| 817 | if ( bTestAMP_Hor ) |
---|
| 818 | { |
---|
[608] | 819 | if(doNotBlockPu |
---|
| 820 | #if H_3D_QTLPC |
---|
| 821 | && bTry2NxN |
---|
| 822 | #endif |
---|
| 823 | ) |
---|
[116] | 824 | { |
---|
[655] | 825 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 826 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFMD ); |
---|
| 827 | #else |
---|
| 828 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); |
---|
[115] | 829 | #endif |
---|
[872] | 830 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 831 | #if H_3D_VSP |
---|
[608] | 832 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 833 | #endif |
---|
| 834 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) |
---|
[116] | 835 | { |
---|
[608] | 836 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 837 | } |
---|
| 838 | } |
---|
| 839 | if(doNotBlockPu |
---|
| 840 | #if H_3D_QTLPC |
---|
| 841 | && bTry2NxN |
---|
[115] | 842 | #endif |
---|
[608] | 843 | ) |
---|
| 844 | { |
---|
[655] | 845 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 846 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFMD ); |
---|
[115] | 847 | #else |
---|
[608] | 848 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); |
---|
[115] | 849 | #endif |
---|
[872] | 850 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 851 | #if H_3D_VSP |
---|
[608] | 852 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 853 | #endif |
---|
| 854 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) |
---|
[116] | 855 | { |
---|
[608] | 856 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
[116] | 857 | } |
---|
[115] | 858 | } |
---|
| 859 | } |
---|
[56] | 860 | #if AMP_MRG |
---|
[116] | 861 | else if ( bTestMergeAMP_Hor ) |
---|
| 862 | { |
---|
[608] | 863 | if(doNotBlockPu |
---|
| 864 | #if H_3D_QTLPC |
---|
| 865 | && bTry2NxN |
---|
| 866 | #endif |
---|
| 867 | ) |
---|
[116] | 868 | { |
---|
[655] | 869 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 870 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFMD, true ); |
---|
| 871 | #else |
---|
| 872 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true ); |
---|
[115] | 873 | #endif |
---|
[872] | 874 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 875 | #if H_3D_VSP |
---|
[608] | 876 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 877 | #endif |
---|
| 878 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) |
---|
[116] | 879 | { |
---|
[608] | 880 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 881 | } |
---|
| 882 | } |
---|
| 883 | if(doNotBlockPu |
---|
| 884 | #if H_3D_QTLPC |
---|
| 885 | && bTry2NxN |
---|
[115] | 886 | #endif |
---|
[608] | 887 | ) |
---|
| 888 | { |
---|
[655] | 889 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 890 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFMD, true ); |
---|
[115] | 891 | #else |
---|
[608] | 892 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true ); |
---|
[115] | 893 | #endif |
---|
[872] | 894 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 895 | #if H_3D_VSP |
---|
[608] | 896 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 897 | #endif |
---|
| 898 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) |
---|
[116] | 899 | { |
---|
[608] | 900 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
[116] | 901 | } |
---|
[115] | 902 | } |
---|
| 903 | } |
---|
| 904 | #endif |
---|
[2] | 905 | |
---|
[116] | 906 | //! Do horizontal AMP |
---|
| 907 | if ( bTestAMP_Ver ) |
---|
| 908 | { |
---|
[608] | 909 | if(doNotBlockPu |
---|
| 910 | #if H_3D_QTLPC |
---|
| 911 | && bTryNx2N |
---|
| 912 | #endif |
---|
| 913 | ) |
---|
[116] | 914 | { |
---|
[655] | 915 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 916 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFMD ); |
---|
| 917 | #else |
---|
| 918 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); |
---|
[115] | 919 | #endif |
---|
[872] | 920 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 921 | #if H_3D_VSP |
---|
[608] | 922 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 923 | #endif |
---|
| 924 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) |
---|
[116] | 925 | { |
---|
[608] | 926 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 927 | } |
---|
| 928 | } |
---|
| 929 | if(doNotBlockPu |
---|
| 930 | #if H_3D_QTLPC |
---|
| 931 | && bTryNx2N |
---|
[115] | 932 | #endif |
---|
[608] | 933 | ) |
---|
| 934 | { |
---|
[655] | 935 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 936 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFMD ); |
---|
[115] | 937 | #else |
---|
[608] | 938 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); |
---|
[115] | 939 | #endif |
---|
[872] | 940 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 941 | #if H_3D_VSP |
---|
[608] | 942 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
[115] | 943 | #endif |
---|
[116] | 944 | } |
---|
[115] | 945 | } |
---|
[56] | 946 | #if AMP_MRG |
---|
[116] | 947 | else if ( bTestMergeAMP_Ver ) |
---|
| 948 | { |
---|
[608] | 949 | if(doNotBlockPu |
---|
| 950 | #if H_3D_QTLPC |
---|
| 951 | && bTryNx2N |
---|
| 952 | #endif |
---|
| 953 | ) |
---|
[116] | 954 | { |
---|
[655] | 955 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 956 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFMD, true ); |
---|
| 957 | #else |
---|
| 958 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true ); |
---|
[115] | 959 | #endif |
---|
[872] | 960 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 961 | #if H_3D_VSP |
---|
[608] | 962 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
| 963 | #endif |
---|
| 964 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) |
---|
[116] | 965 | { |
---|
[608] | 966 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 967 | } |
---|
| 968 | } |
---|
| 969 | if(doNotBlockPu |
---|
| 970 | #if H_3D_QTLPC |
---|
| 971 | && bTryNx2N |
---|
[115] | 972 | #endif |
---|
[608] | 973 | ) |
---|
| 974 | { |
---|
[655] | 975 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 976 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFMD, true ); |
---|
[115] | 977 | #else |
---|
[608] | 978 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true ); |
---|
[115] | 979 | #endif |
---|
[872] | 980 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 981 | #if H_3D_VSP |
---|
[608] | 982 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
[115] | 983 | #endif |
---|
[116] | 984 | } |
---|
[115] | 985 | } |
---|
[56] | 986 | #endif |
---|
[2] | 987 | |
---|
[56] | 988 | #else |
---|
[608] | 989 | #if H_3D_QTLPC |
---|
| 990 | if (bTry2NxN) |
---|
| 991 | { |
---|
[5] | 992 | #endif |
---|
[608] | 993 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); |
---|
[872] | 994 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 995 | #if H_3D_VSP |
---|
[608] | 996 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
[56] | 997 | #endif |
---|
[608] | 998 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); |
---|
[872] | 999 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 1000 | #if H_3D_VSP |
---|
[608] | 1001 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
[56] | 1002 | #endif |
---|
[608] | 1003 | #if H_3D_QTLPC |
---|
| 1004 | } |
---|
| 1005 | if (bTryNx2N) |
---|
| 1006 | { |
---|
[56] | 1007 | #endif |
---|
[608] | 1008 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); |
---|
[872] | 1009 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 1010 | #if H_3D_VSP |
---|
[608] | 1011 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
[56] | 1012 | #endif |
---|
[608] | 1013 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); |
---|
[872] | 1014 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[622] | 1015 | #if H_3D_VSP |
---|
[608] | 1016 | rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); |
---|
[56] | 1017 | #endif |
---|
[608] | 1018 | #if H_3D_QTLPC |
---|
| 1019 | } |
---|
[56] | 1020 | #endif |
---|
[2] | 1021 | |
---|
[56] | 1022 | #endif |
---|
[608] | 1023 | } |
---|
[56] | 1024 | #endif |
---|
[608] | 1025 | } |
---|
[655] | 1026 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 1027 | if(!bFMD) |
---|
| 1028 | { |
---|
[189] | 1029 | #endif |
---|
[608] | 1030 | // do normal intra modes |
---|
[655] | 1031 | |
---|
[608] | 1032 | // speedup for inter frames |
---|
| 1033 | if( rpcBestCU->getSlice()->getSliceType() == I_SLICE || |
---|
[1039] | 1034 | rpcBestCU->getCbf( 0, TEXT_LUMA ) != 0 || |
---|
| 1035 | rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0 || |
---|
[608] | 1036 | rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 |
---|
| 1037 | #if H_3D_DIM_ENC |
---|
[1039] | 1038 | || rpcBestCU->getSlice()->getIsDepth() |
---|
[189] | 1039 | #endif |
---|
[608] | 1040 | ) // avoid very complex intra if it is unlikely |
---|
[2] | 1041 | { |
---|
[1084] | 1042 | #if H_3D_DIM |
---|
[1039] | 1043 | Bool bOnlyIVP = false; |
---|
| 1044 | if( rpcBestCU->getSlice()->getIsDepth() && !(rpcBestCU->getSlice()->isIRAP()) && |
---|
| 1045 | rpcBestCU->getSlice()->getSliceType() != I_SLICE && |
---|
| 1046 | rpcBestCU->getCbf( 0, TEXT_LUMA ) == 0 && |
---|
| 1047 | rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) == 0 && |
---|
| 1048 | rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) == 0 |
---|
| 1049 | ) |
---|
| 1050 | { |
---|
| 1051 | bOnlyIVP = true; |
---|
| 1052 | } |
---|
| 1053 | xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bOnlyIVP ); |
---|
| 1054 | #else |
---|
[608] | 1055 | xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); |
---|
[1039] | 1056 | #endif |
---|
[655] | 1057 | |
---|
[872] | 1058 | #if KWU_RC_MADPRED_E0227 |
---|
[655] | 1059 | if ( uiDepth <= m_addSADDepth ) |
---|
| 1060 | { |
---|
| 1061 | m_LCUPredictionSAD += m_spatialSAD; |
---|
| 1062 | m_addSADDepth = uiDepth; |
---|
| 1063 | } |
---|
| 1064 | #endif |
---|
| 1065 | |
---|
[872] | 1066 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[608] | 1067 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
[116] | 1068 | { |
---|
[608] | 1069 | #if H_3D_QTLPC //Try IntraNxN |
---|
| 1070 | if(bTrySplit) |
---|
[116] | 1071 | { |
---|
[189] | 1072 | #endif |
---|
[608] | 1073 | if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) ) |
---|
| 1074 | { |
---|
[1084] | 1075 | #if H_3D_DIM |
---|
[1039] | 1076 | xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN, bOnlyIVP ); |
---|
| 1077 | #else |
---|
[608] | 1078 | xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN ); |
---|
[1039] | 1079 | #endif |
---|
[872] | 1080 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[608] | 1081 | } |
---|
| 1082 | #if H_3D_QTLPC |
---|
[116] | 1083 | } |
---|
[608] | 1084 | #endif |
---|
[56] | 1085 | } |
---|
[2] | 1086 | } |
---|
[608] | 1087 | // test PCM |
---|
| 1088 | if(pcPic->getSlice(0)->getSPS()->getUsePCM() |
---|
| 1089 | && rpcTempCU->getWidth(0) <= (1<<pcPic->getSlice(0)->getSPS()->getPCMLog2MaxSize()) |
---|
| 1090 | && rpcTempCU->getWidth(0) >= (1<<pcPic->getSlice(0)->getSPS()->getPCMLog2MinSize()) ) |
---|
| 1091 | { |
---|
| 1092 | UInt uiRawBits = (2 * g_bitDepthY + g_bitDepthC) * rpcBestCU->getWidth(0) * rpcBestCU->getHeight(0) / 2; |
---|
| 1093 | UInt uiBestBits = rpcBestCU->getTotalBits(); |
---|
| 1094 | #if H_3D_VSO // M7 |
---|
| 1095 | Double dRDCostTemp = m_pcRdCost->getUseVSO() ? m_pcRdCost->calcRdCostVSO(uiRawBits, 0) : m_pcRdCost->calcRdCost(uiRawBits, 0); |
---|
| 1096 | if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > dRDCostTemp )) |
---|
[56] | 1097 | #else |
---|
[608] | 1098 | if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > m_pcRdCost->calcRdCost(uiRawBits, 0))) |
---|
[56] | 1099 | #endif |
---|
[608] | 1100 | { |
---|
| 1101 | xCheckIntraPCM (rpcBestCU, rpcTempCU); |
---|
[872] | 1102 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[608] | 1103 | } |
---|
| 1104 | } |
---|
[655] | 1105 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 1106 | } |
---|
[189] | 1107 | #endif |
---|
[872] | 1108 | if (bIsLosslessMode) |
---|
[296] | 1109 | { |
---|
[608] | 1110 | iQP = iMinQP; |
---|
[296] | 1111 | } |
---|
[56] | 1112 | } |
---|
[2] | 1113 | } |
---|
| 1114 | |
---|
| 1115 | m_pcEntropyCoder->resetBits(); |
---|
| 1116 | m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true ); |
---|
| 1117 | rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits |
---|
[56] | 1118 | rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
[872] | 1119 | #if H_3D_VSO // M8 |
---|
[608] | 1120 | if ( m_pcRdCost->getUseVSO() ) |
---|
| 1121 | rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); |
---|
[2] | 1122 | else |
---|
[5] | 1123 | #endif |
---|
[608] | 1124 | rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); |
---|
[2] | 1125 | |
---|
[56] | 1126 | // Early CU determination |
---|
[608] | 1127 | if( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->isSkipped(0) ) |
---|
[2] | 1128 | { |
---|
[56] | 1129 | bSubBranch = false; |
---|
[2] | 1130 | } |
---|
[56] | 1131 | else |
---|
| 1132 | { |
---|
| 1133 | bSubBranch = true; |
---|
| 1134 | } |
---|
[655] | 1135 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 1136 | if(rpcBestCU->getSlice()->getViewIndex() && !rpcBestCU->getSlice()->getIsDepth() && (uiDepth >=iIVFMaxD) && rpcBestCU->isSkipped(0)) |
---|
| 1137 | { |
---|
| 1138 | bSubBranch = false; |
---|
| 1139 | } |
---|
[2] | 1140 | #endif |
---|
| 1141 | } |
---|
[56] | 1142 | else if(!(bSliceEnd && bInsidePicture)) |
---|
[2] | 1143 | { |
---|
| 1144 | bBoundary = true; |
---|
| 1145 | } |
---|
| 1146 | |
---|
[56] | 1147 | // copy orginal YUV samples to PCM buffer |
---|
| 1148 | if( rpcBestCU->isLosslessCoded(0) && (rpcBestCU->getIPCMFlag(0) == false)) |
---|
[2] | 1149 | { |
---|
[56] | 1150 | xFillPCMBuffer(rpcBestCU, m_ppcOrigYuv[uiDepth]); |
---|
| 1151 | } |
---|
| 1152 | if( (g_uiMaxCUWidth>>uiDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
| 1153 | { |
---|
| 1154 | Int idQP = m_pcEncCfg->getMaxDeltaQP(); |
---|
| 1155 | iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); |
---|
| 1156 | iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); |
---|
| 1157 | } |
---|
| 1158 | else if( (g_uiMaxCUWidth>>uiDepth) > rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
| 1159 | { |
---|
| 1160 | iMinQP = iBaseQP; |
---|
| 1161 | iMaxQP = iBaseQP; |
---|
| 1162 | } |
---|
| 1163 | else |
---|
| 1164 | { |
---|
| 1165 | Int iStartQP; |
---|
[608] | 1166 | if( pcPic->getCU( rpcTempCU->getAddr() )->getSliceSegmentStartCU(rpcTempCU->getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr()) |
---|
[56] | 1167 | { |
---|
| 1168 | iStartQP = rpcTempCU->getQP(0); |
---|
| 1169 | } |
---|
| 1170 | else |
---|
| 1171 | { |
---|
[608] | 1172 | UInt uiCurSliceStartPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU() - rpcTempCU->getZorderIdxInCU(); |
---|
[56] | 1173 | iStartQP = rpcTempCU->getQP(uiCurSliceStartPartIdx); |
---|
| 1174 | } |
---|
| 1175 | iMinQP = iStartQP; |
---|
| 1176 | iMaxQP = iStartQP; |
---|
| 1177 | } |
---|
[608] | 1178 | if ( m_pcEncCfg->getUseRateCtrl() ) |
---|
| 1179 | { |
---|
| 1180 | iMinQP = m_pcRateCtrl->getRCQP(); |
---|
| 1181 | iMaxQP = m_pcRateCtrl->getRCQP(); |
---|
| 1182 | } |
---|
[872] | 1183 | |
---|
| 1184 | if ( m_pcEncCfg->getCUTransquantBypassFlagForceValue() ) |
---|
[608] | 1185 | { |
---|
[872] | 1186 | iMaxQP = iMinQP; // If all blocks are forced into using transquant bypass, do not loop here. |
---|
[608] | 1187 | } |
---|
[56] | 1188 | for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) |
---|
| 1189 | { |
---|
[872] | 1190 | const Bool bIsLosslessMode = false; // False at this level. Next level down may set it to true. |
---|
| 1191 | rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode ); |
---|
[2] | 1192 | |
---|
[56] | 1193 | // further split |
---|
[655] | 1194 | #if H_3D_QTLPC |
---|
[56] | 1195 | if( bSubBranch && bTrySplitDQP && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
[655] | 1196 | #else |
---|
| 1197 | if( bSubBranch && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
| 1198 | #endif |
---|
[2] | 1199 | { |
---|
[608] | 1200 | #if H_3D_VSO // M9 |
---|
[56] | 1201 | // reset Model |
---|
| 1202 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 1203 | { |
---|
[81] | 1204 | UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth ( ); |
---|
| 1205 | UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight( ); |
---|
| 1206 | Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr( 0 ); |
---|
| 1207 | UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride(); |
---|
| 1208 | m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[56] | 1209 | } |
---|
| 1210 | #endif |
---|
[608] | 1211 | |
---|
[56] | 1212 | UChar uhNextDepth = uiDepth+1; |
---|
| 1213 | TComDataCU* pcSubBestPartCU = m_ppcBestCU[uhNextDepth]; |
---|
| 1214 | TComDataCU* pcSubTempPartCU = m_ppcTempCU[uhNextDepth]; |
---|
[2] | 1215 | |
---|
[56] | 1216 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
[2] | 1217 | { |
---|
[56] | 1218 | pcSubBestPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. |
---|
| 1219 | pcSubTempPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. |
---|
| 1220 | |
---|
[608] | 1221 | Bool bInSlice = pcSubBestPartCU->getSCUAddr()+pcSubBestPartCU->getTotalNumPart()>pcSlice->getSliceSegmentCurStartCUAddr()&&pcSubBestPartCU->getSCUAddr()<pcSlice->getSliceSegmentCurEndCUAddr(); |
---|
[56] | 1222 | if(bInSlice && ( pcSubBestPartCU->getCUPelX() < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( pcSubBestPartCU->getCUPelY() < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[2] | 1223 | { |
---|
[56] | 1224 | if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer |
---|
| 1225 | { |
---|
| 1226 | m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); |
---|
| 1227 | } |
---|
| 1228 | else |
---|
| 1229 | { |
---|
| 1230 | m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); |
---|
| 1231 | } |
---|
| 1232 | |
---|
| 1233 | #if AMP_ENC_SPEEDUP |
---|
| 1234 | if ( rpcBestCU->isIntra(0) ) |
---|
| 1235 | { |
---|
| 1236 | xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth, SIZE_NONE ); |
---|
| 1237 | } |
---|
[2] | 1238 | else |
---|
| 1239 | { |
---|
[56] | 1240 | xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth, rpcBestCU->getPartitionSize(0) ); |
---|
[2] | 1241 | } |
---|
[56] | 1242 | #else |
---|
| 1243 | xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth ); |
---|
| 1244 | #endif |
---|
[2] | 1245 | |
---|
[56] | 1246 | rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth ); // Keep best part data to current temporary data. |
---|
| 1247 | xCopyYuv2Tmp( pcSubBestPartCU->getTotalNumPart()*uiPartUnitIdx, uhNextDepth ); |
---|
| 1248 | } |
---|
| 1249 | else if (bInSlice) |
---|
[2] | 1250 | { |
---|
[56] | 1251 | pcSubBestPartCU->copyToPic( uhNextDepth ); |
---|
| 1252 | rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth ); |
---|
[2] | 1253 | } |
---|
| 1254 | } |
---|
| 1255 | |
---|
[56] | 1256 | if( !bBoundary ) |
---|
| 1257 | { |
---|
| 1258 | m_pcEntropyCoder->resetBits(); |
---|
| 1259 | m_pcEntropyCoder->encodeSplitFlag( rpcTempCU, 0, uiDepth, true ); |
---|
[2] | 1260 | |
---|
[56] | 1261 | rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits |
---|
| 1262 | rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
| 1263 | } |
---|
[608] | 1264 | #if H_3D_VSO // M10 |
---|
[56] | 1265 | if ( m_pcRdCost->getUseVSO() ) |
---|
| 1266 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 1267 | else |
---|
[5] | 1268 | #endif |
---|
[608] | 1269 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
[2] | 1270 | |
---|
[56] | 1271 | if( (g_uiMaxCUWidth>>uiDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() && rpcTempCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 1272 | { |
---|
[608] | 1273 | Bool hasResidual = false; |
---|
[56] | 1274 | for( UInt uiBlkIdx = 0; uiBlkIdx < rpcTempCU->getTotalNumPart(); uiBlkIdx ++) |
---|
| 1275 | { |
---|
[608] | 1276 | if( ( pcPic->getCU( rpcTempCU->getAddr() )->getSliceSegmentStartCU(uiBlkIdx+rpcTempCU->getZorderIdxInCU()) == rpcTempCU->getSlice()->getSliceSegmentCurStartCUAddr() ) && |
---|
| 1277 | ( rpcTempCU->getCbf( uiBlkIdx, TEXT_LUMA ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_U ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_V ) ) ) |
---|
[56] | 1278 | { |
---|
[608] | 1279 | hasResidual = true; |
---|
[56] | 1280 | break; |
---|
| 1281 | } |
---|
| 1282 | } |
---|
[2] | 1283 | |
---|
[56] | 1284 | UInt uiTargetPartIdx; |
---|
[608] | 1285 | if ( pcPic->getCU( rpcTempCU->getAddr() )->getSliceSegmentStartCU(rpcTempCU->getZorderIdxInCU()) != pcSlice->getSliceSegmentCurStartCUAddr() ) |
---|
[56] | 1286 | { |
---|
[608] | 1287 | uiTargetPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU() - rpcTempCU->getZorderIdxInCU(); |
---|
[56] | 1288 | } |
---|
| 1289 | else |
---|
| 1290 | { |
---|
| 1291 | uiTargetPartIdx = 0; |
---|
| 1292 | } |
---|
[608] | 1293 | if ( hasResidual ) |
---|
[56] | 1294 | { |
---|
| 1295 | #if !RDO_WITHOUT_DQP_BITS |
---|
| 1296 | m_pcEntropyCoder->resetBits(); |
---|
| 1297 | m_pcEntropyCoder->encodeQP( rpcTempCU, uiTargetPartIdx, false ); |
---|
| 1298 | rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits |
---|
| 1299 | rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
[608] | 1300 | #if H_3D_VSO // M11 |
---|
| 1301 | if ( m_pcRdCost->getUseLambdaScaleVSO()) |
---|
| 1302 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
[56] | 1303 | else |
---|
[5] | 1304 | #endif |
---|
[608] | 1305 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
[56] | 1306 | #endif |
---|
[608] | 1307 | |
---|
| 1308 | Bool foundNonZeroCbf = false; |
---|
| 1309 | rpcTempCU->setQPSubCUs( rpcTempCU->getRefQP( uiTargetPartIdx ), rpcTempCU, 0, uiDepth, foundNonZeroCbf ); |
---|
| 1310 | assert( foundNonZeroCbf ); |
---|
[56] | 1311 | } |
---|
| 1312 | else |
---|
| 1313 | { |
---|
| 1314 | rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( uiTargetPartIdx ), 0, uiDepth ); // set QP to default QP |
---|
| 1315 | } |
---|
| 1316 | } |
---|
[2] | 1317 | |
---|
[56] | 1318 | m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); |
---|
[608] | 1319 | Bool isEndOfSlice = rpcBestCU->getSlice()->getSliceMode()==FIXED_NUMBER_OF_BYTES |
---|
| 1320 | && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceArgument()<<3); |
---|
| 1321 | Bool isEndOfSliceSegment = rpcBestCU->getSlice()->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES |
---|
| 1322 | && (rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceSegmentArgument()<<3); |
---|
| 1323 | if(isEndOfSlice||isEndOfSliceSegment) |
---|
[56] | 1324 | { |
---|
| 1325 | rpcBestCU->getTotalCost()=rpcTempCU->getTotalCost()+1; |
---|
| 1326 | } |
---|
| 1327 | xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth); // RD compare current larger prediction |
---|
| 1328 | } // with sub partitioned prediction. |
---|
[116] | 1329 | } |
---|
[56] | 1330 | |
---|
[608] | 1331 | #if H_3D_VSO // M12 |
---|
[56] | 1332 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 1333 | { |
---|
[116] | 1334 | UInt uiWidth = m_ppcRecoYuvBest[uiDepth]->getWidth ( ); |
---|
| 1335 | UInt uiHeight = m_ppcRecoYuvBest[uiDepth]->getHeight ( ); |
---|
| 1336 | Pel* piSrc = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 ); |
---|
| 1337 | UInt uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride ( ); |
---|
| 1338 | m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[56] | 1339 | } |
---|
| 1340 | #endif |
---|
[2] | 1341 | rpcBestCU->copyToPic(uiDepth); // Copy Best data to Picture for next partition prediction. |
---|
| 1342 | |
---|
[56] | 1343 | xCopyYuv2Pic( rpcBestCU->getPic(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU(), uiDepth, uiDepth, rpcBestCU, uiLPelX, uiTPelY ); // Copy Yuv data to picture Yuv |
---|
| 1344 | if( bBoundary ||(bSliceEnd && bInsidePicture)) |
---|
| 1345 | { |
---|
[2] | 1346 | return; |
---|
[56] | 1347 | } |
---|
[2] | 1348 | |
---|
| 1349 | // Assert if Best prediction mode is NONE |
---|
| 1350 | // Selected mode's RD-cost must be not MAX_DOUBLE. |
---|
| 1351 | assert( rpcBestCU->getPartitionSize ( 0 ) != SIZE_NONE ); |
---|
| 1352 | assert( rpcBestCU->getPredictionMode( 0 ) != MODE_NONE ); |
---|
| 1353 | assert( rpcBestCU->getTotalCost ( ) != MAX_DOUBLE ); |
---|
| 1354 | } |
---|
| 1355 | |
---|
[56] | 1356 | /** finish encoding a cu and handle end-of-slice conditions |
---|
| 1357 | * \param pcCU |
---|
| 1358 | * \param uiAbsPartIdx |
---|
| 1359 | * \param uiDepth |
---|
| 1360 | * \returns Void |
---|
| 1361 | */ |
---|
| 1362 | Void TEncCu::finishCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1363 | { |
---|
| 1364 | TComPic* pcPic = pcCU->getPic(); |
---|
| 1365 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 1366 | |
---|
| 1367 | //Calculate end address |
---|
| 1368 | UInt uiCUAddr = pcCU->getSCUAddr()+uiAbsPartIdx; |
---|
| 1369 | |
---|
[608] | 1370 | UInt uiInternalAddress = pcPic->getPicSym()->getPicSCUAddr(pcSlice->getSliceSegmentCurEndCUAddr()-1) % pcPic->getNumPartInCU(); |
---|
| 1371 | UInt uiExternalAddress = pcPic->getPicSym()->getPicSCUAddr(pcSlice->getSliceSegmentCurEndCUAddr()-1) / pcPic->getNumPartInCU(); |
---|
[56] | 1372 | UInt uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
| 1373 | UInt uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
| 1374 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
| 1375 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
| 1376 | while(uiPosX>=uiWidth||uiPosY>=uiHeight) |
---|
| 1377 | { |
---|
| 1378 | uiInternalAddress--; |
---|
| 1379 | uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
| 1380 | uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
| 1381 | } |
---|
| 1382 | uiInternalAddress++; |
---|
| 1383 | if(uiInternalAddress==pcCU->getPic()->getNumPartInCU()) |
---|
| 1384 | { |
---|
| 1385 | uiInternalAddress = 0; |
---|
| 1386 | uiExternalAddress = pcPic->getPicSym()->getCUOrderMap(pcPic->getPicSym()->getInverseCUOrderMap(uiExternalAddress)+1); |
---|
| 1387 | } |
---|
| 1388 | UInt uiRealEndAddress = pcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*pcPic->getNumPartInCU()+uiInternalAddress); |
---|
| 1389 | |
---|
| 1390 | // Encode slice finish |
---|
| 1391 | Bool bTerminateSlice = false; |
---|
| 1392 | if (uiCUAddr+(pcCU->getPic()->getNumPartInCU()>>(uiDepth<<1)) == uiRealEndAddress) |
---|
| 1393 | { |
---|
| 1394 | bTerminateSlice = true; |
---|
| 1395 | } |
---|
[608] | 1396 | UInt uiGranularityWidth = g_uiMaxCUWidth; |
---|
[56] | 1397 | uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 1398 | uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 1399 | Bool granularityBoundary=((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
---|
| 1400 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)); |
---|
| 1401 | |
---|
[608] | 1402 | if(granularityBoundary) |
---|
[56] | 1403 | { |
---|
| 1404 | // The 1-terminating bit is added to all streams, so don't add it here when it's 1. |
---|
| 1405 | if (!bTerminateSlice) |
---|
| 1406 | m_pcEntropyCoder->encodeTerminatingBit( bTerminateSlice ? 1 : 0 ); |
---|
| 1407 | } |
---|
| 1408 | |
---|
| 1409 | Int numberOfWrittenBits = 0; |
---|
| 1410 | if (m_pcBitCounter) |
---|
| 1411 | { |
---|
| 1412 | numberOfWrittenBits = m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
| 1413 | } |
---|
| 1414 | |
---|
| 1415 | // Calculate slice end IF this CU puts us over slice bit size. |
---|
[608] | 1416 | UInt iGranularitySize = pcCU->getPic()->getNumPartInCU(); |
---|
| 1417 | Int iGranularityEnd = ((pcCU->getSCUAddr()+uiAbsPartIdx)/iGranularitySize)*iGranularitySize; |
---|
| 1418 | if(iGranularityEnd<=pcSlice->getSliceSegmentCurStartCUAddr()) |
---|
[56] | 1419 | { |
---|
| 1420 | iGranularityEnd+=max(iGranularitySize,(pcCU->getPic()->getNumPartInCU()>>(uiDepth<<1))); |
---|
| 1421 | } |
---|
| 1422 | // Set slice end parameter |
---|
[608] | 1423 | if(pcSlice->getSliceMode()==FIXED_NUMBER_OF_BYTES&&!pcSlice->getFinalized()&&pcSlice->getSliceBits()+numberOfWrittenBits>pcSlice->getSliceArgument()<<3) |
---|
[56] | 1424 | { |
---|
[608] | 1425 | pcSlice->setSliceSegmentCurEndCUAddr(iGranularityEnd); |
---|
[56] | 1426 | pcSlice->setSliceCurEndCUAddr(iGranularityEnd); |
---|
| 1427 | return; |
---|
| 1428 | } |
---|
[608] | 1429 | // Set dependent slice end parameter |
---|
| 1430 | if(pcSlice->getSliceSegmentMode()==FIXED_NUMBER_OF_BYTES&&!pcSlice->getFinalized()&&pcSlice->getSliceSegmentBits()+numberOfWrittenBits > pcSlice->getSliceSegmentArgument()<<3) |
---|
[56] | 1431 | { |
---|
[608] | 1432 | pcSlice->setSliceSegmentCurEndCUAddr(iGranularityEnd); |
---|
| 1433 | return; |
---|
[56] | 1434 | } |
---|
| 1435 | if(granularityBoundary) |
---|
| 1436 | { |
---|
| 1437 | pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + numberOfWrittenBits) ); |
---|
[608] | 1438 | pcSlice->setSliceSegmentBits(pcSlice->getSliceSegmentBits()+numberOfWrittenBits); |
---|
[56] | 1439 | if (m_pcBitCounter) |
---|
| 1440 | { |
---|
| 1441 | m_pcEntropyCoder->resetBits(); |
---|
| 1442 | } |
---|
| 1443 | } |
---|
| 1444 | } |
---|
| 1445 | |
---|
| 1446 | /** Compute QP for each CU |
---|
| 1447 | * \param pcCU Target CU |
---|
| 1448 | * \param uiDepth CU depth |
---|
| 1449 | * \returns quantization parameter |
---|
| 1450 | */ |
---|
| 1451 | Int TEncCu::xComputeQP( TComDataCU* pcCU, UInt uiDepth ) |
---|
| 1452 | { |
---|
| 1453 | Int iBaseQp = pcCU->getSlice()->getSliceQp(); |
---|
| 1454 | Int iQpOffset = 0; |
---|
| 1455 | if ( m_pcEncCfg->getUseAdaptiveQP() ) |
---|
| 1456 | { |
---|
| 1457 | TEncPic* pcEPic = dynamic_cast<TEncPic*>( pcCU->getPic() ); |
---|
| 1458 | UInt uiAQDepth = min( uiDepth, pcEPic->getMaxAQDepth()-1 ); |
---|
| 1459 | TEncPicQPAdaptationLayer* pcAQLayer = pcEPic->getAQLayer( uiAQDepth ); |
---|
| 1460 | UInt uiAQUPosX = pcCU->getCUPelX() / pcAQLayer->getAQPartWidth(); |
---|
| 1461 | UInt uiAQUPosY = pcCU->getCUPelY() / pcAQLayer->getAQPartHeight(); |
---|
| 1462 | UInt uiAQUStride = pcAQLayer->getAQPartStride(); |
---|
| 1463 | TEncQPAdaptationUnit* acAQU = pcAQLayer->getQPAdaptationUnit(); |
---|
| 1464 | |
---|
| 1465 | Double dMaxQScale = pow(2.0, m_pcEncCfg->getQPAdaptationRange()/6.0); |
---|
| 1466 | Double dAvgAct = pcAQLayer->getAvgActivity(); |
---|
| 1467 | Double dCUAct = acAQU[uiAQUPosY * uiAQUStride + uiAQUPosX].getActivity(); |
---|
| 1468 | Double dNormAct = (dMaxQScale*dCUAct + dAvgAct) / (dCUAct + dMaxQScale*dAvgAct); |
---|
| 1469 | Double dQpOffset = log(dNormAct) / log(2.0) * 6.0; |
---|
| 1470 | iQpOffset = Int(floor( dQpOffset + 0.49999 )); |
---|
| 1471 | } |
---|
| 1472 | return Clip3(-pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQp+iQpOffset ); |
---|
| 1473 | } |
---|
| 1474 | |
---|
[2] | 1475 | /** encode a CU block recursively |
---|
| 1476 | * \param pcCU |
---|
| 1477 | * \param uiAbsPartIdx |
---|
[56] | 1478 | * \param uiDepth |
---|
[2] | 1479 | * \returns Void |
---|
| 1480 | */ |
---|
| 1481 | Void TEncCu::xEncodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1482 | { |
---|
| 1483 | TComPic* pcPic = pcCU->getPic(); |
---|
[56] | 1484 | |
---|
[2] | 1485 | Bool bBoundary = false; |
---|
| 1486 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 1487 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 1488 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 1489 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
[608] | 1490 | |
---|
| 1491 | #if H_MV_ENC_DEC_TRAC |
---|
| 1492 | DTRACE_CU_S("=========== coding_quadtree ===========\n") |
---|
| 1493 | DTRACE_CU("x0", uiLPelX) |
---|
| 1494 | DTRACE_CU("x1", uiTPelY) |
---|
| 1495 | DTRACE_CU("log2CbSize", g_uiMaxCUWidth>>uiDepth) |
---|
| 1496 | DTRACE_CU("cqtDepth" , uiDepth) |
---|
| 1497 | #endif |
---|
[443] | 1498 | |
---|
[56] | 1499 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 1500 | // If slice start is within this cu... |
---|
[608] | 1501 | Bool bSliceStart = pcSlice->getSliceSegmentCurStartCUAddr() > pcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && |
---|
| 1502 | pcSlice->getSliceSegmentCurStartCUAddr() < pcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcPic->getNumPartInCU() >> (uiDepth<<1) ); |
---|
[56] | 1503 | // We need to split, so don't try these modes. |
---|
| 1504 | if(!bSliceStart&&( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[2] | 1505 | { |
---|
[56] | 1506 | m_pcEntropyCoder->encodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 1507 | } |
---|
| 1508 | else |
---|
| 1509 | { |
---|
| 1510 | bBoundary = true; |
---|
| 1511 | } |
---|
[56] | 1512 | |
---|
[2] | 1513 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < (g_uiMaxCUDepth-g_uiAddCUDepth) ) ) || bBoundary ) |
---|
| 1514 | { |
---|
| 1515 | UInt uiQNumParts = ( pcPic->getNumPartInCU() >> (uiDepth<<1) )>>2; |
---|
[56] | 1516 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 1517 | { |
---|
| 1518 | setdQPFlag(true); |
---|
| 1519 | } |
---|
[2] | 1520 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx+=uiQNumParts ) |
---|
| 1521 | { |
---|
| 1522 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 1523 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
[608] | 1524 | Bool bInSlice = pcCU->getSCUAddr()+uiAbsPartIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurEndCUAddr(); |
---|
[56] | 1525 | if(bInSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 1526 | { |
---|
[2] | 1527 | xEncodeCU( pcCU, uiAbsPartIdx, uiDepth+1 ); |
---|
[56] | 1528 | } |
---|
[2] | 1529 | } |
---|
| 1530 | return; |
---|
| 1531 | } |
---|
[56] | 1532 | |
---|
[608] | 1533 | #if H_MV_ENC_DEC_TRAC |
---|
| 1534 | DTRACE_CU_S("=========== coding_unit ===========\n") |
---|
| 1535 | #endif |
---|
| 1536 | |
---|
[56] | 1537 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 1538 | { |
---|
| 1539 | setdQPFlag(true); |
---|
| 1540 | } |
---|
[608] | 1541 | if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
---|
| 1542 | { |
---|
| 1543 | m_pcEntropyCoder->encodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx ); |
---|
| 1544 | } |
---|
[5] | 1545 | if( !pcCU->getSlice()->isIntra() ) |
---|
[2] | 1546 | { |
---|
| 1547 | m_pcEntropyCoder->encodeSkipFlag( pcCU, uiAbsPartIdx ); |
---|
| 1548 | } |
---|
[56] | 1549 | |
---|
[2] | 1550 | if( pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
| 1551 | { |
---|
[608] | 1552 | #if H_MV_ENC_DEC_TRAC |
---|
| 1553 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
| 1554 | DTRACE_PU("x0", uiLPelX) |
---|
| 1555 | DTRACE_PU("x1", uiTPelY) |
---|
[115] | 1556 | #endif |
---|
[608] | 1557 | m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx ); |
---|
| 1558 | #if H_3D_ARP |
---|
| 1559 | m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx ); |
---|
[443] | 1560 | #endif |
---|
[833] | 1561 | #if H_3D_IC |
---|
| 1562 | m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx ); |
---|
| 1563 | #endif |
---|
[56] | 1564 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
[2] | 1565 | return; |
---|
| 1566 | } |
---|
[1084] | 1567 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 1568 | m_pcEntropyCoder->encodeSingleDepthMode( pcCU, uiAbsPartIdx ); |
---|
| 1569 | if(!pcCU->getSingleDepthFlag(uiAbsPartIdx)) |
---|
| 1570 | { |
---|
| 1571 | #endif |
---|
[56] | 1572 | m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx ); |
---|
[608] | 1573 | |
---|
[56] | 1574 | m_pcEntropyCoder->encodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[608] | 1575 | |
---|
[884] | 1576 | #if H_3D_DIM_SDC |
---|
[833] | 1577 | m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx, false ); |
---|
| 1578 | #endif |
---|
[56] | 1579 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
| 1580 | { |
---|
| 1581 | m_pcEntropyCoder->encodeIPCMInfo( pcCU, uiAbsPartIdx ); |
---|
[2] | 1582 | |
---|
[56] | 1583 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
| 1584 | { |
---|
| 1585 | // Encode slice finish |
---|
| 1586 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
| 1587 | return; |
---|
| 1588 | } |
---|
| 1589 | } |
---|
[2] | 1590 | |
---|
[56] | 1591 | // prediction Info ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
| 1592 | m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx ); |
---|
[884] | 1593 | |
---|
[608] | 1594 | #if H_3D_ARP |
---|
| 1595 | m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx ); |
---|
[296] | 1596 | #endif |
---|
[833] | 1597 | #if H_3D_IC |
---|
| 1598 | m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx ); |
---|
| 1599 | #endif |
---|
[2] | 1600 | // Encode Coefficients |
---|
[56] | 1601 | Bool bCodeDQP = getdQPFlag(); |
---|
| 1602 | m_pcEntropyCoder->encodeCoeff( pcCU, uiAbsPartIdx, uiDepth, pcCU->getWidth (uiAbsPartIdx), pcCU->getHeight(uiAbsPartIdx), bCodeDQP ); |
---|
| 1603 | setdQPFlag( bCodeDQP ); |
---|
[1084] | 1604 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 1605 | } |
---|
| 1606 | #endif |
---|
[56] | 1607 | // --- write terminating bit --- |
---|
| 1608 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
[2] | 1609 | } |
---|
| 1610 | |
---|
[608] | 1611 | Int xCalcHADs8x8_ISlice(Pel *piOrg, Int iStrideOrg) |
---|
| 1612 | { |
---|
| 1613 | Int k, i, j, jj; |
---|
| 1614 | Int diff[64], m1[8][8], m2[8][8], m3[8][8], iSumHad = 0; |
---|
| 1615 | |
---|
| 1616 | for( k = 0; k < 64; k += 8 ) |
---|
| 1617 | { |
---|
| 1618 | diff[k+0] = piOrg[0] ; |
---|
| 1619 | diff[k+1] = piOrg[1] ; |
---|
| 1620 | diff[k+2] = piOrg[2] ; |
---|
| 1621 | diff[k+3] = piOrg[3] ; |
---|
| 1622 | diff[k+4] = piOrg[4] ; |
---|
| 1623 | diff[k+5] = piOrg[5] ; |
---|
| 1624 | diff[k+6] = piOrg[6] ; |
---|
| 1625 | diff[k+7] = piOrg[7] ; |
---|
| 1626 | |
---|
| 1627 | piOrg += iStrideOrg; |
---|
| 1628 | } |
---|
| 1629 | |
---|
| 1630 | //horizontal |
---|
| 1631 | for (j=0; j < 8; j++) |
---|
| 1632 | { |
---|
| 1633 | jj = j << 3; |
---|
| 1634 | m2[j][0] = diff[jj ] + diff[jj+4]; |
---|
| 1635 | m2[j][1] = diff[jj+1] + diff[jj+5]; |
---|
| 1636 | m2[j][2] = diff[jj+2] + diff[jj+6]; |
---|
| 1637 | m2[j][3] = diff[jj+3] + diff[jj+7]; |
---|
| 1638 | m2[j][4] = diff[jj ] - diff[jj+4]; |
---|
| 1639 | m2[j][5] = diff[jj+1] - diff[jj+5]; |
---|
| 1640 | m2[j][6] = diff[jj+2] - diff[jj+6]; |
---|
| 1641 | m2[j][7] = diff[jj+3] - diff[jj+7]; |
---|
| 1642 | |
---|
| 1643 | m1[j][0] = m2[j][0] + m2[j][2]; |
---|
| 1644 | m1[j][1] = m2[j][1] + m2[j][3]; |
---|
| 1645 | m1[j][2] = m2[j][0] - m2[j][2]; |
---|
| 1646 | m1[j][3] = m2[j][1] - m2[j][3]; |
---|
| 1647 | m1[j][4] = m2[j][4] + m2[j][6]; |
---|
| 1648 | m1[j][5] = m2[j][5] + m2[j][7]; |
---|
| 1649 | m1[j][6] = m2[j][4] - m2[j][6]; |
---|
| 1650 | m1[j][7] = m2[j][5] - m2[j][7]; |
---|
| 1651 | |
---|
| 1652 | m2[j][0] = m1[j][0] + m1[j][1]; |
---|
| 1653 | m2[j][1] = m1[j][0] - m1[j][1]; |
---|
| 1654 | m2[j][2] = m1[j][2] + m1[j][3]; |
---|
| 1655 | m2[j][3] = m1[j][2] - m1[j][3]; |
---|
| 1656 | m2[j][4] = m1[j][4] + m1[j][5]; |
---|
| 1657 | m2[j][5] = m1[j][4] - m1[j][5]; |
---|
| 1658 | m2[j][6] = m1[j][6] + m1[j][7]; |
---|
| 1659 | m2[j][7] = m1[j][6] - m1[j][7]; |
---|
| 1660 | } |
---|
| 1661 | |
---|
| 1662 | //vertical |
---|
| 1663 | for (i=0; i < 8; i++) |
---|
| 1664 | { |
---|
| 1665 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
| 1666 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
| 1667 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
| 1668 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
| 1669 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
| 1670 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
| 1671 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
| 1672 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
| 1673 | |
---|
| 1674 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
| 1675 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
| 1676 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
| 1677 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
| 1678 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
| 1679 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
| 1680 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
| 1681 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
| 1682 | |
---|
| 1683 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
| 1684 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
| 1685 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
| 1686 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
| 1687 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
| 1688 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
| 1689 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
| 1690 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
| 1691 | } |
---|
| 1692 | |
---|
| 1693 | for (i = 0; i < 8; i++) |
---|
| 1694 | { |
---|
| 1695 | for (j = 0; j < 8; j++) |
---|
| 1696 | { |
---|
| 1697 | iSumHad += abs(m2[i][j]); |
---|
| 1698 | } |
---|
| 1699 | } |
---|
| 1700 | iSumHad -= abs(m2[0][0]); |
---|
| 1701 | iSumHad =(iSumHad+2)>>2; |
---|
| 1702 | return(iSumHad); |
---|
| 1703 | } |
---|
| 1704 | |
---|
| 1705 | Int TEncCu::updateLCUDataISlice(TComDataCU* pcCU, Int LCUIdx, Int width, Int height) |
---|
| 1706 | { |
---|
| 1707 | Int xBl, yBl; |
---|
| 1708 | const Int iBlkSize = 8; |
---|
| 1709 | |
---|
| 1710 | Pel* pOrgInit = pcCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0); |
---|
| 1711 | Int iStrideOrig = pcCU->getPic()->getPicYuvOrg()->getStride(); |
---|
| 1712 | Pel *pOrg; |
---|
| 1713 | |
---|
| 1714 | Int iSumHad = 0; |
---|
| 1715 | for ( yBl=0; (yBl+iBlkSize)<=height; yBl+= iBlkSize) |
---|
| 1716 | { |
---|
| 1717 | for ( xBl=0; (xBl+iBlkSize)<=width; xBl+= iBlkSize) |
---|
| 1718 | { |
---|
| 1719 | pOrg = pOrgInit + iStrideOrig*yBl + xBl; |
---|
| 1720 | iSumHad += xCalcHADs8x8_ISlice(pOrg, iStrideOrig); |
---|
| 1721 | } |
---|
| 1722 | } |
---|
| 1723 | return(iSumHad); |
---|
| 1724 | } |
---|
| 1725 | |
---|
[2] | 1726 | /** check RD costs for a CU block encoded with merge |
---|
| 1727 | * \param rpcBestCU |
---|
| 1728 | * \param rpcTempCU |
---|
| 1729 | * \returns Void |
---|
| 1730 | */ |
---|
[608] | 1731 | Void TEncCu::xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool *earlyDetectionSkipMode ) |
---|
[2] | 1732 | { |
---|
| 1733 | assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE ); |
---|
[608] | 1734 | #if H_3D_IV_MERGE |
---|
[56] | 1735 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
| 1736 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 1737 | #else |
---|
[608] | 1738 | TComMvField cMvFieldNeighbours[2 * MRG_MAX_NUM_CANDS]; // double length for mv of both lists |
---|
[2] | 1739 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
[56] | 1740 | #endif |
---|
| 1741 | Int numValidMergeCand = 0; |
---|
[872] | 1742 | const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0); |
---|
[2] | 1743 | |
---|
[608] | 1744 | for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
[2] | 1745 | { |
---|
| 1746 | uhInterDirNeighbours[ui] = 0; |
---|
| 1747 | } |
---|
| 1748 | UChar uhDepth = rpcTempCU->getDepth( 0 ); |
---|
[608] | 1749 | #if H_3D_IC |
---|
| 1750 | Bool bICFlag = rpcTempCU->getICFlag( 0 ); |
---|
| 1751 | #endif |
---|
| 1752 | #if H_3D_VSO // M1 //nececcary here? |
---|
[2] | 1753 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 1754 | { |
---|
[81] | 1755 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( ); |
---|
| 1756 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( ); |
---|
| 1757 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( ); |
---|
| 1758 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride(); |
---|
| 1759 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[2] | 1760 | } |
---|
[5] | 1761 | #endif |
---|
[2] | 1762 | |
---|
[773] | 1763 | #if H_3D_ARP |
---|
[724] | 1764 | DisInfo cOrigDisInfo = rpcTempCU->getDvInfo(0); |
---|
| 1765 | #else |
---|
[2] | 1766 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level |
---|
[724] | 1767 | #endif |
---|
[608] | 1768 | |
---|
| 1769 | #if H_3D_VSP |
---|
[773] | 1770 | #if !H_3D_ARP |
---|
[608] | 1771 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 1772 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 1773 | InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; |
---|
[724] | 1774 | rpcTempCU->m_bAvailableFlagA1 = 0; |
---|
| 1775 | rpcTempCU->m_bAvailableFlagB1 = 0; |
---|
| 1776 | rpcTempCU->m_bAvailableFlagB0 = 0; |
---|
| 1777 | rpcTempCU->m_bAvailableFlagA0 = 0; |
---|
| 1778 | rpcTempCU->m_bAvailableFlagB2 = 0; |
---|
| 1779 | rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 1780 | rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo, numValidMergeCand ); |
---|
| 1781 | #endif |
---|
| 1782 | #else |
---|
[773] | 1783 | #if H_3D |
---|
[724] | 1784 | rpcTempCU->m_bAvailableFlagA1 = 0; |
---|
| 1785 | rpcTempCU->m_bAvailableFlagB1 = 0; |
---|
| 1786 | rpcTempCU->m_bAvailableFlagB0 = 0; |
---|
| 1787 | rpcTempCU->m_bAvailableFlagA0 = 0; |
---|
| 1788 | rpcTempCU->m_bAvailableFlagB2 = 0; |
---|
| 1789 | rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 1790 | rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); |
---|
| 1791 | #else |
---|
[608] | 1792 | rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); |
---|
[443] | 1793 | #endif |
---|
[724] | 1794 | #endif |
---|
[608] | 1795 | |
---|
| 1796 | #if H_3D_IV_MERGE |
---|
| 1797 | Int mergeCandBuffer[MRG_MAX_NUM_CANDS_MEM]; |
---|
[296] | 1798 | #else |
---|
[608] | 1799 | Int mergeCandBuffer[MRG_MAX_NUM_CANDS]; |
---|
[296] | 1800 | #endif |
---|
[773] | 1801 | #if H_3D_ARP |
---|
[724] | 1802 | for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
| 1803 | #else |
---|
[608] | 1804 | for( UInt ui = 0; ui < numValidMergeCand; ++ui ) |
---|
[724] | 1805 | #endif |
---|
[608] | 1806 | { |
---|
| 1807 | mergeCandBuffer[ui] = 0; |
---|
| 1808 | } |
---|
[2] | 1809 | |
---|
[56] | 1810 | Bool bestIsSkip = false; |
---|
[608] | 1811 | |
---|
| 1812 | UInt iteration; |
---|
| 1813 | if ( rpcTempCU->isLosslessCoded(0)) |
---|
[443] | 1814 | { |
---|
[608] | 1815 | iteration = 1; |
---|
| 1816 | } |
---|
| 1817 | else |
---|
[2] | 1818 | { |
---|
[608] | 1819 | iteration = 2; |
---|
| 1820 | } |
---|
| 1821 | |
---|
| 1822 | #if H_3D_ARP |
---|
| 1823 | Int nARPWMax = rpcTempCU->getSlice()->getARPStepNum() - 1; |
---|
[833] | 1824 | if( nARPWMax < 0 || !rpcTempCU->getDvInfo(0).bDV || bICFlag ) |
---|
[608] | 1825 | { |
---|
| 1826 | nARPWMax = 0; |
---|
| 1827 | } |
---|
| 1828 | for( Int nARPW=nARPWMax; nARPW >= 0 ; nARPW-- ) |
---|
| 1829 | { |
---|
[724] | 1830 | memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS_MEM*sizeof(Int) ); |
---|
| 1831 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level |
---|
| 1832 | rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth ); |
---|
| 1833 | #if H_3D_IC |
---|
| 1834 | rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth ); |
---|
| 1835 | #endif |
---|
| 1836 | rpcTempCU->getDvInfo(0) = cOrigDisInfo; |
---|
| 1837 | rpcTempCU->setDvInfoSubParts(cOrigDisInfo, 0, 0, uhDepth ); |
---|
| 1838 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 1839 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
[773] | 1840 | #if H_3D_SPIVMP |
---|
[724] | 1841 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 1842 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 1843 | TComMvField* pcMvFieldSP; |
---|
| 1844 | UChar* puhInterDirSP; |
---|
| 1845 | pcMvFieldSP = new TComMvField[rpcTempCU->getPic()->getPicSym()->getNumPartition()*2]; |
---|
| 1846 | puhInterDirSP = new UChar[rpcTempCU->getPic()->getPicSym()->getNumPartition()]; |
---|
| 1847 | #endif |
---|
[773] | 1848 | #if H_3D |
---|
[724] | 1849 | rpcTempCU->initAvailableFlags(); |
---|
| 1850 | rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
[950] | 1851 | rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours |
---|
[773] | 1852 | #if H_3D_SPIVMP |
---|
[950] | 1853 | , pcMvFieldSP, puhInterDirSP |
---|
| 1854 | #endif |
---|
[724] | 1855 | , numValidMergeCand |
---|
| 1856 | ); |
---|
[950] | 1857 | |
---|
| 1858 | rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag |
---|
| 1859 | #if H_3D_SPIVMP |
---|
| 1860 | , bSPIVMPFlag |
---|
| 1861 | #endif |
---|
| 1862 | , numValidMergeCand |
---|
| 1863 | ); |
---|
| 1864 | |
---|
[724] | 1865 | #else |
---|
[1039] | 1866 | rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, numValidMergeCand ); |
---|
[724] | 1867 | #endif |
---|
[773] | 1868 | |
---|
[1039] | 1869 | |
---|
[724] | 1870 | #endif |
---|
[833] | 1871 | |
---|
[884] | 1872 | #if H_3D_DDD |
---|
[833] | 1873 | Int iDDDCand = rpcTempCU->getUseDDDCandIdx(); |
---|
| 1874 | UChar ucDDDepth = rpcTempCU->getDDTmpDepth(); |
---|
| 1875 | rpcTempCU->setUseDDD( false, 0, uhDepth ); |
---|
| 1876 | #endif |
---|
| 1877 | |
---|
[608] | 1878 | for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual ) |
---|
| 1879 | { |
---|
| 1880 | for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand ) |
---|
| 1881 | { |
---|
| 1882 | #if H_3D_IC |
---|
| 1883 | if( rpcTempCU->getSlice()->getApplyIC() && rpcTempCU->getSlice()->getIcSkipParseFlag() ) |
---|
[443] | 1884 | { |
---|
[608] | 1885 | if( bICFlag && uiMergeCand == 0 ) |
---|
| 1886 | { |
---|
| 1887 | continue; |
---|
| 1888 | } |
---|
[443] | 1889 | } |
---|
| 1890 | #endif |
---|
[608] | 1891 | if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1)) |
---|
| 1892 | { |
---|
[56] | 1893 | if( !(bestIsSkip && uiNoResidual == 0) ) |
---|
| 1894 | { |
---|
| 1895 | // set MC parameters |
---|
[608] | 1896 | rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth ); // interprets depth relative to LCU level |
---|
[872] | 1897 | rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag, 0, uhDepth ); |
---|
[56] | 1898 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level |
---|
[608] | 1899 | #if H_3D_IC |
---|
| 1900 | rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth ); |
---|
[443] | 1901 | #endif |
---|
[608] | 1902 | #if H_3D_ARP |
---|
| 1903 | rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth ); |
---|
| 1904 | #endif |
---|
[56] | 1905 | rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level |
---|
| 1906 | rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to LCU level |
---|
[608] | 1907 | #if H_3D_VSP |
---|
| 1908 | rpcTempCU->setVSPFlagSubParts( vspFlag[uiMergeCand], 0, 0, uhDepth ); |
---|
[443] | 1909 | #endif |
---|
[884] | 1910 | #if H_3D_DDD |
---|
[833] | 1911 | if( rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getViewIndex() != 0 && iDDDCand == uiMergeCand ) |
---|
| 1912 | { |
---|
| 1913 | rpcTempCU->setUseDDD( true, 0, 0, uhDepth ); |
---|
| 1914 | rpcTempCU->setDDDepthSubParts( ucDDDepth, 0, 0, uhDepth ); |
---|
| 1915 | } |
---|
| 1916 | else |
---|
| 1917 | { |
---|
| 1918 | rpcTempCU->setUseDDD( false, 0, 0, uhDepth ); |
---|
| 1919 | } |
---|
| 1920 | #endif |
---|
[773] | 1921 | #if H_3D_SPIVMP |
---|
[724] | 1922 | rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth); |
---|
| 1923 | if (bSPIVMPFlag[uiMergeCand]) |
---|
| 1924 | { |
---|
| 1925 | UInt uiSPAddr; |
---|
| 1926 | Int iWidth = rpcTempCU->getWidth(0); |
---|
| 1927 | Int iHeight = rpcTempCU->getHeight(0); |
---|
| 1928 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 1929 | rpcTempCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 1930 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
---|
| 1931 | { |
---|
| 1932 | rpcTempCU->getSPAbsPartIdx(0, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
---|
| 1933 | rpcTempCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
---|
| 1934 | rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
---|
| 1935 | rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
---|
| 1936 | } |
---|
| 1937 | } |
---|
| 1938 | else |
---|
[833] | 1939 | #endif |
---|
[884] | 1940 | #if H_3D_VSP |
---|
| 1941 | { |
---|
[833] | 1942 | if ( vspFlag[uiMergeCand] ) |
---|
[724] | 1943 | { |
---|
[833] | 1944 | UInt partAddr; |
---|
| 1945 | Int vspSize; |
---|
| 1946 | Int width, height; |
---|
| 1947 | rpcTempCU->getPartIndexAndSize( 0, partAddr, width, height ); |
---|
| 1948 | if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 ) |
---|
| 1949 | { |
---|
| 1950 | rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize ); |
---|
| 1951 | rpcTempCU->setVSPFlag( partAddr, vspSize ); |
---|
| 1952 | } |
---|
| 1953 | else |
---|
| 1954 | { |
---|
| 1955 | rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level |
---|
| 1956 | } |
---|
| 1957 | if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 ) |
---|
| 1958 | { |
---|
| 1959 | rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_1 , cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize ); |
---|
| 1960 | rpcTempCU->setVSPFlag( partAddr, vspSize ); |
---|
| 1961 | } |
---|
| 1962 | else |
---|
| 1963 | { |
---|
| 1964 | rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level |
---|
| 1965 | } |
---|
| 1966 | rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level |
---|
| 1967 | } |
---|
| 1968 | else |
---|
[872] | 1969 | { |
---|
[724] | 1970 | #endif |
---|
| 1971 | rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level |
---|
| 1972 | rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level |
---|
| 1973 | rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level |
---|
[884] | 1974 | #if H_3D_VSP |
---|
[724] | 1975 | } |
---|
[872] | 1976 | } |
---|
| 1977 | #endif |
---|
[608] | 1978 | // do MC |
---|
| 1979 | m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); |
---|
| 1980 | // estimate residual and encode everything |
---|
| 1981 | #if H_3D_VSO //M2 |
---|
| 1982 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 1983 | { //Reset |
---|
| 1984 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth (); |
---|
| 1985 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight (); |
---|
| 1986 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr (); |
---|
| 1987 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride (); |
---|
| 1988 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
| 1989 | } |
---|
[2] | 1990 | #endif |
---|
[608] | 1991 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, |
---|
| 1992 | m_ppcOrigYuv [uhDepth], |
---|
| 1993 | m_ppcPredYuvTemp[uhDepth], |
---|
| 1994 | m_ppcResiYuvTemp[uhDepth], |
---|
| 1995 | m_ppcResiYuvBest[uhDepth], |
---|
| 1996 | m_ppcRecoYuvTemp[uhDepth], |
---|
| 1997 | (uiNoResidual? true:false)); |
---|
| 1998 | |
---|
| 1999 | |
---|
| 2000 | if ( uiNoResidual == 0 && rpcTempCU->getQtRootCbf(0) == 0 ) |
---|
| 2001 | { |
---|
| 2002 | // If no residual when allowing for one, then set mark to not try case where residual is forced to 0 |
---|
| 2003 | mergeCandBuffer[uiMergeCand] = 1; |
---|
| 2004 | } |
---|
| 2005 | |
---|
| 2006 | rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth ); |
---|
[1084] | 2007 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2008 | rpcTempCU->setSingleDepthFlagSubParts( false, 0, uhDepth ); |
---|
| 2009 | #endif |
---|
[884] | 2010 | #if H_3D_VSP // possible bug fix |
---|
[833] | 2011 | if( rpcTempCU->getSkipFlag(0) ) |
---|
| 2012 | { |
---|
| 2013 | rpcTempCU->setTrIdxSubParts(0, 0, uhDepth); |
---|
| 2014 | } |
---|
| 2015 | #endif |
---|
[655] | 2016 | #if H_3D_INTER_SDC |
---|
[608] | 2017 | TComDataCU *rpcTempCUPre = rpcTempCU; |
---|
[296] | 2018 | #endif |
---|
[608] | 2019 | Int orgQP = rpcTempCU->getQP( 0 ); |
---|
| 2020 | xCheckDQP( rpcTempCU ); |
---|
| 2021 | xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); |
---|
[655] | 2022 | #if H_3D_INTER_SDC |
---|
[608] | 2023 | if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() && !uiNoResidual ) |
---|
| 2024 | { |
---|
[1039] | 2025 | Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE}; |
---|
| 2026 | for( Int uiOffest = 1 ; uiOffest <= 5 ; uiOffest++ ) |
---|
[833] | 2027 | { |
---|
[1039] | 2028 | if( uiOffest > 3) |
---|
| 2029 | { |
---|
| 2030 | if ( dOffsetCost[0] < (0.9*dOffsetCost[1]) && dOffsetCost[0] < (0.9*dOffsetCost[2]) ) |
---|
| 2031 | { |
---|
| 2032 | continue; |
---|
| 2033 | } |
---|
| 2034 | if ( dOffsetCost[1] < dOffsetCost[0] && dOffsetCost[0] < dOffsetCost[2] && uiOffest == 5) |
---|
| 2035 | { |
---|
| 2036 | continue; |
---|
| 2037 | } |
---|
| 2038 | if ( dOffsetCost[0] < dOffsetCost[1] && dOffsetCost[2] < dOffsetCost[0] && uiOffest == 4) |
---|
| 2039 | { |
---|
| 2040 | continue; |
---|
| 2041 | } |
---|
| 2042 | } |
---|
[833] | 2043 | if( rpcTempCU != rpcTempCUPre ) |
---|
| 2044 | { |
---|
[872] | 2045 | rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag ); |
---|
[833] | 2046 | rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth ); |
---|
| 2047 | } |
---|
| 2048 | rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth ); |
---|
[1084] | 2049 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2050 | rpcTempCU->setSingleDepthFlagSubParts( false, 0, uhDepth ); |
---|
| 2051 | #endif |
---|
[833] | 2052 | rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth ); |
---|
| 2053 | rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth ); |
---|
| 2054 | #if H_3D_VSO //M2 |
---|
| 2055 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 2056 | { //Reset |
---|
| 2057 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth (); |
---|
| 2058 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight (); |
---|
| 2059 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr (); |
---|
| 2060 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride (); |
---|
| 2061 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
| 2062 | } |
---|
| 2063 | #endif |
---|
[1039] | 2064 | Int iSdcOffset = 0; |
---|
| 2065 | if(uiOffest % 2 == 0) |
---|
| 2066 | { |
---|
| 2067 | iSdcOffset = uiOffest >> 1; |
---|
| 2068 | } |
---|
| 2069 | else |
---|
| 2070 | { |
---|
| 2071 | iSdcOffset = -1 * (uiOffest >> 1); |
---|
| 2072 | } |
---|
[833] | 2073 | m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU, |
---|
| 2074 | m_ppcOrigYuv[uhDepth], |
---|
| 2075 | ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth], |
---|
| 2076 | m_ppcResiYuvTemp[uhDepth], |
---|
| 2077 | m_ppcRecoYuvTemp[uhDepth], |
---|
[1039] | 2078 | iSdcOffset, |
---|
| 2079 | uhDepth ); |
---|
| 2080 | if (uiOffest <= 3 ) |
---|
| 2081 | { |
---|
| 2082 | dOffsetCost [uiOffest -1] = rpcTempCU->getTotalCost(); |
---|
| 2083 | } |
---|
[833] | 2084 | |
---|
| 2085 | xCheckDQP( rpcTempCU ); |
---|
| 2086 | xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth ); |
---|
| 2087 | } |
---|
[56] | 2088 | } |
---|
[296] | 2089 | #endif |
---|
[872] | 2090 | rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag ); |
---|
[608] | 2091 | |
---|
| 2092 | if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip ) |
---|
| 2093 | { |
---|
[655] | 2094 | #if H_3D_INTER_SDC |
---|
[608] | 2095 | if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) ) |
---|
| 2096 | { |
---|
| 2097 | bestIsSkip = !rpcBestCU->getSDCFlag( 0 ) && ( rpcBestCU->getQtRootCbf(0) == 0 ); |
---|
| 2098 | } |
---|
| 2099 | else |
---|
| 2100 | { |
---|
[296] | 2101 | #endif |
---|
[608] | 2102 | bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0; |
---|
[655] | 2103 | #if H_3D_INTER_SDC |
---|
[608] | 2104 | } |
---|
[5] | 2105 | #endif |
---|
[608] | 2106 | } |
---|
| 2107 | } |
---|
| 2108 | } |
---|
| 2109 | } |
---|
[2] | 2110 | |
---|
[608] | 2111 | if(uiNoResidual == 0 && m_pcEncCfg->getUseEarlySkipDetection()) |
---|
| 2112 | { |
---|
| 2113 | if(rpcBestCU->getQtRootCbf( 0 ) == 0) |
---|
| 2114 | { |
---|
| 2115 | if( rpcBestCU->getMergeFlag( 0 )) |
---|
| 2116 | { |
---|
| 2117 | *earlyDetectionSkipMode = true; |
---|
| 2118 | } |
---|
| 2119 | else |
---|
| 2120 | { |
---|
| 2121 | Int absoulte_MV=0; |
---|
| 2122 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 2123 | { |
---|
| 2124 | if ( rpcBestCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
[56] | 2125 | { |
---|
[608] | 2126 | TComCUMvField* pcCUMvField = rpcBestCU->getCUMvField(RefPicList( uiRefListIdx )); |
---|
| 2127 | Int iHor = pcCUMvField->getMvd( 0 ).getAbsHor(); |
---|
| 2128 | Int iVer = pcCUMvField->getMvd( 0 ).getAbsVer(); |
---|
| 2129 | absoulte_MV+=iHor+iVer; |
---|
[56] | 2130 | } |
---|
[608] | 2131 | } |
---|
[2] | 2132 | |
---|
[608] | 2133 | if(absoulte_MV == 0) |
---|
| 2134 | { |
---|
| 2135 | *earlyDetectionSkipMode = true; |
---|
[56] | 2136 | } |
---|
[2] | 2137 | } |
---|
| 2138 | } |
---|
| 2139 | } |
---|
[608] | 2140 | } |
---|
[773] | 2141 | #if H_3D_SPIVMP |
---|
[735] | 2142 | delete[] pcMvFieldSP; |
---|
| 2143 | delete[] puhInterDirSP; |
---|
[724] | 2144 | #endif |
---|
[608] | 2145 | #if H_3D_ARP |
---|
| 2146 | } |
---|
[443] | 2147 | #endif |
---|
[2] | 2148 | } |
---|
| 2149 | |
---|
[608] | 2150 | |
---|
[56] | 2151 | #if AMP_MRG |
---|
[655] | 2152 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 2153 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bFMD, Bool bUseMRG) |
---|
[56] | 2154 | #else |
---|
| 2155 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bUseMRG) |
---|
| 2156 | #endif |
---|
| 2157 | #else |
---|
[2] | 2158 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize ) |
---|
| 2159 | #endif |
---|
[608] | 2160 | { |
---|
[872] | 2161 | |
---|
| 2162 | #if H_3D |
---|
| 2163 | const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0); |
---|
| 2164 | #endif |
---|
[655] | 2165 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 2166 | if(!(bFMD && (ePartSize == SIZE_2Nx2N))) //have motion estimation or merge check |
---|
| 2167 | { |
---|
[56] | 2168 | #endif |
---|
[2] | 2169 | UChar uhDepth = rpcTempCU->getDepth( 0 ); |
---|
[608] | 2170 | #if H_3D_ARP |
---|
| 2171 | Int iLayerId = rpcTempCU->getSlice()->getLayerId(); |
---|
[443] | 2172 | Bool bFirstTime = true; |
---|
[608] | 2173 | Int nARPWMax = rpcTempCU->getSlice()->getARPStepNum() - 1; |
---|
| 2174 | |
---|
[833] | 2175 | if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N || !rpcTempCU->getDvInfo(0).bDV || rpcTempCU->getICFlag(0) ) |
---|
[608] | 2176 | { |
---|
[443] | 2177 | nARPWMax = 0; |
---|
[608] | 2178 | } |
---|
| 2179 | |
---|
| 2180 | for( Int nARPW = 0; nARPW <= nARPWMax; nARPW++ ) |
---|
[443] | 2181 | { |
---|
[608] | 2182 | if( bFirstTime == false && rpcTempCU->getSlice()->getVPS()->getUseAdvRP( iLayerId ) ) |
---|
| 2183 | { |
---|
[872] | 2184 | rpcTempCU->initEstData( rpcTempCU->getDepth(0), rpcTempCU->getQP(0),bTransquantBypassFlag ); |
---|
[608] | 2185 | } |
---|
| 2186 | #endif |
---|
| 2187 | #if H_3D_VSO // M3 |
---|
[2] | 2188 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 2189 | { |
---|
[81] | 2190 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( ); |
---|
| 2191 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( ); |
---|
| 2192 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( ); |
---|
| 2193 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride(); |
---|
| 2194 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[2] | 2195 | } |
---|
[608] | 2196 | #endif |
---|
[2] | 2197 | |
---|
| 2198 | rpcTempCU->setDepthSubParts( uhDepth, 0 ); |
---|
[56] | 2199 | |
---|
[608] | 2200 | rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth ); |
---|
[1084] | 2201 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2202 | rpcTempCU->setSingleDepthFlagSubParts( false, 0, uhDepth ); |
---|
| 2203 | #endif |
---|
[608] | 2204 | rpcTempCU->setPartSizeSubParts ( ePartSize, 0, uhDepth ); |
---|
| 2205 | rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); |
---|
[884] | 2206 | #if H_3D_DDD |
---|
[833] | 2207 | rpcTempCU->setUseDDD( false, 0, uhDepth ); |
---|
| 2208 | #endif |
---|
| 2209 | |
---|
[608] | 2210 | #if H_3D_ARP |
---|
| 2211 | rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth ); |
---|
[5] | 2212 | #endif |
---|
[56] | 2213 | |
---|
[608] | 2214 | #if H_3D_ARP |
---|
| 2215 | if( bFirstTime == false && nARPWMax ) |
---|
[443] | 2216 | { |
---|
[608] | 2217 | rpcTempCU->copyPartFrom( m_ppcWeightedTempCU[uhDepth] , 0 , uhDepth ); |
---|
| 2218 | rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth ); |
---|
| 2219 | |
---|
[443] | 2220 | m_pcPredSearch->motionCompensation( rpcTempCU , m_ppcPredYuvTemp[uhDepth] ); |
---|
| 2221 | } |
---|
| 2222 | else |
---|
| 2223 | { |
---|
| 2224 | bFirstTime = false; |
---|
| 2225 | #endif |
---|
[56] | 2226 | #if AMP_MRG |
---|
| 2227 | rpcTempCU->setMergeAMP (true); |
---|
[655] | 2228 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 2229 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bFMD, false, bUseMRG ); |
---|
[56] | 2230 | #else |
---|
| 2231 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG ); |
---|
| 2232 | #endif |
---|
| 2233 | #else |
---|
[2] | 2234 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] ); |
---|
| 2235 | #endif |
---|
[608] | 2236 | #if H_3D_ARP |
---|
| 2237 | if( nARPWMax ) |
---|
[443] | 2238 | { |
---|
| 2239 | m_ppcWeightedTempCU[uhDepth]->copyPartFrom( rpcTempCU , 0 , uhDepth ); |
---|
| 2240 | } |
---|
| 2241 | } |
---|
| 2242 | #endif |
---|
[56] | 2243 | |
---|
| 2244 | #if AMP_MRG |
---|
| 2245 | if ( !rpcTempCU->getMergeAMP() ) |
---|
[2] | 2246 | { |
---|
[608] | 2247 | #if H_3D_ARP |
---|
| 2248 | if( nARPWMax ) |
---|
| 2249 | { |
---|
[443] | 2250 | continue; |
---|
[608] | 2251 | } |
---|
[443] | 2252 | else |
---|
| 2253 | #endif |
---|
[2] | 2254 | return; |
---|
| 2255 | } |
---|
| 2256 | #endif |
---|
[56] | 2257 | |
---|
[872] | 2258 | #if KWU_RC_MADPRED_E0227 |
---|
[608] | 2259 | if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth ) |
---|
| 2260 | { |
---|
| 2261 | UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(), |
---|
| 2262 | m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(), |
---|
| 2263 | rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) ); |
---|
| 2264 | m_temporalSAD = (Int)SAD; |
---|
| 2265 | } |
---|
[56] | 2266 | #endif |
---|
[608] | 2267 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false ); |
---|
[884] | 2268 | #if H_3D_VSP // possible bug fix |
---|
[833] | 2269 | if( rpcTempCU->getQtRootCbf(0)==0 ) |
---|
| 2270 | { |
---|
| 2271 | rpcTempCU->setTrIdxSubParts(0, 0, uhDepth); |
---|
| 2272 | } |
---|
| 2273 | #endif |
---|
[608] | 2274 | #if H_3D_VSO // M4 |
---|
[2] | 2275 | if( m_pcRdCost->getUseLambdaScaleVSO() ) |
---|
| 2276 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 2277 | else |
---|
[5] | 2278 | #endif |
---|
[608] | 2279 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
[655] | 2280 | #if H_3D_INTER_SDC |
---|
[608] | 2281 | TComDataCU *rpcTempCUPre = rpcTempCU; |
---|
| 2282 | #endif |
---|
| 2283 | xCheckDQP( rpcTempCU ); |
---|
| 2284 | xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); |
---|
[655] | 2285 | #if H_3D_INTER_SDC |
---|
[833] | 2286 | if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() && ePartSize == SIZE_2Nx2N) |
---|
[2] | 2287 | { |
---|
[1039] | 2288 | Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE}; |
---|
| 2289 | for( Int uiOffest = 1 ; uiOffest <= 5 ; uiOffest++ ) |
---|
[833] | 2290 | { |
---|
[1039] | 2291 | if( uiOffest > 3) |
---|
| 2292 | { |
---|
| 2293 | if ( dOffsetCost[0] < (0.9*dOffsetCost[1]) && dOffsetCost[0] < (0.9*dOffsetCost[2]) ) |
---|
| 2294 | { |
---|
| 2295 | continue; |
---|
| 2296 | } |
---|
| 2297 | if ( dOffsetCost[1] < dOffsetCost[0] && dOffsetCost[0] < dOffsetCost[2] && uiOffest == 5) |
---|
| 2298 | { |
---|
| 2299 | continue; |
---|
| 2300 | } |
---|
| 2301 | if ( dOffsetCost[0] < dOffsetCost[1] && dOffsetCost[2] < dOffsetCost[0] && uiOffest == 4) |
---|
| 2302 | { |
---|
| 2303 | continue; |
---|
| 2304 | } |
---|
| 2305 | } |
---|
[1084] | 2306 | |
---|
[833] | 2307 | if( rpcTempCU != rpcTempCUPre ) |
---|
| 2308 | { |
---|
| 2309 | Int orgQP = rpcBestCU->getQP( 0 ); |
---|
[872] | 2310 | rpcTempCU->initEstData( uhDepth, orgQP ,bTransquantBypassFlag ); |
---|
[833] | 2311 | rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth ); |
---|
| 2312 | } |
---|
| 2313 | rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth ); |
---|
[1084] | 2314 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2315 | rpcTempCU->setSingleDepthFlagSubParts( false, 0, uhDepth ); |
---|
| 2316 | #endif |
---|
[833] | 2317 | rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth ); |
---|
| 2318 | rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth ); |
---|
| 2319 | #if H_3D_VSO // M3 |
---|
| 2320 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 2321 | { |
---|
| 2322 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( ); |
---|
| 2323 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( ); |
---|
| 2324 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( ); |
---|
| 2325 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride(); |
---|
| 2326 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
| 2327 | } |
---|
| 2328 | #endif |
---|
| 2329 | |
---|
[1039] | 2330 | Int iSdcOffset = 0; |
---|
| 2331 | if(uiOffest % 2 == 0) |
---|
| 2332 | { |
---|
| 2333 | iSdcOffset = uiOffest >> 1; |
---|
| 2334 | } |
---|
| 2335 | else |
---|
| 2336 | { |
---|
| 2337 | iSdcOffset = -1 * (uiOffest >> 1); |
---|
| 2338 | } |
---|
[833] | 2339 | m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU, |
---|
| 2340 | m_ppcOrigYuv[uhDepth], |
---|
| 2341 | ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth], |
---|
| 2342 | m_ppcResiYuvTemp[uhDepth], |
---|
| 2343 | m_ppcRecoYuvTemp[uhDepth], |
---|
[1039] | 2344 | iSdcOffset, |
---|
| 2345 | uhDepth ); |
---|
| 2346 | if (uiOffest <= 3 ) |
---|
| 2347 | { |
---|
| 2348 | dOffsetCost [uiOffest -1] = rpcTempCU->getTotalCost(); |
---|
| 2349 | } |
---|
[833] | 2350 | |
---|
| 2351 | xCheckDQP( rpcTempCU ); |
---|
| 2352 | xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); |
---|
| 2353 | } |
---|
[2] | 2354 | |
---|
[443] | 2355 | } |
---|
| 2356 | #endif |
---|
[608] | 2357 | #if H_3D_ARP |
---|
| 2358 | } |
---|
| 2359 | #endif |
---|
[655] | 2360 | #if H_3D_FAST_TEXTURE_ENCODING |
---|
[608] | 2361 | } |
---|
| 2362 | #endif |
---|
[2] | 2363 | } |
---|
| 2364 | |
---|
[833] | 2365 | #if H_3D_DBBP |
---|
| 2366 | Void TEncCu::xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment ) |
---|
| 2367 | { |
---|
| 2368 | UInt uiWidth = pOrigYuv->getWidth ( ); |
---|
| 2369 | UInt uiHeight = pOrigYuv->getHeight( ); |
---|
| 2370 | Pel* piSrc = pOrigYuv->getLumaAddr( ); |
---|
| 2371 | UInt uiSrcStride = pOrigYuv->getStride(); |
---|
| 2372 | Pel* piDst = pOrigYuvTemp->getLumaAddr( ); |
---|
| 2373 | UInt uiDstStride = pOrigYuvTemp->getStride(); |
---|
| 2374 | |
---|
| 2375 | UInt uiMaskStride= MAX_CU_SIZE; |
---|
| 2376 | |
---|
| 2377 | AOF( uiWidth == uiHeight ); |
---|
| 2378 | |
---|
| 2379 | // backup pointer |
---|
| 2380 | Bool* pMaskStart = pMask; |
---|
| 2381 | |
---|
| 2382 | for (Int y=0; y<uiHeight; y++) |
---|
| 2383 | { |
---|
| 2384 | for (Int x=0; x<uiWidth; x++) |
---|
| 2385 | { |
---|
| 2386 | UChar ucSegment = (UChar)pMask[x]; |
---|
| 2387 | AOF( ucSegment < 2 ); |
---|
| 2388 | |
---|
| 2389 | piDst[x] = (ucSegment==uiValidSegment)?piSrc[x]:DBBP_INVALID_SHORT; |
---|
| 2390 | } |
---|
| 2391 | |
---|
| 2392 | piSrc += uiSrcStride; |
---|
| 2393 | piDst += uiDstStride; |
---|
| 2394 | pMask += uiMaskStride; |
---|
| 2395 | } |
---|
| 2396 | |
---|
| 2397 | // now invalidate chroma |
---|
| 2398 | Pel* piSrcU = pOrigYuv->getCbAddr(); |
---|
| 2399 | Pel* piSrcV = pOrigYuv->getCrAddr(); |
---|
| 2400 | UInt uiSrcStrideC = pOrigYuv->getCStride(); |
---|
| 2401 | Pel* piDstU = pOrigYuvTemp->getCbAddr( ); |
---|
| 2402 | Pel* piDstV = pOrigYuvTemp->getCrAddr( ); |
---|
| 2403 | UInt uiDstStrideC = pOrigYuvTemp->getCStride(); |
---|
| 2404 | pMask = pMaskStart; |
---|
| 2405 | |
---|
| 2406 | for (Int y=0; y<uiHeight/2; y++) |
---|
| 2407 | { |
---|
| 2408 | for (Int x=0; x<uiWidth/2; x++) |
---|
| 2409 | { |
---|
| 2410 | UChar ucSegment = (UChar)pMask[x*2]; |
---|
| 2411 | AOF( ucSegment < 2 ); |
---|
| 2412 | |
---|
| 2413 | piDstU[x] = (ucSegment==uiValidSegment)?piSrcU[x]:DBBP_INVALID_SHORT; |
---|
| 2414 | piDstV[x] = (ucSegment==uiValidSegment)?piSrcV[x]:DBBP_INVALID_SHORT; |
---|
| 2415 | } |
---|
| 2416 | |
---|
| 2417 | piSrcU += uiSrcStrideC; |
---|
| 2418 | piSrcV += uiSrcStrideC; |
---|
| 2419 | piDstU += uiDstStrideC; |
---|
| 2420 | piDstV += uiDstStrideC; |
---|
| 2421 | pMask += 2*uiMaskStride; |
---|
| 2422 | } |
---|
| 2423 | } |
---|
[1084] | 2424 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2425 | Void TEncCu::xCheckRDCostSingleDepth( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize ) |
---|
| 2426 | { |
---|
| 2427 | UInt uiDepth = rpcTempCU->getDepth( 0 ); |
---|
| 2428 | if( !rpcBestCU->getSlice()->getIsDepth() || (eSize != SIZE_2Nx2N)) |
---|
| 2429 | { |
---|
| 2430 | return; |
---|
| 2431 | } |
---|
| 2432 | |
---|
| 2433 | #if H_3D_VSO // M5 |
---|
| 2434 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 2435 | { |
---|
| 2436 | UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth (); |
---|
| 2437 | UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight (); |
---|
| 2438 | Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr(); |
---|
| 2439 | UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride (); |
---|
| 2440 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
| 2441 | } |
---|
| 2442 | #endif |
---|
[833] | 2443 | |
---|
[1039] | 2444 | rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth ); |
---|
| 2445 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 2446 | rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); |
---|
| 2447 | rpcTempCU->setCUTransquantBypassSubParts( rpcTempCU->getCUTransquantBypass(0), 0, uiDepth ); |
---|
| 2448 | |
---|
| 2449 | rpcTempCU->setTrIdxSubParts(0, 0, uiDepth); |
---|
| 2450 | rpcTempCU->setCbfSubParts(0, 1, 1, 0, uiDepth); |
---|
| 2451 | rpcTempCU->setSingleDepthFlagSubParts(true, 0, uiDepth); |
---|
| 2452 | rpcTempCU->setLumaIntraDirSubParts (DC_IDX, 0, uiDepth); |
---|
| 2453 | #if H_3D_DIM_SDC |
---|
| 2454 | rpcTempCU->setSDCFlagSubParts( false, 0, uiDepth); |
---|
| 2455 | #endif |
---|
| 2456 | |
---|
| 2457 | UInt uiPreCalcDistC; |
---|
| 2458 | m_pcPredSearch ->estIntraPredSingleDepth ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, false ); |
---|
| 2459 | |
---|
| 2460 | |
---|
| 2461 | m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() ); |
---|
| 2462 | |
---|
| 2463 | |
---|
| 2464 | m_pcEntropyCoder->resetBits(); |
---|
| 2465 | if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
---|
| 2466 | { |
---|
| 2467 | m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0, true ); |
---|
| 2468 | } |
---|
| 2469 | m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); |
---|
| 2470 | m_pcEntropyCoder->encodeSingleDepthMode( rpcTempCU, 0, true ); |
---|
| 2471 | |
---|
| 2472 | |
---|
| 2473 | m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); |
---|
| 2474 | |
---|
| 2475 | rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
| 2476 | rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
| 2477 | |
---|
| 2478 | |
---|
| 2479 | #if H_3D_VSO // M6 |
---|
| 2480 | if( m_pcRdCost->getUseLambdaScaleVSO()) |
---|
| 2481 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 2482 | else |
---|
| 2483 | #endif |
---|
| 2484 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 2485 | |
---|
| 2486 | |
---|
| 2487 | xCheckDQP( rpcTempCU ); |
---|
| 2488 | xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth); |
---|
| 2489 | } |
---|
| 2490 | #endif |
---|
[1084] | 2491 | |
---|
[833] | 2492 | Void TEncCu::xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bUseMRG ) |
---|
| 2493 | { |
---|
| 2494 | AOF( !rpcTempCU->getSlice()->getIsDepth() ); |
---|
| 2495 | |
---|
| 2496 | UChar uhDepth = rpcTempCU->getDepth( 0 ); |
---|
| 2497 | |
---|
| 2498 | #if H_3D_VSO |
---|
| 2499 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 2500 | { |
---|
| 2501 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( ); |
---|
| 2502 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( ); |
---|
| 2503 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( ); |
---|
| 2504 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride(); |
---|
| 2505 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
| 2506 | } |
---|
| 2507 | #endif |
---|
| 2508 | |
---|
| 2509 | UInt uiWidth = rpcTempCU->getWidth(0); |
---|
| 2510 | UInt uiHeight = rpcTempCU->getHeight(0); |
---|
| 2511 | AOF( uiWidth == uiHeight ); |
---|
| 2512 | |
---|
[1084] | 2513 | #if H_3D_DBBP |
---|
| 2514 | // Is this correct here, was under the macro SEC_DBBP_DISALLOW_8x8_I0078, however the function is related to Single Depth Mode |
---|
[1039] | 2515 | if(uiWidth <= 8) |
---|
| 2516 | { |
---|
| 2517 | return; |
---|
| 2518 | } |
---|
| 2519 | #endif |
---|
| 2520 | |
---|
[833] | 2521 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); |
---|
| 2522 | |
---|
| 2523 | // fetch virtual depth block |
---|
| 2524 | UInt uiDepthStride = 0; |
---|
[1084] | 2525 | #if H_3D_FCO |
---|
[1066] | 2526 | Pel* pDepthPels = rpcTempCU->getVirtualDepthBlock(rpcTempCU->getZorderIdxInCU(), uiWidth, uiHeight, uiDepthStride); |
---|
| 2527 | #else |
---|
[833] | 2528 | Pel* pDepthPels = rpcTempCU->getVirtualDepthBlock(0, uiWidth, uiHeight, uiDepthStride); |
---|
[1066] | 2529 | #endif |
---|
[833] | 2530 | AOF( pDepthPels != NULL ); |
---|
| 2531 | AOF( uiDepthStride != 0 ); |
---|
| 2532 | |
---|
| 2533 | // derive partitioning from depth |
---|
| 2534 | PartSize eVirtualPartSize = m_pcPredSearch->getPartitionSizeFromDepth(pDepthPels, uiDepthStride, uiWidth); |
---|
| 2535 | |
---|
| 2536 | // derive segmentation mask from depth |
---|
| 2537 | Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE]; |
---|
| 2538 | Bool bValidMask = m_pcPredSearch->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, uiWidth, uiHeight, pMask); |
---|
| 2539 | |
---|
| 2540 | if( !bValidMask ) |
---|
| 2541 | { |
---|
| 2542 | return; |
---|
| 2543 | } |
---|
| 2544 | |
---|
| 2545 | // find optimal motion/disparity vector for each segment |
---|
| 2546 | DisInfo originalDvInfo = rpcTempCU->getDvInfo(0); |
---|
| 2547 | DBBPTmpData* pDBBPTmpData = rpcTempCU->getDBBPTmpData(); |
---|
| 2548 | TComYuv* apPredYuv[2] = { m_ppcRecoYuvTemp[uhDepth], m_ppcPredYuvTemp[uhDepth] }; |
---|
| 2549 | |
---|
| 2550 | // find optimal motion vector fields for both segments (as 2Nx2N) |
---|
| 2551 | rpcTempCU->setDepthSubParts( uhDepth, 0 ); |
---|
| 2552 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); |
---|
| 2553 | rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth ); |
---|
| 2554 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
| 2555 | { |
---|
| 2556 | rpcTempCU->setDBBPFlagSubParts(true, 0, 0, uhDepth); |
---|
| 2557 | rpcTempCU->setDvInfoSubParts(originalDvInfo, 0, uhDepth); |
---|
| 2558 | |
---|
| 2559 | // invalidate all other segments in original YUV |
---|
| 2560 | xInvalidateOriginalSegments(m_ppcOrigYuv[uhDepth], m_ppcOrigYuvDBBP[uhDepth], pMask, uiSegment); |
---|
| 2561 | |
---|
| 2562 | // do motion estimation for this segment |
---|
| 2563 | m_pcRdCost->setUseMask(true); |
---|
| 2564 | rpcTempCU->getDBBPTmpData()->eVirtualPartSize = eVirtualPartSize; |
---|
| 2565 | rpcTempCU->getDBBPTmpData()->uiVirtualPartIndex = uiSegment; |
---|
| 2566 | m_pcPredSearch->predInterSearch( rpcTempCU, m_ppcOrigYuvDBBP[uhDepth], apPredYuv[uiSegment], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], false, false, bUseMRG ); |
---|
| 2567 | m_pcRdCost->setUseMask(false); |
---|
| 2568 | |
---|
| 2569 | // extract motion parameters of full block for this segment |
---|
| 2570 | pDBBPTmpData->auhInterDir[uiSegment] = rpcTempCU->getInterDir(0); |
---|
| 2571 | |
---|
| 2572 | pDBBPTmpData->abMergeFlag[uiSegment] = rpcTempCU->getMergeFlag(0); |
---|
| 2573 | pDBBPTmpData->auhMergeIndex[uiSegment] = rpcTempCU->getMergeIndex(0); |
---|
| 2574 | |
---|
[950] | 2575 | AOF( rpcTempCU->getSPIVMPFlag(0) == false ); |
---|
| 2576 | AOF( rpcTempCU->getVSPFlag(0) == 0 ); |
---|
[833] | 2577 | |
---|
| 2578 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 2579 | { |
---|
| 2580 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
| 2581 | |
---|
| 2582 | pDBBPTmpData->acMvd[uiSegment][eRefList] = rpcTempCU->getCUMvField(eRefList)->getMvd(0); |
---|
| 2583 | pDBBPTmpData->aiMvpNum[uiSegment][eRefList] = rpcTempCU->getMVPNum(eRefList, 0); |
---|
| 2584 | pDBBPTmpData->aiMvpIdx[uiSegment][eRefList] = rpcTempCU->getMVPIdx(eRefList, 0); |
---|
| 2585 | |
---|
| 2586 | rpcTempCU->getMvField(rpcTempCU, 0, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]); |
---|
| 2587 | } |
---|
| 2588 | } |
---|
| 2589 | |
---|
| 2590 | // store final motion/disparity information in each PU using derived partitioning |
---|
| 2591 | rpcTempCU->setDepthSubParts( uhDepth, 0 ); |
---|
| 2592 | rpcTempCU->setPartSizeSubParts ( eVirtualPartSize, 0, uhDepth ); |
---|
| 2593 | rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); |
---|
| 2594 | |
---|
| 2595 | UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( rpcTempCU->getSlice()->getSPS()->getMaxCUDepth() - uhDepth ) << 1 ) ) >> 4; |
---|
| 2596 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
| 2597 | { |
---|
| 2598 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
| 2599 | |
---|
| 2600 | rpcTempCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uhDepth); |
---|
| 2601 | |
---|
| 2602 | // now set stored information from 2Nx2N motion search to each partition |
---|
| 2603 | rpcTempCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uhDepth); // interprets depth relative to LCU level |
---|
| 2604 | |
---|
| 2605 | rpcTempCU->setMergeFlagSubParts(pDBBPTmpData->abMergeFlag[uiSegment], uiPartAddr, uiSegment, uhDepth); |
---|
| 2606 | rpcTempCU->setMergeIndexSubParts(pDBBPTmpData->auhMergeIndex[uiSegment], uiPartAddr, uiSegment, uhDepth); |
---|
[976] | 2607 | |
---|
[833] | 2608 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 2609 | { |
---|
| 2610 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
| 2611 | |
---|
| 2612 | rpcTempCU->getCUMvField( eRefList )->setAllMvd(pDBBPTmpData->acMvd[uiSegment][eRefList], eVirtualPartSize, uiPartAddr, 0, uiSegment); |
---|
| 2613 | rpcTempCU->setMVPNum(eRefList, uiPartAddr, pDBBPTmpData->aiMvpNum[uiSegment][eRefList]); |
---|
| 2614 | rpcTempCU->setMVPIdx(eRefList, uiPartAddr, pDBBPTmpData->aiMvpIdx[uiSegment][eRefList]); |
---|
| 2615 | |
---|
| 2616 | rpcTempCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], eVirtualPartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level |
---|
| 2617 | } |
---|
| 2618 | } |
---|
| 2619 | |
---|
| 2620 | // reconstruct final prediction signal by combining both segments |
---|
[1039] | 2621 | m_pcPredSearch->combineSegmentsWithMask(apPredYuv, m_ppcPredYuvTemp[uhDepth], pMask, uiWidth, uiHeight, 0, eVirtualPartSize); |
---|
[833] | 2622 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false ); |
---|
| 2623 | |
---|
| 2624 | xCheckDQP( rpcTempCU ); |
---|
| 2625 | xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); |
---|
| 2626 | } |
---|
| 2627 | #endif |
---|
[1084] | 2628 | #if H_3D_DIM |
---|
[1039] | 2629 | Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize, Bool bOnlyIVP ) |
---|
| 2630 | #else |
---|
[2] | 2631 | Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize ) |
---|
[1039] | 2632 | #endif |
---|
[2] | 2633 | { |
---|
[1084] | 2634 | UInt uiDepth = rpcTempCU->getDepth( 0 ); |
---|
[608] | 2635 | #if H_3D_VSO // M5 |
---|
[2] | 2636 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 2637 | { |
---|
[81] | 2638 | UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth (); |
---|
| 2639 | UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight (); |
---|
| 2640 | Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr(); |
---|
| 2641 | UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride (); |
---|
| 2642 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[2] | 2643 | } |
---|
[5] | 2644 | #endif |
---|
[2] | 2645 | |
---|
[608] | 2646 | rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth ); |
---|
[1084] | 2647 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2648 | rpcTempCU->setSingleDepthFlagSubParts( false, 0, uiDepth ); |
---|
| 2649 | #endif |
---|
[2] | 2650 | rpcTempCU->setPartSizeSubParts( eSize, 0, uiDepth ); |
---|
| 2651 | rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); |
---|
[56] | 2652 | |
---|
[2] | 2653 | Bool bSeparateLumaChroma = true; // choose estimation mode |
---|
[608] | 2654 | UInt uiPreCalcDistC = 0; |
---|
[2] | 2655 | if( !bSeparateLumaChroma ) |
---|
| 2656 | { |
---|
| 2657 | m_pcPredSearch->preestChromaPredMode( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth] ); |
---|
| 2658 | } |
---|
[1084] | 2659 | #if H_3D_DIM |
---|
[1039] | 2660 | m_pcPredSearch ->estIntraPredQT ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, bSeparateLumaChroma, bOnlyIVP ); |
---|
| 2661 | #else |
---|
[2] | 2662 | m_pcPredSearch ->estIntraPredQT ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, bSeparateLumaChroma ); |
---|
[1039] | 2663 | #endif |
---|
[2] | 2664 | m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() ); |
---|
[56] | 2665 | |
---|
[608] | 2666 | #if H_3D_DIM_SDC |
---|
[189] | 2667 | if( !rpcTempCU->getSDCFlag( 0 ) ) |
---|
| 2668 | #endif |
---|
[2] | 2669 | m_pcPredSearch ->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC ); |
---|
[56] | 2670 | |
---|
[2] | 2671 | m_pcEntropyCoder->resetBits(); |
---|
[608] | 2672 | if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
---|
| 2673 | { |
---|
| 2674 | m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0, true ); |
---|
| 2675 | } |
---|
[2] | 2676 | m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); |
---|
[1084] | 2677 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2678 | m_pcEntropyCoder->encodeSingleDepthMode( rpcTempCU, 0, true ); |
---|
| 2679 | if(!rpcTempCU->getSingleDepthFlag(0)) |
---|
| 2680 | { |
---|
| 2681 | #endif |
---|
[2] | 2682 | m_pcEntropyCoder->encodePredMode( rpcTempCU, 0, true ); |
---|
| 2683 | m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true ); |
---|
[884] | 2684 | #if H_3D_DIM_SDC |
---|
[833] | 2685 | m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true ); |
---|
| 2686 | #endif |
---|
[2] | 2687 | m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0, true ); |
---|
[56] | 2688 | m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true ); |
---|
[2] | 2689 | |
---|
| 2690 | // Encode Coefficients |
---|
[56] | 2691 | Bool bCodeDQP = getdQPFlag(); |
---|
| 2692 | m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP ); |
---|
| 2693 | setdQPFlag( bCodeDQP ); |
---|
[1084] | 2694 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2695 | } |
---|
| 2696 | #endif |
---|
[872] | 2697 | m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); |
---|
[56] | 2698 | |
---|
[2] | 2699 | rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
[56] | 2700 | rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
[608] | 2701 | #if H_3D_VSO // M6 |
---|
| 2702 | if( m_pcRdCost->getUseLambdaScaleVSO()) |
---|
| 2703 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
[2] | 2704 | else |
---|
[5] | 2705 | #endif |
---|
[56] | 2706 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 2707 | |
---|
| 2708 | xCheckDQP( rpcTempCU ); |
---|
| 2709 | xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth); |
---|
| 2710 | } |
---|
[2] | 2711 | |
---|
[56] | 2712 | /** Check R-D costs for a CU with PCM mode. |
---|
| 2713 | * \param rpcBestCU pointer to best mode CU data structure |
---|
| 2714 | * \param rpcTempCU pointer to testing mode CU data structure |
---|
| 2715 | * \returns Void |
---|
| 2716 | * |
---|
| 2717 | * \note Current PCM implementation encodes sample values in a lossless way. The distortion of PCM mode CUs are zero. PCM mode is selected if the best mode yields bits greater than that of PCM mode. |
---|
| 2718 | */ |
---|
| 2719 | Void TEncCu::xCheckIntraPCM( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ) |
---|
| 2720 | { |
---|
| 2721 | UInt uiDepth = rpcTempCU->getDepth( 0 ); |
---|
| 2722 | |
---|
[608] | 2723 | rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth ); |
---|
[1084] | 2724 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2725 | rpcTempCU->setSingleDepthFlagSubParts( false, 0, uiDepth ); |
---|
| 2726 | #endif |
---|
[56] | 2727 | rpcTempCU->setIPCMFlag(0, true); |
---|
| 2728 | rpcTempCU->setIPCMFlagSubParts (true, 0, rpcTempCU->getDepth(0)); |
---|
| 2729 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 2730 | rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); |
---|
[608] | 2731 | rpcTempCU->setTrIdxSubParts ( 0, 0, uiDepth ); |
---|
[56] | 2732 | |
---|
| 2733 | m_pcPredSearch->IPCMSearch( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth]); |
---|
| 2734 | |
---|
[872] | 2735 | m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); |
---|
[56] | 2736 | |
---|
| 2737 | m_pcEntropyCoder->resetBits(); |
---|
[608] | 2738 | if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
---|
| 2739 | { |
---|
| 2740 | m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0, true ); |
---|
| 2741 | } |
---|
[56] | 2742 | m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); |
---|
[1084] | 2743 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2744 | m_pcEntropyCoder->encodeSingleDepthMode( rpcTempCU, 0, true ); |
---|
| 2745 | #endif |
---|
[56] | 2746 | m_pcEntropyCoder->encodePredMode ( rpcTempCU, 0, true ); |
---|
| 2747 | m_pcEntropyCoder->encodePartSize ( rpcTempCU, 0, uiDepth, true ); |
---|
[884] | 2748 | #if H_3D_DIM_SDC |
---|
[833] | 2749 | m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true ); |
---|
| 2750 | #endif |
---|
[56] | 2751 | m_pcEntropyCoder->encodeIPCMInfo ( rpcTempCU, 0, true ); |
---|
| 2752 | |
---|
[872] | 2753 | m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); |
---|
[56] | 2754 | |
---|
| 2755 | rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
| 2756 | rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
[608] | 2757 | #if H_3D_VSO // M44 |
---|
[56] | 2758 | if ( m_pcRdCost->getUseVSO() ) |
---|
| 2759 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 2760 | else |
---|
| 2761 | #endif |
---|
| 2762 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 2763 | |
---|
| 2764 | xCheckDQP( rpcTempCU ); |
---|
[2] | 2765 | xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth ); |
---|
| 2766 | } |
---|
| 2767 | |
---|
[56] | 2768 | /** check whether current try is the best with identifying the depth of current try |
---|
| 2769 | * \param rpcBestCU |
---|
| 2770 | * \param rpcTempCU |
---|
| 2771 | * \returns Void |
---|
| 2772 | */ |
---|
| 2773 | Void TEncCu::xCheckBestMode( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth ) |
---|
[2] | 2774 | { |
---|
[56] | 2775 | if( rpcTempCU->getTotalCost() < rpcBestCU->getTotalCost() ) |
---|
| 2776 | { |
---|
| 2777 | TComYuv* pcYuv; |
---|
| 2778 | // Change Information data |
---|
| 2779 | TComDataCU* pcCU = rpcBestCU; |
---|
| 2780 | rpcBestCU = rpcTempCU; |
---|
| 2781 | rpcTempCU = pcCU; |
---|
[2] | 2782 | |
---|
[56] | 2783 | // Change Prediction data |
---|
| 2784 | pcYuv = m_ppcPredYuvBest[uiDepth]; |
---|
| 2785 | m_ppcPredYuvBest[uiDepth] = m_ppcPredYuvTemp[uiDepth]; |
---|
| 2786 | m_ppcPredYuvTemp[uiDepth] = pcYuv; |
---|
[2] | 2787 | |
---|
[56] | 2788 | // Change Reconstruction data |
---|
| 2789 | pcYuv = m_ppcRecoYuvBest[uiDepth]; |
---|
| 2790 | m_ppcRecoYuvBest[uiDepth] = m_ppcRecoYuvTemp[uiDepth]; |
---|
| 2791 | m_ppcRecoYuvTemp[uiDepth] = pcYuv; |
---|
[2] | 2792 | |
---|
[56] | 2793 | pcYuv = NULL; |
---|
| 2794 | pcCU = NULL; |
---|
[2] | 2795 | |
---|
[872] | 2796 | // store temp best CI for next CU coding |
---|
[56] | 2797 | m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); |
---|
| 2798 | } |
---|
| 2799 | } |
---|
| 2800 | |
---|
| 2801 | Void TEncCu::xCheckDQP( TComDataCU* pcCU ) |
---|
| 2802 | { |
---|
| 2803 | UInt uiDepth = pcCU->getDepth( 0 ); |
---|
| 2804 | |
---|
| 2805 | if( pcCU->getSlice()->getPPS()->getUseDQP() && (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
[2] | 2806 | { |
---|
[56] | 2807 | if ( pcCU->getCbf( 0, TEXT_LUMA, 0 ) || pcCU->getCbf( 0, TEXT_CHROMA_U, 0 ) || pcCU->getCbf( 0, TEXT_CHROMA_V, 0 ) ) |
---|
| 2808 | { |
---|
| 2809 | #if !RDO_WITHOUT_DQP_BITS |
---|
| 2810 | m_pcEntropyCoder->resetBits(); |
---|
| 2811 | m_pcEntropyCoder->encodeQP( pcCU, 0, false ); |
---|
| 2812 | pcCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits |
---|
| 2813 | pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
[608] | 2814 | #if H_3D_VSO // M45 |
---|
| 2815 | if ( m_pcRdCost->getUseVSO() ) |
---|
| 2816 | pcCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); |
---|
[56] | 2817 | else |
---|
| 2818 | #endif |
---|
| 2819 | pcCU->getTotalCost() = m_pcRdCost->calcRdCost( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); |
---|
| 2820 | #endif |
---|
[2] | 2821 | } |
---|
[56] | 2822 | else |
---|
[2] | 2823 | { |
---|
[56] | 2824 | pcCU->setQPSubParts( pcCU->getRefQP( 0 ), 0, uiDepth ); // set QP to default QP |
---|
[2] | 2825 | } |
---|
[56] | 2826 | } |
---|
| 2827 | } |
---|
| 2828 | |
---|
[2] | 2829 | Void TEncCu::xCopyAMVPInfo (AMVPInfo* pSrc, AMVPInfo* pDst) |
---|
| 2830 | { |
---|
| 2831 | pDst->iN = pSrc->iN; |
---|
| 2832 | for (Int i = 0; i < pSrc->iN; i++) |
---|
| 2833 | { |
---|
| 2834 | pDst->m_acMvCand[i] = pSrc->m_acMvCand[i]; |
---|
| 2835 | } |
---|
| 2836 | } |
---|
[56] | 2837 | Void TEncCu::xCopyYuv2Pic(TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth, TComDataCU* pcCU, UInt uiLPelX, UInt uiTPelY ) |
---|
| 2838 | { |
---|
| 2839 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 2840 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
| 2841 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
[608] | 2842 | Bool bSliceStart = pcSlice->getSliceSegmentCurStartCUAddr() > rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && |
---|
| 2843 | pcSlice->getSliceSegmentCurStartCUAddr() < rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) ); |
---|
| 2844 | Bool bSliceEnd = pcSlice->getSliceSegmentCurEndCUAddr() > rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && |
---|
| 2845 | pcSlice->getSliceSegmentCurEndCUAddr() < rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) ); |
---|
[56] | 2846 | if(!bSliceEnd && !bSliceStart && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 2847 | { |
---|
| 2848 | UInt uiAbsPartIdxInRaster = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
| 2849 | UInt uiSrcBlkWidth = rpcPic->getNumPartInWidth() >> (uiSrcDepth); |
---|
| 2850 | UInt uiBlkWidth = rpcPic->getNumPartInWidth() >> (uiDepth); |
---|
| 2851 | UInt uiPartIdxX = ( ( uiAbsPartIdxInRaster % rpcPic->getNumPartInWidth() ) % uiSrcBlkWidth) / uiBlkWidth; |
---|
| 2852 | UInt uiPartIdxY = ( ( uiAbsPartIdxInRaster / rpcPic->getNumPartInWidth() ) % uiSrcBlkWidth) / uiBlkWidth; |
---|
| 2853 | UInt uiPartIdx = uiPartIdxY * ( uiSrcBlkWidth / uiBlkWidth ) + uiPartIdxX; |
---|
| 2854 | m_ppcRecoYuvBest[uiSrcDepth]->copyToPicYuv( rpcPic->getPicYuvRec (), uiCUAddr, uiAbsPartIdx, uiDepth - uiSrcDepth, uiPartIdx); |
---|
| 2855 | } |
---|
| 2856 | else |
---|
| 2857 | { |
---|
| 2858 | UInt uiQNumParts = ( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) )>>2; |
---|
[2] | 2859 | |
---|
[56] | 2860 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx+=uiQNumParts ) |
---|
| 2861 | { |
---|
| 2862 | UInt uiSubCULPelX = uiLPelX + ( g_uiMaxCUWidth >>(uiDepth+1) )*( uiPartUnitIdx & 1 ); |
---|
| 2863 | UInt uiSubCUTPelY = uiTPelY + ( g_uiMaxCUHeight>>(uiDepth+1) )*( uiPartUnitIdx >> 1 ); |
---|
| 2864 | |
---|
[608] | 2865 | Bool bInSlice = rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+uiQNumParts > pcSlice->getSliceSegmentCurStartCUAddr() && |
---|
| 2866 | rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx < pcSlice->getSliceSegmentCurEndCUAddr(); |
---|
[56] | 2867 | if(bInSlice&&( uiSubCULPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiSubCUTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 2868 | { |
---|
| 2869 | xCopyYuv2Pic( rpcPic, uiCUAddr, uiAbsPartIdx, uiDepth+1, uiSrcDepth, pcCU, uiSubCULPelX, uiSubCUTPelY ); // Copy Yuv data to picture Yuv |
---|
| 2870 | } |
---|
| 2871 | } |
---|
| 2872 | } |
---|
[2] | 2873 | } |
---|
| 2874 | |
---|
| 2875 | Void TEncCu::xCopyYuv2Tmp( UInt uiPartUnitIdx, UInt uiNextDepth ) |
---|
| 2876 | { |
---|
| 2877 | UInt uiCurrDepth = uiNextDepth - 1; |
---|
| 2878 | m_ppcRecoYuvBest[uiNextDepth]->copyToPartYuv( m_ppcRecoYuvTemp[uiCurrDepth], uiPartUnitIdx ); |
---|
| 2879 | } |
---|
| 2880 | |
---|
[56] | 2881 | /** Function for filling the PCM buffer of a CU using its original sample array |
---|
| 2882 | * \param pcCU pointer to current CU |
---|
| 2883 | * \param pcOrgYuv pointer to original sample array |
---|
| 2884 | * \returns Void |
---|
| 2885 | */ |
---|
| 2886 | Void TEncCu::xFillPCMBuffer ( TComDataCU*& pCU, TComYuv* pOrgYuv ) |
---|
| 2887 | { |
---|
| 2888 | |
---|
| 2889 | UInt width = pCU->getWidth(0); |
---|
| 2890 | UInt height = pCU->getHeight(0); |
---|
| 2891 | |
---|
| 2892 | Pel* pSrcY = pOrgYuv->getLumaAddr(0, width); |
---|
| 2893 | Pel* pDstY = pCU->getPCMSampleY(); |
---|
| 2894 | UInt srcStride = pOrgYuv->getStride(); |
---|
| 2895 | |
---|
| 2896 | for(Int y = 0; y < height; y++ ) |
---|
| 2897 | { |
---|
| 2898 | for(Int x = 0; x < width; x++ ) |
---|
| 2899 | { |
---|
| 2900 | pDstY[x] = pSrcY[x]; |
---|
| 2901 | } |
---|
| 2902 | pDstY += width; |
---|
| 2903 | pSrcY += srcStride; |
---|
| 2904 | } |
---|
| 2905 | |
---|
| 2906 | Pel* pSrcCb = pOrgYuv->getCbAddr(); |
---|
| 2907 | Pel* pSrcCr = pOrgYuv->getCrAddr();; |
---|
| 2908 | |
---|
| 2909 | Pel* pDstCb = pCU->getPCMSampleCb(); |
---|
| 2910 | Pel* pDstCr = pCU->getPCMSampleCr();; |
---|
| 2911 | |
---|
| 2912 | UInt srcStrideC = pOrgYuv->getCStride(); |
---|
| 2913 | UInt heightC = height >> 1; |
---|
| 2914 | UInt widthC = width >> 1; |
---|
| 2915 | |
---|
| 2916 | for(Int y = 0; y < heightC; y++ ) |
---|
| 2917 | { |
---|
| 2918 | for(Int x = 0; x < widthC; x++ ) |
---|
| 2919 | { |
---|
| 2920 | pDstCb[x] = pSrcCb[x]; |
---|
| 2921 | pDstCr[x] = pSrcCr[x]; |
---|
| 2922 | } |
---|
| 2923 | pDstCb += widthC; |
---|
| 2924 | pDstCr += widthC; |
---|
| 2925 | pSrcCb += srcStrideC; |
---|
| 2926 | pSrcCr += srcStrideC; |
---|
| 2927 | } |
---|
| 2928 | } |
---|
| 2929 | |
---|
| 2930 | #if ADAPTIVE_QP_SELECTION |
---|
| 2931 | /** Collect ARL statistics from one block |
---|
| 2932 | */ |
---|
| 2933 | Int TEncCu::xTuCollectARLStats(TCoeff* rpcCoeff, Int* rpcArlCoeff, Int NumCoeffInCU, Double* cSum, UInt* numSamples ) |
---|
| 2934 | { |
---|
| 2935 | for( Int n = 0; n < NumCoeffInCU; n++ ) |
---|
| 2936 | { |
---|
| 2937 | Int u = abs( rpcCoeff[ n ] ); |
---|
| 2938 | Int absc = rpcArlCoeff[ n ]; |
---|
| 2939 | |
---|
| 2940 | if( u != 0 ) |
---|
| 2941 | { |
---|
| 2942 | if( u < LEVEL_RANGE ) |
---|
| 2943 | { |
---|
| 2944 | cSum[ u ] += ( Double )absc; |
---|
| 2945 | numSamples[ u ]++; |
---|
| 2946 | } |
---|
| 2947 | else |
---|
| 2948 | { |
---|
| 2949 | cSum[ LEVEL_RANGE ] += ( Double )absc - ( Double )( u << ARL_C_PRECISION ); |
---|
| 2950 | numSamples[ LEVEL_RANGE ]++; |
---|
| 2951 | } |
---|
| 2952 | } |
---|
| 2953 | } |
---|
| 2954 | |
---|
| 2955 | return 0; |
---|
| 2956 | } |
---|
| 2957 | |
---|
| 2958 | /** Collect ARL statistics from one LCU |
---|
| 2959 | * \param pcCU |
---|
| 2960 | */ |
---|
| 2961 | Void TEncCu::xLcuCollectARLStats(TComDataCU* rpcCU ) |
---|
| 2962 | { |
---|
| 2963 | Double cSum[ LEVEL_RANGE + 1 ]; //: the sum of DCT coefficients corresponding to datatype and quantization output |
---|
| 2964 | UInt numSamples[ LEVEL_RANGE + 1 ]; //: the number of coefficients corresponding to datatype and quantization output |
---|
| 2965 | |
---|
| 2966 | TCoeff* pCoeffY = rpcCU->getCoeffY(); |
---|
| 2967 | Int* pArlCoeffY = rpcCU->getArlCoeffY(); |
---|
| 2968 | |
---|
| 2969 | UInt uiMinCUWidth = g_uiMaxCUWidth >> g_uiMaxCUDepth; |
---|
| 2970 | UInt uiMinNumCoeffInCU = 1 << uiMinCUWidth; |
---|
| 2971 | |
---|
| 2972 | memset( cSum, 0, sizeof( Double )*(LEVEL_RANGE+1) ); |
---|
| 2973 | memset( numSamples, 0, sizeof( UInt )*(LEVEL_RANGE+1) ); |
---|
| 2974 | |
---|
| 2975 | // Collect stats to cSum[][] and numSamples[][] |
---|
| 2976 | for(Int i = 0; i < rpcCU->getTotalNumPart(); i ++ ) |
---|
| 2977 | { |
---|
| 2978 | UInt uiTrIdx = rpcCU->getTransformIdx(i); |
---|
| 2979 | |
---|
| 2980 | if(rpcCU->getPredictionMode(i) == MODE_INTER) |
---|
| 2981 | if( rpcCU->getCbf( i, TEXT_LUMA, uiTrIdx ) ) |
---|
| 2982 | { |
---|
| 2983 | xTuCollectARLStats(pCoeffY, pArlCoeffY, uiMinNumCoeffInCU, cSum, numSamples); |
---|
| 2984 | }//Note that only InterY is processed. QP rounding is based on InterY data only. |
---|
| 2985 | |
---|
| 2986 | pCoeffY += uiMinNumCoeffInCU; |
---|
| 2987 | pArlCoeffY += uiMinNumCoeffInCU; |
---|
| 2988 | } |
---|
| 2989 | |
---|
| 2990 | for(Int u=1; u<LEVEL_RANGE;u++) |
---|
| 2991 | { |
---|
| 2992 | m_pcTrQuant->getSliceSumC()[u] += cSum[ u ] ; |
---|
| 2993 | m_pcTrQuant->getSliceNSamples()[u] += numSamples[ u ] ; |
---|
| 2994 | } |
---|
| 2995 | m_pcTrQuant->getSliceSumC()[LEVEL_RANGE] += cSum[ LEVEL_RANGE ] ; |
---|
| 2996 | m_pcTrQuant->getSliceNSamples()[LEVEL_RANGE] += numSamples[ LEVEL_RANGE ] ; |
---|
| 2997 | } |
---|
| 2998 | #endif |
---|
| 2999 | //! \} |
---|