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