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