[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 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, 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]; |
---|
[56] | 66 | |
---|
[2] | 67 | m_ppcPredYuvBest = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 68 | m_ppcResiYuvBest = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 69 | m_ppcRecoYuvBest = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 70 | m_ppcPredYuvTemp = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 71 | m_ppcResiYuvTemp = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 72 | m_ppcRecoYuvTemp = new TComYuv*[m_uhTotalDepth-1]; |
---|
| 73 | m_ppcOrigYuv = new TComYuv*[m_uhTotalDepth-1]; |
---|
[56] | 74 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 75 | m_ppcResPredTmp = new TComYuv*[m_uhTotalDepth-1]; |
---|
[56] | 76 | #endif |
---|
| 77 | |
---|
[5] | 78 | #if HHI_MPI |
---|
[2] | 79 | m_puhDepthSaved = new UChar[1ll<<( ( m_uhTotalDepth - 1 )<<1 )]; |
---|
| 80 | m_puhWidthSaved = new UChar[1ll<<( ( m_uhTotalDepth - 1 )<<1 )]; |
---|
| 81 | m_puhHeightSaved = new UChar[1ll<<( ( m_uhTotalDepth - 1 )<<1 )]; |
---|
| 82 | #endif |
---|
[56] | 83 | |
---|
[2] | 84 | UInt uiNumPartitions; |
---|
| 85 | for( i=0 ; i<m_uhTotalDepth-1 ; i++) |
---|
| 86 | { |
---|
| 87 | uiNumPartitions = 1<<( ( m_uhTotalDepth - i - 1 )<<1 ); |
---|
| 88 | UInt uiWidth = uiMaxWidth >> i; |
---|
| 89 | UInt uiHeight = uiMaxHeight >> i; |
---|
[56] | 90 | |
---|
| 91 | m_ppcBestCU[i] = new TComDataCU; m_ppcBestCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); |
---|
| 92 | m_ppcTempCU[i] = new TComDataCU; m_ppcTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); |
---|
| 93 | |
---|
[2] | 94 | m_ppcPredYuvBest[i] = new TComYuv; m_ppcPredYuvBest[i]->create(uiWidth, uiHeight); |
---|
| 95 | m_ppcResiYuvBest[i] = new TComYuv; m_ppcResiYuvBest[i]->create(uiWidth, uiHeight); |
---|
| 96 | m_ppcRecoYuvBest[i] = new TComYuv; m_ppcRecoYuvBest[i]->create(uiWidth, uiHeight); |
---|
[56] | 97 | |
---|
[2] | 98 | m_ppcPredYuvTemp[i] = new TComYuv; m_ppcPredYuvTemp[i]->create(uiWidth, uiHeight); |
---|
| 99 | m_ppcResiYuvTemp[i] = new TComYuv; m_ppcResiYuvTemp[i]->create(uiWidth, uiHeight); |
---|
| 100 | m_ppcRecoYuvTemp[i] = new TComYuv; m_ppcRecoYuvTemp[i]->create(uiWidth, uiHeight); |
---|
[56] | 101 | |
---|
[2] | 102 | m_ppcOrigYuv [i] = new TComYuv; m_ppcOrigYuv [i]->create(uiWidth, uiHeight); |
---|
[56] | 103 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 104 | m_ppcResPredTmp [i] = new TComYuv; m_ppcResPredTmp [i]->create(uiWidth, uiHeight); |
---|
[56] | 105 | #endif |
---|
[2] | 106 | } |
---|
[56] | 107 | |
---|
| 108 | m_bEncodeDQP = false; |
---|
| 109 | #if BURST_IPCM |
---|
| 110 | m_checkBurstIPCMFlag = false; |
---|
| 111 | #endif |
---|
[2] | 112 | |
---|
| 113 | // initialize partition order. |
---|
| 114 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
| 115 | initZscanToRaster( m_uhTotalDepth, 1, 0, piTmp); |
---|
| 116 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); |
---|
[56] | 117 | |
---|
[2] | 118 | // initialize conversion matrix from partition index to pel |
---|
| 119 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); |
---|
[56] | 120 | initMotionReferIdx ( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); |
---|
[2] | 121 | } |
---|
| 122 | |
---|
| 123 | Void TEncCu::destroy() |
---|
| 124 | { |
---|
| 125 | Int i; |
---|
[56] | 126 | |
---|
[5] | 127 | #if HHI_MPI |
---|
[2] | 128 | delete[] m_puhDepthSaved; m_puhDepthSaved = NULL; |
---|
| 129 | delete[] m_puhWidthSaved; m_puhWidthSaved = NULL; |
---|
| 130 | delete[] m_puhHeightSaved; m_puhHeightSaved = NULL; |
---|
| 131 | #endif |
---|
| 132 | for( i=0 ; i<m_uhTotalDepth-1 ; i++) |
---|
| 133 | { |
---|
| 134 | if(m_ppcBestCU[i]) |
---|
| 135 | { |
---|
| 136 | m_ppcBestCU[i]->destroy(); delete m_ppcBestCU[i]; m_ppcBestCU[i] = NULL; |
---|
| 137 | } |
---|
| 138 | if(m_ppcTempCU[i]) |
---|
| 139 | { |
---|
| 140 | m_ppcTempCU[i]->destroy(); delete m_ppcTempCU[i]; m_ppcTempCU[i] = NULL; |
---|
| 141 | } |
---|
| 142 | if(m_ppcPredYuvBest[i]) |
---|
| 143 | { |
---|
| 144 | m_ppcPredYuvBest[i]->destroy(); delete m_ppcPredYuvBest[i]; m_ppcPredYuvBest[i] = NULL; |
---|
| 145 | } |
---|
| 146 | if(m_ppcResiYuvBest[i]) |
---|
| 147 | { |
---|
| 148 | m_ppcResiYuvBest[i]->destroy(); delete m_ppcResiYuvBest[i]; m_ppcResiYuvBest[i] = NULL; |
---|
| 149 | } |
---|
| 150 | if(m_ppcRecoYuvBest[i]) |
---|
| 151 | { |
---|
| 152 | m_ppcRecoYuvBest[i]->destroy(); delete m_ppcRecoYuvBest[i]; m_ppcRecoYuvBest[i] = NULL; |
---|
| 153 | } |
---|
| 154 | if(m_ppcPredYuvTemp[i]) |
---|
| 155 | { |
---|
| 156 | m_ppcPredYuvTemp[i]->destroy(); delete m_ppcPredYuvTemp[i]; m_ppcPredYuvTemp[i] = NULL; |
---|
| 157 | } |
---|
| 158 | if(m_ppcResiYuvTemp[i]) |
---|
| 159 | { |
---|
| 160 | m_ppcResiYuvTemp[i]->destroy(); delete m_ppcResiYuvTemp[i]; m_ppcResiYuvTemp[i] = NULL; |
---|
| 161 | } |
---|
| 162 | if(m_ppcRecoYuvTemp[i]) |
---|
| 163 | { |
---|
| 164 | m_ppcRecoYuvTemp[i]->destroy(); delete m_ppcRecoYuvTemp[i]; m_ppcRecoYuvTemp[i] = NULL; |
---|
| 165 | } |
---|
| 166 | if(m_ppcOrigYuv[i]) |
---|
| 167 | { |
---|
| 168 | m_ppcOrigYuv[i]->destroy(); delete m_ppcOrigYuv[i]; m_ppcOrigYuv[i] = NULL; |
---|
| 169 | } |
---|
[56] | 170 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 171 | if(m_ppcResPredTmp[i]) |
---|
| 172 | { |
---|
| 173 | m_ppcResPredTmp [i]->destroy(); delete m_ppcResPredTmp[i]; m_ppcResPredTmp[i] = NULL; |
---|
| 174 | } |
---|
[56] | 175 | #endif |
---|
[2] | 176 | } |
---|
| 177 | if(m_ppcBestCU) |
---|
| 178 | { |
---|
| 179 | delete [] m_ppcBestCU; |
---|
| 180 | m_ppcBestCU = NULL; |
---|
| 181 | } |
---|
| 182 | if(m_ppcTempCU) |
---|
| 183 | { |
---|
| 184 | delete [] m_ppcTempCU; |
---|
| 185 | m_ppcTempCU = NULL; |
---|
| 186 | } |
---|
[56] | 187 | |
---|
[2] | 188 | if(m_ppcPredYuvBest) |
---|
| 189 | { |
---|
| 190 | delete [] m_ppcPredYuvBest; |
---|
| 191 | m_ppcPredYuvBest = NULL; |
---|
| 192 | } |
---|
| 193 | if(m_ppcResiYuvBest) |
---|
| 194 | { |
---|
| 195 | delete [] m_ppcResiYuvBest; |
---|
| 196 | m_ppcResiYuvBest = NULL; |
---|
| 197 | } |
---|
| 198 | if(m_ppcRecoYuvBest) |
---|
| 199 | { |
---|
| 200 | delete [] m_ppcRecoYuvBest; |
---|
| 201 | m_ppcRecoYuvBest = NULL; |
---|
| 202 | } |
---|
| 203 | if(m_ppcPredYuvTemp) |
---|
| 204 | { |
---|
| 205 | delete [] m_ppcPredYuvTemp; |
---|
| 206 | m_ppcPredYuvTemp = NULL; |
---|
| 207 | } |
---|
| 208 | if(m_ppcResiYuvTemp) |
---|
| 209 | { |
---|
| 210 | delete [] m_ppcResiYuvTemp; |
---|
| 211 | m_ppcResiYuvTemp = NULL; |
---|
| 212 | } |
---|
| 213 | if(m_ppcRecoYuvTemp) |
---|
| 214 | { |
---|
| 215 | delete [] m_ppcRecoYuvTemp; |
---|
| 216 | m_ppcRecoYuvTemp = NULL; |
---|
| 217 | } |
---|
| 218 | if(m_ppcOrigYuv) |
---|
| 219 | { |
---|
| 220 | delete [] m_ppcOrigYuv; |
---|
| 221 | m_ppcOrigYuv = NULL; |
---|
| 222 | } |
---|
[56] | 223 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 224 | if(m_ppcResPredTmp) |
---|
| 225 | { |
---|
| 226 | delete [] m_ppcResPredTmp; |
---|
| 227 | m_ppcResPredTmp = NULL; |
---|
| 228 | } |
---|
[56] | 229 | #endif |
---|
[2] | 230 | } |
---|
| 231 | |
---|
| 232 | /** \param pcEncTop pointer of encoder class |
---|
| 233 | */ |
---|
| 234 | Void TEncCu::init( TEncTop* pcEncTop ) |
---|
| 235 | { |
---|
| 236 | m_pcEncCfg = pcEncTop; |
---|
| 237 | m_pcPredSearch = pcEncTop->getPredSearch(); |
---|
| 238 | m_pcTrQuant = pcEncTop->getTrQuant(); |
---|
| 239 | m_pcBitCounter = pcEncTop->getBitCounter(); |
---|
| 240 | m_pcRdCost = pcEncTop->getRdCost(); |
---|
[56] | 241 | |
---|
[2] | 242 | m_pcEntropyCoder = pcEncTop->getEntropyCoder(); |
---|
| 243 | m_pcCavlcCoder = pcEncTop->getCavlcCoder(); |
---|
| 244 | m_pcSbacCoder = pcEncTop->getSbacCoder(); |
---|
| 245 | m_pcBinCABAC = pcEncTop->getBinCABAC(); |
---|
[56] | 246 | |
---|
[2] | 247 | m_pppcRDSbacCoder = pcEncTop->getRDSbacCoder(); |
---|
| 248 | m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder(); |
---|
[56] | 249 | |
---|
[2] | 250 | m_bUseSBACRD = pcEncTop->getUseSBACRD(); |
---|
| 251 | } |
---|
| 252 | |
---|
| 253 | // ==================================================================================================================== |
---|
| 254 | // Public member functions |
---|
| 255 | // ==================================================================================================================== |
---|
| 256 | |
---|
| 257 | /** \param rpcCU pointer of CU data class |
---|
| 258 | */ |
---|
| 259 | Void TEncCu::compressCU( TComDataCU*& rpcCU ) |
---|
| 260 | { |
---|
[56] | 261 | // initialize CU data |
---|
| 262 | m_ppcBestCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() ); |
---|
| 263 | m_ppcTempCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() ); |
---|
| 264 | |
---|
| 265 | // analysis of CU |
---|
| 266 | xCompressCU( m_ppcBestCU[0], m_ppcTempCU[0], 0 ); |
---|
| 267 | |
---|
| 268 | #if ADAPTIVE_QP_SELECTION |
---|
| 269 | if( m_pcEncCfg->getUseAdaptQpSelect() ) |
---|
[2] | 270 | { |
---|
[56] | 271 | if(rpcCU->getSlice()->getSliceType()!=I_SLICE) //IIII |
---|
| 272 | { |
---|
| 273 | xLcuCollectARLStats( rpcCU); |
---|
| 274 | } |
---|
[2] | 275 | } |
---|
[56] | 276 | #endif |
---|
| 277 | } |
---|
| 278 | /** \param pcCU pointer of CU data class, bForceTerminate when set to true terminates slice (default is false). |
---|
| 279 | */ |
---|
| 280 | Void TEncCu::encodeCU ( TComDataCU* pcCU, Bool bForceTerminate ) |
---|
| 281 | { |
---|
| 282 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 283 | { |
---|
[56] | 284 | setdQPFlag(true); |
---|
| 285 | } |
---|
[2] | 286 | |
---|
[56] | 287 | #if BURST_IPCM |
---|
| 288 | TComPic* pcPic = pcCU->getPic(); |
---|
| 289 | Bool checkBurstIPCMFlag = (pcPic->getSlice(0)->getSPS()->getUsePCM())? true : false; |
---|
[2] | 290 | |
---|
[56] | 291 | setCheckBurstIPCMFlag( checkBurstIPCMFlag ); |
---|
[2] | 292 | |
---|
[56] | 293 | pcCU->setNumSucIPCM(0); |
---|
| 294 | pcCU->setLastCUSucIPCMFlag(false); |
---|
| 295 | #endif |
---|
| 296 | |
---|
| 297 | // Encode CU data |
---|
| 298 | xEncodeCU( pcCU, 0, 0 ); |
---|
| 299 | |
---|
| 300 | #if OL_FLUSH |
---|
| 301 | bool bTerminateSlice = bForceTerminate; |
---|
| 302 | UInt uiCUAddr = pcCU->getAddr(); |
---|
| 303 | /* If at the end of an LCU line but not at the end of a substream, perform CABAC flush */ |
---|
| 304 | #if WPP_SIMPLIFICATION |
---|
| 305 | if (!bTerminateSlice && pcCU->getSlice()->getPPS()->getNumSubstreams() > 1) |
---|
| 306 | #else |
---|
| 307 | if (!bTerminateSlice && pcCU->getSlice()->getPPS()->getCabacIstateReset()) |
---|
| 308 | #endif |
---|
[2] | 309 | { |
---|
[56] | 310 | Int iNumSubstreams = pcCU->getSlice()->getPPS()->getNumSubstreams(); |
---|
| 311 | UInt uiWidthInLCUs = pcCU->getPic()->getPicSym()->getFrameWidthInCU(); |
---|
| 312 | UInt uiCol = uiCUAddr % uiWidthInLCUs; |
---|
| 313 | UInt uiLin = uiCUAddr / uiWidthInLCUs; |
---|
| 314 | #if !REMOVE_TILE_DEPENDENCE |
---|
| 315 | Int iBreakDep = pcCU->getPic()->getPicSym()->getTileBoundaryIndependenceIdr(); |
---|
| 316 | #endif |
---|
| 317 | UInt uiTileStartLCU = pcCU->getPic()->getPicSym()->getTComTile(pcCU->getPic()->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); |
---|
| 318 | UInt uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; |
---|
| 319 | UInt uiTileLCUY = uiTileStartLCU / uiWidthInLCUs; |
---|
| 320 | UInt uiTileWidth = pcCU->getPic()->getPicSym()->getTComTile(pcCU->getPic()->getPicSym()->getTileIdxMap(uiCUAddr))->getTileWidth(); |
---|
| 321 | UInt uiTileHeight = pcCU->getPic()->getPicSym()->getTComTile(pcCU->getPic()->getPicSym()->getTileIdxMap(uiCUAddr))->getTileHeight(); |
---|
| 322 | Int iNumSubstreamsPerTile = iNumSubstreams; |
---|
| 323 | #if !REMOVE_TILE_DEPENDENCE |
---|
| 324 | #if WPP_SIMPLIFICATION |
---|
| 325 | if (iBreakDep && pcCU->getSlice()->getPPS()->getNumSubstreams() > 1) |
---|
| 326 | #else |
---|
| 327 | if (iBreakDep && pcCU->getSlice()->getPPS()->getEntropyCodingSynchro()) |
---|
| 328 | #endif |
---|
| 329 | iNumSubstreamsPerTile /= pcCU->getPic()->getPicSym()->getNumTiles(); |
---|
| 330 | if ((iBreakDep && (uiCol == uiTileLCUX+uiTileWidth-1) && (uiLin+iNumSubstreamsPerTile < uiTileLCUY+uiTileHeight)) |
---|
| 331 | || (!iBreakDep && (uiCol == uiWidthInLCUs-1) && (uiLin+iNumSubstreams < pcCU->getPic()->getFrameHeightInCU()))) |
---|
[2] | 332 | { |
---|
[56] | 333 | m_pcEntropyCoder->encodeFlush(); |
---|
[2] | 334 | } |
---|
[56] | 335 | #else |
---|
| 336 | #if WPP_SIMPLIFICATION |
---|
| 337 | if (pcCU->getSlice()->getPPS()->getNumSubstreams() > 1) |
---|
| 338 | #else |
---|
| 339 | if (pcCU->getSlice()->getPPS()->getEntropyCodingSynchro()) |
---|
[5] | 340 | #endif |
---|
[2] | 341 | { |
---|
[56] | 342 | iNumSubstreamsPerTile /= pcCU->getPic()->getPicSym()->getNumTiles(); |
---|
[2] | 343 | } |
---|
[56] | 344 | if ((uiCol == uiTileLCUX+uiTileWidth-1) && (uiLin+iNumSubstreamsPerTile < uiTileLCUY+uiTileHeight)) |
---|
[2] | 345 | { |
---|
[56] | 346 | m_pcEntropyCoder->encodeFlush(); |
---|
[2] | 347 | } |
---|
[5] | 348 | #endif |
---|
[2] | 349 | } |
---|
[56] | 350 | #endif // OL_FLUSH |
---|
[2] | 351 | } |
---|
| 352 | |
---|
[56] | 353 | // ==================================================================================================================== |
---|
| 354 | // Protected member functions |
---|
| 355 | // ==================================================================================================================== |
---|
| 356 | /** Derive small set of test modes for AMP encoder speed-up |
---|
| 357 | *\param rpcBestCU |
---|
| 358 | *\param eParentPartSize |
---|
| 359 | *\param bTestAMP_Hor |
---|
| 360 | *\param bTestAMP_Ver |
---|
| 361 | *\param bTestMergeAMP_Hor |
---|
| 362 | *\param bTestMergeAMP_Ver |
---|
| 363 | *\returns Void |
---|
| 364 | */ |
---|
| 365 | #if AMP_ENC_SPEEDUP |
---|
| 366 | #if AMP_MRG |
---|
| 367 | Void TEncCu::deriveTestModeAMP (TComDataCU *&rpcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver) |
---|
| 368 | #else |
---|
| 369 | Void TEncCu::deriveTestModeAMP (TComDataCU *&rpcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver) |
---|
| 370 | #endif |
---|
[2] | 371 | { |
---|
[56] | 372 | if ( rpcBestCU->getPartitionSize(0) == SIZE_2NxN ) |
---|
[2] | 373 | { |
---|
[56] | 374 | bTestAMP_Hor = true; |
---|
[2] | 375 | } |
---|
[56] | 376 | else if ( rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) |
---|
[2] | 377 | { |
---|
[56] | 378 | bTestAMP_Ver = true; |
---|
| 379 | } |
---|
| 380 | else if ( rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N && rpcBestCU->getMergeFlag(0) == false && rpcBestCU->isSkipped(0) == false ) |
---|
| 381 | { |
---|
| 382 | bTestAMP_Hor = true; |
---|
| 383 | bTestAMP_Ver = true; |
---|
| 384 | } |
---|
[2] | 385 | |
---|
[56] | 386 | #if AMP_MRG |
---|
| 387 | //! Utilizing the partition size of parent PU |
---|
| 388 | if ( eParentPartSize >= SIZE_2NxnU && eParentPartSize <= SIZE_nRx2N ) |
---|
| 389 | { |
---|
| 390 | bTestMergeAMP_Hor = true; |
---|
| 391 | bTestMergeAMP_Ver = true; |
---|
[2] | 392 | } |
---|
[56] | 393 | |
---|
| 394 | if ( eParentPartSize == SIZE_NONE ) //! if parent is intra |
---|
[2] | 395 | { |
---|
[56] | 396 | if ( rpcBestCU->getPartitionSize(0) == SIZE_2NxN ) |
---|
[2] | 397 | { |
---|
[56] | 398 | bTestMergeAMP_Hor = true; |
---|
[2] | 399 | } |
---|
[56] | 400 | else if ( rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) |
---|
[2] | 401 | { |
---|
[56] | 402 | bTestMergeAMP_Ver = true; |
---|
[2] | 403 | } |
---|
| 404 | } |
---|
| 405 | |
---|
[56] | 406 | if ( rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N && rpcBestCU->isSkipped(0) == false ) |
---|
| 407 | { |
---|
| 408 | bTestMergeAMP_Hor = true; |
---|
| 409 | bTestMergeAMP_Ver = true; |
---|
| 410 | } |
---|
[2] | 411 | |
---|
[56] | 412 | if ( rpcBestCU->getWidth(0) == 64 ) |
---|
| 413 | { |
---|
| 414 | bTestAMP_Hor = false; |
---|
| 415 | bTestAMP_Ver = false; |
---|
| 416 | } |
---|
| 417 | #else |
---|
| 418 | //! Utilizing the partition size of parent PU |
---|
| 419 | if ( eParentPartSize >= SIZE_2NxnU && eParentPartSize <= SIZE_nRx2N ) |
---|
| 420 | { |
---|
| 421 | bTestAMP_Hor = true; |
---|
| 422 | bTestAMP_Ver = true; |
---|
| 423 | } |
---|
[2] | 424 | |
---|
[56] | 425 | if ( eParentPartSize == SIZE_2Nx2N ) |
---|
| 426 | { |
---|
| 427 | bTestAMP_Hor = false; |
---|
| 428 | bTestAMP_Ver = false; |
---|
| 429 | } |
---|
| 430 | #endif |
---|
[2] | 431 | } |
---|
[56] | 432 | #endif |
---|
[2] | 433 | |
---|
| 434 | // ==================================================================================================================== |
---|
| 435 | // Protected member functions |
---|
| 436 | // ==================================================================================================================== |
---|
[56] | 437 | /** Compress a CU block recursively with enabling sub-LCU-level delta QP |
---|
| 438 | *\param rpcBestCU |
---|
| 439 | *\param rpcTempCU |
---|
| 440 | *\param uiDepth |
---|
| 441 | *\returns Void |
---|
| 442 | * |
---|
| 443 | *- for loop of QP value to compress the current CU with all possible QP |
---|
| 444 | */ |
---|
| 445 | #if AMP_ENC_SPEEDUP |
---|
| 446 | Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth, PartSize eParentPartSize ) |
---|
| 447 | #else |
---|
[2] | 448 | Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth ) |
---|
[56] | 449 | #endif |
---|
[2] | 450 | { |
---|
| 451 | TComPic* pcPic = rpcBestCU->getPic(); |
---|
| 452 | |
---|
[116] | 453 | #if OL_DEPTHLIMIT_A0044 |
---|
[115] | 454 | TComSPS *sps = pcPic->getSlice(0)->getSPS(); |
---|
| 455 | TComPic *pcTexture; |
---|
[116] | 456 | TComDataCU * pcTextureCU; |
---|
[126] | 457 | Bool depthMapDetect = false; |
---|
[153] | 458 | #if !LGE_CLEAN_UP |
---|
[116] | 459 | UInt uiPrevTexPartIndex = 0; |
---|
[152] | 460 | #endif |
---|
[115] | 461 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[126] | 462 | Bool bIntraSliceDetect = false; |
---|
[115] | 463 | #endif |
---|
| 464 | Bool bTry2NxN = false; |
---|
| 465 | Bool bTryNx2N = false; |
---|
[116] | 466 | pcTexture = rpcBestCU->getSlice()->getTexturePic(); |
---|
| 467 | if(pcTexture != NULL) //depth map being encoded |
---|
| 468 | { |
---|
[126] | 469 | depthMapDetect = true; |
---|
[115] | 470 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 471 | bIntraSliceDetect = (rpcBestCU->getSlice()->getSliceType()==I_SLICE); |
---|
[115] | 472 | #endif |
---|
[126] | 473 | if(uiDepth == 0) |
---|
| 474 | { |
---|
[116] | 475 | pcTextureCU = pcTexture->getCU( rpcBestCU->getAddr() ); |
---|
[126] | 476 | pcTexture->setPartInfo(pcTextureCU->readPartInfo()); |
---|
| 477 | pcTexture->setTexPartIndex(0); |
---|
[116] | 478 | } |
---|
[126] | 479 | } |
---|
[116] | 480 | else |
---|
| 481 | { |
---|
| 482 | depthMapDetect = false; |
---|
| 483 | } |
---|
[115] | 484 | #endif |
---|
[2] | 485 | // get Original YUV data from picture |
---|
| 486 | m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); |
---|
| 487 | |
---|
| 488 | // variables for fast encoder decision |
---|
| 489 | Bool bEarlySkip = false; |
---|
[116] | 490 | Bool bTrySplit = true; |
---|
[2] | 491 | Double fRD_Skip = MAX_DOUBLE; |
---|
| 492 | |
---|
[56] | 493 | // variable for Early CU determination |
---|
| 494 | Bool bSubBranch = true; |
---|
| 495 | |
---|
| 496 | // variable for Cbf fast mode PU decision |
---|
| 497 | Bool doNotBlockPu = true; |
---|
| 498 | |
---|
| 499 | Bool bTrySplitDQP = true; |
---|
| 500 | |
---|
[116] | 501 | static Double afCost [ MAX_CU_DEPTH ]; |
---|
[2] | 502 | static Int aiNum [ MAX_CU_DEPTH ]; |
---|
| 503 | |
---|
| 504 | if ( rpcBestCU->getAddr() == 0 ) |
---|
| 505 | { |
---|
| 506 | ::memset( afCost, 0, sizeof( afCost ) ); |
---|
| 507 | ::memset( aiNum, 0, sizeof( aiNum ) ); |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | Bool bBoundary = false; |
---|
| 511 | UInt uiLPelX = rpcBestCU->getCUPelX(); |
---|
| 512 | UInt uiRPelX = uiLPelX + rpcBestCU->getWidth(0) - 1; |
---|
| 513 | UInt uiTPelY = rpcBestCU->getCUPelY(); |
---|
| 514 | UInt uiBPelY = uiTPelY + rpcBestCU->getHeight(0) - 1; |
---|
| 515 | |
---|
[152] | 516 | #if LGE_ILLUCOMP_B0045 |
---|
| 517 | Bool bICEnabled = (!rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getViewId()); |
---|
| 518 | |
---|
| 519 | bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC(); |
---|
| 520 | #endif |
---|
| 521 | |
---|
[56] | 522 | #if HHI_INTERVIEW_SKIP |
---|
[2] | 523 | Bool bFullyRenderedSec = true ; |
---|
| 524 | if( m_pcEncCfg->getInterViewSkip() ) |
---|
| 525 | { |
---|
| 526 | Pel* pUsedSamples ; |
---|
| 527 | UInt uiStride ; |
---|
| 528 | pUsedSamples = pcPic->getUsedPelsMap()->getLumaAddr( rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); |
---|
| 529 | uiStride = pcPic->getUsedPelsMap()->getStride(); |
---|
| 530 | |
---|
| 531 | for ( Int y=0; y<m_ppcOrigYuv[uiDepth]->getHeight(); y++) |
---|
| 532 | { |
---|
| 533 | for ( Int x=0; x<m_ppcOrigYuv[uiDepth]->getWidth(); x++) |
---|
| 534 | { |
---|
| 535 | if( pUsedSamples[x] !=0 ) |
---|
| 536 | { |
---|
| 537 | bFullyRenderedSec = false ; |
---|
| 538 | break ; |
---|
| 539 | } |
---|
| 540 | } |
---|
| 541 | if ( !bFullyRenderedSec ) |
---|
| 542 | { |
---|
| 543 | break; |
---|
| 544 | } |
---|
| 545 | pUsedSamples += uiStride ; |
---|
| 546 | } |
---|
| 547 | } |
---|
| 548 | else |
---|
| 549 | { |
---|
| 550 | bFullyRenderedSec = false ; |
---|
| 551 | } |
---|
[56] | 552 | |
---|
[5] | 553 | #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
[2] | 554 | if( bFullyRenderedSec ) |
---|
| 555 | { |
---|
| 556 | m_pcRdCost->setLambdaScale( m_pcEncCfg->getInterViewSkipLambdaScale() ); |
---|
| 557 | } |
---|
| 558 | else |
---|
| 559 | { |
---|
| 560 | m_pcRdCost->setLambdaScale( 1 ); |
---|
| 561 | } |
---|
| 562 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 563 | #endif |
---|
| 564 | |
---|
| 565 | #endif |
---|
[56] | 566 | Int iBaseQP = xComputeQP( rpcBestCU, uiDepth ); |
---|
| 567 | Int iMinQP; |
---|
| 568 | Int iMaxQP; |
---|
| 569 | #if LOSSLESS_CODING |
---|
| 570 | Bool isAddLowestQP = false; |
---|
| 571 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 572 | Int lowestQP = -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 573 | #else |
---|
| 574 | Int lowestQP = 0; |
---|
| 575 | #endif |
---|
| 576 | #endif |
---|
| 577 | |
---|
| 578 | if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
[2] | 579 | { |
---|
[56] | 580 | Int idQP = m_pcEncCfg->getMaxDeltaQP(); |
---|
| 581 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 582 | iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); |
---|
| 583 | iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); |
---|
| 584 | #if LOSSLESS_CODING |
---|
| 585 | if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 586 | { |
---|
[56] | 587 | isAddLowestQP = true; |
---|
| 588 | iMinQP = iMinQP - 1; |
---|
[116] | 589 | |
---|
[56] | 590 | } |
---|
| 591 | #endif |
---|
| 592 | #else |
---|
| 593 | iMinQP = Clip3( MIN_QP, MAX_QP, iBaseQP-idQP ); |
---|
| 594 | iMaxQP = Clip3( MIN_QP, MAX_QP, iBaseQP+idQP ); |
---|
| 595 | #if LOSSLESS_CODING |
---|
| 596 | if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) |
---|
| 597 | { |
---|
| 598 | isAddLowestQP = true; |
---|
| 599 | iMinQP = iMinQP - 1; |
---|
| 600 | } |
---|
| 601 | #endif |
---|
| 602 | #endif |
---|
| 603 | } |
---|
| 604 | else |
---|
| 605 | { |
---|
| 606 | iMinQP = rpcTempCU->getQP(0); |
---|
| 607 | iMaxQP = rpcTempCU->getQP(0); |
---|
| 608 | } |
---|
| 609 | |
---|
| 610 | // If slice start or slice end is within this cu... |
---|
| 611 | TComSlice * pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx()); |
---|
| 612 | Bool bSliceStart = pcSlice->getEntropySliceCurStartCUAddr()>rpcTempCU->getSCUAddr()&&pcSlice->getEntropySliceCurStartCUAddr()<rpcTempCU->getSCUAddr()+rpcTempCU->getTotalNumPart(); |
---|
| 613 | Bool bSliceEnd = (pcSlice->getEntropySliceCurEndCUAddr()>rpcTempCU->getSCUAddr()&&pcSlice->getEntropySliceCurEndCUAddr()<rpcTempCU->getSCUAddr()+rpcTempCU->getTotalNumPart()); |
---|
| 614 | Bool bInsidePicture = ( uiRPelX < rpcBestCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < rpcBestCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); |
---|
| 615 | // We need to split, so don't try these modes. |
---|
| 616 | if(!bSliceEnd && !bSliceStart && bInsidePicture ) |
---|
| 617 | { |
---|
| 618 | for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) |
---|
| 619 | { |
---|
| 620 | #if LOSSLESS_CODING |
---|
| 621 | if (isAddLowestQP && (iQP == iMinQP)) |
---|
[2] | 622 | { |
---|
[56] | 623 | iQP = lowestQP; |
---|
[2] | 624 | } |
---|
[5] | 625 | #endif |
---|
[56] | 626 | // variables for fast encoder decision |
---|
| 627 | bEarlySkip = false; |
---|
| 628 | bTrySplit = true; |
---|
| 629 | fRD_Skip = MAX_DOUBLE; |
---|
[2] | 630 | |
---|
[56] | 631 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
[2] | 632 | |
---|
[116] | 633 | #if OL_DEPTHLIMIT_A0044 |
---|
| 634 | //logic for setting bTrySplit using the partition information that is stored of the texture colocated CU |
---|
[115] | 635 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 636 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL()) |
---|
[115] | 637 | #else |
---|
[116] | 638 | if(depthMapDetect && sps->getUseDPL()) //depth map being encoded |
---|
[115] | 639 | #endif |
---|
[116] | 640 | { |
---|
[126] | 641 | assert(uiDepth == pcTexture->accessPartInfo(1)); |
---|
| 642 | if(pcTexture->accessPartInfo(0) == 1) //NxN modes |
---|
[116] | 643 | { |
---|
| 644 | bTrySplit = true; |
---|
| 645 | bTryNx2N = true; |
---|
| 646 | bTry2NxN = true; |
---|
[153] | 647 | #if !LGE_CLEAN_UP |
---|
[126] | 648 | uiPrevTexPartIndex = pcTexture->getTexPartIndex(); |
---|
[152] | 649 | #endif |
---|
[126] | 650 | pcTexture->incrementTexPartIndex(); |
---|
[116] | 651 | } |
---|
[126] | 652 | else if(pcTexture->accessPartInfo(0) == 0) //2Nx2N modes |
---|
[116] | 653 | { |
---|
| 654 | UInt uiTexdepth; |
---|
| 655 | UInt temp_uiTexPartIndex; |
---|
| 656 | bTrySplit = false; |
---|
| 657 | |
---|
| 658 | //scan ahead till next depth |
---|
[126] | 659 | uiTexdepth = pcTexture->accessPartInfo(1); |
---|
[153] | 660 | #if !LGE_CLEAN_UP |
---|
[126] | 661 | uiPrevTexPartIndex = pcTexture->getTexPartIndex(); |
---|
[152] | 662 | #endif |
---|
[126] | 663 | pcTexture->incrementTexPartIndex(); |
---|
| 664 | temp_uiTexPartIndex = pcTexture->getTexPartIndex(); //store in case to rewind |
---|
[116] | 665 | |
---|
[126] | 666 | while(uiTexdepth != pcTexture->accessPartInfo(1) && uiTexdepth != 0) |
---|
[116] | 667 | { |
---|
[126] | 668 | if(pcTexture->accessPartInfo(1) < uiTexdepth) |
---|
[116] | 669 | { |
---|
| 670 | break; |
---|
| 671 | } |
---|
[126] | 672 | pcTexture->incrementTexPartIndex(); |
---|
[116] | 673 | |
---|
[126] | 674 | if(pcTexture->accessPartInfo(1) == OL_END_CU) |
---|
[116] | 675 | { |
---|
[126] | 676 | pcTexture->setTexPartIndex(temp_uiTexPartIndex); |
---|
[116] | 677 | uiTexdepth++; |
---|
| 678 | if(uiTexdepth >= g_uiMaxCUDepth) |
---|
| 679 | { |
---|
| 680 | break; |
---|
| 681 | } |
---|
| 682 | } |
---|
| 683 | } |
---|
| 684 | } |
---|
[126] | 685 | else if(pcTexture->accessPartInfo(0) == OL_END_CU) |
---|
[116] | 686 | { |
---|
| 687 | bTrySplit = false; |
---|
| 688 | bTryNx2N = false; |
---|
| 689 | bTry2NxN = false; |
---|
| 690 | } |
---|
[126] | 691 | else if(pcTexture->accessPartInfo(0) == 2) //2NxN case |
---|
[116] | 692 | { |
---|
| 693 | bTrySplit = false; |
---|
| 694 | bTryNx2N = false; |
---|
| 695 | bTry2NxN = true; |
---|
[153] | 696 | #if !LGE_CLEAN_UP |
---|
[126] | 697 | uiPrevTexPartIndex = pcTexture->getTexPartIndex(); |
---|
[152] | 698 | #endif |
---|
[126] | 699 | pcTexture->incrementTexPartIndex(); ; |
---|
[116] | 700 | } |
---|
[126] | 701 | else if(pcTexture->accessPartInfo(0) == 3) //Nx2N case |
---|
[116] | 702 | { |
---|
| 703 | bTrySplit = false; |
---|
| 704 | bTryNx2N = true; |
---|
| 705 | bTry2NxN = false; |
---|
[153] | 706 | #if !LGE_CLEAN_UP |
---|
[126] | 707 | uiPrevTexPartIndex = pcTexture->getTexPartIndex(); |
---|
[152] | 708 | #endif |
---|
[126] | 709 | pcTexture->incrementTexPartIndex(); ; |
---|
[116] | 710 | } |
---|
| 711 | } |
---|
[115] | 712 | #endif |
---|
| 713 | |
---|
| 714 | |
---|
[56] | 715 | // do inter modes, SKIP and 2Nx2N |
---|
| 716 | if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) |
---|
[2] | 717 | { |
---|
[5] | 718 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[56] | 719 | // check availability of residual prediction |
---|
| 720 | Bool bResPredAvailable = false; |
---|
| 721 | Bool bResPredAllowed = (!rpcBestCU->getSlice()->getSPS()->isDepth () ); |
---|
| 722 | bResPredAllowed = bResPredAllowed && ( rpcBestCU->getSlice()->getSPS()->getViewId () ); |
---|
| 723 | bResPredAllowed = bResPredAllowed && ( rpcBestCU->getSlice()->getSPS()->getMultiviewResPredMode() ); |
---|
| 724 | if( bResPredAllowed ) |
---|
| 725 | { |
---|
[77] | 726 | bResPredAvailable = rpcBestCU->getResidualSamples( 0, |
---|
| 727 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 728 | true , |
---|
| 729 | #endif |
---|
| 730 | m_ppcResPredTmp[uiDepth] ); |
---|
[56] | 731 | } |
---|
| 732 | |
---|
| 733 | for( UInt uiResPrdId = 0; uiResPrdId < ( bResPredAvailable ? 2 : 1 ); uiResPrdId++ ) |
---|
| 734 | { |
---|
| 735 | Bool bResPredFlag = ( uiResPrdId > 0 ); |
---|
[152] | 736 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 737 | for(UInt uiICId = 0; uiICId < (bICEnabled ? 2 : 1); uiICId++) |
---|
| 738 | { |
---|
| 739 | Bool bICFlag = (uiICId ? true : false); |
---|
| 740 | rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); |
---|
[56] | 741 | #endif |
---|
[152] | 742 | #endif |
---|
[56] | 743 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 744 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[5] | 745 | #endif |
---|
[116] | 746 | // SKIP |
---|
[56] | 747 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 748 | xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, bFullyRenderedSec ); |
---|
[56] | 749 | #else |
---|
[116] | 750 | xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU ); |
---|
[2] | 751 | #endif |
---|
[116] | 752 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
[56] | 753 | |
---|
[116] | 754 | // fast encoder decision for early skip |
---|
| 755 | if ( m_pcEncCfg->getUseFastEnc() ) |
---|
[56] | 756 | { |
---|
[116] | 757 | Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ]; |
---|
| 758 | if ( aiNum [ iIdx ] > 5 && fRD_Skip < EARLY_SKIP_THRES*afCost[ iIdx ]/aiNum[ iIdx ] ) |
---|
| 759 | { |
---|
| 760 | bEarlySkip = true; |
---|
| 761 | bTrySplit = false; |
---|
| 762 | } |
---|
[56] | 763 | } |
---|
[152] | 764 | #if LGE_ILLUCOMP_B0045_ENCSIMP |
---|
[156] | 765 | if(bICFlag && rpcBestCU->getMergeFlag(0) && !rpcBestCU->getICFlag(0)) |
---|
| 766 | { |
---|
| 767 | bICEnabled = false; |
---|
| 768 | break; |
---|
| 769 | } |
---|
[152] | 770 | #endif |
---|
[116] | 771 | // 2Nx2N, NxN |
---|
| 772 | if ( !bEarlySkip ) |
---|
| 773 | { |
---|
[5] | 774 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 775 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[5] | 776 | #endif |
---|
| 777 | #if HHI_INTERVIEW_SKIP |
---|
[56] | 778 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFullyRenderedSec ); |
---|
| 779 | |
---|
[2] | 780 | #else |
---|
[56] | 781 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); |
---|
[2] | 782 | #endif |
---|
[116] | 783 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 784 | if(m_pcEncCfg->getUseCbfFastMode()) |
---|
| 785 | { |
---|
| 786 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 787 | } |
---|
[56] | 788 | } |
---|
[152] | 789 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 790 | } |
---|
[152] | 791 | #endif |
---|
[56] | 792 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 793 | } // uiResPrdId |
---|
| 794 | #endif |
---|
| 795 | } // != I_SLICE |
---|
| 796 | |
---|
[152] | 797 | #if LGE_ILLUCOMP_B0045_ENCSIMP |
---|
| 798 | bICEnabled = rpcBestCU->getICFlag(0); |
---|
| 799 | #endif |
---|
| 800 | |
---|
[116] | 801 | #if OL_DEPTHLIMIT_A0044 |
---|
[115] | 802 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 803 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL()) |
---|
[115] | 804 | #else |
---|
[116] | 805 | if(depthMapDetect && sps->getUseDPL()) //depth map being encoded |
---|
[115] | 806 | #endif |
---|
[116] | 807 | { |
---|
| 808 | bTrySplitDQP = bTrySplit; |
---|
| 809 | } |
---|
| 810 | else |
---|
| 811 | { |
---|
| 812 | if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
| 813 | { |
---|
| 814 | if(iQP == iBaseQP) |
---|
| 815 | { |
---|
| 816 | bTrySplitDQP = bTrySplit; |
---|
| 817 | } |
---|
| 818 | } |
---|
| 819 | else |
---|
| 820 | { |
---|
| 821 | bTrySplitDQP = bTrySplit; |
---|
| 822 | } |
---|
| 823 | } |
---|
[115] | 824 | #else |
---|
[56] | 825 | |
---|
| 826 | if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
| 827 | { |
---|
| 828 | if(iQP == iBaseQP) |
---|
| 829 | { |
---|
| 830 | bTrySplitDQP = bTrySplit; |
---|
| 831 | } |
---|
[2] | 832 | } |
---|
| 833 | else |
---|
| 834 | { |
---|
[56] | 835 | bTrySplitDQP = bTrySplit; |
---|
| 836 | } |
---|
[115] | 837 | #endif |
---|
[56] | 838 | #if LOSSLESS_CODING |
---|
| 839 | if (isAddLowestQP && (iQP == lowestQP)) |
---|
| 840 | { |
---|
| 841 | iQP = iMinQP; |
---|
| 842 | } |
---|
[5] | 843 | #endif |
---|
[56] | 844 | } // end for iMinQP to iMaxQP |
---|
| 845 | |
---|
| 846 | |
---|
| 847 | for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) |
---|
| 848 | { |
---|
| 849 | #if LOSSLESS_CODING |
---|
| 850 | if (isAddLowestQP && (iQP == iMinQP)) |
---|
| 851 | { |
---|
| 852 | iQP = lowestQP; |
---|
[2] | 853 | } |
---|
[56] | 854 | #endif |
---|
| 855 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
[2] | 856 | |
---|
[56] | 857 | // do inter modes, NxN, 2NxN, and Nx2N |
---|
| 858 | if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) |
---|
[2] | 859 | { |
---|
[56] | 860 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 861 | // check availability of residual prediction |
---|
| 862 | Bool bResPredAvailable = false; |
---|
| 863 | Bool bResPredAllowed = (!rpcBestCU->getSlice()->getSPS()->isDepth () ); |
---|
| 864 | bResPredAllowed = bResPredAllowed && ( rpcBestCU->getSlice()->getSPS()->getViewId () ); |
---|
| 865 | bResPredAllowed = bResPredAllowed && ( rpcBestCU->getSlice()->getSPS()->getMultiviewResPredMode() ); |
---|
| 866 | if( bResPredAllowed ) |
---|
[2] | 867 | { |
---|
[77] | 868 | bResPredAvailable = rpcBestCU->getResidualSamples( 0, |
---|
| 869 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 870 | true, |
---|
| 871 | #endif |
---|
| 872 | m_ppcResPredTmp[uiDepth] ); |
---|
[2] | 873 | } |
---|
| 874 | |
---|
[56] | 875 | for( UInt uiResPrdId = 0; uiResPrdId < ( bResPredAvailable ? 2 : 1 ); uiResPrdId++ ) |
---|
| 876 | { |
---|
| 877 | Bool bResPredFlag = ( uiResPrdId > 0 ); |
---|
[152] | 878 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 879 | for(UInt uiICId = 0; uiICId < (bICEnabled ? 2 : 1); uiICId++) |
---|
| 880 | { |
---|
| 881 | Bool bICFlag = (uiICId ? true : false); |
---|
| 882 | rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); |
---|
[56] | 883 | #endif |
---|
[152] | 884 | #endif |
---|
[116] | 885 | // 2Nx2N, NxN |
---|
| 886 | if ( !bEarlySkip ) |
---|
| 887 | { |
---|
[56] | 888 | |
---|
[116] | 889 | if(!( rpcBestCU->getSlice()->getSPS()->getDisInter4x4() && (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) )) |
---|
| 890 | { |
---|
| 891 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu) |
---|
| 892 | { |
---|
| 893 | #if OL_DEPTHLIMIT_A0044 //add code here to select 2NxN or Nx2N or none |
---|
[115] | 894 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 895 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL()) |
---|
[115] | 896 | #else |
---|
[116] | 897 | if(depthMapDetect && sps->getUseDPL()) //depth map being encoded |
---|
[115] | 898 | #endif |
---|
[116] | 899 | { |
---|
| 900 | if (bTrySplit) |
---|
| 901 | { |
---|
[115] | 902 | #endif |
---|
[5] | 903 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 904 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[5] | 905 | #endif |
---|
| 906 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 907 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN, bFullyRenderedSec ); |
---|
[2] | 908 | #else |
---|
[116] | 909 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); |
---|
[2] | 910 | #endif |
---|
[116] | 911 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 912 | #if OL_DEPTHLIMIT_A0044 |
---|
| 913 | }//bTrySplit |
---|
| 914 | }//depthMapDetect |
---|
| 915 | else//do things normally |
---|
| 916 | { |
---|
[115] | 917 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 918 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 919 | #endif |
---|
| 920 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 921 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN, bFullyRenderedSec ); |
---|
[115] | 922 | #else |
---|
[116] | 923 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); |
---|
[115] | 924 | #endif |
---|
[116] | 925 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 926 | } |
---|
| 927 | #endif |
---|
| 928 | } |
---|
| 929 | } |
---|
[56] | 930 | } |
---|
| 931 | |
---|
[116] | 932 | { // 2NxN, Nx2N |
---|
| 933 | #if OL_DEPTHLIMIT_A0044 //add code here to select 2NxN or Nx2N or none |
---|
[115] | 934 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 935 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL()) |
---|
[115] | 936 | #else |
---|
[116] | 937 | if(depthMapDetect && sps->getUseDPL()) //depth map being encoded |
---|
[115] | 938 | #endif |
---|
[116] | 939 | { |
---|
| 940 | if (bTryNx2N) |
---|
| 941 | { |
---|
[115] | 942 | #endif |
---|
[116] | 943 | if(doNotBlockPu) |
---|
| 944 | { |
---|
[5] | 945 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 946 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[5] | 947 | #endif |
---|
| 948 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 949 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N, bFullyRenderedSec ); |
---|
[2] | 950 | #else |
---|
[116] | 951 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N ); |
---|
[2] | 952 | #endif |
---|
[116] | 953 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 954 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) |
---|
| 955 | { |
---|
| 956 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 957 | } |
---|
| 958 | } |
---|
| 959 | #if OL_DEPTHLIMIT_A0044 |
---|
| 960 | }//bTryNx2N |
---|
| 961 | }//depthMapDetect |
---|
| 962 | else//do things normally |
---|
[56] | 963 | { |
---|
[116] | 964 | if(doNotBlockPu) |
---|
| 965 | { |
---|
[56] | 966 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 967 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[56] | 968 | #endif |
---|
| 969 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 970 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N, bFullyRenderedSec ); |
---|
[115] | 971 | #else |
---|
[116] | 972 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N ); |
---|
[115] | 973 | #endif |
---|
[116] | 974 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 975 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) |
---|
| 976 | { |
---|
| 977 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 978 | } |
---|
| 979 | } |
---|
[115] | 980 | } |
---|
| 981 | #endif |
---|
| 982 | |
---|
[116] | 983 | #if OL_DEPTHLIMIT_A0044 //add code here to select 2NxN or Nx2N or none |
---|
[115] | 984 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 985 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL()) |
---|
[115] | 986 | #else |
---|
[116] | 987 | if(depthMapDetect && sps->getUseDPL()) //depth map being encoded |
---|
[115] | 988 | #endif |
---|
[116] | 989 | { |
---|
| 990 | if (bTry2NxN) |
---|
| 991 | { |
---|
[115] | 992 | #endif |
---|
[116] | 993 | if(doNotBlockPu) |
---|
| 994 | { |
---|
[115] | 995 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 996 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 997 | #endif |
---|
| 998 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 999 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxN, bFullyRenderedSec ); |
---|
[56] | 1000 | #else |
---|
[116] | 1001 | xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN ); |
---|
[56] | 1002 | #endif |
---|
[116] | 1003 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1004 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN) |
---|
| 1005 | { |
---|
| 1006 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1007 | } |
---|
| 1008 | } |
---|
| 1009 | #if OL_DEPTHLIMIT_A0044 |
---|
| 1010 | }//bTryNx2N |
---|
| 1011 | }//depthMapDetect |
---|
| 1012 | else//do things normally |
---|
[56] | 1013 | { |
---|
[116] | 1014 | if(doNotBlockPu) |
---|
| 1015 | { |
---|
[115] | 1016 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1017 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 1018 | #endif |
---|
| 1019 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1020 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxN, bFullyRenderedSec ); |
---|
[115] | 1021 | #else |
---|
[116] | 1022 | xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN ); |
---|
[115] | 1023 | #endif |
---|
[116] | 1024 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1025 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN) |
---|
| 1026 | { |
---|
| 1027 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1028 | } |
---|
| 1029 | } |
---|
[115] | 1030 | } |
---|
[116] | 1031 | #endif |
---|
[115] | 1032 | } |
---|
[56] | 1033 | |
---|
| 1034 | #if 1 |
---|
[116] | 1035 | //! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N) |
---|
| 1036 | if( pcPic->getSlice(0)->getSPS()->getAMPAcc(uiDepth) ) |
---|
| 1037 | { |
---|
[56] | 1038 | #if AMP_ENC_SPEEDUP |
---|
[116] | 1039 | Bool bTestAMP_Hor = false, bTestAMP_Ver = false; |
---|
[56] | 1040 | |
---|
| 1041 | #if AMP_MRG |
---|
[116] | 1042 | Bool bTestMergeAMP_Hor = false, bTestMergeAMP_Ver = false; |
---|
[56] | 1043 | |
---|
[116] | 1044 | deriveTestModeAMP (rpcBestCU, eParentPartSize, bTestAMP_Hor, bTestAMP_Ver, bTestMergeAMP_Hor, bTestMergeAMP_Ver); |
---|
[2] | 1045 | #else |
---|
[116] | 1046 | deriveTestModeAMP (rpcBestCU, eParentPartSize, bTestAMP_Hor, bTestAMP_Ver); |
---|
[56] | 1047 | #endif |
---|
| 1048 | |
---|
[116] | 1049 | //! Do horizontal AMP |
---|
| 1050 | if ( bTestAMP_Hor ) |
---|
| 1051 | { |
---|
| 1052 | #if OL_DEPTHLIMIT_A0044 //add code here to select 2NxN or Nx2N or none |
---|
[115] | 1053 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 1054 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL()) |
---|
[115] | 1055 | #else |
---|
[116] | 1056 | if(depthMapDetect && sps->getUseDPL()) //depth map being encoded |
---|
[115] | 1057 | #endif |
---|
[116] | 1058 | { |
---|
| 1059 | if (bTry2NxN) |
---|
| 1060 | { |
---|
[115] | 1061 | #endif |
---|
[116] | 1062 | if(doNotBlockPu) |
---|
| 1063 | { |
---|
[5] | 1064 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1065 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[5] | 1066 | #endif |
---|
| 1067 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1068 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec ); |
---|
[2] | 1069 | #else |
---|
[116] | 1070 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); |
---|
[2] | 1071 | #endif |
---|
[116] | 1072 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1073 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) |
---|
| 1074 | { |
---|
| 1075 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1076 | } |
---|
| 1077 | } |
---|
| 1078 | if(doNotBlockPu) |
---|
| 1079 | { |
---|
[5] | 1080 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1081 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[5] | 1082 | #endif |
---|
| 1083 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1084 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec ); |
---|
[2] | 1085 | #else |
---|
[116] | 1086 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); |
---|
[2] | 1087 | #endif |
---|
[116] | 1088 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1089 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) |
---|
| 1090 | { |
---|
| 1091 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1092 | } |
---|
| 1093 | } |
---|
| 1094 | #if OL_DEPTHLIMIT_A0044 |
---|
| 1095 | }//bTry2NxN |
---|
| 1096 | }//depthMapDetect |
---|
| 1097 | else//do things normally |
---|
[56] | 1098 | { |
---|
[116] | 1099 | if(doNotBlockPu) |
---|
| 1100 | { |
---|
[115] | 1101 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1102 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 1103 | #endif |
---|
| 1104 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1105 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec ); |
---|
[115] | 1106 | #else |
---|
[116] | 1107 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); |
---|
[115] | 1108 | #endif |
---|
[116] | 1109 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1110 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) |
---|
| 1111 | { |
---|
| 1112 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1113 | } |
---|
| 1114 | } |
---|
| 1115 | if(doNotBlockPu) |
---|
| 1116 | { |
---|
[115] | 1117 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1118 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 1119 | #endif |
---|
| 1120 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1121 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec ); |
---|
[115] | 1122 | #else |
---|
[116] | 1123 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); |
---|
[115] | 1124 | #endif |
---|
[116] | 1125 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1126 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) |
---|
| 1127 | { |
---|
| 1128 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1129 | } |
---|
| 1130 | } |
---|
[115] | 1131 | } |
---|
[116] | 1132 | #endif |
---|
[115] | 1133 | } |
---|
[56] | 1134 | #if AMP_MRG |
---|
[116] | 1135 | else if ( bTestMergeAMP_Hor ) |
---|
| 1136 | { |
---|
| 1137 | #if OL_DEPTHLIMIT_A0044 //add code here to select 2NxN or Nx2N or none |
---|
[115] | 1138 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 1139 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL()) |
---|
[115] | 1140 | #else |
---|
[116] | 1141 | if(depthMapDetect && sps->getUseDPL()) //depth map being encoded |
---|
[115] | 1142 | #endif |
---|
[116] | 1143 | { |
---|
| 1144 | if (bTry2NxN) |
---|
| 1145 | { |
---|
[115] | 1146 | #endif |
---|
[116] | 1147 | if(doNotBlockPu) |
---|
| 1148 | { |
---|
[56] | 1149 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1150 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[2] | 1151 | #endif |
---|
[56] | 1152 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1153 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec, true ); |
---|
[56] | 1154 | #else |
---|
[116] | 1155 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true ); |
---|
[56] | 1156 | #endif |
---|
[116] | 1157 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1158 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) |
---|
| 1159 | { |
---|
| 1160 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1161 | } |
---|
| 1162 | } |
---|
| 1163 | if(doNotBlockPu) |
---|
| 1164 | { |
---|
[56] | 1165 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1166 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[56] | 1167 | #endif |
---|
| 1168 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1169 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec, true ); |
---|
[56] | 1170 | #else |
---|
[116] | 1171 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true ); |
---|
[56] | 1172 | #endif |
---|
[116] | 1173 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1174 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) |
---|
| 1175 | { |
---|
| 1176 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1177 | } |
---|
| 1178 | } |
---|
| 1179 | #if OL_DEPTHLIMIT_A0044 |
---|
| 1180 | }//bTry2NxN |
---|
| 1181 | }//depthMapDetect |
---|
| 1182 | else//do things normally |
---|
[56] | 1183 | { |
---|
[116] | 1184 | if(doNotBlockPu) |
---|
| 1185 | { |
---|
[115] | 1186 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1187 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 1188 | #endif |
---|
| 1189 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1190 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec, true ); |
---|
[115] | 1191 | #else |
---|
[116] | 1192 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true ); |
---|
[115] | 1193 | #endif |
---|
[116] | 1194 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1195 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) |
---|
| 1196 | { |
---|
| 1197 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1198 | } |
---|
| 1199 | } |
---|
| 1200 | if(doNotBlockPu) |
---|
| 1201 | { |
---|
[115] | 1202 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1203 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 1204 | #endif |
---|
| 1205 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1206 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec, true ); |
---|
[115] | 1207 | #else |
---|
[116] | 1208 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true ); |
---|
[115] | 1209 | #endif |
---|
[116] | 1210 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1211 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) |
---|
| 1212 | { |
---|
| 1213 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1214 | } |
---|
| 1215 | } |
---|
| 1216 | |
---|
[115] | 1217 | } |
---|
[116] | 1218 | #endif |
---|
[115] | 1219 | } |
---|
| 1220 | #endif |
---|
[2] | 1221 | |
---|
[116] | 1222 | //! Do horizontal AMP |
---|
| 1223 | if ( bTestAMP_Ver ) |
---|
| 1224 | { |
---|
| 1225 | #if OL_DEPTHLIMIT_A0044 //add code here to select 2NxN or Nx2N or none |
---|
[115] | 1226 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 1227 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL()) |
---|
[115] | 1228 | #else |
---|
[116] | 1229 | if(depthMapDetect && sps->getUseDPL()) //depth map being encoded |
---|
[115] | 1230 | #endif |
---|
[116] | 1231 | { |
---|
| 1232 | if (bTryNx2N) |
---|
| 1233 | { |
---|
[115] | 1234 | #endif |
---|
[116] | 1235 | if(doNotBlockPu) |
---|
| 1236 | { |
---|
[56] | 1237 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1238 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[2] | 1239 | #endif |
---|
[56] | 1240 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1241 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec ); |
---|
[56] | 1242 | #else |
---|
[116] | 1243 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); |
---|
[56] | 1244 | #endif |
---|
[116] | 1245 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1246 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) |
---|
| 1247 | { |
---|
| 1248 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1249 | } |
---|
| 1250 | } |
---|
| 1251 | if(doNotBlockPu) |
---|
| 1252 | { |
---|
[5] | 1253 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1254 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[5] | 1255 | #endif |
---|
| 1256 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1257 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec ); |
---|
[2] | 1258 | #else |
---|
[116] | 1259 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); |
---|
[2] | 1260 | #endif |
---|
[116] | 1261 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1262 | } |
---|
| 1263 | #if OL_DEPTHLIMIT_A0044 |
---|
| 1264 | }//bTryNx2N |
---|
| 1265 | }//depthMapDetect |
---|
| 1266 | else//do things normally |
---|
| 1267 | { |
---|
| 1268 | if(doNotBlockPu) |
---|
| 1269 | { |
---|
[115] | 1270 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1271 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 1272 | #endif |
---|
| 1273 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1274 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec ); |
---|
[115] | 1275 | #else |
---|
[116] | 1276 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); |
---|
[115] | 1277 | #endif |
---|
[116] | 1278 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1279 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) |
---|
| 1280 | { |
---|
| 1281 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1282 | } |
---|
| 1283 | } |
---|
| 1284 | if(doNotBlockPu) |
---|
| 1285 | { |
---|
[115] | 1286 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1287 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 1288 | #endif |
---|
| 1289 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1290 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec ); |
---|
[115] | 1291 | #else |
---|
[116] | 1292 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); |
---|
[115] | 1293 | #endif |
---|
[116] | 1294 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1295 | } |
---|
| 1296 | } |
---|
| 1297 | #endif |
---|
[115] | 1298 | } |
---|
[56] | 1299 | #if AMP_MRG |
---|
[116] | 1300 | else if ( bTestMergeAMP_Ver ) |
---|
| 1301 | { |
---|
| 1302 | #if OL_DEPTHLIMIT_A0044 //add code here to select 2NxN or Nx2N or none |
---|
[115] | 1303 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 1304 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL()) |
---|
[115] | 1305 | #else |
---|
[116] | 1306 | if(depthMapDetect && sps->getUseDPL()) //depth map being encoded |
---|
[115] | 1307 | #endif |
---|
[116] | 1308 | { |
---|
| 1309 | if (bTryNx2N) |
---|
| 1310 | { |
---|
[115] | 1311 | #endif |
---|
[116] | 1312 | if(doNotBlockPu) |
---|
| 1313 | { |
---|
[5] | 1314 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1315 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[5] | 1316 | #endif |
---|
| 1317 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1318 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec, true ); |
---|
[2] | 1319 | #else |
---|
[116] | 1320 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true ); |
---|
[2] | 1321 | #endif |
---|
[116] | 1322 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1323 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) |
---|
| 1324 | { |
---|
| 1325 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1326 | } |
---|
| 1327 | } |
---|
| 1328 | if(doNotBlockPu) |
---|
| 1329 | { |
---|
[56] | 1330 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1331 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[56] | 1332 | #endif |
---|
| 1333 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1334 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec, true ); |
---|
[56] | 1335 | #else |
---|
[116] | 1336 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true ); |
---|
[56] | 1337 | #endif |
---|
[116] | 1338 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1339 | } |
---|
| 1340 | #if OL_DEPTHLIMIT_A0044 |
---|
| 1341 | }//bTryNx2N |
---|
| 1342 | }//depthMapDetect |
---|
| 1343 | else//do things normally |
---|
| 1344 | { |
---|
| 1345 | if(doNotBlockPu) |
---|
| 1346 | { |
---|
[115] | 1347 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1348 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 1349 | #endif |
---|
| 1350 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1351 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec, true ); |
---|
[115] | 1352 | #else |
---|
[116] | 1353 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true ); |
---|
[115] | 1354 | #endif |
---|
[116] | 1355 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1356 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) |
---|
| 1357 | { |
---|
| 1358 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
| 1359 | } |
---|
| 1360 | } |
---|
| 1361 | if(doNotBlockPu) |
---|
| 1362 | { |
---|
[115] | 1363 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1364 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[115] | 1365 | #endif |
---|
| 1366 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1367 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec, true ); |
---|
[115] | 1368 | #else |
---|
[116] | 1369 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true ); |
---|
[115] | 1370 | #endif |
---|
[116] | 1371 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1372 | } |
---|
| 1373 | } |
---|
| 1374 | #endif |
---|
[115] | 1375 | } |
---|
[56] | 1376 | #endif |
---|
[2] | 1377 | |
---|
[56] | 1378 | #else |
---|
[5] | 1379 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1380 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[5] | 1381 | #endif |
---|
[56] | 1382 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1383 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec ); |
---|
[56] | 1384 | #else |
---|
[116] | 1385 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); |
---|
[56] | 1386 | #endif |
---|
[116] | 1387 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
[56] | 1388 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1389 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[56] | 1390 | #endif |
---|
| 1391 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1392 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec ); |
---|
[56] | 1393 | #else |
---|
[116] | 1394 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); |
---|
[56] | 1395 | #endif |
---|
[116] | 1396 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
[56] | 1397 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1398 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[56] | 1399 | #endif |
---|
| 1400 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1401 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec ); |
---|
[56] | 1402 | #else |
---|
[116] | 1403 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); |
---|
[56] | 1404 | #endif |
---|
[116] | 1405 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
[56] | 1406 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[116] | 1407 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
[56] | 1408 | #endif |
---|
| 1409 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1410 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec ); |
---|
[56] | 1411 | #else |
---|
[116] | 1412 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); |
---|
[56] | 1413 | #endif |
---|
[116] | 1414 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
[2] | 1415 | |
---|
[56] | 1416 | #endif |
---|
[116] | 1417 | } //! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N) |
---|
[56] | 1418 | #endif |
---|
[152] | 1419 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 1420 | } |
---|
[152] | 1421 | #endif |
---|
[56] | 1422 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 1423 | } // uiResPrdId |
---|
| 1424 | #endif |
---|
| 1425 | } // != I_SLICE |
---|
| 1426 | |
---|
| 1427 | // initialize PCM flag |
---|
| 1428 | rpcTempCU->setIPCMFlag( 0, false); |
---|
| 1429 | rpcTempCU->setIPCMFlagSubParts ( false, 0, uiDepth); //SUB_LCU_DQP |
---|
| 1430 | |
---|
| 1431 | // do normal intra modes |
---|
| 1432 | if ( !bEarlySkip ) |
---|
| 1433 | { |
---|
| 1434 | // speedup for inter frames |
---|
[5] | 1435 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1436 | if( ( rpcBestCU->getSlice()->getSliceType() == I_SLICE || |
---|
| 1437 | rpcBestCU->getCbf( 0, TEXT_LUMA ) != 0 || |
---|
| 1438 | rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0 || |
---|
| 1439 | rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 ) && !bFullyRenderedSec ) // avoid very complex intra if it is unlikely |
---|
[2] | 1440 | #else |
---|
[56] | 1441 | if( rpcBestCU->getSlice()->getSliceType() == I_SLICE || |
---|
| 1442 | rpcBestCU->getCbf( 0, TEXT_LUMA ) != 0 || |
---|
| 1443 | rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0 || |
---|
| 1444 | rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 ) // avoid very complex intra if it is unlikely |
---|
[2] | 1445 | #endif |
---|
| 1446 | { |
---|
[152] | 1447 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 1448 | rpcTempCU->setICFlagSubParts(false, 0, 0, uiDepth); |
---|
[152] | 1449 | #endif |
---|
[56] | 1450 | xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); |
---|
| 1451 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1452 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
[2] | 1453 | { |
---|
[116] | 1454 | #if OL_DEPTHLIMIT_A0044 //add code here to select or deselect NxN mode for Intra |
---|
[115] | 1455 | #if OL_DO_NOT_LIMIT_INTRA_SLICES_PART |
---|
[116] | 1456 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseDPL()) |
---|
[115] | 1457 | #else |
---|
[116] | 1458 | if(depthMapDetect && sps->getUseDPL()) //depth map being encoded |
---|
[115] | 1459 | #endif |
---|
[116] | 1460 | { |
---|
| 1461 | if (bTrySplit) |
---|
| 1462 | { |
---|
| 1463 | |
---|
[115] | 1464 | #endif |
---|
[116] | 1465 | if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) ) |
---|
| 1466 | { |
---|
[152] | 1467 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 1468 | rpcTempCU->setICFlagSubParts(false, 0, 0, uiDepth); |
---|
[152] | 1469 | #endif |
---|
[116] | 1470 | xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN ); |
---|
| 1471 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1472 | } |
---|
| 1473 | #if OL_DEPTHLIMIT_A0044 |
---|
| 1474 | }//bTrySplit |
---|
| 1475 | }//depthMapDetect |
---|
| 1476 | else |
---|
[56] | 1477 | { |
---|
[116] | 1478 | if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) ) |
---|
| 1479 | { |
---|
| 1480 | xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN ); |
---|
| 1481 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1482 | } |
---|
[56] | 1483 | } |
---|
[115] | 1484 | #endif |
---|
[2] | 1485 | } |
---|
| 1486 | } |
---|
| 1487 | } |
---|
[56] | 1488 | |
---|
| 1489 | // test PCM |
---|
| 1490 | if(pcPic->getSlice(0)->getSPS()->getUsePCM() |
---|
| 1491 | && rpcTempCU->getWidth(0) <= (1<<pcPic->getSlice(0)->getSPS()->getPCMLog2MaxSize()) |
---|
| 1492 | && rpcTempCU->getWidth(0) >= (1<<pcPic->getSlice(0)->getSPS()->getPCMLog2MinSize()) ) |
---|
| 1493 | { |
---|
| 1494 | UInt uiRawBits = (g_uiBitDepth * rpcBestCU->getWidth(0) * rpcBestCU->getHeight(0) * 3 / 2); |
---|
| 1495 | UInt uiBestBits = rpcBestCU->getTotalBits(); |
---|
| 1496 | #if HHI_VSO |
---|
| 1497 | Double dRDCostTemp = m_pcRdCost->getUseVSO() ? m_pcRdCost->calcRdCostVSO(uiRawBits, 0) : m_pcRdCost->calcRdCost(uiRawBits, 0); |
---|
| 1498 | if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > dRDCostTemp )) |
---|
| 1499 | #else |
---|
| 1500 | if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > m_pcRdCost->calcRdCost(uiRawBits, 0))) |
---|
| 1501 | #endif |
---|
| 1502 | { |
---|
[152] | 1503 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 1504 | rpcTempCU->setICFlagSubParts(false, 0, 0, uiDepth); |
---|
[152] | 1505 | #endif |
---|
[56] | 1506 | xCheckIntraPCM (rpcBestCU, rpcTempCU); |
---|
| 1507 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1508 | } |
---|
| 1509 | } |
---|
| 1510 | #if HHI_MPI |
---|
| 1511 | if( rpcBestCU->getSlice()->getSPS()->getUseMVI() && rpcBestCU->getSlice()->getSliceType() != I_SLICE ) |
---|
| 1512 | { |
---|
| 1513 | xCheckRDCostMvInheritance( rpcBestCU, rpcTempCU, uiDepth, false, false ); |
---|
| 1514 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1515 | xCheckRDCostMvInheritance( rpcBestCU, rpcTempCU, uiDepth, true, false ); |
---|
| 1516 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
| 1517 | } |
---|
| 1518 | #endif |
---|
| 1519 | #if LOSSLESS_CODING |
---|
| 1520 | if (isAddLowestQP && (iQP == lowestQP)) |
---|
| 1521 | { |
---|
| 1522 | iQP = iMinQP; |
---|
| 1523 | } |
---|
| 1524 | #endif |
---|
[2] | 1525 | } |
---|
| 1526 | |
---|
| 1527 | m_pcEntropyCoder->resetBits(); |
---|
| 1528 | m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true ); |
---|
| 1529 | rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits |
---|
[56] | 1530 | if(m_pcEncCfg->getUseSBACRD()) |
---|
| 1531 | { |
---|
| 1532 | rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
| 1533 | } |
---|
[2] | 1534 | |
---|
[56] | 1535 | #if HHI_VSO |
---|
| 1536 | if ( m_pcRdCost->getUseVSO() ) |
---|
[2] | 1537 | { |
---|
| 1538 | rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); |
---|
| 1539 | } |
---|
| 1540 | else |
---|
[5] | 1541 | #endif |
---|
[2] | 1542 | { |
---|
[116] | 1543 | rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); |
---|
[2] | 1544 | } |
---|
| 1545 | |
---|
| 1546 | // accumulate statistics for early skip |
---|
| 1547 | if ( m_pcEncCfg->getUseFastEnc() ) |
---|
| 1548 | { |
---|
| 1549 | if ( rpcBestCU->isSkipped(0) ) |
---|
| 1550 | { |
---|
| 1551 | Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ]; |
---|
| 1552 | afCost[ iIdx ] += rpcBestCU->getTotalCost(); |
---|
| 1553 | aiNum [ iIdx ] ++; |
---|
| 1554 | } |
---|
| 1555 | } |
---|
[56] | 1556 | |
---|
| 1557 | // Early CU determination |
---|
| 1558 | if( m_pcEncCfg->getUseEarlyCU() && ((*rpcBestCU->getPredictionMode()) == 0) ) |
---|
[2] | 1559 | { |
---|
[56] | 1560 | bSubBranch = false; |
---|
[2] | 1561 | } |
---|
[56] | 1562 | else |
---|
| 1563 | { |
---|
| 1564 | bSubBranch = true; |
---|
| 1565 | } |
---|
| 1566 | #if HHI_INTERVIEW_SKIP |
---|
[116] | 1567 | rpcBestCU->setRenderableSubParts(bFullyRenderedSec,0,rpcBestCU->getDepth( 0 )) ; |
---|
[2] | 1568 | #endif |
---|
| 1569 | } |
---|
[56] | 1570 | else if(!(bSliceEnd && bInsidePicture)) |
---|
[2] | 1571 | { |
---|
| 1572 | bBoundary = true; |
---|
| 1573 | } |
---|
| 1574 | |
---|
[56] | 1575 | #if LOSSLESS_CODING |
---|
| 1576 | // copy orginal YUV samples to PCM buffer |
---|
| 1577 | if( rpcBestCU->isLosslessCoded(0) && (rpcBestCU->getIPCMFlag(0) == false)) |
---|
[2] | 1578 | { |
---|
[56] | 1579 | xFillPCMBuffer(rpcBestCU, m_ppcOrigYuv[uiDepth]); |
---|
| 1580 | } |
---|
| 1581 | #endif |
---|
| 1582 | if( (g_uiMaxCUWidth>>uiDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
| 1583 | { |
---|
| 1584 | Int idQP = m_pcEncCfg->getMaxDeltaQP(); |
---|
| 1585 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1586 | iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); |
---|
| 1587 | iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); |
---|
| 1588 | #if LOSSLESS_CODING |
---|
| 1589 | if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 1590 | { |
---|
[56] | 1591 | isAddLowestQP = true; |
---|
| 1592 | iMinQP = iMinQP - 1; |
---|
[2] | 1593 | } |
---|
[5] | 1594 | #endif |
---|
[56] | 1595 | #else |
---|
| 1596 | iMinQP = Clip3( MIN_QP, MAX_QP, iBaseQP-idQP ); |
---|
| 1597 | iMaxQP = Clip3( MIN_QP, MAX_QP, iBaseQP+idQP ); |
---|
| 1598 | #if LOSSLESS_CODING |
---|
| 1599 | if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) |
---|
| 1600 | { |
---|
| 1601 | isAddLowestQP = true; |
---|
| 1602 | iMinQP = iMinQP - 1; |
---|
| 1603 | } |
---|
| 1604 | #endif |
---|
| 1605 | #endif |
---|
| 1606 | } |
---|
| 1607 | else if( (g_uiMaxCUWidth>>uiDepth) > rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
| 1608 | { |
---|
| 1609 | iMinQP = iBaseQP; |
---|
| 1610 | iMaxQP = iBaseQP; |
---|
| 1611 | } |
---|
| 1612 | else |
---|
| 1613 | { |
---|
| 1614 | Int iStartQP; |
---|
| 1615 | if( pcPic->getCU( rpcTempCU->getAddr() )->getEntropySliceStartCU(rpcTempCU->getZorderIdxInCU()) == pcSlice->getEntropySliceCurStartCUAddr()) |
---|
| 1616 | { |
---|
| 1617 | iStartQP = rpcTempCU->getQP(0); |
---|
| 1618 | } |
---|
| 1619 | else |
---|
| 1620 | { |
---|
| 1621 | UInt uiCurSliceStartPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU() - rpcTempCU->getZorderIdxInCU(); |
---|
| 1622 | iStartQP = rpcTempCU->getQP(uiCurSliceStartPartIdx); |
---|
| 1623 | } |
---|
| 1624 | iMinQP = iStartQP; |
---|
| 1625 | iMaxQP = iStartQP; |
---|
| 1626 | } |
---|
[2] | 1627 | |
---|
[56] | 1628 | for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) |
---|
| 1629 | { |
---|
| 1630 | #if LOSSLESS_CODING |
---|
[116] | 1631 | if (isAddLowestQP && (iQP == iMinQP)) |
---|
| 1632 | { |
---|
| 1633 | iQP = lowestQP; |
---|
| 1634 | } |
---|
[56] | 1635 | #endif |
---|
| 1636 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
[2] | 1637 | |
---|
[56] | 1638 | // further split |
---|
| 1639 | if( bSubBranch && bTrySplitDQP && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
[2] | 1640 | { |
---|
[56] | 1641 | #if HHI_VSO |
---|
| 1642 | // reset Model |
---|
| 1643 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 1644 | { |
---|
[81] | 1645 | UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth ( ); |
---|
| 1646 | UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight( ); |
---|
| 1647 | Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr( 0 ); |
---|
| 1648 | UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride(); |
---|
| 1649 | m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[56] | 1650 | } |
---|
| 1651 | #endif |
---|
| 1652 | UChar uhNextDepth = uiDepth+1; |
---|
| 1653 | TComDataCU* pcSubBestPartCU = m_ppcBestCU[uhNextDepth]; |
---|
| 1654 | TComDataCU* pcSubTempPartCU = m_ppcTempCU[uhNextDepth]; |
---|
[2] | 1655 | |
---|
[56] | 1656 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
[2] | 1657 | { |
---|
[56] | 1658 | pcSubBestPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. |
---|
| 1659 | pcSubTempPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. |
---|
| 1660 | |
---|
| 1661 | Bool bInSlice = pcSubBestPartCU->getSCUAddr()+pcSubBestPartCU->getTotalNumPart()>pcSlice->getEntropySliceCurStartCUAddr()&&pcSubBestPartCU->getSCUAddr()<pcSlice->getEntropySliceCurEndCUAddr(); |
---|
| 1662 | if(bInSlice && ( pcSubBestPartCU->getCUPelX() < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( pcSubBestPartCU->getCUPelY() < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[2] | 1663 | { |
---|
[56] | 1664 | if( m_bUseSBACRD ) |
---|
[2] | 1665 | { |
---|
[56] | 1666 | if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer |
---|
| 1667 | { |
---|
| 1668 | m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); |
---|
| 1669 | } |
---|
| 1670 | else |
---|
| 1671 | { |
---|
| 1672 | m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); |
---|
| 1673 | } |
---|
[2] | 1674 | } |
---|
[56] | 1675 | |
---|
| 1676 | #if AMP_ENC_SPEEDUP |
---|
| 1677 | if ( rpcBestCU->isIntra(0) ) |
---|
| 1678 | { |
---|
| 1679 | xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth, SIZE_NONE ); |
---|
| 1680 | } |
---|
[2] | 1681 | else |
---|
| 1682 | { |
---|
[56] | 1683 | xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth, rpcBestCU->getPartitionSize(0) ); |
---|
[2] | 1684 | } |
---|
[56] | 1685 | #else |
---|
| 1686 | xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth ); |
---|
| 1687 | #endif |
---|
[2] | 1688 | |
---|
[56] | 1689 | rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth ); // Keep best part data to current temporary data. |
---|
| 1690 | xCopyYuv2Tmp( pcSubBestPartCU->getTotalNumPart()*uiPartUnitIdx, uhNextDepth ); |
---|
[2] | 1691 | |
---|
[5] | 1692 | #if HHI_VSO |
---|
[100] | 1693 | #if HHI_VSO_SET_OPTIM |
---|
| 1694 | #else |
---|
[56] | 1695 | if( m_pcRdCost->getUseRenModel() ) // necessary ?? |
---|
| 1696 | { |
---|
[81] | 1697 | UInt uiWidth = m_ppcRecoYuvBest[uhNextDepth]->getWidth ( ); |
---|
| 1698 | UInt uiHeight = m_ppcRecoYuvBest[uhNextDepth]->getHeight ( ); |
---|
| 1699 | Pel* piSrc = m_ppcRecoYuvBest[uhNextDepth]->getLumaAddr( 0 ); |
---|
| 1700 | UInt uiSrcStride = m_ppcRecoYuvBest[uhNextDepth]->getStride ( ); |
---|
| 1701 | m_pcRdCost->setRenModelData( pcSubBestPartCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[56] | 1702 | } |
---|
| 1703 | #endif |
---|
[100] | 1704 | #endif |
---|
[56] | 1705 | } |
---|
| 1706 | else if (bInSlice) |
---|
[2] | 1707 | { |
---|
[56] | 1708 | pcSubBestPartCU->copyToPic( uhNextDepth ); |
---|
| 1709 | rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth ); |
---|
[2] | 1710 | } |
---|
| 1711 | } |
---|
| 1712 | |
---|
[56] | 1713 | if( !bBoundary ) |
---|
| 1714 | { |
---|
| 1715 | m_pcEntropyCoder->resetBits(); |
---|
| 1716 | m_pcEntropyCoder->encodeSplitFlag( rpcTempCU, 0, uiDepth, true ); |
---|
[2] | 1717 | |
---|
[56] | 1718 | rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits |
---|
| 1719 | if(m_pcEncCfg->getUseSBACRD()) |
---|
| 1720 | { |
---|
| 1721 | rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
| 1722 | } |
---|
| 1723 | } |
---|
[5] | 1724 | #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
[56] | 1725 | if( bFullyRenderedSec ) |
---|
| 1726 | { |
---|
| 1727 | m_pcRdCost->setLambdaScale( m_pcEncCfg->getInterViewSkipLambdaScale() ); |
---|
| 1728 | } |
---|
| 1729 | else |
---|
| 1730 | { |
---|
| 1731 | m_pcRdCost->setLambdaScale( 1 ); |
---|
| 1732 | } |
---|
[2] | 1733 | #endif |
---|
[56] | 1734 | |
---|
[5] | 1735 | #if HHI_VSO |
---|
[56] | 1736 | if ( m_pcRdCost->getUseVSO() ) |
---|
| 1737 | { |
---|
| 1738 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 1739 | } |
---|
| 1740 | else |
---|
[5] | 1741 | #endif |
---|
[56] | 1742 | { |
---|
[116] | 1743 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
[56] | 1744 | } |
---|
[2] | 1745 | |
---|
[56] | 1746 | if( (g_uiMaxCUWidth>>uiDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() && rpcTempCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 1747 | { |
---|
| 1748 | Bool bHasRedisual = false; |
---|
| 1749 | for( UInt uiBlkIdx = 0; uiBlkIdx < rpcTempCU->getTotalNumPart(); uiBlkIdx ++) |
---|
| 1750 | { |
---|
| 1751 | if( ( pcPic->getCU( rpcTempCU->getAddr() )->getEntropySliceStartCU(uiBlkIdx+rpcTempCU->getZorderIdxInCU()) == rpcTempCU->getSlice()->getEntropySliceCurStartCUAddr() ) && |
---|
[116] | 1752 | ( rpcTempCU->getCbf( uiBlkIdx, TEXT_LUMA ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_U ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_V ) ) ) |
---|
[56] | 1753 | { |
---|
| 1754 | bHasRedisual = true; |
---|
| 1755 | break; |
---|
| 1756 | } |
---|
| 1757 | } |
---|
[2] | 1758 | |
---|
[56] | 1759 | UInt uiTargetPartIdx; |
---|
| 1760 | if ( pcPic->getCU( rpcTempCU->getAddr() )->getEntropySliceStartCU(rpcTempCU->getZorderIdxInCU()) != pcSlice->getEntropySliceCurStartCUAddr() ) |
---|
| 1761 | { |
---|
| 1762 | uiTargetPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU() - rpcTempCU->getZorderIdxInCU(); |
---|
| 1763 | } |
---|
| 1764 | else |
---|
| 1765 | { |
---|
| 1766 | uiTargetPartIdx = 0; |
---|
| 1767 | } |
---|
| 1768 | if ( bHasRedisual ) |
---|
| 1769 | { |
---|
| 1770 | #if !RDO_WITHOUT_DQP_BITS |
---|
| 1771 | m_pcEntropyCoder->resetBits(); |
---|
| 1772 | m_pcEntropyCoder->encodeQP( rpcTempCU, uiTargetPartIdx, false ); |
---|
| 1773 | rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits |
---|
| 1774 | if(m_pcEncCfg->getUseSBACRD()) |
---|
| 1775 | { |
---|
| 1776 | rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
| 1777 | } |
---|
[5] | 1778 | #if HHI_VSO |
---|
[56] | 1779 | if ( m_pcRdCost->getUseLambdaScaleVSO()) |
---|
| 1780 | { |
---|
| 1781 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 1782 | } |
---|
| 1783 | else |
---|
[5] | 1784 | #endif |
---|
[56] | 1785 | { |
---|
[116] | 1786 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
[56] | 1787 | } |
---|
| 1788 | #endif |
---|
| 1789 | } |
---|
| 1790 | else |
---|
| 1791 | { |
---|
| 1792 | #if LOSSLESS_CODING |
---|
| 1793 | if (((rpcTempCU->getQP(uiTargetPartIdx) != rpcTempCU->getRefQP(uiTargetPartIdx)) ) && (rpcTempCU->getSlice()->getSPS()->getUseLossless())) |
---|
| 1794 | { |
---|
| 1795 | rpcTempCU->getTotalCost() = MAX_DOUBLE; |
---|
| 1796 | } |
---|
| 1797 | #endif |
---|
| 1798 | rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( uiTargetPartIdx ), 0, uiDepth ); // set QP to default QP |
---|
| 1799 | } |
---|
| 1800 | } |
---|
[2] | 1801 | |
---|
[56] | 1802 | if( m_bUseSBACRD ) |
---|
| 1803 | { |
---|
| 1804 | m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); |
---|
| 1805 | } |
---|
| 1806 | Bool bEntropyLimit=false; |
---|
| 1807 | Bool bSliceLimit=false; |
---|
| 1808 | bSliceLimit=rpcBestCU->getSlice()->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&&(rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceArgument()<<3); |
---|
| 1809 | if(rpcBestCU->getSlice()->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&m_pcEncCfg->getUseSBACRD()) |
---|
| 1810 | { |
---|
| 1811 | if(rpcBestCU->getTotalBins()>rpcBestCU->getSlice()->getEntropySliceArgument()) |
---|
| 1812 | { |
---|
| 1813 | bEntropyLimit=true; |
---|
| 1814 | } |
---|
| 1815 | } |
---|
| 1816 | else if(rpcBestCU->getSlice()->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE) |
---|
| 1817 | { |
---|
| 1818 | if(rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getEntropySliceArgument()) |
---|
| 1819 | { |
---|
| 1820 | bEntropyLimit=true; |
---|
| 1821 | } |
---|
| 1822 | } |
---|
| 1823 | if(rpcBestCU->getDepth(0)>=rpcBestCU->getSlice()->getPPS()->getSliceGranularity()) |
---|
| 1824 | { |
---|
| 1825 | bSliceLimit=false; |
---|
| 1826 | bEntropyLimit=false; |
---|
| 1827 | } |
---|
| 1828 | if(bSliceLimit||bEntropyLimit) |
---|
| 1829 | { |
---|
| 1830 | rpcBestCU->getTotalCost()=rpcTempCU->getTotalCost()+1; |
---|
| 1831 | } |
---|
| 1832 | xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth); // RD compare current larger prediction |
---|
| 1833 | } // with sub partitioned prediction. |
---|
| 1834 | #if LOSSLESS_CODING |
---|
[116] | 1835 | if (isAddLowestQP && (iQP == lowestQP)) |
---|
| 1836 | { |
---|
| 1837 | iQP = iMinQP; |
---|
| 1838 | } |
---|
[56] | 1839 | #endif |
---|
| 1840 | } // SPLIT- QP Loop |
---|
| 1841 | |
---|
| 1842 | #if HHI_VSO |
---|
| 1843 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 1844 | { |
---|
[116] | 1845 | UInt uiWidth = m_ppcRecoYuvBest[uiDepth]->getWidth ( ); |
---|
| 1846 | UInt uiHeight = m_ppcRecoYuvBest[uiDepth]->getHeight ( ); |
---|
| 1847 | Pel* piSrc = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 ); |
---|
| 1848 | UInt uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride ( ); |
---|
| 1849 | m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[56] | 1850 | } |
---|
| 1851 | #endif |
---|
| 1852 | |
---|
[2] | 1853 | rpcBestCU->copyToPic(uiDepth); // Copy Best data to Picture for next partition prediction. |
---|
| 1854 | |
---|
[56] | 1855 | xCopyYuv2Pic( rpcBestCU->getPic(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU(), uiDepth, uiDepth, rpcBestCU, uiLPelX, uiTPelY ); // Copy Yuv data to picture Yuv |
---|
| 1856 | if( bBoundary ||(bSliceEnd && bInsidePicture)) |
---|
| 1857 | { |
---|
[2] | 1858 | return; |
---|
[56] | 1859 | } |
---|
[2] | 1860 | |
---|
| 1861 | // Assert if Best prediction mode is NONE |
---|
| 1862 | // Selected mode's RD-cost must be not MAX_DOUBLE. |
---|
| 1863 | assert( rpcBestCU->getPartitionSize ( 0 ) != SIZE_NONE ); |
---|
| 1864 | assert( rpcBestCU->getPredictionMode( 0 ) != MODE_NONE ); |
---|
| 1865 | assert( rpcBestCU->getTotalCost ( ) != MAX_DOUBLE ); |
---|
| 1866 | } |
---|
| 1867 | |
---|
[56] | 1868 | /** finish encoding a cu and handle end-of-slice conditions |
---|
| 1869 | * \param pcCU |
---|
| 1870 | * \param uiAbsPartIdx |
---|
| 1871 | * \param uiDepth |
---|
| 1872 | * \returns Void |
---|
| 1873 | */ |
---|
| 1874 | Void TEncCu::finishCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1875 | { |
---|
| 1876 | TComPic* pcPic = pcCU->getPic(); |
---|
| 1877 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 1878 | |
---|
| 1879 | //Calculate end address |
---|
| 1880 | UInt uiCUAddr = pcCU->getSCUAddr()+uiAbsPartIdx; |
---|
| 1881 | |
---|
| 1882 | UInt uiInternalAddress = pcPic->getPicSym()->getPicSCUAddr(pcSlice->getEntropySliceCurEndCUAddr()-1) % pcPic->getNumPartInCU(); |
---|
| 1883 | UInt uiExternalAddress = pcPic->getPicSym()->getPicSCUAddr(pcSlice->getEntropySliceCurEndCUAddr()-1) / pcPic->getNumPartInCU(); |
---|
| 1884 | UInt uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
| 1885 | UInt uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
| 1886 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
| 1887 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
| 1888 | while(uiPosX>=uiWidth||uiPosY>=uiHeight) |
---|
| 1889 | { |
---|
| 1890 | uiInternalAddress--; |
---|
| 1891 | uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
| 1892 | uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
| 1893 | } |
---|
| 1894 | uiInternalAddress++; |
---|
| 1895 | if(uiInternalAddress==pcCU->getPic()->getNumPartInCU()) |
---|
| 1896 | { |
---|
| 1897 | uiInternalAddress = 0; |
---|
| 1898 | uiExternalAddress = pcPic->getPicSym()->getCUOrderMap(pcPic->getPicSym()->getInverseCUOrderMap(uiExternalAddress)+1); |
---|
| 1899 | } |
---|
| 1900 | UInt uiRealEndAddress = pcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*pcPic->getNumPartInCU()+uiInternalAddress); |
---|
| 1901 | |
---|
| 1902 | // Encode slice finish |
---|
| 1903 | Bool bTerminateSlice = false; |
---|
| 1904 | if (uiCUAddr+(pcCU->getPic()->getNumPartInCU()>>(uiDepth<<1)) == uiRealEndAddress) |
---|
| 1905 | { |
---|
| 1906 | bTerminateSlice = true; |
---|
| 1907 | } |
---|
| 1908 | UInt uiGranularityWidth = g_uiMaxCUWidth>>(pcSlice->getPPS()->getSliceGranularity()); |
---|
| 1909 | uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 1910 | uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 1911 | Bool granularityBoundary=((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
---|
| 1912 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)); |
---|
| 1913 | |
---|
| 1914 | #if BURST_IPCM |
---|
| 1915 | if(granularityBoundary && (!(pcCU->getIPCMFlag(uiAbsPartIdx) && ( pcCU->getNumSucIPCM() > 1 )))) |
---|
| 1916 | #else |
---|
| 1917 | if(granularityBoundary) |
---|
| 1918 | #endif |
---|
| 1919 | { |
---|
| 1920 | // The 1-terminating bit is added to all streams, so don't add it here when it's 1. |
---|
| 1921 | if (!bTerminateSlice) |
---|
| 1922 | m_pcEntropyCoder->encodeTerminatingBit( bTerminateSlice ? 1 : 0 ); |
---|
| 1923 | } |
---|
| 1924 | |
---|
| 1925 | Int numberOfWrittenBits = 0; |
---|
| 1926 | if (m_pcBitCounter) |
---|
| 1927 | { |
---|
| 1928 | numberOfWrittenBits = m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
| 1929 | } |
---|
| 1930 | |
---|
| 1931 | // Calculate slice end IF this CU puts us over slice bit size. |
---|
| 1932 | unsigned iGranularitySize = pcCU->getPic()->getNumPartInCU()>>(pcSlice->getPPS()->getSliceGranularity()<<1); |
---|
| 1933 | int iGranularityEnd = ((pcCU->getSCUAddr()+uiAbsPartIdx)/iGranularitySize)*iGranularitySize; |
---|
| 1934 | if(iGranularityEnd<=pcSlice->getEntropySliceCurStartCUAddr()) |
---|
| 1935 | { |
---|
| 1936 | iGranularityEnd+=max(iGranularitySize,(pcCU->getPic()->getNumPartInCU()>>(uiDepth<<1))); |
---|
| 1937 | } |
---|
| 1938 | // Set slice end parameter |
---|
| 1939 | if(pcSlice->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&&!pcSlice->getFinalized()&&pcSlice->getSliceBits()+numberOfWrittenBits>pcSlice->getSliceArgument()<<3) |
---|
| 1940 | { |
---|
| 1941 | pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd); |
---|
| 1942 | pcSlice->setSliceCurEndCUAddr(iGranularityEnd); |
---|
| 1943 | return; |
---|
| 1944 | } |
---|
| 1945 | // Set entropy slice end parameter |
---|
| 1946 | if(m_pcEncCfg->getUseSBACRD()) |
---|
| 1947 | { |
---|
| 1948 | TEncBinCABAC *pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf(); |
---|
| 1949 | UInt uiBinsCoded = pppcRDSbacCoder->getBinsCoded(); |
---|
| 1950 | if(pcSlice->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&!pcSlice->getFinalized()&&pcSlice->getEntropySliceCounter()+uiBinsCoded>pcSlice->getEntropySliceArgument()) |
---|
| 1951 | { |
---|
| 1952 | pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd); |
---|
| 1953 | return; |
---|
| 1954 | } |
---|
| 1955 | } |
---|
| 1956 | else |
---|
| 1957 | { |
---|
| 1958 | if(pcSlice->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&!pcSlice->getFinalized()&&pcSlice->getEntropySliceCounter()+numberOfWrittenBits>pcSlice->getEntropySliceArgument()) |
---|
| 1959 | { |
---|
| 1960 | pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd); |
---|
| 1961 | return; |
---|
| 1962 | } |
---|
| 1963 | } |
---|
| 1964 | if(granularityBoundary) |
---|
| 1965 | { |
---|
| 1966 | pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + numberOfWrittenBits) ); |
---|
| 1967 | if(m_pcEncCfg->getUseSBACRD()) |
---|
| 1968 | { |
---|
| 1969 | TEncBinCABAC *pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf(); |
---|
| 1970 | pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+pppcRDSbacCoder->getBinsCoded()); |
---|
| 1971 | pppcRDSbacCoder->setBinsCoded( 0 ); |
---|
| 1972 | } |
---|
| 1973 | else |
---|
| 1974 | { |
---|
| 1975 | pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+numberOfWrittenBits); |
---|
| 1976 | } |
---|
| 1977 | if (m_pcBitCounter) |
---|
| 1978 | { |
---|
| 1979 | m_pcEntropyCoder->resetBits(); |
---|
| 1980 | } |
---|
| 1981 | } |
---|
| 1982 | } |
---|
| 1983 | |
---|
| 1984 | /** Compute QP for each CU |
---|
| 1985 | * \param pcCU Target CU |
---|
| 1986 | * \param uiDepth CU depth |
---|
| 1987 | * \returns quantization parameter |
---|
| 1988 | */ |
---|
| 1989 | Int TEncCu::xComputeQP( TComDataCU* pcCU, UInt uiDepth ) |
---|
| 1990 | { |
---|
| 1991 | Int iBaseQp = pcCU->getSlice()->getSliceQp(); |
---|
| 1992 | Int iQpOffset = 0; |
---|
| 1993 | if ( m_pcEncCfg->getUseAdaptiveQP() ) |
---|
| 1994 | { |
---|
| 1995 | TEncPic* pcEPic = dynamic_cast<TEncPic*>( pcCU->getPic() ); |
---|
| 1996 | UInt uiAQDepth = min( uiDepth, pcEPic->getMaxAQDepth()-1 ); |
---|
| 1997 | TEncPicQPAdaptationLayer* pcAQLayer = pcEPic->getAQLayer( uiAQDepth ); |
---|
| 1998 | UInt uiAQUPosX = pcCU->getCUPelX() / pcAQLayer->getAQPartWidth(); |
---|
| 1999 | UInt uiAQUPosY = pcCU->getCUPelY() / pcAQLayer->getAQPartHeight(); |
---|
| 2000 | UInt uiAQUStride = pcAQLayer->getAQPartStride(); |
---|
| 2001 | TEncQPAdaptationUnit* acAQU = pcAQLayer->getQPAdaptationUnit(); |
---|
| 2002 | |
---|
| 2003 | Double dMaxQScale = pow(2.0, m_pcEncCfg->getQPAdaptationRange()/6.0); |
---|
| 2004 | Double dAvgAct = pcAQLayer->getAvgActivity(); |
---|
| 2005 | Double dCUAct = acAQU[uiAQUPosY * uiAQUStride + uiAQUPosX].getActivity(); |
---|
| 2006 | Double dNormAct = (dMaxQScale*dCUAct + dAvgAct) / (dCUAct + dMaxQScale*dAvgAct); |
---|
| 2007 | Double dQpOffset = log(dNormAct) / log(2.0) * 6.0; |
---|
| 2008 | iQpOffset = Int(floor( dQpOffset + 0.49999 )); |
---|
| 2009 | } |
---|
| 2010 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 2011 | return Clip3(-pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQp+iQpOffset ); |
---|
| 2012 | #else |
---|
| 2013 | return Clip3( MIN_QP, MAX_QP, iBaseQp+iQpOffset ); |
---|
| 2014 | #endif |
---|
| 2015 | } |
---|
| 2016 | |
---|
[2] | 2017 | /** encode a CU block recursively |
---|
| 2018 | * \param pcCU |
---|
| 2019 | * \param uiAbsPartIdx |
---|
[56] | 2020 | * \param uiDepth |
---|
[2] | 2021 | * \returns Void |
---|
| 2022 | */ |
---|
| 2023 | Void TEncCu::xEncodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2024 | { |
---|
| 2025 | TComPic* pcPic = pcCU->getPic(); |
---|
[56] | 2026 | |
---|
[2] | 2027 | Bool bBoundary = false; |
---|
| 2028 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 2029 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 2030 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 2031 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
[56] | 2032 | |
---|
| 2033 | #if BURST_IPCM |
---|
| 2034 | if( getCheckBurstIPCMFlag() ) |
---|
| 2035 | { |
---|
| 2036 | pcCU->setLastCUSucIPCMFlag( checkLastCUSucIPCM( pcCU, uiAbsPartIdx )); |
---|
| 2037 | pcCU->setNumSucIPCM( countNumSucIPCM ( pcCU, uiAbsPartIdx ) ); |
---|
| 2038 | } |
---|
| 2039 | #endif |
---|
[2] | 2040 | |
---|
[56] | 2041 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 2042 | // If slice start is within this cu... |
---|
| 2043 | Bool bSliceStart = pcSlice->getEntropySliceCurStartCUAddr() > pcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && |
---|
| 2044 | pcSlice->getEntropySliceCurStartCUAddr() < pcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcPic->getNumPartInCU() >> (uiDepth<<1) ); |
---|
| 2045 | // We need to split, so don't try these modes. |
---|
| 2046 | if(!bSliceStart&&( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[2] | 2047 | { |
---|
[5] | 2048 | #if HHI_MPI |
---|
[2] | 2049 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) ) |
---|
[115] | 2050 | { |
---|
[5] | 2051 | #endif |
---|
[115] | 2052 | |
---|
[56] | 2053 | m_pcEntropyCoder->encodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[115] | 2054 | |
---|
| 2055 | #if HHI_MPI |
---|
| 2056 | } |
---|
| 2057 | #endif |
---|
[2] | 2058 | } |
---|
| 2059 | else |
---|
| 2060 | { |
---|
| 2061 | bBoundary = true; |
---|
| 2062 | } |
---|
[56] | 2063 | |
---|
[5] | 2064 | #if HHI_MPI |
---|
[2] | 2065 | if( uiDepth == pcCU->getTextureModeDepth( uiAbsPartIdx ) ) |
---|
| 2066 | { |
---|
| 2067 | xSaveDepthWidthHeight( pcCU ); |
---|
| 2068 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 2069 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
| 2070 | |
---|
[56] | 2071 | if( ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[116] | 2072 | { |
---|
[2] | 2073 | m_pcEntropyCoder->encodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[116] | 2074 | } |
---|
| 2075 | |
---|
[2] | 2076 | if( !pcCU->getSlice()->isIntra() ) |
---|
| 2077 | { |
---|
| 2078 | m_pcEntropyCoder->encodeSkipFlag( pcCU, uiAbsPartIdx ); |
---|
| 2079 | } |
---|
| 2080 | |
---|
| 2081 | if( pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
| 2082 | { |
---|
| 2083 | m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 ); |
---|
[56] | 2084 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
[2] | 2085 | xRestoreDepthWidthHeight( pcCU ); |
---|
| 2086 | return; |
---|
| 2087 | } |
---|
| 2088 | |
---|
| 2089 | m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx ); |
---|
| 2090 | |
---|
| 2091 | m_pcEntropyCoder->encodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 2092 | |
---|
| 2093 | // prediction Info ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
| 2094 | m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx ); |
---|
| 2095 | xRestoreDepthWidthHeight( pcCU ); |
---|
| 2096 | } |
---|
| 2097 | #endif |
---|
| 2098 | |
---|
| 2099 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < (g_uiMaxCUDepth-g_uiAddCUDepth) ) ) || bBoundary ) |
---|
| 2100 | { |
---|
| 2101 | UInt uiQNumParts = ( pcPic->getNumPartInCU() >> (uiDepth<<1) )>>2; |
---|
[56] | 2102 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 2103 | { |
---|
| 2104 | setdQPFlag(true); |
---|
| 2105 | } |
---|
| 2106 | #if BURST_IPCM |
---|
| 2107 | pcCU->setNumSucIPCM(0); |
---|
| 2108 | pcCU->setLastCUSucIPCMFlag(false); |
---|
| 2109 | #endif |
---|
[2] | 2110 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx+=uiQNumParts ) |
---|
| 2111 | { |
---|
| 2112 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 2113 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
[56] | 2114 | Bool bInSlice = pcCU->getSCUAddr()+uiAbsPartIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurEndCUAddr(); |
---|
| 2115 | if(bInSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 2116 | { |
---|
[2] | 2117 | xEncodeCU( pcCU, uiAbsPartIdx, uiDepth+1 ); |
---|
[56] | 2118 | } |
---|
[2] | 2119 | } |
---|
| 2120 | return; |
---|
| 2121 | } |
---|
[56] | 2122 | |
---|
| 2123 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 2124 | { |
---|
| 2125 | setdQPFlag(true); |
---|
| 2126 | } |
---|
| 2127 | #if HHI_MPI |
---|
| 2128 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 ) |
---|
[115] | 2129 | { |
---|
[2] | 2130 | #endif |
---|
[5] | 2131 | if( !pcCU->getSlice()->isIntra() ) |
---|
[2] | 2132 | { |
---|
| 2133 | m_pcEntropyCoder->encodeSkipFlag( pcCU, uiAbsPartIdx ); |
---|
| 2134 | } |
---|
[115] | 2135 | #if HHI_MPI |
---|
| 2136 | } |
---|
| 2137 | #endif |
---|
[56] | 2138 | |
---|
[2] | 2139 | if( pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
| 2140 | { |
---|
[116] | 2141 | #if OL_DEPTHLIMIT_A0044 |
---|
| 2142 | if(pcCU->getPartDumpFlag()) |
---|
| 2143 | { |
---|
| 2144 | pcCU->updatePartInfo(0,uiDepth); |
---|
| 2145 | pcCU->incrementPartInfo(); |
---|
| 2146 | } |
---|
[115] | 2147 | #endif |
---|
[2] | 2148 | m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 ); |
---|
[152] | 2149 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 2150 | m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx ); |
---|
[152] | 2151 | #endif |
---|
[5] | 2152 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 2153 | m_pcEntropyCoder->encodeResPredFlag( pcCU, uiAbsPartIdx, 0 ); |
---|
[5] | 2154 | #endif |
---|
[56] | 2155 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
[2] | 2156 | return; |
---|
| 2157 | } |
---|
[5] | 2158 | #if HHI_MPI |
---|
[2] | 2159 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 ) |
---|
| 2160 | { |
---|
[5] | 2161 | #endif |
---|
[56] | 2162 | m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx ); |
---|
| 2163 | |
---|
| 2164 | m_pcEntropyCoder->encodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 2165 | |
---|
| 2166 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
| 2167 | { |
---|
| 2168 | m_pcEntropyCoder->encodeIPCMInfo( pcCU, uiAbsPartIdx ); |
---|
[2] | 2169 | |
---|
[56] | 2170 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
| 2171 | { |
---|
| 2172 | // Encode slice finish |
---|
| 2173 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
| 2174 | return; |
---|
| 2175 | } |
---|
| 2176 | } |
---|
[2] | 2177 | |
---|
[56] | 2178 | // prediction Info ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
| 2179 | m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx ); |
---|
[152] | 2180 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 2181 | m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx ); |
---|
[152] | 2182 | #endif |
---|
[5] | 2183 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 2184 | if( !pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 2185 | { |
---|
| 2186 | m_pcEntropyCoder->encodeResPredFlag( pcCU, uiAbsPartIdx, 0 ); |
---|
| 2187 | } |
---|
[5] | 2188 | #endif |
---|
| 2189 | #if HHI_MPI |
---|
[2] | 2190 | } |
---|
[5] | 2191 | #endif |
---|
[56] | 2192 | |
---|
[2] | 2193 | // Encode Coefficients |
---|
[56] | 2194 | Bool bCodeDQP = getdQPFlag(); |
---|
| 2195 | m_pcEntropyCoder->encodeCoeff( pcCU, uiAbsPartIdx, uiDepth, pcCU->getWidth (uiAbsPartIdx), pcCU->getHeight(uiAbsPartIdx), bCodeDQP ); |
---|
| 2196 | setdQPFlag( bCodeDQP ); |
---|
[2] | 2197 | |
---|
[56] | 2198 | // --- write terminating bit --- |
---|
| 2199 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
[2] | 2200 | } |
---|
| 2201 | |
---|
| 2202 | /** check RD costs for a CU block encoded with merge |
---|
| 2203 | * \param rpcBestCU |
---|
| 2204 | * \param rpcTempCU |
---|
| 2205 | * \returns Void |
---|
| 2206 | */ |
---|
[5] | 2207 | #if HHI_INTERVIEW_SKIP |
---|
[2] | 2208 | Void TEncCu::xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bSkipRes ) |
---|
| 2209 | #else |
---|
| 2210 | Void TEncCu::xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ) |
---|
| 2211 | #endif |
---|
| 2212 | { |
---|
| 2213 | assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE ); |
---|
[56] | 2214 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 2215 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
| 2216 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 2217 | #else |
---|
[2] | 2218 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 2219 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
[56] | 2220 | #endif |
---|
| 2221 | Int numValidMergeCand = 0; |
---|
[2] | 2222 | |
---|
[5] | 2223 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 2224 | Bool bResPrdAvail = rpcTempCU->getResPredAvail( 0 ); |
---|
| 2225 | Bool bResPrdFlag = rpcTempCU->getResPredFlag ( 0 ); |
---|
[5] | 2226 | #endif |
---|
[152] | 2227 | #if LGE_ILLUCOMP_B0045 |
---|
| 2228 | Bool bICFlag = rpcTempCU->getICFlag(0); |
---|
| 2229 | #endif |
---|
[2] | 2230 | |
---|
[56] | 2231 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 2232 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui ) |
---|
| 2233 | #else |
---|
[2] | 2234 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
[56] | 2235 | #endif |
---|
[2] | 2236 | { |
---|
| 2237 | uhInterDirNeighbours[ui] = 0; |
---|
| 2238 | } |
---|
| 2239 | UChar uhDepth = rpcTempCU->getDepth( 0 ); |
---|
| 2240 | |
---|
[5] | 2241 | #if HHI_VSO |
---|
[2] | 2242 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 2243 | { |
---|
[81] | 2244 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( ); |
---|
| 2245 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( ); |
---|
| 2246 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( ); |
---|
| 2247 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride(); |
---|
| 2248 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[2] | 2249 | } |
---|
[5] | 2250 | #endif |
---|
[2] | 2251 | |
---|
| 2252 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level |
---|
[56] | 2253 | rpcTempCU->getInterMergeCandidates( 0, 0, uhDepth, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); |
---|
[2] | 2254 | |
---|
[56] | 2255 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
| 2256 | Bool bestIsSkip = false; |
---|
| 2257 | #endif |
---|
| 2258 | |
---|
| 2259 | for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand ) |
---|
[2] | 2260 | { |
---|
| 2261 | { |
---|
| 2262 | TComYuv* pcPredYuvTemp = NULL; |
---|
[56] | 2263 | #if LOSSLESS_CODING |
---|
| 2264 | UInt iteration; |
---|
| 2265 | if ( rpcTempCU->isLosslessCoded(0)) |
---|
| 2266 | { |
---|
| 2267 | iteration = 1; |
---|
| 2268 | } |
---|
| 2269 | else |
---|
| 2270 | { |
---|
| 2271 | iteration = 2; |
---|
| 2272 | } |
---|
| 2273 | |
---|
[5] | 2274 | #if HHI_INTERVIEW_SKIP |
---|
[56] | 2275 | for( UInt uiNoResidual = (bSkipRes ? 1:0); uiNoResidual < iteration; ++uiNoResidual ) |
---|
[2] | 2276 | #else |
---|
[56] | 2277 | for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual ) |
---|
| 2278 | #endif |
---|
| 2279 | #else |
---|
| 2280 | #if HHI_INTERVIEW_SKIP |
---|
| 2281 | for( UInt uiNoResidual = (bSkipRes ? 1:0); uiNoResidual < 2; ++uiNoResidual ) |
---|
| 2282 | #else |
---|
[2] | 2283 | for( UInt uiNoResidual = 0; uiNoResidual < 2; ++uiNoResidual ) |
---|
| 2284 | #endif |
---|
[56] | 2285 | #endif |
---|
[2] | 2286 | { |
---|
[56] | 2287 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
| 2288 | if( !(bestIsSkip && uiNoResidual == 0) ) |
---|
| 2289 | { |
---|
[2] | 2290 | #endif |
---|
[56] | 2291 | // set MC parameters |
---|
| 2292 | rpcTempCU->setPredModeSubParts( MODE_SKIP, 0, uhDepth ); // interprets depth relative to LCU level |
---|
| 2293 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level |
---|
| 2294 | rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level |
---|
| 2295 | rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to LCU level |
---|
| 2296 | rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level |
---|
| 2297 | rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level |
---|
| 2298 | rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level |
---|
[2] | 2299 | |
---|
[5] | 2300 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[56] | 2301 | rpcTempCU->setResPredAvailSubParts( bResPrdAvail, 0, 0, uhDepth ); |
---|
| 2302 | rpcTempCU->setResPredFlagSubParts ( bResPrdFlag, 0, 0, uhDepth ); |
---|
[5] | 2303 | #endif |
---|
[152] | 2304 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 2305 | rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uhDepth); |
---|
[152] | 2306 | #endif |
---|
[2] | 2307 | |
---|
[56] | 2308 | // do MC |
---|
[5] | 2309 | #if HHI_INTERVIEW_SKIP |
---|
[2] | 2310 | if ( (uiNoResidual == 0) || bSkipRes ){ |
---|
| 2311 | #else |
---|
| 2312 | if ( uiNoResidual == 0 ){ |
---|
| 2313 | #endif |
---|
[56] | 2314 | m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); |
---|
| 2315 | // save pred adress |
---|
| 2316 | pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth]; |
---|
[2] | 2317 | |
---|
[56] | 2318 | } |
---|
| 2319 | else |
---|
| 2320 | { |
---|
| 2321 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
| 2322 | if( bestIsSkip) |
---|
| 2323 | { |
---|
| 2324 | m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); |
---|
| 2325 | // save pred adress |
---|
| 2326 | pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth]; |
---|
| 2327 | } |
---|
| 2328 | else |
---|
| 2329 | { |
---|
| 2330 | #endif |
---|
| 2331 | if ( pcPredYuvTemp != m_ppcPredYuvTemp[uhDepth]) |
---|
| 2332 | { |
---|
| 2333 | //adress changes take best (old temp) |
---|
| 2334 | pcPredYuvTemp = m_ppcPredYuvBest[uhDepth]; |
---|
| 2335 | } |
---|
| 2336 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
| 2337 | } |
---|
| 2338 | #endif |
---|
| 2339 | } |
---|
[5] | 2340 | #if HHI_VSO |
---|
[56] | 2341 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 2342 | { //Reset |
---|
[81] | 2343 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth (); |
---|
| 2344 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight (); |
---|
| 2345 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr (); |
---|
| 2346 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride (); |
---|
| 2347 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[56] | 2348 | } |
---|
[5] | 2349 | #endif |
---|
[56] | 2350 | // estimate residual and encode everything |
---|
| 2351 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, |
---|
| 2352 | m_ppcOrigYuv [uhDepth], |
---|
| 2353 | pcPredYuvTemp, |
---|
| 2354 | m_ppcResiYuvTemp[uhDepth], |
---|
| 2355 | m_ppcResiYuvBest[uhDepth], |
---|
| 2356 | m_ppcRecoYuvTemp[uhDepth], |
---|
| 2357 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 2358 | m_ppcResPredTmp [uhDepth], |
---|
| 2359 | #endif |
---|
| 2360 | (uiNoResidual? true:false) ); |
---|
| 2361 | Bool bQtRootCbf = rpcTempCU->getQtRootCbf(0) == 1; |
---|
[2] | 2362 | |
---|
[56] | 2363 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 2364 | Int orgQP = rpcTempCU->getQP( 0 ); |
---|
| 2365 | xCheckDQP( rpcTempCU ); |
---|
| 2366 | xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); |
---|
| 2367 | rpcTempCU->initEstData( uhDepth, orgQP ); |
---|
[2] | 2368 | #else |
---|
[56] | 2369 | UInt uiOrgQP = rpcTempCU->getQP( 0 ); |
---|
| 2370 | xCheckDQP( rpcTempCU ); |
---|
| 2371 | xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); |
---|
| 2372 | rpcTempCU->initEstData( uhDepth, uiOrgQP ); |
---|
| 2373 | #endif |
---|
[2] | 2374 | |
---|
[56] | 2375 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
| 2376 | if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip ) |
---|
| 2377 | { |
---|
| 2378 | bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0; |
---|
| 2379 | } |
---|
[2] | 2380 | #endif |
---|
| 2381 | |
---|
[56] | 2382 | if (!bQtRootCbf) |
---|
| 2383 | break; |
---|
| 2384 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
| 2385 | } |
---|
| 2386 | #endif |
---|
[2] | 2387 | } |
---|
| 2388 | } |
---|
| 2389 | } |
---|
| 2390 | } |
---|
| 2391 | |
---|
[56] | 2392 | #if AMP_MRG |
---|
[5] | 2393 | #if HHI_INTERVIEW_SKIP |
---|
[56] | 2394 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bSkipRes, Bool bUseMRG) |
---|
| 2395 | #else |
---|
| 2396 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bUseMRG) |
---|
| 2397 | #endif |
---|
| 2398 | #else |
---|
| 2399 | #if HHI_INTERVIEW_SKIP |
---|
[2] | 2400 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bSkipRes) |
---|
| 2401 | #else |
---|
| 2402 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize ) |
---|
| 2403 | #endif |
---|
[56] | 2404 | #endif |
---|
[2] | 2405 | { |
---|
| 2406 | UChar uhDepth = rpcTempCU->getDepth( 0 ); |
---|
[56] | 2407 | |
---|
[5] | 2408 | #if HHI_VSO |
---|
[2] | 2409 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 2410 | { |
---|
[81] | 2411 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( ); |
---|
| 2412 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( ); |
---|
| 2413 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( ); |
---|
| 2414 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride(); |
---|
| 2415 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[2] | 2416 | } |
---|
[56] | 2417 | #endif |
---|
[2] | 2418 | |
---|
| 2419 | rpcTempCU->setDepthSubParts( uhDepth, 0 ); |
---|
[56] | 2420 | |
---|
[5] | 2421 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 2422 | Bool bResPrdAvail = rpcTempCU->getResPredAvail( 0 ); |
---|
| 2423 | Bool bResPrdFlag = rpcTempCU->getResPredFlag ( 0 ); |
---|
[5] | 2424 | #endif |
---|
[56] | 2425 | |
---|
| 2426 | rpcTempCU->setPartSizeSubParts ( ePartSize, 0, uhDepth ); |
---|
[5] | 2427 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 2428 | rpcTempCU->setResPredAvailSubParts( bResPrdAvail, 0, 0, uhDepth ); |
---|
| 2429 | rpcTempCU->setResPredFlagSubParts ( bResPrdFlag, 0, 0, uhDepth ); |
---|
[5] | 2430 | #endif |
---|
[56] | 2431 | rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); |
---|
| 2432 | |
---|
[5] | 2433 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[77] | 2434 | #if !LG_RESTRICTEDRESPRED_M24766 |
---|
[2] | 2435 | if( rpcTempCU->getResPredFlag( 0 ) ) |
---|
| 2436 | { // subtract residual prediction from original in motion search |
---|
| 2437 | m_ppcOrigYuv[uhDepth]->add( m_ppcResPredTmp [uhDepth], rpcTempCU->getWidth( 0 ), rpcTempCU->getHeight( 0 ), true ); |
---|
| 2438 | } |
---|
[5] | 2439 | #endif |
---|
[77] | 2440 | #endif |
---|
[56] | 2441 | |
---|
| 2442 | #if AMP_MRG |
---|
| 2443 | rpcTempCU->setMergeAMP (true); |
---|
| 2444 | #if HHI_INTERVIEW_SKIP |
---|
[77] | 2445 | #if LG_RESTRICTEDRESPRED_M24766 |
---|
| 2446 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcResPredTmp[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG ); |
---|
| 2447 | #else |
---|
[56] | 2448 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG ); |
---|
[77] | 2449 | #endif |
---|
[56] | 2450 | #else |
---|
| 2451 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG ); |
---|
| 2452 | #endif |
---|
| 2453 | #else |
---|
| 2454 | #if HHI_INTERVIEW_SKIP |
---|
[2] | 2455 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes ); |
---|
[56] | 2456 | #else |
---|
[2] | 2457 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] ); |
---|
| 2458 | #endif |
---|
[56] | 2459 | #endif |
---|
| 2460 | |
---|
[5] | 2461 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[77] | 2462 | #if !LG_RESTRICTEDRESPRED_M24766 |
---|
[2] | 2463 | if( rpcTempCU->getResPredFlag( 0 ) ) |
---|
| 2464 | { // add residual prediction to original again |
---|
| 2465 | m_ppcOrigYuv[uhDepth]->add( m_ppcResPredTmp [uhDepth], rpcTempCU->getWidth( 0 ), rpcTempCU->getHeight( 0 ) ); |
---|
| 2466 | } |
---|
[5] | 2467 | #endif |
---|
[77] | 2468 | #endif |
---|
[2] | 2469 | |
---|
[56] | 2470 | #if AMP_MRG |
---|
| 2471 | if ( !rpcTempCU->getMergeAMP() ) |
---|
[2] | 2472 | { |
---|
| 2473 | return; |
---|
| 2474 | } |
---|
| 2475 | #endif |
---|
[56] | 2476 | |
---|
[5] | 2477 | #if HHI_INTERVIEW_SKIP |
---|
[56] | 2478 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, |
---|
| 2479 | m_ppcOrigYuv[uhDepth], |
---|
| 2480 | m_ppcPredYuvTemp[uhDepth], |
---|
| 2481 | m_ppcResiYuvTemp[uhDepth], |
---|
| 2482 | m_ppcResiYuvBest[uhDepth], |
---|
| 2483 | m_ppcRecoYuvTemp[uhDepth], |
---|
| 2484 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 2485 | m_ppcResPredTmp [uhDepth], |
---|
| 2486 | #endif |
---|
| 2487 | bSkipRes ); |
---|
[2] | 2488 | #else |
---|
[56] | 2489 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, |
---|
| 2490 | m_ppcOrigYuv[uhDepth], |
---|
| 2491 | m_ppcPredYuvTemp[uhDepth], |
---|
| 2492 | m_ppcResiYuvTemp[uhDepth], |
---|
| 2493 | m_ppcResiYuvBest[uhDepth], |
---|
| 2494 | m_ppcRecoYuvTemp[uhDepth], |
---|
| 2495 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 2496 | m_ppcResPredTmp [uhDepth], |
---|
[2] | 2497 | #endif |
---|
[56] | 2498 | false ); |
---|
| 2499 | #endif |
---|
[5] | 2500 | #if HHI_VSO |
---|
[2] | 2501 | if( m_pcRdCost->getUseLambdaScaleVSO() ) |
---|
| 2502 | { |
---|
| 2503 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 2504 | } |
---|
| 2505 | else |
---|
[5] | 2506 | #endif |
---|
[2] | 2507 | { |
---|
[56] | 2508 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
[2] | 2509 | } |
---|
| 2510 | |
---|
[56] | 2511 | xCheckDQP( rpcTempCU ); |
---|
| 2512 | xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); |
---|
[2] | 2513 | } |
---|
| 2514 | |
---|
| 2515 | Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize ) |
---|
| 2516 | { |
---|
| 2517 | UInt uiDepth = rpcTempCU->getDepth( 0 ); |
---|
[56] | 2518 | |
---|
[5] | 2519 | #if HHI_VSO |
---|
[2] | 2520 | if( m_pcRdCost->getUseRenModel() ) |
---|
| 2521 | { |
---|
[81] | 2522 | UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth (); |
---|
| 2523 | UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight (); |
---|
| 2524 | Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr(); |
---|
| 2525 | UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride (); |
---|
| 2526 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[2] | 2527 | } |
---|
[5] | 2528 | #endif |
---|
[2] | 2529 | |
---|
| 2530 | rpcTempCU->setPartSizeSubParts( eSize, 0, uiDepth ); |
---|
| 2531 | rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); |
---|
[56] | 2532 | |
---|
[2] | 2533 | Bool bSeparateLumaChroma = true; // choose estimation mode |
---|
| 2534 | Dist uiPreCalcDistC = 0; |
---|
| 2535 | if( !bSeparateLumaChroma ) |
---|
| 2536 | { |
---|
| 2537 | m_pcPredSearch->preestChromaPredMode( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth] ); |
---|
| 2538 | } |
---|
| 2539 | m_pcPredSearch ->estIntraPredQT ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, bSeparateLumaChroma ); |
---|
| 2540 | |
---|
| 2541 | m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() ); |
---|
[56] | 2542 | |
---|
[2] | 2543 | m_pcPredSearch ->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC ); |
---|
[56] | 2544 | |
---|
[2] | 2545 | m_pcEntropyCoder->resetBits(); |
---|
| 2546 | m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); |
---|
| 2547 | m_pcEntropyCoder->encodePredMode( rpcTempCU, 0, true ); |
---|
| 2548 | m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true ); |
---|
| 2549 | m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0, true ); |
---|
[56] | 2550 | m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true ); |
---|
[2] | 2551 | |
---|
| 2552 | // Encode Coefficients |
---|
[56] | 2553 | Bool bCodeDQP = getdQPFlag(); |
---|
| 2554 | m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP ); |
---|
| 2555 | setdQPFlag( bCodeDQP ); |
---|
| 2556 | |
---|
[2] | 2557 | if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); |
---|
[56] | 2558 | |
---|
[2] | 2559 | rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
[56] | 2560 | if(m_pcEncCfg->getUseSBACRD()) |
---|
| 2561 | { |
---|
| 2562 | rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
| 2563 | } |
---|
[5] | 2564 | #if HHI_VSO |
---|
[2] | 2565 | if( m_pcRdCost->getUseLambdaScaleVSO()) |
---|
| 2566 | { |
---|
| 2567 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 2568 | } |
---|
| 2569 | else |
---|
[5] | 2570 | #endif |
---|
[2] | 2571 | { |
---|
[56] | 2572 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
[2] | 2573 | } |
---|
[56] | 2574 | |
---|
| 2575 | xCheckDQP( rpcTempCU ); |
---|
| 2576 | xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth); |
---|
| 2577 | } |
---|
[2] | 2578 | |
---|
[56] | 2579 | /** Check R-D costs for a CU with PCM mode. |
---|
| 2580 | * \param rpcBestCU pointer to best mode CU data structure |
---|
| 2581 | * \param rpcTempCU pointer to testing mode CU data structure |
---|
| 2582 | * \returns Void |
---|
| 2583 | * |
---|
| 2584 | * \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. |
---|
| 2585 | */ |
---|
| 2586 | Void TEncCu::xCheckIntraPCM( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ) |
---|
| 2587 | { |
---|
| 2588 | UInt uiDepth = rpcTempCU->getDepth( 0 ); |
---|
| 2589 | |
---|
| 2590 | rpcTempCU->setIPCMFlag(0, true); |
---|
| 2591 | rpcTempCU->setIPCMFlagSubParts (true, 0, rpcTempCU->getDepth(0)); |
---|
| 2592 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 2593 | rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); |
---|
| 2594 | |
---|
| 2595 | m_pcPredSearch->IPCMSearch( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth]); |
---|
| 2596 | |
---|
| 2597 | if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); |
---|
| 2598 | |
---|
| 2599 | m_pcEntropyCoder->resetBits(); |
---|
| 2600 | m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); |
---|
| 2601 | m_pcEntropyCoder->encodePredMode ( rpcTempCU, 0, true ); |
---|
| 2602 | m_pcEntropyCoder->encodePartSize ( rpcTempCU, 0, uiDepth, true ); |
---|
| 2603 | m_pcEntropyCoder->encodeIPCMInfo ( rpcTempCU, 0, true ); |
---|
| 2604 | |
---|
| 2605 | if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); |
---|
| 2606 | |
---|
| 2607 | rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
| 2608 | if(m_pcEncCfg->getUseSBACRD()) |
---|
| 2609 | { |
---|
| 2610 | rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
| 2611 | } |
---|
| 2612 | #if HHI_VSO |
---|
| 2613 | if ( m_pcRdCost->getUseVSO() ) |
---|
| 2614 | { |
---|
| 2615 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 2616 | } |
---|
| 2617 | else |
---|
| 2618 | #endif |
---|
| 2619 | { |
---|
| 2620 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 2621 | } |
---|
| 2622 | |
---|
| 2623 | xCheckDQP( rpcTempCU ); |
---|
[2] | 2624 | xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth ); |
---|
| 2625 | } |
---|
| 2626 | |
---|
| 2627 | // check whether current try is the best |
---|
[56] | 2628 | Void TEncCu::xCheckBestMode( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ) |
---|
[2] | 2629 | { |
---|
| 2630 | if( rpcTempCU->getTotalCost() < rpcBestCU->getTotalCost() ) |
---|
| 2631 | { |
---|
| 2632 | TComYuv* pcYuv; |
---|
[56] | 2633 | UChar uhDepth = rpcBestCU->getDepth(0); |
---|
[2] | 2634 | |
---|
| 2635 | // Change Information data |
---|
| 2636 | TComDataCU* pcCU = rpcBestCU; |
---|
| 2637 | rpcBestCU = rpcTempCU; |
---|
| 2638 | rpcTempCU = pcCU; |
---|
[56] | 2639 | |
---|
[2] | 2640 | // Change Prediction data |
---|
| 2641 | pcYuv = m_ppcPredYuvBest[uhDepth]; |
---|
| 2642 | m_ppcPredYuvBest[uhDepth] = m_ppcPredYuvTemp[uhDepth]; |
---|
| 2643 | m_ppcPredYuvTemp[uhDepth] = pcYuv; |
---|
[56] | 2644 | |
---|
[2] | 2645 | // Change Reconstruction data |
---|
| 2646 | pcYuv = m_ppcRecoYuvBest[uhDepth]; |
---|
| 2647 | m_ppcRecoYuvBest[uhDepth] = m_ppcRecoYuvTemp[uhDepth]; |
---|
| 2648 | m_ppcRecoYuvTemp[uhDepth] = pcYuv; |
---|
[56] | 2649 | |
---|
[2] | 2650 | pcYuv = NULL; |
---|
| 2651 | pcCU = NULL; |
---|
[56] | 2652 | |
---|
[2] | 2653 | if( m_bUseSBACRD ) // store temp best CI for next CU coding |
---|
| 2654 | m_pppcRDSbacCoder[uhDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uhDepth][CI_NEXT_BEST]); |
---|
| 2655 | } |
---|
| 2656 | } |
---|
| 2657 | |
---|
[56] | 2658 | /** check whether current try is the best with identifying the depth of current try |
---|
| 2659 | * \param rpcBestCU |
---|
| 2660 | * \param rpcTempCU |
---|
| 2661 | * \returns Void |
---|
| 2662 | */ |
---|
| 2663 | Void TEncCu::xCheckBestMode( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth ) |
---|
[2] | 2664 | { |
---|
[56] | 2665 | if( rpcTempCU->getTotalCost() < rpcBestCU->getTotalCost() ) |
---|
| 2666 | { |
---|
| 2667 | TComYuv* pcYuv; |
---|
| 2668 | // Change Information data |
---|
| 2669 | TComDataCU* pcCU = rpcBestCU; |
---|
| 2670 | rpcBestCU = rpcTempCU; |
---|
| 2671 | rpcTempCU = pcCU; |
---|
[2] | 2672 | |
---|
[56] | 2673 | // Change Prediction data |
---|
| 2674 | pcYuv = m_ppcPredYuvBest[uiDepth]; |
---|
| 2675 | m_ppcPredYuvBest[uiDepth] = m_ppcPredYuvTemp[uiDepth]; |
---|
| 2676 | m_ppcPredYuvTemp[uiDepth] = pcYuv; |
---|
[2] | 2677 | |
---|
[56] | 2678 | // Change Reconstruction data |
---|
| 2679 | pcYuv = m_ppcRecoYuvBest[uiDepth]; |
---|
| 2680 | m_ppcRecoYuvBest[uiDepth] = m_ppcRecoYuvTemp[uiDepth]; |
---|
| 2681 | m_ppcRecoYuvTemp[uiDepth] = pcYuv; |
---|
[2] | 2682 | |
---|
[56] | 2683 | pcYuv = NULL; |
---|
| 2684 | pcCU = NULL; |
---|
[2] | 2685 | |
---|
[56] | 2686 | if( m_bUseSBACRD ) // store temp best CI for next CU coding |
---|
| 2687 | m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); |
---|
| 2688 | } |
---|
| 2689 | } |
---|
| 2690 | |
---|
| 2691 | Void TEncCu::xCheckDQP( TComDataCU* pcCU ) |
---|
| 2692 | { |
---|
| 2693 | UInt uiDepth = pcCU->getDepth( 0 ); |
---|
| 2694 | |
---|
| 2695 | if( pcCU->getSlice()->getPPS()->getUseDQP() && (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
[2] | 2696 | { |
---|
[56] | 2697 | if ( pcCU->getCbf( 0, TEXT_LUMA, 0 ) || pcCU->getCbf( 0, TEXT_CHROMA_U, 0 ) || pcCU->getCbf( 0, TEXT_CHROMA_V, 0 ) ) |
---|
| 2698 | { |
---|
| 2699 | #if !RDO_WITHOUT_DQP_BITS |
---|
| 2700 | m_pcEntropyCoder->resetBits(); |
---|
| 2701 | m_pcEntropyCoder->encodeQP( pcCU, 0, false ); |
---|
| 2702 | pcCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits |
---|
| 2703 | if(m_pcEncCfg->getUseSBACRD()) |
---|
| 2704 | { |
---|
| 2705 | pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
| 2706 | } |
---|
[2] | 2707 | |
---|
[56] | 2708 | // GT: Change here?? |
---|
| 2709 | #if HHI_VSO |
---|
| 2710 | if ( m_pcRdCost->getUseVSO() ) |
---|
| 2711 | { |
---|
| 2712 | pcCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); |
---|
| 2713 | } |
---|
| 2714 | else |
---|
| 2715 | #endif |
---|
| 2716 | { |
---|
| 2717 | pcCU->getTotalCost() = m_pcRdCost->calcRdCost( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); |
---|
| 2718 | } |
---|
| 2719 | #endif |
---|
[2] | 2720 | } |
---|
[56] | 2721 | else |
---|
[2] | 2722 | { |
---|
[56] | 2723 | #if LOSSLESS_CODING |
---|
| 2724 | if (( ( pcCU->getRefQP( 0 ) != pcCU->getQP( 0 )) ) && (pcCU->getSlice()->getSPS()->getUseLossless())) |
---|
| 2725 | { |
---|
| 2726 | pcCU->getTotalCost() = MAX_DOUBLE; |
---|
| 2727 | } |
---|
| 2728 | #endif |
---|
| 2729 | pcCU->setQPSubParts( pcCU->getRefQP( 0 ), 0, uiDepth ); // set QP to default QP |
---|
[2] | 2730 | } |
---|
[56] | 2731 | } |
---|
| 2732 | } |
---|
| 2733 | |
---|
| 2734 | #if BURST_IPCM |
---|
| 2735 | /** Check whether the last CU shares the same root as the current CU and is IPCM or not. |
---|
| 2736 | * \param pcCU |
---|
| 2737 | * \param uiCurAbsPartIdx |
---|
| 2738 | * \returns Bool |
---|
| 2739 | */ |
---|
| 2740 | Bool TEncCu::checkLastCUSucIPCM( TComDataCU* pcCU, UInt uiCurAbsPartIdx ) |
---|
| 2741 | { |
---|
| 2742 | Bool lastCUSucIPCMFlag = false; |
---|
| 2743 | |
---|
| 2744 | UInt curDepth = pcCU->getDepth(uiCurAbsPartIdx); |
---|
| 2745 | UInt shift = ((pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx())->getSPS()->getMaxCUDepth() - curDepth)<<1); |
---|
| 2746 | UInt startPartUnitIdx = ((uiCurAbsPartIdx&(0x03<<shift))>>shift); |
---|
| 2747 | |
---|
| 2748 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 2749 | if( pcSlice->getEntropySliceCurStartCUAddr() == ( pcCU->getSCUAddr() + uiCurAbsPartIdx ) ) |
---|
| 2750 | { |
---|
| 2751 | return false; |
---|
| 2752 | } |
---|
| 2753 | |
---|
| 2754 | if(curDepth > 0 && startPartUnitIdx > 0) |
---|
| 2755 | { |
---|
| 2756 | Int lastValidPartIdx = pcCU->getLastValidPartIdx((Int) uiCurAbsPartIdx ); |
---|
| 2757 | |
---|
| 2758 | if( lastValidPartIdx >= 0 ) |
---|
[2] | 2759 | { |
---|
[56] | 2760 | if(( pcCU->getSliceStartCU( uiCurAbsPartIdx ) == pcCU->getSliceStartCU( (UInt) lastValidPartIdx )) |
---|
| 2761 | && |
---|
| 2762 | ( pcCU->getDepth( uiCurAbsPartIdx ) == pcCU->getDepth( (UInt) lastValidPartIdx )) |
---|
| 2763 | && |
---|
| 2764 | pcCU->getIPCMFlag( (UInt) lastValidPartIdx ) ) |
---|
| 2765 | { |
---|
| 2766 | lastCUSucIPCMFlag = true; |
---|
| 2767 | } |
---|
[2] | 2768 | } |
---|
| 2769 | } |
---|
| 2770 | |
---|
[56] | 2771 | return lastCUSucIPCMFlag; |
---|
| 2772 | } |
---|
[2] | 2773 | |
---|
[56] | 2774 | /** Count the number of successive IPCM CUs sharing the same root. |
---|
| 2775 | * \param pcCU |
---|
| 2776 | * \param uiCurAbsPartIdx |
---|
| 2777 | * \returns Int |
---|
| 2778 | */ |
---|
| 2779 | Int TEncCu::countNumSucIPCM ( TComDataCU* pcCU, UInt uiCurAbsPartIdx ) |
---|
| 2780 | { |
---|
| 2781 | Int numSucIPCM = 0; |
---|
| 2782 | UInt CurDepth = pcCU->getDepth(uiCurAbsPartIdx); |
---|
| 2783 | |
---|
| 2784 | if( pcCU->getIPCMFlag(uiCurAbsPartIdx) ) |
---|
[2] | 2785 | { |
---|
[56] | 2786 | if(CurDepth == 0) |
---|
[2] | 2787 | { |
---|
[56] | 2788 | numSucIPCM = 1; |
---|
| 2789 | } |
---|
| 2790 | else |
---|
| 2791 | { |
---|
| 2792 | TComPic* pcPic = pcCU->getPic(); |
---|
| 2793 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 2794 | UInt qNumParts = ( pcPic->getNumPartInCU() >> ((CurDepth-1)<<1) )>>2; |
---|
[2] | 2795 | |
---|
[56] | 2796 | Bool continueFlag = true; |
---|
| 2797 | UInt absPartIdx = uiCurAbsPartIdx; |
---|
| 2798 | UInt shift = ((pcSlice->getSPS()->getMaxCUDepth() - CurDepth)<<1); |
---|
| 2799 | UInt startPartUnitIdx = ((uiCurAbsPartIdx&(0x03<<shift))>>shift); |
---|
[2] | 2800 | |
---|
[56] | 2801 | for ( UInt partUnitIdx = startPartUnitIdx; partUnitIdx < 4 && continueFlag; partUnitIdx++, absPartIdx+=qNumParts ) |
---|
| 2802 | { |
---|
| 2803 | UInt lPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[absPartIdx] ]; |
---|
| 2804 | UInt tPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[absPartIdx] ]; |
---|
| 2805 | Bool inSliceFlag = ( pcCU->getSCUAddr()+absPartIdx+qNumParts>pcSlice->getEntropySliceCurStartCUAddr() ) && ( pcCU->getSCUAddr()+absPartIdx < pcSlice->getEntropySliceCurEndCUAddr()); |
---|
[2] | 2806 | |
---|
[56] | 2807 | if( inSliceFlag && ( lPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( tPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 2808 | { |
---|
| 2809 | UInt uiDepth = pcCU->getDepth(absPartIdx); |
---|
[2] | 2810 | |
---|
[56] | 2811 | if( ( CurDepth == uiDepth) && pcCU->getIPCMFlag( absPartIdx ) ) |
---|
| 2812 | { |
---|
| 2813 | numSucIPCM++; |
---|
| 2814 | } |
---|
| 2815 | else |
---|
| 2816 | { |
---|
| 2817 | continueFlag = false; |
---|
| 2818 | } |
---|
| 2819 | } |
---|
| 2820 | } |
---|
[2] | 2821 | } |
---|
| 2822 | } |
---|
[56] | 2823 | |
---|
| 2824 | return numSucIPCM; |
---|
[2] | 2825 | } |
---|
[56] | 2826 | #endif |
---|
[2] | 2827 | |
---|
| 2828 | Void TEncCu::xCopyAMVPInfo (AMVPInfo* pSrc, AMVPInfo* pDst) |
---|
| 2829 | { |
---|
| 2830 | pDst->iN = pSrc->iN; |
---|
| 2831 | for (Int i = 0; i < pSrc->iN; i++) |
---|
| 2832 | { |
---|
| 2833 | pDst->m_acMvCand[i] = pSrc->m_acMvCand[i]; |
---|
| 2834 | } |
---|
| 2835 | } |
---|
[56] | 2836 | Void TEncCu::xCopyYuv2Pic(TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth, TComDataCU* pcCU, UInt uiLPelX, UInt uiTPelY ) |
---|
| 2837 | { |
---|
| 2838 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 2839 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
| 2840 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 2841 | Bool bSliceStart = pcSlice->getEntropySliceCurStartCUAddr() > rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && |
---|
| 2842 | pcSlice->getEntropySliceCurStartCUAddr() < rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) ); |
---|
| 2843 | Bool bSliceEnd = pcSlice->getEntropySliceCurEndCUAddr() > rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && |
---|
| 2844 | pcSlice->getEntropySliceCurEndCUAddr() < rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) ); |
---|
| 2845 | if(!bSliceEnd && !bSliceStart && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 2846 | { |
---|
| 2847 | UInt uiAbsPartIdxInRaster = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
| 2848 | UInt uiSrcBlkWidth = rpcPic->getNumPartInWidth() >> (uiSrcDepth); |
---|
| 2849 | UInt uiBlkWidth = rpcPic->getNumPartInWidth() >> (uiDepth); |
---|
| 2850 | UInt uiPartIdxX = ( ( uiAbsPartIdxInRaster % rpcPic->getNumPartInWidth() ) % uiSrcBlkWidth) / uiBlkWidth; |
---|
| 2851 | UInt uiPartIdxY = ( ( uiAbsPartIdxInRaster / rpcPic->getNumPartInWidth() ) % uiSrcBlkWidth) / uiBlkWidth; |
---|
| 2852 | UInt uiPartIdx = uiPartIdxY * ( uiSrcBlkWidth / uiBlkWidth ) + uiPartIdxX; |
---|
| 2853 | m_ppcRecoYuvBest[uiSrcDepth]->copyToPicYuv( rpcPic->getPicYuvRec (), uiCUAddr, uiAbsPartIdx, uiDepth - uiSrcDepth, uiPartIdx); |
---|
| 2854 | } |
---|
| 2855 | else |
---|
| 2856 | { |
---|
| 2857 | UInt uiQNumParts = ( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) )>>2; |
---|
[2] | 2858 | |
---|
[56] | 2859 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx+=uiQNumParts ) |
---|
| 2860 | { |
---|
| 2861 | UInt uiSubCULPelX = uiLPelX + ( g_uiMaxCUWidth >>(uiDepth+1) )*( uiPartUnitIdx & 1 ); |
---|
| 2862 | UInt uiSubCUTPelY = uiTPelY + ( g_uiMaxCUHeight>>(uiDepth+1) )*( uiPartUnitIdx >> 1 ); |
---|
| 2863 | |
---|
| 2864 | Bool bInSlice = rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+uiQNumParts > pcSlice->getEntropySliceCurStartCUAddr() && |
---|
| 2865 | rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx < pcSlice->getEntropySliceCurEndCUAddr(); |
---|
| 2866 | if(bInSlice&&( uiSubCULPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiSubCUTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 2867 | { |
---|
| 2868 | xCopyYuv2Pic( rpcPic, uiCUAddr, uiAbsPartIdx, uiDepth+1, uiSrcDepth, pcCU, uiSubCULPelX, uiSubCUTPelY ); // Copy Yuv data to picture Yuv |
---|
| 2869 | } |
---|
| 2870 | } |
---|
| 2871 | } |
---|
[2] | 2872 | } |
---|
| 2873 | |
---|
| 2874 | Void TEncCu::xCopyYuv2Tmp( UInt uiPartUnitIdx, UInt uiNextDepth ) |
---|
| 2875 | { |
---|
| 2876 | UInt uiCurrDepth = uiNextDepth - 1; |
---|
| 2877 | m_ppcRecoYuvBest[uiNextDepth]->copyToPartYuv( m_ppcRecoYuvTemp[uiCurrDepth], uiPartUnitIdx ); |
---|
| 2878 | } |
---|
| 2879 | |
---|
[56] | 2880 | #if LOSSLESS_CODING |
---|
| 2881 | /** Function for filling the PCM buffer of a CU using its original sample array |
---|
| 2882 | * \param pcCU pointer to current CU |
---|
| 2883 | * \param pcOrgYuv pointer to original sample array |
---|
| 2884 | * \returns Void |
---|
| 2885 | */ |
---|
| 2886 | Void TEncCu::xFillPCMBuffer ( TComDataCU*& pCU, TComYuv* pOrgYuv ) |
---|
| 2887 | { |
---|
| 2888 | |
---|
| 2889 | UInt width = pCU->getWidth(0); |
---|
| 2890 | UInt height = pCU->getHeight(0); |
---|
| 2891 | |
---|
| 2892 | Pel* pSrcY = pOrgYuv->getLumaAddr(0, width); |
---|
| 2893 | Pel* pDstY = pCU->getPCMSampleY(); |
---|
| 2894 | UInt srcStride = pOrgYuv->getStride(); |
---|
| 2895 | |
---|
| 2896 | for(Int y = 0; y < height; y++ ) |
---|
| 2897 | { |
---|
| 2898 | for(Int x = 0; x < width; x++ ) |
---|
| 2899 | { |
---|
| 2900 | pDstY[x] = pSrcY[x]; |
---|
| 2901 | } |
---|
| 2902 | pDstY += width; |
---|
| 2903 | pSrcY += srcStride; |
---|
| 2904 | } |
---|
| 2905 | |
---|
| 2906 | Pel* pSrcCb = pOrgYuv->getCbAddr(); |
---|
| 2907 | Pel* pSrcCr = pOrgYuv->getCrAddr();; |
---|
| 2908 | |
---|
| 2909 | Pel* pDstCb = pCU->getPCMSampleCb(); |
---|
| 2910 | Pel* pDstCr = pCU->getPCMSampleCr();; |
---|
| 2911 | |
---|
| 2912 | UInt srcStrideC = pOrgYuv->getCStride(); |
---|
| 2913 | UInt heightC = height >> 1; |
---|
| 2914 | UInt widthC = width >> 1; |
---|
| 2915 | |
---|
| 2916 | for(Int y = 0; y < heightC; y++ ) |
---|
| 2917 | { |
---|
| 2918 | for(Int x = 0; x < widthC; x++ ) |
---|
| 2919 | { |
---|
| 2920 | pDstCb[x] = pSrcCb[x]; |
---|
| 2921 | pDstCr[x] = pSrcCr[x]; |
---|
| 2922 | } |
---|
| 2923 | pDstCb += widthC; |
---|
| 2924 | pDstCr += widthC; |
---|
| 2925 | pSrcCb += srcStrideC; |
---|
| 2926 | pSrcCr += srcStrideC; |
---|
| 2927 | } |
---|
| 2928 | } |
---|
| 2929 | #endif |
---|
| 2930 | |
---|
| 2931 | #if ADAPTIVE_QP_SELECTION |
---|
| 2932 | /** Collect ARL statistics from one block |
---|
| 2933 | */ |
---|
| 2934 | Int TEncCu::xTuCollectARLStats(TCoeff* rpcCoeff, Int* rpcArlCoeff, Int NumCoeffInCU, Double* cSum, UInt* numSamples ) |
---|
| 2935 | { |
---|
| 2936 | for( Int n = 0; n < NumCoeffInCU; n++ ) |
---|
| 2937 | { |
---|
| 2938 | Int u = abs( rpcCoeff[ n ] ); |
---|
| 2939 | Int absc = rpcArlCoeff[ n ]; |
---|
| 2940 | |
---|
| 2941 | if( u != 0 ) |
---|
| 2942 | { |
---|
| 2943 | if( u < LEVEL_RANGE ) |
---|
| 2944 | { |
---|
| 2945 | cSum[ u ] += ( Double )absc; |
---|
| 2946 | numSamples[ u ]++; |
---|
| 2947 | } |
---|
| 2948 | else |
---|
| 2949 | { |
---|
| 2950 | cSum[ LEVEL_RANGE ] += ( Double )absc - ( Double )( u << ARL_C_PRECISION ); |
---|
| 2951 | numSamples[ LEVEL_RANGE ]++; |
---|
| 2952 | } |
---|
| 2953 | } |
---|
| 2954 | } |
---|
| 2955 | |
---|
| 2956 | return 0; |
---|
| 2957 | } |
---|
| 2958 | |
---|
| 2959 | /** Collect ARL statistics from one LCU |
---|
| 2960 | * \param pcCU |
---|
| 2961 | */ |
---|
| 2962 | Void TEncCu::xLcuCollectARLStats(TComDataCU* rpcCU ) |
---|
| 2963 | { |
---|
| 2964 | Double cSum[ LEVEL_RANGE + 1 ]; //: the sum of DCT coefficients corresponding to datatype and quantization output |
---|
| 2965 | UInt numSamples[ LEVEL_RANGE + 1 ]; //: the number of coefficients corresponding to datatype and quantization output |
---|
| 2966 | |
---|
| 2967 | TCoeff* pCoeffY = rpcCU->getCoeffY(); |
---|
| 2968 | Int* pArlCoeffY = rpcCU->getArlCoeffY(); |
---|
| 2969 | |
---|
| 2970 | UInt uiMinCUWidth = g_uiMaxCUWidth >> g_uiMaxCUDepth; |
---|
| 2971 | UInt uiMinNumCoeffInCU = 1 << uiMinCUWidth; |
---|
| 2972 | |
---|
| 2973 | memset( cSum, 0, sizeof( Double )*(LEVEL_RANGE+1) ); |
---|
| 2974 | memset( numSamples, 0, sizeof( UInt )*(LEVEL_RANGE+1) ); |
---|
| 2975 | |
---|
| 2976 | // Collect stats to cSum[][] and numSamples[][] |
---|
| 2977 | for(Int i = 0; i < rpcCU->getTotalNumPart(); i ++ ) |
---|
| 2978 | { |
---|
| 2979 | UInt uiTrIdx = rpcCU->getTransformIdx(i); |
---|
| 2980 | |
---|
| 2981 | if(rpcCU->getPredictionMode(i) == MODE_INTER) |
---|
| 2982 | if( rpcCU->getCbf( i, TEXT_LUMA, uiTrIdx ) ) |
---|
| 2983 | { |
---|
| 2984 | xTuCollectARLStats(pCoeffY, pArlCoeffY, uiMinNumCoeffInCU, cSum, numSamples); |
---|
| 2985 | }//Note that only InterY is processed. QP rounding is based on InterY data only. |
---|
| 2986 | |
---|
| 2987 | pCoeffY += uiMinNumCoeffInCU; |
---|
| 2988 | pArlCoeffY += uiMinNumCoeffInCU; |
---|
| 2989 | } |
---|
| 2990 | |
---|
| 2991 | for(Int u=1; u<LEVEL_RANGE;u++) |
---|
| 2992 | { |
---|
| 2993 | m_pcTrQuant->getSliceSumC()[u] += cSum[ u ] ; |
---|
| 2994 | m_pcTrQuant->getSliceNSamples()[u] += numSamples[ u ] ; |
---|
| 2995 | } |
---|
| 2996 | m_pcTrQuant->getSliceSumC()[LEVEL_RANGE] += cSum[ LEVEL_RANGE ] ; |
---|
| 2997 | m_pcTrQuant->getSliceNSamples()[LEVEL_RANGE] += numSamples[ LEVEL_RANGE ] ; |
---|
| 2998 | } |
---|
| 2999 | #endif |
---|
| 3000 | |
---|
[5] | 3001 | #if HHI_MPI |
---|
[2] | 3002 | Void TEncCu::xCheckRDCostMvInheritance( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UChar uhTextureModeDepth, Bool bSkipResidual, Bool bRecursiveCall ) |
---|
| 3003 | { |
---|
[56] | 3004 | assert( rpcTempCU->getSlice()->getIsDepth() ); |
---|
[2] | 3005 | TComDataCU *pcTextureCU = rpcTempCU->getSlice()->getTexturePic()->getCU( rpcTempCU->getAddr() ); |
---|
| 3006 | |
---|
| 3007 | const UChar uhDepth = rpcTempCU->getDepth( 0 ); |
---|
[56] | 3008 | const Int iQP = rpcTempCU->getQP( 0 ); |
---|
[2] | 3009 | assert( bRecursiveCall == ( uhDepth != uhTextureModeDepth ) ); |
---|
| 3010 | |
---|
| 3011 | if( uhDepth == uhTextureModeDepth ) |
---|
| 3012 | { |
---|
| 3013 | for( UInt ui = 0; ui < rpcTempCU->getTotalNumPart(); ui++ ) |
---|
| 3014 | { |
---|
| 3015 | if( pcTextureCU->isIntra( rpcTempCU->getZorderIdxInCU() + ui ) ) |
---|
| 3016 | { |
---|
| 3017 | return; |
---|
| 3018 | } |
---|
| 3019 | } |
---|
| 3020 | } |
---|
| 3021 | |
---|
[5] | 3022 | #if HHI_VSO |
---|
[2] | 3023 | if( m_pcRdCost->getUseRenModel() && !bRecursiveCall) |
---|
| 3024 | { |
---|
[81] | 3025 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth (); |
---|
| 3026 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight (); |
---|
| 3027 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr(); |
---|
| 3028 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride (); |
---|
| 3029 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[2] | 3030 | } |
---|
[5] | 3031 | #endif |
---|
[2] | 3032 | |
---|
| 3033 | Bool bSplit = uhDepth < pcTextureCU->getDepth( rpcTempCU->getZorderIdxInCU() ); |
---|
| 3034 | if( bSplit ) |
---|
| 3035 | { |
---|
| 3036 | const UChar uhNextDepth = uhDepth+1; |
---|
| 3037 | TComDataCU* pcSubBestPartCU = m_ppcBestCU[uhNextDepth]; |
---|
| 3038 | TComDataCU* pcSubTempPartCU = m_ppcTempCU[uhNextDepth]; |
---|
| 3039 | |
---|
| 3040 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
| 3041 | { |
---|
[56] | 3042 | pcSubBestPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. |
---|
| 3043 | pcSubTempPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. |
---|
[2] | 3044 | |
---|
[56] | 3045 | TComSlice * pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx()); |
---|
| 3046 | Bool bInSlice = pcSubBestPartCU->getSCUAddr()+pcSubBestPartCU->getTotalNumPart()>pcSlice->getEntropySliceCurStartCUAddr()&&pcSubBestPartCU->getSCUAddr()<pcSlice->getEntropySliceCurEndCUAddr(); |
---|
| 3047 | if(bInSlice && ( pcSubBestPartCU->getCUPelX() < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( pcSubBestPartCU->getCUPelY() < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[2] | 3048 | { |
---|
| 3049 | if( m_bUseSBACRD ) |
---|
| 3050 | { |
---|
| 3051 | if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer |
---|
| 3052 | { |
---|
| 3053 | m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhDepth][CI_CURR_BEST]); |
---|
| 3054 | } |
---|
| 3055 | else |
---|
| 3056 | { |
---|
| 3057 | m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); |
---|
| 3058 | } |
---|
| 3059 | } |
---|
| 3060 | |
---|
| 3061 | xCheckRDCostMvInheritance( pcSubBestPartCU, pcSubTempPartCU, uhTextureModeDepth, bSkipResidual, true ); |
---|
| 3062 | |
---|
| 3063 | rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth ); // Keep best part data to current temporary data. |
---|
| 3064 | xCopyYuv2Tmp( pcSubBestPartCU->getTotalNumPart()*uiPartUnitIdx, uhNextDepth ); |
---|
| 3065 | } |
---|
[56] | 3066 | else if (bInSlice) |
---|
| 3067 | { |
---|
| 3068 | pcSubBestPartCU->copyToPic( uhNextDepth ); |
---|
| 3069 | rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth ); |
---|
| 3070 | } |
---|
[2] | 3071 | } |
---|
| 3072 | |
---|
| 3073 | if( uhDepth == uhTextureModeDepth ) |
---|
| 3074 | { |
---|
| 3075 | xAddMVISignallingBits( rpcTempCU ); |
---|
| 3076 | } |
---|
| 3077 | |
---|
[61] | 3078 | // DQP stuff |
---|
[56] | 3079 | { |
---|
| 3080 | if( (g_uiMaxCUWidth>>uhDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() && rpcTempCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 3081 | { |
---|
| 3082 | TComPic *pcPic = rpcTempCU->getPic(); |
---|
| 3083 | TComSlice *pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx()); |
---|
| 3084 | Bool bHasRedisual = false; |
---|
| 3085 | for( UInt uiBlkIdx = 0; uiBlkIdx < rpcTempCU->getTotalNumPart(); uiBlkIdx ++) |
---|
| 3086 | { |
---|
| 3087 | if( ( pcPic->getCU( rpcTempCU->getAddr() )->getEntropySliceStartCU(uiBlkIdx+rpcTempCU->getZorderIdxInCU()) == rpcTempCU->getSlice()->getEntropySliceCurStartCUAddr() ) && |
---|
| 3088 | ( rpcTempCU->getCbf( uiBlkIdx, TEXT_LUMA ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_U ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_V ) ) ) |
---|
| 3089 | { |
---|
| 3090 | bHasRedisual = true; |
---|
| 3091 | break; |
---|
| 3092 | } |
---|
| 3093 | } |
---|
| 3094 | |
---|
| 3095 | UInt uiTargetPartIdx; |
---|
| 3096 | if ( pcPic->getCU( rpcTempCU->getAddr() )->getEntropySliceStartCU(rpcTempCU->getZorderIdxInCU()) != pcSlice->getEntropySliceCurStartCUAddr() ) |
---|
| 3097 | { |
---|
| 3098 | uiTargetPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU() - rpcTempCU->getZorderIdxInCU(); |
---|
| 3099 | } |
---|
| 3100 | else |
---|
| 3101 | { |
---|
| 3102 | uiTargetPartIdx = 0; |
---|
| 3103 | } |
---|
| 3104 | if ( ! bHasRedisual ) |
---|
| 3105 | { |
---|
| 3106 | #if LOSSLESS_CODING |
---|
| 3107 | if (((rpcTempCU->getQP(uiTargetPartIdx) != rpcTempCU->getRefQP(uiTargetPartIdx)) ) && (rpcTempCU->getSlice()->getSPS()->getUseLossless())) |
---|
| 3108 | { |
---|
| 3109 | rpcTempCU->getTotalCost() = MAX_DOUBLE; |
---|
| 3110 | } |
---|
| 3111 | #endif |
---|
| 3112 | rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( uiTargetPartIdx ), 0, uhDepth ); // set QP to default QP |
---|
| 3113 | } |
---|
| 3114 | } |
---|
| 3115 | } |
---|
| 3116 | |
---|
[2] | 3117 | if( m_bUseSBACRD ) |
---|
| 3118 | { |
---|
| 3119 | m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uhDepth][CI_TEMP_BEST]); |
---|
| 3120 | } |
---|
| 3121 | } |
---|
| 3122 | else |
---|
| 3123 | { |
---|
| 3124 | rpcTempCU->setTextureModeDepthSubParts( uhTextureModeDepth, 0, uhDepth ); |
---|
| 3125 | rpcTempCU->copyTextureMotionDataFrom( pcTextureCU, uhDepth, rpcTempCU->getZorderIdxInCU() ); |
---|
| 3126 | rpcTempCU->setPartSizeSubParts( SIZE_NxN, 0, uhDepth ); |
---|
| 3127 | for( UInt ui = 0; ui < rpcTempCU->getTotalNumPart(); ui++ ) |
---|
| 3128 | { |
---|
| 3129 | assert( rpcTempCU->getInterDir( ui ) != 0 ); |
---|
| 3130 | assert( rpcTempCU->getPredictionMode( ui ) != MODE_NONE ); |
---|
| 3131 | } |
---|
| 3132 | rpcTempCU->setPredModeSubParts( bSkipResidual ? MODE_SKIP : MODE_INTER, 0, uhDepth ); |
---|
| 3133 | m_pcPredSearch->motionCompensation( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); |
---|
| 3134 | |
---|
| 3135 | // get Original YUV data from picture |
---|
| 3136 | m_ppcOrigYuv[uhDepth]->copyFromPicYuv( rpcBestCU->getPic()->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); |
---|
[56] | 3137 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, |
---|
| 3138 | m_ppcOrigYuv[uhDepth], |
---|
| 3139 | m_ppcPredYuvTemp[uhDepth], |
---|
| 3140 | m_ppcResiYuvTemp[uhDepth], |
---|
| 3141 | m_ppcResiYuvBest[uhDepth], |
---|
| 3142 | m_ppcRecoYuvTemp[uhDepth], |
---|
| 3143 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 3144 | m_ppcResPredTmp [uhDepth], |
---|
| 3145 | #endif |
---|
| 3146 | bSkipResidual ); |
---|
[2] | 3147 | |
---|
| 3148 | if( uhDepth == uhTextureModeDepth ) |
---|
| 3149 | { |
---|
| 3150 | xAddMVISignallingBits( rpcTempCU ); |
---|
| 3151 | } |
---|
[56] | 3152 | xCheckDQP( rpcTempCU ); |
---|
[2] | 3153 | } |
---|
[5] | 3154 | |
---|
| 3155 | #if HHI_VSO |
---|
[2] | 3156 | if( m_pcRdCost->getUseLambdaScaleVSO() ) |
---|
| 3157 | { |
---|
| 3158 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 3159 | } |
---|
| 3160 | else |
---|
[5] | 3161 | #endif |
---|
[2] | 3162 | { |
---|
| 3163 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
| 3164 | } |
---|
| 3165 | |
---|
[56] | 3166 | if( rpcTempCU->getPredictionMode( 0 ) == MODE_SKIP && uhDepth == uhTextureModeDepth ) |
---|
| 3167 | { |
---|
| 3168 | if( rpcTempCU->getSlice()->getPPS()->getUseDQP() && (g_uiMaxCUWidth>>uhDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
| 3169 | rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( 0 ), 0, uhDepth ); // set QP to default QP |
---|
| 3170 | } |
---|
[2] | 3171 | xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth ); |
---|
[56] | 3172 | rpcBestCU->copyToPic(uhDepth); // Copy Best data to Picture for next partition prediction. |
---|
[2] | 3173 | |
---|
[5] | 3174 | #if HHI_VSO |
---|
[2] | 3175 | if( !bSplit && bRecursiveCall && m_pcRdCost->getUseRenModel() ) |
---|
| 3176 | { |
---|
[81] | 3177 | UInt uiWidth = m_ppcRecoYuvBest[uhDepth]->getWidth ( ); |
---|
| 3178 | UInt uiHeight = m_ppcRecoYuvBest[uhDepth]->getHeight ( ); |
---|
| 3179 | UInt uiSrcStride = m_ppcRecoYuvBest[uhDepth]->getStride ( ); |
---|
| 3180 | Pel* piSrc = m_ppcRecoYuvBest[uhDepth]->getLumaAddr( 0 ); |
---|
| 3181 | m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
[2] | 3182 | } |
---|
[5] | 3183 | #endif |
---|
[2] | 3184 | } |
---|
| 3185 | |
---|
| 3186 | Void TEncCu::xAddMVISignallingBits( TComDataCU* pcCU ) |
---|
| 3187 | { |
---|
| 3188 | const UChar uhDepth = pcCU->getTextureModeDepth( 0 ); |
---|
| 3189 | m_pcEntropyCoder->resetBits(); |
---|
| 3190 | xSaveDepthWidthHeight( pcCU ); |
---|
| 3191 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uhDepth, g_uiMaxCUHeight>>uhDepth, 0, uhDepth ); |
---|
| 3192 | pcCU->setDepthSubParts( uhDepth, 0 ); |
---|
| 3193 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); |
---|
| 3194 | pcCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); |
---|
[56] | 3195 | pcCU->setMergeIndexSubParts( HHI_MPI_MERGE_POS, 0, 0, uhDepth ); |
---|
[2] | 3196 | |
---|
| 3197 | // check for skip mode |
---|
| 3198 | { |
---|
| 3199 | Bool bAllZero = true; |
---|
| 3200 | for( UInt ui = 0; ui < pcCU->getTotalNumPart(); ui++ ) |
---|
| 3201 | { |
---|
| 3202 | if( pcCU->getCbf( ui, TEXT_LUMA ) || pcCU->getCbf( ui, TEXT_CHROMA_U ) || pcCU->getCbf( ui, TEXT_CHROMA_V ) ) |
---|
| 3203 | { |
---|
| 3204 | bAllZero = false; |
---|
| 3205 | break; |
---|
| 3206 | } |
---|
| 3207 | } |
---|
| 3208 | if( bAllZero ) |
---|
| 3209 | pcCU->setPredModeSubParts( MODE_SKIP, 0, uhDepth ); |
---|
| 3210 | } |
---|
| 3211 | |
---|
| 3212 | |
---|
| 3213 | m_pcEntropyCoder->encodeSplitFlag( pcCU, 0, uhDepth, true ); |
---|
| 3214 | m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true ); |
---|
| 3215 | |
---|
| 3216 | if( pcCU->isSkipped( 0 ) ) |
---|
| 3217 | { |
---|
| 3218 | m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, 0, true ); |
---|
[152] | 3219 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 3220 | m_pcEntropyCoder->encodeICFlag( pcCU, 0, true ); |
---|
[152] | 3221 | #endif |
---|
[2] | 3222 | } |
---|
| 3223 | else |
---|
| 3224 | { |
---|
| 3225 | m_pcEntropyCoder->encodePredMode( pcCU, 0, true ); |
---|
| 3226 | m_pcEntropyCoder->encodePartSize( pcCU, 0, uhDepth, true ); |
---|
| 3227 | // prediction Info ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
| 3228 | m_pcEntropyCoder->encodePredInfo( pcCU, 0, true ); |
---|
[152] | 3229 | #if LGE_ILLUCOMP_B0045 |
---|
[156] | 3230 | m_pcEntropyCoder->encodeICFlag( pcCU, 0, true ); |
---|
[152] | 3231 | #endif |
---|
[2] | 3232 | } |
---|
| 3233 | xRestoreDepthWidthHeight( pcCU ); |
---|
| 3234 | |
---|
| 3235 | pcCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
| 3236 | } |
---|
| 3237 | |
---|
| 3238 | Void TEncCu::xSaveDepthWidthHeight( TComDataCU* pcCU ) |
---|
| 3239 | { |
---|
| 3240 | const Int iSizeInUchar = sizeof( UChar ) * pcCU->getTotalNumPart(); |
---|
| 3241 | memcpy( m_puhDepthSaved, pcCU->getDepth(), iSizeInUchar ); |
---|
| 3242 | memcpy( m_puhWidthSaved, pcCU->getWidth(), iSizeInUchar ); |
---|
| 3243 | memcpy( m_puhHeightSaved, pcCU->getHeight(), iSizeInUchar ); |
---|
| 3244 | } |
---|
| 3245 | |
---|
| 3246 | Void TEncCu::xRestoreDepthWidthHeight( TComDataCU* pcCU ) |
---|
| 3247 | { |
---|
| 3248 | const Int iSizeInUchar = sizeof( UChar ) * pcCU->getTotalNumPart(); |
---|
| 3249 | memcpy( pcCU->getDepth(), m_puhDepthSaved, iSizeInUchar ); |
---|
| 3250 | memcpy( pcCU->getWidth(), m_puhWidthSaved, iSizeInUchar ); |
---|
| 3251 | memcpy( pcCU->getHeight(), m_puhHeightSaved, iSizeInUchar ); |
---|
| 3252 | } |
---|
| 3253 | #endif |
---|
[56] | 3254 | |
---|
| 3255 | //! \} |
---|