| 1 | /* The copyright in this software is being made available under the BSD |
|---|
| 2 | * License, included below. This software may be subject to other third party |
|---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
|---|
| 4 | * granted under this license. |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) 2010-2017, ITU/ISO/IEC |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * Redistribution and use in source and binary forms, with or without |
|---|
| 10 | * modification, are permitted provided that the following conditions are met: |
|---|
| 11 | * |
|---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
|---|
| 13 | * this list of conditions and the following disclaimer. |
|---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
|---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
|---|
| 16 | * and/or other materials provided with the distribution. |
|---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
|---|
| 18 | * be used to endorse or promote products derived from this software without |
|---|
| 19 | * specific prior written permission. |
|---|
| 20 | * |
|---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
|---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | /** \file TEncTop.cpp |
|---|
| 35 | \brief encoder class |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | #include "TLibCommon/CommonDef.h" |
|---|
| 39 | #include "TEncTop.h" |
|---|
| 40 | #include "TEncPic.h" |
|---|
| 41 | #include "TLibCommon/TComChromaFormat.h" |
|---|
| 42 | #if FAST_BIT_EST |
|---|
| 43 | #include "TLibCommon/ContextModel.h" |
|---|
| 44 | #endif |
|---|
| 45 | #if NH_MV |
|---|
| 46 | //#include "../../App/TAppEncoder/TAppEncTop.h" |
|---|
| 47 | #endif |
|---|
| 48 | |
|---|
| 49 | //! \ingroup TLibEncoder |
|---|
| 50 | //! \{ |
|---|
| 51 | |
|---|
| 52 | // ==================================================================================================================== |
|---|
| 53 | // Constructor / destructor / create / destroy |
|---|
| 54 | // ==================================================================================================================== |
|---|
| 55 | |
|---|
| 56 | #if !NH_MV |
|---|
| 57 | TEncTop::TEncTop() : |
|---|
| 58 | m_spsMap(MAX_NUM_SPS) |
|---|
| 59 | , m_ppsMap(MAX_NUM_PPS) |
|---|
| 60 | #else |
|---|
| 61 | TEncTop::TEncTop( ParameterSetMap<TComSPS>& spsMap, ParameterSetMap<TComPPS>& ppsMap ) : |
|---|
| 62 | m_spsMap(spsMap) |
|---|
| 63 | , m_ppsMap(ppsMap) |
|---|
| 64 | #endif |
|---|
| 65 | { |
|---|
| 66 | |
|---|
| 67 | m_iPOCLast = -1; |
|---|
| 68 | m_iNumPicRcvd = 0; |
|---|
| 69 | m_uiNumAllPicCoded = 0; |
|---|
| 70 | m_pppcRDSbacCoder = NULL; |
|---|
| 71 | m_pppcBinCoderCABAC = NULL; |
|---|
| 72 | m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC ); |
|---|
| 73 | #if ENC_DEC_TRACE |
|---|
| 74 | if (g_hTrace == NULL) |
|---|
| 75 | { |
|---|
| 76 | g_hTrace = fopen( "TraceEnc.txt", "wb" ); |
|---|
| 77 | } |
|---|
| 78 | g_bJustDoIt = g_bEncDecTraceDisable; |
|---|
| 79 | g_nSymbolCounter = 0; |
|---|
| 80 | #endif |
|---|
| 81 | |
|---|
| 82 | m_iMaxRefPicNum = 0; |
|---|
| 83 | |
|---|
| 84 | #if FAST_BIT_EST |
|---|
| 85 | ContextModel::buildNextStateTable(); |
|---|
| 86 | #endif |
|---|
| 87 | #if NH_MV |
|---|
| 88 | m_ivPicLists = NULL; |
|---|
| 89 | #endif |
|---|
| 90 | #if NH_3D |
|---|
| 91 | m_aICEnableCandidate = NULL; |
|---|
| 92 | m_aICEnableNum = NULL; |
|---|
| 93 | #endif |
|---|
| 94 | #if NH_MV |
|---|
| 95 | m_cCavlcCoder.setEncTop(this); |
|---|
| 96 | #endif |
|---|
| 97 | |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | TEncTop::~TEncTop() |
|---|
| 101 | { |
|---|
| 102 | #if NH_3D |
|---|
| 103 | if ( m_aICEnableCandidate != NULL ) |
|---|
| 104 | { |
|---|
| 105 | delete[] m_aICEnableCandidate; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | if ( m_aICEnableNum != NULL ) |
|---|
| 109 | { |
|---|
| 110 | delete[] m_aICEnableNum; |
|---|
| 111 | } |
|---|
| 112 | #endif |
|---|
| 113 | |
|---|
| 114 | #if ENC_DEC_TRACE |
|---|
| 115 | if (g_hTrace != stdout) |
|---|
| 116 | { |
|---|
| 117 | fclose( g_hTrace ); |
|---|
| 118 | } |
|---|
| 119 | #endif |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | Void TEncTop::create () |
|---|
| 123 | { |
|---|
| 124 | #if !NH_MV |
|---|
| 125 | // initialize global variables |
|---|
| 126 | initROM(); |
|---|
| 127 | #endif |
|---|
| 128 | |
|---|
| 129 | // create processing unit classes |
|---|
| 130 | m_cGOPEncoder. create( ); |
|---|
| 131 | m_cSliceEncoder. create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth ); |
|---|
| 132 | m_cCuEncoder. create( m_maxTotalCUDepth, m_maxCUWidth, m_maxCUHeight, m_chromaFormatIDC ); |
|---|
| 133 | if (m_bUseSAO) |
|---|
| 134 | { |
|---|
| 135 | m_cEncSAO.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA], m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] ); |
|---|
| 136 | m_cEncSAO.createEncData(getSaoCtuBoundary()); |
|---|
| 137 | } |
|---|
| 138 | #if ADAPTIVE_QP_SELECTION |
|---|
| 139 | if (m_bUseAdaptQpSelect) |
|---|
| 140 | { |
|---|
| 141 | m_cTrQuant.initSliceQpDelta(); |
|---|
| 142 | } |
|---|
| 143 | #endif |
|---|
| 144 | |
|---|
| 145 | m_cLoopFilter.create( m_maxTotalCUDepth ); |
|---|
| 146 | |
|---|
| 147 | if ( m_RCEnableRateControl ) |
|---|
| 148 | { |
|---|
| 149 | #if KWU_RC_MADPRED_E0227 |
|---|
| 150 | m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight, |
|---|
| 151 | g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList, getLayerId() ); |
|---|
| 152 | #else |
|---|
| 153 | m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, (Int)( (Double)m_iFrameRate/m_temporalSubsampleRatio + 0.5), m_iGOPSize, m_iSourceWidth, m_iSourceHeight, |
|---|
| 154 | m_maxCUWidth, m_maxCUHeight,m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList ); |
|---|
| 155 | #endif |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | m_pppcRDSbacCoder = new TEncSbac** [m_maxTotalCUDepth+1]; |
|---|
| 159 | #if FAST_BIT_EST |
|---|
| 160 | m_pppcBinCoderCABAC = new TEncBinCABACCounter** [m_maxTotalCUDepth+1]; |
|---|
| 161 | #else |
|---|
| 162 | m_pppcBinCoderCABAC = new TEncBinCABAC** [m_maxTotalCUDepth+1]; |
|---|
| 163 | #endif |
|---|
| 164 | |
|---|
| 165 | for ( Int iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ ) |
|---|
| 166 | { |
|---|
| 167 | m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM]; |
|---|
| 168 | #if FAST_BIT_EST |
|---|
| 169 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM]; |
|---|
| 170 | #else |
|---|
| 171 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM]; |
|---|
| 172 | #endif |
|---|
| 173 | |
|---|
| 174 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
|---|
| 175 | { |
|---|
| 176 | m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac; |
|---|
| 177 | #if FAST_BIT_EST |
|---|
| 178 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; |
|---|
| 179 | #else |
|---|
| 180 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; |
|---|
| 181 | #endif |
|---|
| 182 | m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); |
|---|
| 183 | } |
|---|
| 184 | } |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | Void TEncTop::destroy () |
|---|
| 188 | { |
|---|
| 189 | // destroy processing unit classes |
|---|
| 190 | m_cGOPEncoder. destroy(); |
|---|
| 191 | m_cSliceEncoder. destroy(); |
|---|
| 192 | m_cCuEncoder. destroy(); |
|---|
| 193 | m_cEncSAO. destroyEncData(); |
|---|
| 194 | m_cEncSAO. destroy(); |
|---|
| 195 | m_cLoopFilter. destroy(); |
|---|
| 196 | m_cRateCtrl. destroy(); |
|---|
| 197 | m_cSearch. destroy(); |
|---|
| 198 | Int iDepth; |
|---|
| 199 | for ( iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ ) |
|---|
| 200 | { |
|---|
| 201 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
|---|
| 202 | { |
|---|
| 203 | delete m_pppcRDSbacCoder[iDepth][iCIIdx]; |
|---|
| 204 | delete m_pppcBinCoderCABAC[iDepth][iCIIdx]; |
|---|
| 205 | } |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | for ( iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ ) |
|---|
| 209 | { |
|---|
| 210 | delete [] m_pppcRDSbacCoder[iDepth]; |
|---|
| 211 | delete [] m_pppcBinCoderCABAC[iDepth]; |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | delete [] m_pppcRDSbacCoder; |
|---|
| 215 | delete [] m_pppcBinCoderCABAC; |
|---|
| 216 | |
|---|
| 217 | #if !NH_MV |
|---|
| 218 | // destroy ROM |
|---|
| 219 | destroyROM(); |
|---|
| 220 | #endif |
|---|
| 221 | |
|---|
| 222 | return; |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | #if KWU_RC_MADPRED_E0227 |
|---|
| 226 | Void TEncTop::init(TAppEncTop* pcTAppEncTop, Bool isFieldCoding) |
|---|
| 227 | #else |
|---|
| 228 | Void TEncTop::init(Bool isFieldCoding) |
|---|
| 229 | #endif |
|---|
| 230 | { |
|---|
| 231 | #if NH_MV |
|---|
| 232 | Int parameterSetId = getParameterSetId( ); |
|---|
| 233 | |
|---|
| 234 | TComSPS& sps0 = *(m_spsMap.allocatePS( parameterSetId ) ); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues. |
|---|
| 235 | TComPPS& pps0 = *(m_ppsMap.allocatePS( parameterSetId ) ); |
|---|
| 236 | #else |
|---|
| 237 | TComSPS &sps0=*(m_spsMap.allocatePS(0)); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues. |
|---|
| 238 | TComPPS &pps0=*(m_ppsMap.allocatePS(0)); |
|---|
| 239 | #endif |
|---|
| 240 | // initialize SPS |
|---|
| 241 | #if H_3D |
|---|
| 242 | // Assuming that all PPS indirectly refer to the same VPS via different SPS |
|---|
| 243 | sps.setVPS(m_cVPS); |
|---|
| 244 | #endif |
|---|
| 245 | |
|---|
| 246 | #if NH_MV |
|---|
| 247 | Bool initParameterSets = getSendParameterSets(); |
|---|
| 248 | |
|---|
| 249 | if ( initParameterSets ) |
|---|
| 250 | { |
|---|
| 251 | xInitSPS( sps0 ); |
|---|
| 252 | } |
|---|
| 253 | #else |
|---|
| 254 | xInitSPS( sps0 ); |
|---|
| 255 | xInitVPS((*m_cVPS), sps0); |
|---|
| 256 | #endif |
|---|
| 257 | |
|---|
| 258 | if (m_RCCpbSaturationEnabled) |
|---|
| 259 | { |
|---|
| 260 | m_cRateCtrl.initHrdParam(sps0.getVuiParameters()->getHrdParameters(), m_iFrameRate, m_RCInitialCpbFullness); |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | m_cRdCost.setCostMode(m_costMode); |
|---|
| 264 | |
|---|
| 265 | #if NH_MV |
|---|
| 266 | if ( initParameterSets ) |
|---|
| 267 | { |
|---|
| 268 | // This seems to be incorrect, but irrelevant for the MV-HEVC |
|---|
| 269 | if (m_layerId == 0 ) |
|---|
| 270 | { |
|---|
| 271 | *(m_cVPS->getPTL()) = *sps0.getPTL(); |
|---|
| 272 | m_cVPS->getTimingInfo()->setTimingInfoPresentFlag ( false ); |
|---|
| 273 | } |
|---|
| 274 | #endif |
|---|
| 275 | // initialize PPS |
|---|
| 276 | xInitPPS(pps0, sps0); |
|---|
| 277 | xInitRPS(sps0, isFieldCoding); |
|---|
| 278 | xInitScalingLists(sps0, pps0); |
|---|
| 279 | |
|---|
| 280 | if (m_wcgChromaQpControl.isEnabled()) |
|---|
| 281 | { |
|---|
| 282 | #if NH_MV |
|---|
| 283 | AOT( true ); // This is currently not supported. |
|---|
| 284 | #endif |
|---|
| 285 | TComPPS &pps1=*(m_ppsMap.allocatePS(1)); |
|---|
| 286 | xInitPPS(pps1, sps0); |
|---|
| 287 | xInitScalingLists(sps0, pps1); |
|---|
| 288 | } |
|---|
| 289 | #if NH_MV |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | // Copy initialized PS |
|---|
| 293 | m_activeSps = sps0; |
|---|
| 294 | m_activePps = pps0; |
|---|
| 295 | |
|---|
| 296 | // Infer layer specific values for copy |
|---|
| 297 | m_activeSps.inferRepFormat( m_cVPS, getLayerId(), initParameterSets ); |
|---|
| 298 | #endif |
|---|
| 299 | |
|---|
| 300 | #if NH_3D |
|---|
| 301 | m_aICEnableCandidate = new Int[ 10 ]; |
|---|
| 302 | m_aICEnableNum = new Int[ 10 ]; |
|---|
| 303 | |
|---|
| 304 | for(int i=0;i<10;i++) |
|---|
| 305 | { |
|---|
| 306 | m_aICEnableCandidate[i]=0; |
|---|
| 307 | m_aICEnableNum[i]=0; |
|---|
| 308 | } |
|---|
| 309 | #endif |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | // initialize processing unit classes |
|---|
| 313 | m_cGOPEncoder. init( this ); |
|---|
| 314 | m_cSliceEncoder.init( this ); |
|---|
| 315 | m_cCuEncoder. init( this ); |
|---|
| 316 | m_cCuEncoder.setSliceEncoder(&m_cSliceEncoder); |
|---|
| 317 | |
|---|
| 318 | #if KWU_RC_MADPRED_E0227 |
|---|
| 319 | m_pcTAppEncTop = pcTAppEncTop; |
|---|
| 320 | #endif |
|---|
| 321 | // initialize transform & quantization class |
|---|
| 322 | m_pcCavlcCoder = getCavlcCoder(); |
|---|
| 323 | |
|---|
| 324 | m_cTrQuant.init( 1 << m_uiQuadtreeTULog2MaxSize, |
|---|
| 325 | m_useRDOQ, |
|---|
| 326 | m_useRDOQTS, |
|---|
| 327 | m_useSelectiveRDOQ, |
|---|
| 328 | true |
|---|
| 329 | ,m_useTransformSkipFast |
|---|
| 330 | #if ADAPTIVE_QP_SELECTION |
|---|
| 331 | ,m_bUseAdaptQpSelect |
|---|
| 332 | #endif |
|---|
| 333 | ); |
|---|
| 334 | |
|---|
| 335 | // initialize encoder search class |
|---|
| 336 | m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_motionEstimationSearchMethod, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); |
|---|
| 337 | |
|---|
| 338 | m_iMaxRefPicNum = 0; |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | Void TEncTop::xInitScalingLists(TComSPS &sps, TComPPS &pps) |
|---|
| 342 | { |
|---|
| 343 | // Initialise scaling lists |
|---|
| 344 | // The encoder will only use the SPS scaling lists. The PPS will never be marked present. |
|---|
| 345 | const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] = |
|---|
| 346 | { |
|---|
| 347 | sps.getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA), |
|---|
| 348 | sps.getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA) |
|---|
| 349 | }; |
|---|
| 350 | if(getUseScalingListId() == SCALING_LIST_OFF) |
|---|
| 351 | { |
|---|
| 352 | getTrQuant()->setFlatScalingList(maxLog2TrDynamicRange, sps.getBitDepths()); |
|---|
| 353 | getTrQuant()->setUseScalingList(false); |
|---|
| 354 | sps.setScalingListPresentFlag(false); |
|---|
| 355 | pps.setScalingListPresentFlag(false); |
|---|
| 356 | } |
|---|
| 357 | else if(getUseScalingListId() == SCALING_LIST_DEFAULT) |
|---|
| 358 | { |
|---|
| 359 | sps.getScalingList().setDefaultScalingList (); |
|---|
| 360 | sps.setScalingListPresentFlag(false); |
|---|
| 361 | pps.setScalingListPresentFlag(false); |
|---|
| 362 | |
|---|
| 363 | getTrQuant()->setScalingList(&(sps.getScalingList()), maxLog2TrDynamicRange, sps.getBitDepths()); |
|---|
| 364 | getTrQuant()->setUseScalingList(true); |
|---|
| 365 | } |
|---|
| 366 | else if(getUseScalingListId() == SCALING_LIST_FILE_READ) |
|---|
| 367 | { |
|---|
| 368 | sps.getScalingList().setDefaultScalingList (); |
|---|
| 369 | if(sps.getScalingList().xParseScalingList(getScalingListFileName())) |
|---|
| 370 | { |
|---|
| 371 | Bool bParsedScalingList=false; // Use of boolean so that assertion outputs useful string |
|---|
| 372 | assert(bParsedScalingList); |
|---|
| 373 | exit(1); |
|---|
| 374 | } |
|---|
| 375 | sps.getScalingList().checkDcOfMatrix(); |
|---|
| 376 | sps.setScalingListPresentFlag(sps.getScalingList().checkDefaultScalingList()); |
|---|
| 377 | pps.setScalingListPresentFlag(false); |
|---|
| 378 | getTrQuant()->setScalingList(&(sps.getScalingList()), maxLog2TrDynamicRange, sps.getBitDepths()); |
|---|
| 379 | getTrQuant()->setUseScalingList(true); |
|---|
| 380 | } |
|---|
| 381 | else |
|---|
| 382 | { |
|---|
| 383 | printf("error : ScalingList == %d not supported\n",getUseScalingListId()); |
|---|
| 384 | assert(0); |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | if (getUseScalingListId() != SCALING_LIST_OFF) |
|---|
| 388 | { |
|---|
| 389 | // Prepare delta's: |
|---|
| 390 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
|---|
| 391 | { |
|---|
| 392 | const Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
|---|
| 393 | |
|---|
| 394 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep) |
|---|
| 395 | { |
|---|
| 396 | sps.getScalingList().checkPredMode( sizeId, listId ); |
|---|
| 397 | } |
|---|
| 398 | } |
|---|
| 399 | } |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | // ==================================================================================================================== |
|---|
| 403 | // Public member functions |
|---|
| 404 | // ==================================================================================================================== |
|---|
| 405 | |
|---|
| 406 | #if NH_MV |
|---|
| 407 | Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg ) |
|---|
| 408 | { |
|---|
| 409 | TComPic* pcPicCurr = NULL; |
|---|
| 410 | |
|---|
| 411 | // get original YUV |
|---|
| 412 | |
|---|
| 413 | xGetNewPicBuffer( pcPicCurr, getParameterSetId() ); |
|---|
| 414 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
|---|
| 415 | |
|---|
| 416 | // compute image characteristics |
|---|
| 417 | if ( getUseAdaptiveQP() ) |
|---|
| 418 | { |
|---|
| 419 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
|---|
| 420 | } |
|---|
| 421 | pcPicCurr->setLayerId( getLayerId()); |
|---|
| 422 | #if NH_3D |
|---|
| 423 | pcPicCurr->setScaleOffset( m_cameraParameters->getCodedScale(), m_cameraParameters->getCodedOffset() ); |
|---|
| 424 | #endif |
|---|
| 425 | } |
|---|
| 426 | #endif |
|---|
| 427 | |
|---|
| 428 | Void TEncTop::deletePicBuffer() |
|---|
| 429 | { |
|---|
| 430 | |
|---|
| 431 | #if !NH_MV |
|---|
| 432 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
|---|
| 433 | Int iSize = Int( m_cListPic.size() ); |
|---|
| 434 | for ( Int i = 0; i < iSize; i++ ) |
|---|
| 435 | { |
|---|
| 436 | TComPic* pcPic = *(iterPic++); |
|---|
| 437 | |
|---|
| 438 | pcPic->destroy(); |
|---|
| 439 | delete pcPic; |
|---|
| 440 | pcPic = NULL; |
|---|
| 441 | } |
|---|
| 442 | #endif |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | /** |
|---|
| 446 | - Application has picture buffer list with size of GOP + 1 |
|---|
| 447 | - Picture buffer list acts like as ring buffer |
|---|
| 448 | - End of the list has the latest picture |
|---|
| 449 | . |
|---|
| 450 | \param flush cause encoder to encode a partial GOP |
|---|
| 451 | \param pcPicYuvOrg original YUV picture |
|---|
| 452 | \param pcPicYuvTrueOrg |
|---|
| 453 | \param snrCSC |
|---|
| 454 | \retval rcListPicYuvRecOut list of reconstruction YUV pictures |
|---|
| 455 | \retval accessUnitsOut list of output access units |
|---|
| 456 | \retval iNumEncoded number of encoded pictures |
|---|
| 457 | */ |
|---|
| 458 | #if NH_MV |
|---|
| 459 | Void TEncTop::encode( Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId ) |
|---|
| 460 | { |
|---|
| 461 | #else |
|---|
| 462 | Void TEncTop::encode( Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ) |
|---|
| 463 | { |
|---|
| 464 | #endif |
|---|
| 465 | #if NH_3D |
|---|
| 466 | TComPic* picLastCoded = getPic( getGOPEncoder()->getPocLastCoded() ); |
|---|
| 467 | if( picLastCoded ) |
|---|
| 468 | { |
|---|
| 469 | picLastCoded->compressMotion(1); |
|---|
| 470 | } |
|---|
| 471 | #endif |
|---|
| 472 | #if NH_MV |
|---|
| 473 | if( gopId == 0) |
|---|
| 474 | { |
|---|
| 475 | m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb( getLayerId(), false )), rcListPicYuvRecOut, accessUnitsOut); |
|---|
| 476 | #else |
|---|
| 477 | if (pcPicYuvOrg != NULL) |
|---|
| 478 | { |
|---|
| 479 | // get original YUV |
|---|
| 480 | TComPic* pcPicCurr = NULL; |
|---|
| 481 | |
|---|
| 482 | Int ppsID=-1; // Use default PPS ID |
|---|
| 483 | if (getWCGChromaQPControl().isEnabled()) |
|---|
| 484 | { |
|---|
| 485 | ppsID=getdQPs()[ m_iPOCLast+1 ]; |
|---|
| 486 | } |
|---|
| 487 | xGetNewPicBuffer( pcPicCurr, ppsID ); |
|---|
| 488 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
|---|
| 489 | pcPicYuvTrueOrg->copyToPic( pcPicCurr->getPicYuvTrueOrg() ); |
|---|
| 490 | |
|---|
| 491 | // compute image characteristics |
|---|
| 492 | if ( getUseAdaptiveQP() ) |
|---|
| 493 | { |
|---|
| 494 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
|---|
| 495 | } |
|---|
| 496 | } |
|---|
| 497 | |
|---|
| 498 | if ((m_iNumPicRcvd == 0) || (!flush && (m_iPOCLast != 0) && (m_iNumPicRcvd != m_iGOPSize) && (m_iGOPSize != 0))) |
|---|
| 499 | { |
|---|
| 500 | iNumEncoded = 0; |
|---|
| 501 | return; |
|---|
| 502 | } |
|---|
| 503 | #endif |
|---|
| 504 | if ( m_RCEnableRateControl ) |
|---|
| 505 | { |
|---|
| 506 | m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); |
|---|
| 507 | } |
|---|
| 508 | #if NH_MV |
|---|
| 509 | } |
|---|
| 510 | m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb(getLayerId(), false) ), rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, m_printMSSSIM, gopId); |
|---|
| 511 | |
|---|
| 512 | if( gopId + 1 == m_cGOPEncoder.getGOPSize() ) |
|---|
| 513 | { |
|---|
| 514 | #else |
|---|
| 515 | // compress GOP |
|---|
| 516 | #if JVET_F0064_MSSSIM |
|---|
| 517 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, m_printMSSSIM); |
|---|
| 518 | #else |
|---|
| 519 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE); |
|---|
| 520 | #endif |
|---|
| 521 | #endif |
|---|
| 522 | if ( m_RCEnableRateControl ) |
|---|
| 523 | { |
|---|
| 524 | m_cRateCtrl.destroyRCGOP(); |
|---|
| 525 | } |
|---|
| 526 | |
|---|
| 527 | iNumEncoded = m_iNumPicRcvd; |
|---|
| 528 | m_iNumPicRcvd = 0; |
|---|
| 529 | m_uiNumAllPicCoded += iNumEncoded; |
|---|
| 530 | #if NH_MV |
|---|
| 531 | } |
|---|
| 532 | #endif |
|---|
| 533 | } |
|---|
| 534 | |
|---|
| 535 | /**------------------------------------------------ |
|---|
| 536 | Separate interlaced frame into two fields |
|---|
| 537 | -------------------------------------------------**/ |
|---|
| 538 | Void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, Bool isTop) |
|---|
| 539 | { |
|---|
| 540 | if (!isTop) |
|---|
| 541 | { |
|---|
| 542 | org += stride; |
|---|
| 543 | } |
|---|
| 544 | for (Int y = 0; y < height>>1; y++) |
|---|
| 545 | { |
|---|
| 546 | for (Int x = 0; x < width; x++) |
|---|
| 547 | { |
|---|
| 548 | dstField[x] = org[x]; |
|---|
| 549 | } |
|---|
| 550 | |
|---|
| 551 | dstField += stride; |
|---|
| 552 | org += stride*2; |
|---|
| 553 | } |
|---|
| 554 | |
|---|
| 555 | } |
|---|
| 556 | #if NH_MV |
|---|
| 557 | Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff, Int gopId ) |
|---|
| 558 | { |
|---|
| 559 | assert( 0 ); // Field coding and multiview need to be further harmonized. |
|---|
| 560 | } |
|---|
| 561 | #else |
|---|
| 562 | Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff) |
|---|
| 563 | { |
|---|
| 564 | iNumEncoded = 0; |
|---|
| 565 | |
|---|
| 566 | for (Int fieldNum=0; fieldNum<2; fieldNum++) |
|---|
| 567 | { |
|---|
| 568 | if (pcPicYuvOrg) |
|---|
| 569 | { |
|---|
| 570 | |
|---|
| 571 | /* -- field initialization -- */ |
|---|
| 572 | const Bool isTopField=isTff==(fieldNum==0); |
|---|
| 573 | |
|---|
| 574 | TComPic *pcField; |
|---|
| 575 | xGetNewPicBuffer( pcField, -1 ); |
|---|
| 576 | pcField->setReconMark (false); // where is this normally? |
|---|
| 577 | |
|---|
| 578 | if (fieldNum==1) // where is this normally? |
|---|
| 579 | { |
|---|
| 580 | TComPicYuv* rpcPicYuvRec; |
|---|
| 581 | |
|---|
| 582 | // org. buffer |
|---|
| 583 | if ( rcListPicYuvRecOut.size() >= (UInt)m_iGOPSize+1 ) // need to maintain field 0 in list of RecOuts while processing field 1. Hence +1 on m_iGOPSize. |
|---|
| 584 | { |
|---|
| 585 | rpcPicYuvRec = rcListPicYuvRecOut.popFront(); |
|---|
| 586 | } |
|---|
| 587 | else |
|---|
| 588 | { |
|---|
| 589 | rpcPicYuvRec = new TComPicYuv; |
|---|
| 590 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, true); |
|---|
| 591 | } |
|---|
| 592 | rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); |
|---|
| 593 | } |
|---|
| 594 | |
|---|
| 595 | pcField->getSlice(0)->setPOC( m_iPOCLast ); // superfluous? |
|---|
| 596 | #if !REDUCED_ENCODER_MEMORY |
|---|
| 597 | pcField->getPicYuvRec()->setBorderExtension(false);// where is this normally? |
|---|
| 598 | #endif |
|---|
| 599 | |
|---|
| 600 | pcField->setTopField(isTopField); // interlaced requirement |
|---|
| 601 | |
|---|
| 602 | for (UInt componentIndex = 0; componentIndex < pcPicYuvOrg->getNumberValidComponents(); componentIndex++) |
|---|
| 603 | { |
|---|
| 604 | const ComponentID component = ComponentID(componentIndex); |
|---|
| 605 | const UInt stride = pcPicYuvOrg->getStride(component); |
|---|
| 606 | |
|---|
| 607 | separateFields((pcPicYuvOrg->getBuf(component) + pcPicYuvOrg->getMarginX(component) + (pcPicYuvOrg->getMarginY(component) * stride)), |
|---|
| 608 | pcField->getPicYuvOrg()->getAddr(component), |
|---|
| 609 | pcPicYuvOrg->getStride(component), |
|---|
| 610 | pcPicYuvOrg->getWidth(component), |
|---|
| 611 | pcPicYuvOrg->getHeight(component), |
|---|
| 612 | isTopField); |
|---|
| 613 | |
|---|
| 614 | separateFields((pcPicYuvTrueOrg->getBuf(component) + pcPicYuvTrueOrg->getMarginX(component) + (pcPicYuvTrueOrg->getMarginY(component) * stride)), |
|---|
| 615 | pcField->getPicYuvTrueOrg()->getAddr(component), |
|---|
| 616 | pcPicYuvTrueOrg->getStride(component), |
|---|
| 617 | pcPicYuvTrueOrg->getWidth(component), |
|---|
| 618 | pcPicYuvTrueOrg->getHeight(component), |
|---|
| 619 | isTopField); |
|---|
| 620 | } |
|---|
| 621 | |
|---|
| 622 | // compute image characteristics |
|---|
| 623 | if ( getUseAdaptiveQP() ) |
|---|
| 624 | { |
|---|
| 625 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcField ) ); |
|---|
| 626 | } |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | if ( m_iNumPicRcvd && ((flush&&fieldNum==1) || (m_iPOCLast/2)==0 || m_iNumPicRcvd==m_iGOPSize ) ) |
|---|
| 630 | { |
|---|
| 631 | // compress GOP |
|---|
| 632 | #if JVET_F0064_MSSSIM |
|---|
| 633 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff, snrCSC, m_printFrameMSE, m_printMSSSIM); |
|---|
| 634 | #else |
|---|
| 635 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff, snrCSC, m_printFrameMSE); |
|---|
| 636 | #endif |
|---|
| 637 | |
|---|
| 638 | iNumEncoded += m_iNumPicRcvd; |
|---|
| 639 | m_uiNumAllPicCoded += m_iNumPicRcvd; |
|---|
| 640 | m_iNumPicRcvd = 0; |
|---|
| 641 | } |
|---|
| 642 | } |
|---|
| 643 | } |
|---|
| 644 | #endif |
|---|
| 645 | // ==================================================================================================================== |
|---|
| 646 | // Protected member functions |
|---|
| 647 | // ==================================================================================================================== |
|---|
| 648 | |
|---|
| 649 | /** |
|---|
| 650 | - Application has picture buffer list with size of GOP + 1 |
|---|
| 651 | - Picture buffer list acts like as ring buffer |
|---|
| 652 | - End of the list has the latest picture |
|---|
| 653 | . |
|---|
| 654 | \retval rpcPic obtained picture buffer |
|---|
| 655 | */ |
|---|
| 656 | Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic, Int ppsId ) |
|---|
| 657 | { |
|---|
| 658 | rpcPic=0; |
|---|
| 659 | |
|---|
| 660 | #if NH_MV |
|---|
| 661 | const TComPPS &pps = m_activePps; |
|---|
| 662 | const TComSPS &sps = m_activeSps; |
|---|
| 663 | |
|---|
| 664 | if ( ppsId > 0 ) |
|---|
| 665 | { |
|---|
| 666 | assert( pps.getPPSId() == ppsId ); |
|---|
| 667 | assert( sps.getSPSId() == pps.getSPSId() ); |
|---|
| 668 | } |
|---|
| 669 | #else |
|---|
| 670 | const TComSPS *pSPS=m_spsMap.getPS(pps.getSPSId()); |
|---|
| 671 | // At this point, the SPS and PPS can be considered activated - they are copied to the new TComPic. |
|---|
| 672 | const TComPPS *pPPS=(ppsId<0) ? m_ppsMap.getFirstPS() : m_ppsMap.getPS(ppsId); |
|---|
| 673 | assert (pPPS!=0); |
|---|
| 674 | const TComPPS &pps=*pPPS; |
|---|
| 675 | assert (pSPS!=0); |
|---|
| 676 | |
|---|
| 677 | assert (pSPS!=0); |
|---|
| 678 | const TComSPS &sps=*pSPS; |
|---|
| 679 | |
|---|
| 680 | #endif |
|---|
| 681 | |
|---|
| 682 | |
|---|
| 683 | #if NH_MV |
|---|
| 684 | TComList<TComPic*>& cListPic = *(m_ivPicLists->getSubDpb(getLayerId(), false) ); |
|---|
| 685 | TComSlice::sortPicList(cListPic); |
|---|
| 686 | // Infer the correct rep format |
|---|
| 687 | |
|---|
| 688 | // As |
|---|
| 689 | #else |
|---|
| 690 | TComSlice::sortPicList(m_cListPic); |
|---|
| 691 | #endif |
|---|
| 692 | |
|---|
| 693 | |
|---|
| 694 | #if NH_MV |
|---|
| 695 | if (cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
|---|
| 696 | { |
|---|
| 697 | TComList<TComPic*>::iterator iterPic = cListPic.begin(); |
|---|
| 698 | Int iSize = Int( cListPic.size() ); |
|---|
| 699 | #else |
|---|
| 700 | // use an entry in the buffered list if the maximum number that need buffering has been reached: |
|---|
| 701 | |
|---|
| 702 | if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
|---|
| 703 | { |
|---|
| 704 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
|---|
| 705 | Int iSize = Int( m_cListPic.size() ); |
|---|
| 706 | #endif |
|---|
| 707 | for ( Int i = 0; i < iSize; i++ ) |
|---|
| 708 | { |
|---|
| 709 | rpcPic = *iterPic; |
|---|
| 710 | if(rpcPic->getSlice(0)->isReferenced() == false) |
|---|
| 711 | { |
|---|
| 712 | break; |
|---|
| 713 | } |
|---|
| 714 | iterPic++; |
|---|
| 715 | } |
|---|
| 716 | // If PPS ID is the same, we will assume that it has not changed since it was last used |
|---|
| 717 | // and return the old object. |
|---|
| 718 | if (pps.getPPSId() == rpcPic->getPicSym()->getPPS().getPPSId()) |
|---|
| 719 | { |
|---|
| 720 | #if REDUCED_ENCODER_MEMORY |
|---|
| 721 | rpcPic->releaseAllReconstructionData(); |
|---|
| 722 | rpcPic->prepareForEncoderSourcePicYuv(); |
|---|
| 723 | #endif |
|---|
| 724 | } |
|---|
| 725 | else |
|---|
| 726 | { |
|---|
| 727 | // the IDs differ - free up an entry in the list, and then create a new one, as with the case where the max buffering state has not been reached. |
|---|
| 728 | delete rpcPic; |
|---|
| 729 | cListPic.erase(iterPic); |
|---|
| 730 | rpcPic=0; |
|---|
| 731 | } |
|---|
| 732 | } |
|---|
| 733 | |
|---|
| 734 | if (rpcPic==0) |
|---|
| 735 | { |
|---|
| 736 | if ( getUseAdaptiveQP() ) |
|---|
| 737 | { |
|---|
| 738 | TEncPic* pcEPic = new TEncPic; |
|---|
| 739 | #if REDUCED_ENCODER_MEMORY |
|---|
| 740 | pcEPic->create( sps, pps, pps.getMaxCuDQPDepth()+1); |
|---|
| 741 | #else |
|---|
| 742 | pcEPic->create( sps, pps, pps.getMaxCuDQPDepth()+1, false); |
|---|
| 743 | #endif |
|---|
| 744 | rpcPic = pcEPic; |
|---|
| 745 | } |
|---|
| 746 | else |
|---|
| 747 | { |
|---|
| 748 | rpcPic = new TComPic; |
|---|
| 749 | #if REDUCED_ENCODER_MEMORY |
|---|
| 750 | rpcPic->create( sps, pps, true, false ); |
|---|
| 751 | #else |
|---|
| 752 | rpcPic->create( sps, pps, false ); |
|---|
| 753 | #endif |
|---|
| 754 | } |
|---|
| 755 | |
|---|
| 756 | #if NH_MV |
|---|
| 757 | cListPic.pushBack( rpcPic ); |
|---|
| 758 | #else |
|---|
| 759 | m_cListPic.pushBack( rpcPic ); |
|---|
| 760 | #endif |
|---|
| 761 | } |
|---|
| 762 | rpcPic->setReconMark (false); |
|---|
| 763 | |
|---|
| 764 | m_iPOCLast++; |
|---|
| 765 | m_iNumPicRcvd++; |
|---|
| 766 | |
|---|
| 767 | rpcPic->getSlice(0)->setPOC( m_iPOCLast ); |
|---|
| 768 | #if !REDUCED_ENCODER_MEMORY |
|---|
| 769 | // mark it should be extended |
|---|
| 770 | rpcPic->getPicYuvRec()->setBorderExtension(false); |
|---|
| 771 | #if NH_MV |
|---|
| 772 | rpcPic->getPicYuvOrg()->setBorderExtension(false); |
|---|
| 773 | #endif |
|---|
| 774 | #endif |
|---|
| 775 | } |
|---|
| 776 | |
|---|
| 777 | Void TEncTop::xInitVPS(TComVPS &vps, const TComSPS &sps) |
|---|
| 778 | { |
|---|
| 779 | // The SPS must have already been set up. |
|---|
| 780 | // set the VPS profile information. |
|---|
| 781 | #if NH_MV |
|---|
| 782 | // Do initialization in TAppEncTop |
|---|
| 783 | #else |
|---|
| 784 | *vps.getPTL() = *sps.getPTL(); |
|---|
| 785 | vps.setMaxOpSets(1); |
|---|
| 786 | vps.getTimingInfo()->setTimingInfoPresentFlag ( false ); |
|---|
| 787 | vps.setNumHrdParameters( 0 ); |
|---|
| 788 | |
|---|
| 789 | vps.createHrdParamBuffer(); |
|---|
| 790 | for( UInt i = 0; i < vps.getNumHrdParameters(); i ++ ) |
|---|
| 791 | { |
|---|
| 792 | vps.setHrdOpSetIdx( 0, i ); |
|---|
| 793 | vps.setCprmsPresentFlag( false, i ); |
|---|
| 794 | // Set up HrdParameters here. |
|---|
| 795 | } |
|---|
| 796 | #endif |
|---|
| 797 | } |
|---|
| 798 | |
|---|
| 799 | Void TEncTop::xInitSPS(TComSPS &sps) |
|---|
| 800 | { |
|---|
| 801 | #if NH_MV |
|---|
| 802 | //AOF( sps.getSPSId() == getLayerIdInVps() ); |
|---|
| 803 | sps.setLayerId( getLayerId() ); |
|---|
| 804 | // Code below needs to be moved to VPS |
|---|
| 805 | #endif |
|---|
| 806 | ProfileTierLevel& profileTierLevel = *sps.getPTL()->getGeneralPTL(); |
|---|
| 807 | profileTierLevel.setLevelIdc(m_level); |
|---|
| 808 | profileTierLevel.setTierFlag(m_levelTier); |
|---|
| 809 | profileTierLevel.setProfileIdc(m_profile); |
|---|
| 810 | profileTierLevel.setProfileCompatibilityFlag(m_profile, 1); |
|---|
| 811 | profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag); |
|---|
| 812 | profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag); |
|---|
| 813 | profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
|---|
| 814 | profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
|---|
| 815 | profileTierLevel.setBitDepthConstraint(m_bitDepthConstraintValue); |
|---|
| 816 | profileTierLevel.setChromaFormatConstraint(m_chromaFormatConstraintValue); |
|---|
| 817 | profileTierLevel.setIntraConstraintFlag(m_intraConstraintFlag); |
|---|
| 818 | profileTierLevel.setOnePictureOnlyConstraintFlag(m_onePictureOnlyConstraintFlag); |
|---|
| 819 | profileTierLevel.setLowerBitRateConstraintFlag(m_lowerBitRateConstraintFlag); |
|---|
| 820 | |
|---|
| 821 | if ((m_profile == Profile::MAIN10) && (m_bitDepth[CHANNEL_TYPE_LUMA] == 8) && (m_bitDepth[CHANNEL_TYPE_CHROMA] == 8)) |
|---|
| 822 | { |
|---|
| 823 | /* The above constraint is equal to Profile::MAIN */ |
|---|
| 824 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN, 1); |
|---|
| 825 | } |
|---|
| 826 | if (m_profile == Profile::MAIN) |
|---|
| 827 | { |
|---|
| 828 | /* A Profile::MAIN10 decoder can always decode Profile::MAIN */ |
|---|
| 829 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN10, 1); |
|---|
| 830 | } |
|---|
| 831 | /* XXX: should Main be marked as compatible with still picture? */ |
|---|
| 832 | /* XXX: may be a good idea to refactor the above into a function |
|---|
| 833 | * that chooses the actual compatibility based upon options */ |
|---|
| 834 | #if NH_MV |
|---|
| 835 | sps.setUpdateRepFormatFlag ( false ); |
|---|
| 836 | |
|---|
| 837 | Bool multiLayerExtensionFlag = ( getLayerId() > 0 && m_cVPS->getNumRefLayers( getLayerId() ) > 0 ); |
|---|
| 838 | sps.setSpsExtOrMaxSubLayersMinus1( multiLayerExtensionFlag ? 7 : m_maxTempLayer - 1 ); |
|---|
| 839 | if ( multiLayerExtensionFlag ) |
|---|
| 840 | { |
|---|
| 841 | sps.setSpsInferScalingListFlag ( true ); |
|---|
| 842 | sps.setSpsScalingListRefLayerId( m_cVPS->getIdRefLayer( getLayerId(), 0 ) ); |
|---|
| 843 | #if NH_MV |
|---|
| 844 | if ( m_bUseDisparitySearchRangeRestriction ) |
|---|
| 845 | { |
|---|
| 846 | sps.setInterViewMvVertConstraintFlag ( true ) ; |
|---|
| 847 | } |
|---|
| 848 | #endif |
|---|
| 849 | } |
|---|
| 850 | sps.setSpsExtensionPresentFlag ( true ); |
|---|
| 851 | sps.setSpsMultilayerExtensionFlag ( true ); |
|---|
| 852 | #if NH_3D |
|---|
| 853 | sps.setSps3dExtensionFlag ( true ); |
|---|
| 854 | #endif |
|---|
| 855 | #endif |
|---|
| 856 | |
|---|
| 857 | sps.setPicWidthInLumaSamples ( m_iSourceWidth ); |
|---|
| 858 | sps.setPicHeightInLumaSamples ( m_iSourceHeight ); |
|---|
| 859 | sps.setConformanceWindow ( m_conformanceWindow ); |
|---|
| 860 | sps.setMaxCUWidth ( m_maxCUWidth ); |
|---|
| 861 | sps.setMaxCUHeight ( m_maxCUHeight ); |
|---|
| 862 | sps.setMaxTotalCUDepth ( m_maxTotalCUDepth ); |
|---|
| 863 | #if NH_3D |
|---|
| 864 | assert( !getIsDepth() || m_chromaFormatIDC == CHROMA_400 ); |
|---|
| 865 | #endif |
|---|
| 866 | sps.setChromaFormatIdc( m_chromaFormatIDC); |
|---|
| 867 | sps.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize); |
|---|
| 868 | |
|---|
| 869 | Int minCUSize = sps.getMaxCUWidth() >> ( sps.getLog2DiffMaxMinCodingBlockSize() ); |
|---|
| 870 | Int log2MinCUSize = 0; |
|---|
| 871 | while(minCUSize > 1) |
|---|
| 872 | { |
|---|
| 873 | minCUSize >>= 1; |
|---|
| 874 | log2MinCUSize++; |
|---|
| 875 | } |
|---|
| 876 | |
|---|
| 877 | sps.setLog2MinCodingBlockSize(log2MinCUSize); |
|---|
| 878 | |
|---|
| 879 | sps.setPCMLog2MinSize (m_uiPCMLog2MinSize); |
|---|
| 880 | sps.setUsePCM ( m_usePCM ); |
|---|
| 881 | sps.setPCMLog2MaxSize( m_pcmLog2MaxSize ); |
|---|
| 882 | |
|---|
| 883 | sps.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); |
|---|
| 884 | sps.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize ); |
|---|
| 885 | sps.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter ); |
|---|
| 886 | sps.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra ); |
|---|
| 887 | |
|---|
| 888 | sps.setSPSTemporalMVPEnabledFlag((getTMVPModeId() == 2 || getTMVPModeId() == 1)); |
|---|
| 889 | |
|---|
| 890 | sps.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); |
|---|
| 891 | |
|---|
| 892 | sps.setUseAMP ( m_useAMP ); |
|---|
| 893 | |
|---|
| 894 | for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++) |
|---|
| 895 | { |
|---|
| 896 | sps.setBitDepth (ChannelType(channelType), m_bitDepth[channelType] ); |
|---|
| 897 | #if O0043_BEST_EFFORT_DECODING |
|---|
| 898 | sps.setStreamBitDepth(ChannelType(channelType), m_bitDepth[channelType] ); |
|---|
| 899 | #endif |
|---|
| 900 | sps.setQpBDOffset (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8))); |
|---|
| 901 | sps.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType] ); |
|---|
| 902 | } |
|---|
| 903 | sps.setUseSAO( m_bUseSAO ); |
|---|
| 904 | |
|---|
| 905 | sps.setMaxTLayers( m_maxTempLayer ); |
|---|
| 906 | sps.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false ); |
|---|
| 907 | |
|---|
| 908 | for (Int i = 0; i < min(sps.getMaxTLayers(),(UInt) MAX_TLAYER); i++ ) |
|---|
| 909 | { |
|---|
| 910 | sps.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); |
|---|
| 911 | sps.setNumReorderPics(m_numReorderPics[i], i); |
|---|
| 912 | } |
|---|
| 913 | #if NH_MV |
|---|
| 914 | for ( Int ols = 0; ols < m_cVPS->getNumOutputLayerSets(); ols++) |
|---|
| 915 | { |
|---|
| 916 | // Check MaxDecPicBuffering |
|---|
| 917 | const std::vector<Int>& targetDecLayerIdList = m_cVPS->getTargetDecLayerIdList( m_cVPS->olsIdxToLsIdx( ols )); |
|---|
| 918 | for( Int is = 0; is < targetDecLayerIdList.size(); is++ ) |
|---|
| 919 | { |
|---|
| 920 | if ( m_cVPS->getNecessaryLayerFlag( ols, is ) ) |
|---|
| 921 | { |
|---|
| 922 | sps.inferSpsMaxDecPicBufferingMinus1( m_cVPS, ols, targetDecLayerIdList[is], true ); |
|---|
| 923 | } |
|---|
| 924 | } |
|---|
| 925 | } |
|---|
| 926 | #endif |
|---|
| 927 | |
|---|
| 928 | |
|---|
| 929 | sps.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag ); |
|---|
| 930 | sps.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 ); |
|---|
| 931 | sps.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
|---|
| 932 | sps.setVuiParametersPresentFlag(getVuiParametersPresentFlag()); |
|---|
| 933 | |
|---|
| 934 | if (sps.getVuiParametersPresentFlag()) |
|---|
| 935 | { |
|---|
| 936 | TComVUI* pcVUI = sps.getVuiParameters(); |
|---|
| 937 | pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag()); |
|---|
| 938 | pcVUI->setAspectRatioIdc(getAspectRatioIdc()); |
|---|
| 939 | pcVUI->setSarWidth(getSarWidth()); |
|---|
| 940 | pcVUI->setSarHeight(getSarHeight()); |
|---|
| 941 | pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag()); |
|---|
| 942 | pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag()); |
|---|
| 943 | #if NH_MV |
|---|
| 944 | pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag() && getLayerId() == 0 ); |
|---|
| 945 | #else |
|---|
| 946 | pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag()); |
|---|
| 947 | #endif |
|---|
| 948 | pcVUI->setVideoFormat(getVideoFormat()); |
|---|
| 949 | pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag()); |
|---|
| 950 | pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag()); |
|---|
| 951 | pcVUI->setColourPrimaries(getColourPrimaries()); |
|---|
| 952 | pcVUI->setTransferCharacteristics(getTransferCharacteristics()); |
|---|
| 953 | pcVUI->setMatrixCoefficients(getMatrixCoefficients()); |
|---|
| 954 | pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag()); |
|---|
| 955 | pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField()); |
|---|
| 956 | pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField()); |
|---|
| 957 | pcVUI->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag()); |
|---|
| 958 | pcVUI->setDefaultDisplayWindow(getDefaultDisplayWindow()); |
|---|
| 959 | pcVUI->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag()); |
|---|
| 960 | pcVUI->setFieldSeqFlag(false); |
|---|
| 961 | pcVUI->setHrdParametersPresentFlag(false); |
|---|
| 962 | pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag()); |
|---|
| 963 | pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1 (getNumTicksPocDiffOneMinus1() ); |
|---|
| 964 | pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag()); |
|---|
| 965 | pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag()); |
|---|
| 966 | pcVUI->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag()); |
|---|
| 967 | pcVUI->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc()); |
|---|
| 968 | pcVUI->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom()); |
|---|
| 969 | pcVUI->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom()); |
|---|
| 970 | pcVUI->setLog2MaxMvLengthHorizontal(getLog2MaxMvLengthHorizontal()); |
|---|
| 971 | pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical()); |
|---|
| 972 | } |
|---|
| 973 | sps.setNumLongTermRefPicSPS(NUM_LONG_TERM_REF_PIC_SPS); |
|---|
| 974 | assert (NUM_LONG_TERM_REF_PIC_SPS <= MAX_NUM_LONG_TERM_REF_PICS); |
|---|
| 975 | for (Int k = 0; k < NUM_LONG_TERM_REF_PIC_SPS; k++) |
|---|
| 976 | { |
|---|
| 977 | sps.setLtRefPicPocLsbSps(k, 0); |
|---|
| 978 | sps.setUsedByCurrPicLtSPSFlag(k, 0); |
|---|
| 979 | } |
|---|
| 980 | |
|---|
| 981 | if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() || getCpbSaturationEnabled() ) |
|---|
| 982 | { |
|---|
| 983 | xInitHrdParameters(sps); |
|---|
| 984 | } |
|---|
| 985 | if( getBufferingPeriodSEIEnabled() || getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() ) |
|---|
| 986 | { |
|---|
| 987 | sps.getVuiParameters()->setHrdParametersPresentFlag( true ); |
|---|
| 988 | } |
|---|
| 989 | |
|---|
| 990 | // Set up SPS range extension settings |
|---|
| 991 | sps.getSpsRangeExtension().setTransformSkipRotationEnabledFlag(m_transformSkipRotationEnabledFlag); |
|---|
| 992 | sps.getSpsRangeExtension().setTransformSkipContextEnabledFlag(m_transformSkipContextEnabledFlag); |
|---|
| 993 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
|---|
| 994 | { |
|---|
| 995 | sps.getSpsRangeExtension().setRdpcmEnabledFlag(RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]); |
|---|
| 996 | } |
|---|
| 997 | sps.getSpsRangeExtension().setExtendedPrecisionProcessingFlag(m_extendedPrecisionProcessingFlag); |
|---|
| 998 | sps.getSpsRangeExtension().setIntraSmoothingDisabledFlag( m_intraSmoothingDisabledFlag ); |
|---|
| 999 | sps.getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag(m_highPrecisionOffsetsEnabledFlag); |
|---|
| 1000 | sps.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag); |
|---|
| 1001 | sps.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag); |
|---|
| 1002 | #if NH_MV |
|---|
| 1003 | sps.setSpsRangeExtensionsFlag( sps.getSpsRangeExtension().settingsDifferFromDefaults() ); |
|---|
| 1004 | #endif |
|---|
| 1005 | #if NH_3D |
|---|
| 1006 | sps.setSps3dExtension( m_sps3dExtension ); |
|---|
| 1007 | #endif |
|---|
| 1008 | } |
|---|
| 1009 | // calculate scale value of bitrate and initial delay |
|---|
| 1010 | Int calcScale(Int x) |
|---|
| 1011 | { |
|---|
| 1012 | if (x==0) |
|---|
| 1013 | { |
|---|
| 1014 | return 0; |
|---|
| 1015 | } |
|---|
| 1016 | UInt iMask = 0xffffffff; |
|---|
| 1017 | Int ScaleValue = 32; |
|---|
| 1018 | |
|---|
| 1019 | while ((x&iMask) != 0) |
|---|
| 1020 | { |
|---|
| 1021 | ScaleValue--; |
|---|
| 1022 | iMask = (iMask >> 1); |
|---|
| 1023 | } |
|---|
| 1024 | |
|---|
| 1025 | return ScaleValue; |
|---|
| 1026 | } |
|---|
| 1027 | Void TEncTop::xInitHrdParameters(TComSPS &sps) |
|---|
| 1028 | { |
|---|
| 1029 | Bool useSubCpbParams = (getSliceMode() > 0) || (getSliceSegmentMode() > 0); |
|---|
| 1030 | Int bitRate = getTargetBitrate(); |
|---|
| 1031 | Bool isRandomAccess = getIntraPeriod() > 0; |
|---|
| 1032 | Int cpbSize = getCpbSize(); |
|---|
| 1033 | |
|---|
| 1034 | assert (cpbSize!=0); // CPB size may not be equal to zero. ToDo: have a better default and check for level constraints |
|---|
| 1035 | if( !getVuiParametersPresentFlag() && !getCpbSaturationEnabled() ) |
|---|
| 1036 | { |
|---|
| 1037 | return; |
|---|
| 1038 | } |
|---|
| 1039 | |
|---|
| 1040 | TComVUI *vui = sps.getVuiParameters(); |
|---|
| 1041 | TComHRD *hrd = vui->getHrdParameters(); |
|---|
| 1042 | |
|---|
| 1043 | TimingInfo *timingInfo = vui->getTimingInfo(); |
|---|
| 1044 | timingInfo->setTimingInfoPresentFlag( true ); |
|---|
| 1045 | switch( getFrameRate() ) |
|---|
| 1046 | { |
|---|
| 1047 | case 24: |
|---|
| 1048 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
|---|
| 1049 | break; |
|---|
| 1050 | case 25: |
|---|
| 1051 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
|---|
| 1052 | break; |
|---|
| 1053 | case 30: |
|---|
| 1054 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
|---|
| 1055 | break; |
|---|
| 1056 | case 50: |
|---|
| 1057 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
|---|
| 1058 | break; |
|---|
| 1059 | case 60: |
|---|
| 1060 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
|---|
| 1061 | break; |
|---|
| 1062 | default: |
|---|
| 1063 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
|---|
| 1064 | break; |
|---|
| 1065 | } |
|---|
| 1066 | |
|---|
| 1067 | if (getTemporalSubsampleRatio()>1) |
|---|
| 1068 | { |
|---|
| 1069 | UInt temporalSubsampleRatio = getTemporalSubsampleRatio(); |
|---|
| 1070 | if ( Double(timingInfo->getNumUnitsInTick()) * temporalSubsampleRatio > std::numeric_limits<UInt>::max() ) |
|---|
| 1071 | { |
|---|
| 1072 | timingInfo->setTimeScale( timingInfo->getTimeScale() / temporalSubsampleRatio ); |
|---|
| 1073 | } |
|---|
| 1074 | else |
|---|
| 1075 | { |
|---|
| 1076 | timingInfo->setNumUnitsInTick( timingInfo->getNumUnitsInTick() * temporalSubsampleRatio ); |
|---|
| 1077 | } |
|---|
| 1078 | } |
|---|
| 1079 | |
|---|
| 1080 | Bool rateCnt = ( bitRate > 0 ); |
|---|
| 1081 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
|---|
| 1082 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
|---|
| 1083 | |
|---|
| 1084 | hrd->setSubPicCpbParamsPresentFlag( useSubCpbParams ); |
|---|
| 1085 | |
|---|
| 1086 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
|---|
| 1087 | { |
|---|
| 1088 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
|---|
| 1089 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
|---|
| 1090 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
|---|
| 1091 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
|---|
| 1092 | } |
|---|
| 1093 | else |
|---|
| 1094 | { |
|---|
| 1095 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
|---|
| 1096 | } |
|---|
| 1097 | |
|---|
| 1098 | if (calcScale(bitRate) <= 6) |
|---|
| 1099 | { |
|---|
| 1100 | hrd->setBitRateScale(0); |
|---|
| 1101 | } |
|---|
| 1102 | else |
|---|
| 1103 | { |
|---|
| 1104 | hrd->setBitRateScale(calcScale(bitRate) - 6); |
|---|
| 1105 | } |
|---|
| 1106 | |
|---|
| 1107 | if (calcScale(cpbSize) <= 4) |
|---|
| 1108 | { |
|---|
| 1109 | hrd->setCpbSizeScale(0); |
|---|
| 1110 | } |
|---|
| 1111 | else |
|---|
| 1112 | { |
|---|
| 1113 | hrd->setCpbSizeScale(calcScale(cpbSize) - 4); |
|---|
| 1114 | } |
|---|
| 1115 | |
|---|
| 1116 | hrd->setDuCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit |
|---|
| 1117 | |
|---|
| 1118 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
|---|
| 1119 | if( isRandomAccess ) |
|---|
| 1120 | { |
|---|
| 1121 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
|---|
| 1122 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
|---|
| 1123 | } |
|---|
| 1124 | else |
|---|
| 1125 | { |
|---|
| 1126 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
|---|
| 1127 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
|---|
| 1128 | } |
|---|
| 1129 | |
|---|
| 1130 | // Note: parameters for all temporal layers are initialized with the same values |
|---|
| 1131 | Int i, j; |
|---|
| 1132 | UInt bitrateValue, cpbSizeValue; |
|---|
| 1133 | UInt duCpbSizeValue; |
|---|
| 1134 | UInt duBitRateValue = 0; |
|---|
| 1135 | |
|---|
| 1136 | for( i = 0; i < MAX_TLAYER; i ++ ) |
|---|
| 1137 | { |
|---|
| 1138 | hrd->setFixedPicRateFlag( i, 1 ); |
|---|
| 1139 | hrd->setPicDurationInTcMinus1( i, 0 ); |
|---|
| 1140 | hrd->setLowDelayHrdFlag( i, 0 ); |
|---|
| 1141 | hrd->setCpbCntMinus1( i, 0 ); |
|---|
| 1142 | |
|---|
| 1143 | //! \todo check for possible PTL violations |
|---|
| 1144 | // BitRate[ i ] = ( bit_rate_value_minus1[ i ] + 1 ) * 2^( 6 + bit_rate_scale ) |
|---|
| 1145 | bitrateValue = bitRate / (1 << (6 + hrd->getBitRateScale()) ); // bitRate is in bits, so it needs to be scaled down |
|---|
| 1146 | // CpbSize[ i ] = ( cpb_size_value_minus1[ i ] + 1 ) * 2^( 4 + cpb_size_scale ) |
|---|
| 1147 | cpbSizeValue = cpbSize / (1 << (4 + hrd->getCpbSizeScale()) ); // using bitRate results in 1 second CPB size |
|---|
| 1148 | |
|---|
| 1149 | // DU CPB size could be smaller (i.e. bitrateValue / number of DUs), but we don't know |
|---|
| 1150 | // in how many DUs the slice segment settings will result |
|---|
| 1151 | duCpbSizeValue = bitrateValue; |
|---|
| 1152 | duBitRateValue = cpbSizeValue; |
|---|
| 1153 | |
|---|
| 1154 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
|---|
| 1155 | { |
|---|
| 1156 | hrd->setBitRateValueMinus1( i, j, 0, ( bitrateValue - 1 ) ); |
|---|
| 1157 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
|---|
| 1158 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( duCpbSizeValue - 1 ) ); |
|---|
| 1159 | hrd->setDuBitRateValueMinus1( i, j, 0, ( duBitRateValue - 1 ) ); |
|---|
| 1160 | hrd->setCbrFlag( i, j, 0, false ); |
|---|
| 1161 | |
|---|
| 1162 | hrd->setBitRateValueMinus1( i, j, 1, ( bitrateValue - 1) ); |
|---|
| 1163 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
|---|
| 1164 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( duCpbSizeValue - 1 ) ); |
|---|
| 1165 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
|---|
| 1166 | hrd->setCbrFlag( i, j, 1, false ); |
|---|
| 1167 | } |
|---|
| 1168 | } |
|---|
| 1169 | } |
|---|
| 1170 | |
|---|
| 1171 | |
|---|
| 1172 | Void TEncTop::xInitPPS(TComPPS &pps, const TComSPS &sps) const |
|---|
| 1173 | { |
|---|
| 1174 | |
|---|
| 1175 | // pps ID already initialised. |
|---|
| 1176 | pps.setSPSId(sps.getSPSId()); |
|---|
| 1177 | |
|---|
| 1178 | #if NH_MV |
|---|
| 1179 | AOF( pps.getPPSId() == getLayerIdInVps() ); |
|---|
| 1180 | pps.setLayerId( getLayerId() ); |
|---|
| 1181 | #if NH_3D |
|---|
| 1182 | // Check if this condition is still correct |
|---|
| 1183 | if( getVPS()->getNumRefListLayers( getLayerId() ) > 0 ) |
|---|
| 1184 | #else |
|---|
| 1185 | if( getVPS()->getNumDirectRefLayers( getLayerId() ) > 0 ) |
|---|
| 1186 | #endif |
|---|
| 1187 | { |
|---|
| 1188 | pps.setListsModificationPresentFlag( true ); |
|---|
| 1189 | } |
|---|
| 1190 | pps.setPpsMultilayerExtensionFlag ( true ); |
|---|
| 1191 | #if NH_3D |
|---|
| 1192 | // Might be used for DLT |
|---|
| 1193 | pps.setPps3dExtensionFlag ( getIsDepth() ); |
|---|
| 1194 | #endif |
|---|
| 1195 | #endif |
|---|
| 1196 | |
|---|
| 1197 | #if NH_3D |
|---|
| 1198 | // This should be done in TEncAppTop |
|---|
| 1199 | TComDLT curDlt = m_cDLT; |
|---|
| 1200 | // create mapping from depth layer indexes to layer ids |
|---|
| 1201 | Int j=0; |
|---|
| 1202 | for( Int i=0; i<=getVPS()->getMaxLayersMinus1(); i++ ) |
|---|
| 1203 | { |
|---|
| 1204 | Int layerId = getVPS()->getLayerIdInNuh(i); |
|---|
| 1205 | if( getVPS()->getDepthId(layerId) ) |
|---|
| 1206 | curDlt.setDepthIdxToLayerId(j++, layerId); |
|---|
| 1207 | } |
|---|
| 1208 | pps.setDLT( curDlt ); |
|---|
| 1209 | #endif |
|---|
| 1210 | |
|---|
| 1211 | pps.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); |
|---|
| 1212 | Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; |
|---|
| 1213 | |
|---|
| 1214 | if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) |
|---|
| 1215 | { |
|---|
| 1216 | bUseDQP = true; |
|---|
| 1217 | } |
|---|
| 1218 | |
|---|
| 1219 | if ( getLumaLevelToDeltaQPMapping().isEnabled() ) |
|---|
| 1220 | { |
|---|
| 1221 | bUseDQP = true; |
|---|
| 1222 | } |
|---|
| 1223 | |
|---|
| 1224 | if (m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING) |
|---|
| 1225 | { |
|---|
| 1226 | bUseDQP=false; |
|---|
| 1227 | } |
|---|
| 1228 | |
|---|
| 1229 | if ( m_RCEnableRateControl ) |
|---|
| 1230 | { |
|---|
| 1231 | pps.setUseDQP(true); |
|---|
| 1232 | pps.setMaxCuDQPDepth( 0 ); |
|---|
| 1233 | } |
|---|
| 1234 | else if(bUseDQP) |
|---|
| 1235 | { |
|---|
| 1236 | pps.setUseDQP(true); |
|---|
| 1237 | pps.setMaxCuDQPDepth( m_iMaxCuDQPDepth ); |
|---|
| 1238 | } |
|---|
| 1239 | else |
|---|
| 1240 | { |
|---|
| 1241 | pps.setUseDQP(false); |
|---|
| 1242 | pps.setMaxCuDQPDepth( 0 ); |
|---|
| 1243 | } |
|---|
| 1244 | |
|---|
| 1245 | if ( m_diffCuChromaQpOffsetDepth >= 0 ) |
|---|
| 1246 | { |
|---|
| 1247 | pps.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(m_diffCuChromaQpOffsetDepth); |
|---|
| 1248 | pps.getPpsRangeExtension().clearChromaQpOffsetList(); |
|---|
| 1249 | pps.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6); |
|---|
| 1250 | /* todo, insert table entries from command line (NB, 0 should not be touched) */ |
|---|
| 1251 | } |
|---|
| 1252 | else |
|---|
| 1253 | { |
|---|
| 1254 | pps.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(0); |
|---|
| 1255 | pps.getPpsRangeExtension().clearChromaQpOffsetList(); |
|---|
| 1256 | } |
|---|
| 1257 | pps.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag); |
|---|
| 1258 | pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA ]); |
|---|
| 1259 | pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]); |
|---|
| 1260 | |
|---|
| 1261 | if (getWCGChromaQPControl().isEnabled()) |
|---|
| 1262 | { |
|---|
| 1263 | const Int baseQp=m_iQP+pps.getPPSId(); |
|---|
| 1264 | const Double chromaQp = m_wcgChromaQpControl.chromaQpScale * baseQp + m_wcgChromaQpControl.chromaQpOffset; |
|---|
| 1265 | const Double dcbQP = m_wcgChromaQpControl.chromaCbQpScale * chromaQp; |
|---|
| 1266 | const Double dcrQP = m_wcgChromaQpControl.chromaCrQpScale * chromaQp; |
|---|
| 1267 | const Int cbQP =(Int)(dcbQP + ( dcbQP < 0 ? -0.5 : 0.5) ); |
|---|
| 1268 | const Int crQP =(Int)(dcrQP + ( dcrQP < 0 ? -0.5 : 0.5) ); |
|---|
| 1269 | pps.setQpOffset(COMPONENT_Cb, Clip3( -12, 12, min(0, cbQP) + m_chromaCbQpOffset )); |
|---|
| 1270 | pps.setQpOffset(COMPONENT_Cr, Clip3( -12, 12, min(0, crQP) + m_chromaCrQpOffset)); |
|---|
| 1271 | } |
|---|
| 1272 | else |
|---|
| 1273 | { |
|---|
| 1274 | pps.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset ); |
|---|
| 1275 | pps.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset ); |
|---|
| 1276 | } |
|---|
| 1277 | Bool bChromaDeltaQPEnabled = false; |
|---|
| 1278 | { |
|---|
| 1279 | bChromaDeltaQPEnabled = ( m_sliceChromaQpOffsetIntraOrPeriodic[0] || m_sliceChromaQpOffsetIntraOrPeriodic[1] ); |
|---|
| 1280 | if( !bChromaDeltaQPEnabled ) |
|---|
| 1281 | { |
|---|
| 1282 | for( Int i=0; i<m_iGOPSize; i++ ) |
|---|
| 1283 | { |
|---|
| 1284 | if( m_GOPList[i].m_CbQPoffset || m_GOPList[i].m_CrQPoffset ) |
|---|
| 1285 | { |
|---|
| 1286 | bChromaDeltaQPEnabled = true; |
|---|
| 1287 | break; |
|---|
| 1288 | } |
|---|
| 1289 | } |
|---|
| 1290 | } |
|---|
| 1291 | } |
|---|
| 1292 | pps.setSliceChromaQpFlag(bChromaDeltaQPEnabled); |
|---|
| 1293 | |
|---|
| 1294 | pps.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag ); |
|---|
| 1295 | pps.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) ); |
|---|
| 1296 | pps.setUseWP( m_useWeightedPred ); |
|---|
| 1297 | pps.setWPBiPred( m_useWeightedBiPred ); |
|---|
| 1298 | pps.setOutputFlagPresentFlag( false ); |
|---|
| 1299 | #if NH_MV |
|---|
| 1300 | pps.setNumExtraSliceHeaderBits( 2 ); |
|---|
| 1301 | #endif |
|---|
| 1302 | pps.setSignDataHidingEnabledFlag(getSignDataHidingEnabledFlag()); |
|---|
| 1303 | |
|---|
| 1304 | if ( getDeblockingFilterMetric() ) |
|---|
| 1305 | { |
|---|
| 1306 | pps.setDeblockingFilterOverrideEnabledFlag(true); |
|---|
| 1307 | pps.setPPSDeblockingFilterDisabledFlag(false); |
|---|
| 1308 | } |
|---|
| 1309 | else |
|---|
| 1310 | { |
|---|
| 1311 | pps.setDeblockingFilterOverrideEnabledFlag( !getLoopFilterOffsetInPPS() ); |
|---|
| 1312 | pps.setPPSDeblockingFilterDisabledFlag( getLoopFilterDisable() ); |
|---|
| 1313 | } |
|---|
| 1314 | |
|---|
| 1315 | if (! pps.getPPSDeblockingFilterDisabledFlag()) |
|---|
| 1316 | { |
|---|
| 1317 | pps.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() ); |
|---|
| 1318 | pps.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() ); |
|---|
| 1319 | } |
|---|
| 1320 | else |
|---|
| 1321 | { |
|---|
| 1322 | pps.setDeblockingFilterBetaOffsetDiv2(0); |
|---|
| 1323 | pps.setDeblockingFilterTcOffsetDiv2(0); |
|---|
| 1324 | } |
|---|
| 1325 | |
|---|
| 1326 | // deblockingFilterControlPresentFlag is true if any of the settings differ from the inferred values: |
|---|
| 1327 | const Bool deblockingFilterControlPresentFlag = pps.getDeblockingFilterOverrideEnabledFlag() || |
|---|
| 1328 | pps.getPPSDeblockingFilterDisabledFlag() || |
|---|
| 1329 | pps.getDeblockingFilterBetaOffsetDiv2() != 0 || |
|---|
| 1330 | pps.getDeblockingFilterTcOffsetDiv2() != 0; |
|---|
| 1331 | |
|---|
| 1332 | pps.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag); |
|---|
| 1333 | |
|---|
| 1334 | pps.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 ); |
|---|
| 1335 | pps.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); |
|---|
| 1336 | pps.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag ); |
|---|
| 1337 | |
|---|
| 1338 | |
|---|
| 1339 | Int histogram[MAX_NUM_REF + 1]; |
|---|
| 1340 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
|---|
| 1341 | { |
|---|
| 1342 | histogram[i]=0; |
|---|
| 1343 | } |
|---|
| 1344 | for( Int i = 0; i < getGOPSize(); i++) |
|---|
| 1345 | { |
|---|
| 1346 | assert(getGOPEntry(i).m_numRefPicsActive >= 0 && getGOPEntry(i).m_numRefPicsActive <= MAX_NUM_REF); |
|---|
| 1347 | histogram[getGOPEntry(i).m_numRefPicsActive]++; |
|---|
| 1348 | } |
|---|
| 1349 | |
|---|
| 1350 | Int maxHist=-1; |
|---|
| 1351 | Int bestPos=0; |
|---|
| 1352 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
|---|
| 1353 | { |
|---|
| 1354 | if(histogram[i]>maxHist) |
|---|
| 1355 | { |
|---|
| 1356 | maxHist=histogram[i]; |
|---|
| 1357 | bestPos=i; |
|---|
| 1358 | } |
|---|
| 1359 | } |
|---|
| 1360 | assert(bestPos <= 15); |
|---|
| 1361 | pps.setNumRefIdxL0DefaultActive(bestPos); |
|---|
| 1362 | pps.setNumRefIdxL1DefaultActive(bestPos); |
|---|
| 1363 | pps.setTransquantBypassEnabledFlag(getTransquantBypassEnabledFlag()); |
|---|
| 1364 | pps.setUseTransformSkip( m_useTransformSkip ); |
|---|
| 1365 | pps.getPpsRangeExtension().setLog2MaxTransformSkipBlockSize( m_log2MaxTransformSkipBlockSize ); |
|---|
| 1366 | |
|---|
| 1367 | if (m_sliceSegmentMode != NO_SLICES) |
|---|
| 1368 | { |
|---|
| 1369 | pps.setDependentSliceSegmentsEnabledFlag( true ); |
|---|
| 1370 | } |
|---|
| 1371 | |
|---|
| 1372 | xInitPPSforTiles(pps); |
|---|
| 1373 | } |
|---|
| 1374 | |
|---|
| 1375 | //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. |
|---|
| 1376 | Void TEncTop::xInitRPS(TComSPS &sps, Bool isFieldCoding) |
|---|
| 1377 | { |
|---|
| 1378 | TComReferencePictureSet* rps; |
|---|
| 1379 | |
|---|
| 1380 | sps.createRPSList(getGOPSize() + m_extraRPSs + 1); |
|---|
| 1381 | TComRPSList* rpsList = sps.getRPSList(); |
|---|
| 1382 | |
|---|
| 1383 | for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) |
|---|
| 1384 | { |
|---|
| 1385 | const GOPEntry &ge = getGOPEntry(i); |
|---|
| 1386 | rps = rpsList->getReferencePictureSet(i); |
|---|
| 1387 | rps->setNumberOfPictures(ge.m_numRefPics); |
|---|
| 1388 | rps->setNumRefIdc(ge.m_numRefIdc); |
|---|
| 1389 | Int numNeg = 0; |
|---|
| 1390 | Int numPos = 0; |
|---|
| 1391 | for( Int j = 0; j < ge.m_numRefPics; j++) |
|---|
| 1392 | { |
|---|
| 1393 | rps->setDeltaPOC(j,ge.m_referencePics[j]); |
|---|
| 1394 | rps->setUsed(j,ge.m_usedByCurrPic[j]); |
|---|
| 1395 | if(ge.m_referencePics[j]>0) |
|---|
| 1396 | { |
|---|
| 1397 | numPos++; |
|---|
| 1398 | } |
|---|
| 1399 | else |
|---|
| 1400 | { |
|---|
| 1401 | numNeg++; |
|---|
| 1402 | } |
|---|
| 1403 | } |
|---|
| 1404 | rps->setNumberOfNegativePictures(numNeg); |
|---|
| 1405 | rps->setNumberOfPositivePictures(numPos); |
|---|
| 1406 | |
|---|
| 1407 | // handle inter RPS intialization from the config file. |
|---|
| 1408 | rps->setInterRPSPrediction(ge.m_interRPSPrediction > 0); // not very clean, converting anything > 0 to true. |
|---|
| 1409 | rps->setDeltaRIdxMinus1(0); // index to the Reference RPS is always the previous one. |
|---|
| 1410 | TComReferencePictureSet* RPSRef = i>0 ? rpsList->getReferencePictureSet(i-1): NULL; // get the reference RPS |
|---|
| 1411 | |
|---|
| 1412 | if (ge.m_interRPSPrediction == 2) // Automatic generation of the inter RPS idc based on the RIdx provided. |
|---|
| 1413 | { |
|---|
| 1414 | assert (RPSRef!=NULL); |
|---|
| 1415 | Int deltaRPS = getGOPEntry(i-1).m_POC - ge.m_POC; // the ref POC - current POC |
|---|
| 1416 | Int numRefDeltaPOC = RPSRef->getNumberOfPictures(); |
|---|
| 1417 | |
|---|
| 1418 | rps->setDeltaRPS(deltaRPS); // set delta RPS |
|---|
| 1419 | rps->setNumRefIdc(numRefDeltaPOC+1); // set the numRefIdc to the number of pictures in the reference RPS + 1. |
|---|
| 1420 | Int count=0; |
|---|
| 1421 | for (Int j = 0; j <= numRefDeltaPOC; j++ ) // cycle through pics in reference RPS. |
|---|
| 1422 | { |
|---|
| 1423 | Int RefDeltaPOC = (j<numRefDeltaPOC)? RPSRef->getDeltaPOC(j): 0; // if it is the last decoded picture, set RefDeltaPOC = 0 |
|---|
| 1424 | rps->setRefIdc(j, 0); |
|---|
| 1425 | for (Int k = 0; k < rps->getNumberOfPictures(); k++ ) // cycle through pics in current RPS. |
|---|
| 1426 | { |
|---|
| 1427 | if (rps->getDeltaPOC(k) == ( RefDeltaPOC + deltaRPS)) // if the current RPS has a same picture as the reference RPS. |
|---|
| 1428 | { |
|---|
| 1429 | rps->setRefIdc(j, (rps->getUsed(k)?1:2)); |
|---|
| 1430 | count++; |
|---|
| 1431 | break; |
|---|
| 1432 | } |
|---|
| 1433 | } |
|---|
| 1434 | } |
|---|
| 1435 | if (count != rps->getNumberOfPictures()) |
|---|
| 1436 | { |
|---|
| 1437 | printf("Warning: Unable fully predict all delta POCs using the reference RPS index given in the config file. Setting Inter RPS to false for this RPS.\n"); |
|---|
| 1438 | rps->setInterRPSPrediction(0); |
|---|
| 1439 | } |
|---|
| 1440 | } |
|---|
| 1441 | else if (ge.m_interRPSPrediction == 1) // inter RPS idc based on the RefIdc values provided in config file. |
|---|
| 1442 | { |
|---|
| 1443 | assert (RPSRef!=NULL); |
|---|
| 1444 | rps->setDeltaRPS(ge.m_deltaRPS); |
|---|
| 1445 | rps->setNumRefIdc(ge.m_numRefIdc); |
|---|
| 1446 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
|---|
| 1447 | { |
|---|
| 1448 | rps->setRefIdc(j, ge.m_refIdc[j]); |
|---|
| 1449 | } |
|---|
| 1450 | // the following code overwrite the deltaPOC and Used by current values read from the config file with the ones |
|---|
| 1451 | // computed from the RefIdc. A warning is printed if they are not identical. |
|---|
| 1452 | numNeg = 0; |
|---|
| 1453 | numPos = 0; |
|---|
| 1454 | TComReferencePictureSet RPSTemp; // temporary variable |
|---|
| 1455 | |
|---|
| 1456 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
|---|
| 1457 | { |
|---|
| 1458 | if (ge.m_refIdc[j]) |
|---|
| 1459 | { |
|---|
| 1460 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
|---|
| 1461 | RPSTemp.setDeltaPOC((numNeg+numPos),deltaPOC); |
|---|
| 1462 | RPSTemp.setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
|---|
| 1463 | if (deltaPOC<0) |
|---|
| 1464 | { |
|---|
| 1465 | numNeg++; |
|---|
| 1466 | } |
|---|
| 1467 | else |
|---|
| 1468 | { |
|---|
| 1469 | numPos++; |
|---|
| 1470 | } |
|---|
| 1471 | } |
|---|
| 1472 | } |
|---|
| 1473 | if (numNeg != rps->getNumberOfNegativePictures()) |
|---|
| 1474 | { |
|---|
| 1475 | printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
|---|
| 1476 | rps->setNumberOfNegativePictures(numNeg); |
|---|
| 1477 | rps->setNumberOfPictures(numNeg+numPos); |
|---|
| 1478 | } |
|---|
| 1479 | if (numPos != rps->getNumberOfPositivePictures()) |
|---|
| 1480 | { |
|---|
| 1481 | printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
|---|
| 1482 | rps->setNumberOfPositivePictures(numPos); |
|---|
| 1483 | rps->setNumberOfPictures(numNeg+numPos); |
|---|
| 1484 | } |
|---|
| 1485 | RPSTemp.setNumberOfPictures(numNeg+numPos); |
|---|
| 1486 | RPSTemp.setNumberOfNegativePictures(numNeg); |
|---|
| 1487 | RPSTemp.sortDeltaPOC(); // sort the created delta POC before comparing |
|---|
| 1488 | // check if Delta POC and Used are the same |
|---|
| 1489 | // print warning if they are not. |
|---|
| 1490 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
|---|
| 1491 | { |
|---|
| 1492 | if (RPSTemp.getDeltaPOC(j) != rps->getDeltaPOC(j)) |
|---|
| 1493 | { |
|---|
| 1494 | printf("Warning: delta POC is different between intra RPS and inter RPS specified in the config file.\n"); |
|---|
| 1495 | rps->setDeltaPOC(j,RPSTemp.getDeltaPOC(j)); |
|---|
| 1496 | } |
|---|
| 1497 | if (RPSTemp.getUsed(j) != rps->getUsed(j)) |
|---|
| 1498 | { |
|---|
| 1499 | printf("Warning: Used by Current in RPS is different between intra and inter RPS specified in the config file.\n"); |
|---|
| 1500 | rps->setUsed(j,RPSTemp.getUsed(j)); |
|---|
| 1501 | } |
|---|
| 1502 | } |
|---|
| 1503 | } |
|---|
| 1504 | } |
|---|
| 1505 | //In case of field coding, we need to set special parameters for the first bottom field of the sequence, since it is not specified in the cfg file. |
|---|
| 1506 | //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS. |
|---|
| 1507 | if (isFieldCoding) |
|---|
| 1508 | { |
|---|
| 1509 | rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs); |
|---|
| 1510 | rps->setNumberOfPictures(1); |
|---|
| 1511 | rps->setNumberOfNegativePictures(1); |
|---|
| 1512 | rps->setNumberOfPositivePictures(0); |
|---|
| 1513 | rps->setNumberOfLongtermPictures(0); |
|---|
| 1514 | rps->setDeltaPOC(0,-1); |
|---|
| 1515 | rps->setPOC(0,0); |
|---|
| 1516 | rps->setUsed(0,true); |
|---|
| 1517 | rps->setInterRPSPrediction(false); |
|---|
| 1518 | rps->setDeltaRIdxMinus1(0); |
|---|
| 1519 | rps->setDeltaRPS(0); |
|---|
| 1520 | rps->setNumRefIdc(0); |
|---|
| 1521 | } |
|---|
| 1522 | } |
|---|
| 1523 | |
|---|
| 1524 | // This is a function that |
|---|
| 1525 | // determines what Reference Picture Set to use |
|---|
| 1526 | // for a specific slice (with POC = POCCurr) |
|---|
| 1527 | Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid ) |
|---|
| 1528 | { |
|---|
| 1529 | #if NH_MV |
|---|
| 1530 | if( slice->getRapPicFlag() == true && getLayerId() > 0 && POCCurr == 0 ) |
|---|
| 1531 | { |
|---|
| 1532 | TComReferencePictureSet* rps = slice->getLocalRPS(); |
|---|
| 1533 | rps->setNumberOfNegativePictures(0); |
|---|
| 1534 | rps->setNumberOfPositivePictures(0); |
|---|
| 1535 | rps->setNumberOfLongtermPictures(0); |
|---|
| 1536 | rps->setNumberOfPictures(0); |
|---|
| 1537 | slice->setRPS(rps); |
|---|
| 1538 | } |
|---|
| 1539 | else |
|---|
| 1540 | { |
|---|
| 1541 | #endif |
|---|
| 1542 | slice->setRPSidx(GOPid); |
|---|
| 1543 | |
|---|
| 1544 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
|---|
| 1545 | { |
|---|
| 1546 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
|---|
| 1547 | { |
|---|
| 1548 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
|---|
| 1549 | if(POCIndex == 0) |
|---|
| 1550 | { |
|---|
| 1551 | POCIndex = m_uiIntraPeriod; |
|---|
| 1552 | } |
|---|
| 1553 | if(POCIndex == m_GOPList[extraNum].m_POC) |
|---|
| 1554 | { |
|---|
| 1555 | slice->setRPSidx(extraNum); |
|---|
| 1556 | } |
|---|
| 1557 | } |
|---|
| 1558 | else |
|---|
| 1559 | { |
|---|
| 1560 | if(POCCurr==m_GOPList[extraNum].m_POC) |
|---|
| 1561 | { |
|---|
| 1562 | slice->setRPSidx(extraNum); |
|---|
| 1563 | } |
|---|
| 1564 | } |
|---|
| 1565 | } |
|---|
| 1566 | |
|---|
| 1567 | if(POCCurr == 1 && slice->getPic()->isField()) |
|---|
| 1568 | { |
|---|
| 1569 | slice->setRPSidx(m_iGOPSize+m_extraRPSs); |
|---|
| 1570 | } |
|---|
| 1571 | |
|---|
| 1572 | const TComReferencePictureSet *rps = (slice->getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); |
|---|
| 1573 | slice->setRPS(rps); |
|---|
| 1574 | #if NH_MV |
|---|
| 1575 | } |
|---|
| 1576 | #endif |
|---|
| 1577 | |
|---|
| 1578 | } |
|---|
| 1579 | |
|---|
| 1580 | Int TEncTop::getReferencePictureSetIdxForSOP(Int POCCurr, Int GOPid ) |
|---|
| 1581 | { |
|---|
| 1582 | Int rpsIdx = GOPid; |
|---|
| 1583 | |
|---|
| 1584 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
|---|
| 1585 | { |
|---|
| 1586 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
|---|
| 1587 | { |
|---|
| 1588 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
|---|
| 1589 | if(POCIndex == 0) |
|---|
| 1590 | { |
|---|
| 1591 | POCIndex = m_uiIntraPeriod; |
|---|
| 1592 | } |
|---|
| 1593 | if(POCIndex == m_GOPList[extraNum].m_POC) |
|---|
| 1594 | { |
|---|
| 1595 | rpsIdx = extraNum; |
|---|
| 1596 | } |
|---|
| 1597 | } |
|---|
| 1598 | else |
|---|
| 1599 | { |
|---|
| 1600 | if(POCCurr==m_GOPList[extraNum].m_POC) |
|---|
| 1601 | { |
|---|
| 1602 | rpsIdx = extraNum; |
|---|
| 1603 | } |
|---|
| 1604 | } |
|---|
| 1605 | } |
|---|
| 1606 | |
|---|
| 1607 | return rpsIdx; |
|---|
| 1608 | } |
|---|
| 1609 | |
|---|
| 1610 | Void TEncTop::xInitPPSforTiles(TComPPS &pps) |
|---|
| 1611 | #if NH_MV |
|---|
| 1612 | const |
|---|
| 1613 | #endif |
|---|
| 1614 | { |
|---|
| 1615 | pps.setTileUniformSpacingFlag( m_tileUniformSpacingFlag ); |
|---|
| 1616 | pps.setNumTileColumnsMinus1( m_iNumColumnsMinus1 ); |
|---|
| 1617 | pps.setNumTileRowsMinus1( m_iNumRowsMinus1 ); |
|---|
| 1618 | if( !m_tileUniformSpacingFlag ) |
|---|
| 1619 | { |
|---|
| 1620 | pps.setTileColumnWidth( m_tileColumnWidth ); |
|---|
| 1621 | pps.setTileRowHeight( m_tileRowHeight ); |
|---|
| 1622 | } |
|---|
| 1623 | pps.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag ); |
|---|
| 1624 | |
|---|
| 1625 | // # substreams is "per tile" when tiles are independent. |
|---|
| 1626 | } |
|---|
| 1627 | |
|---|
| 1628 | Void TEncCfg::xCheckGSParameters() |
|---|
| 1629 | { |
|---|
| 1630 | Int iWidthInCU = ( m_iSourceWidth%m_maxCUWidth ) ? m_iSourceWidth/m_maxCUWidth + 1 : m_iSourceWidth/m_maxCUWidth; |
|---|
| 1631 | Int iHeightInCU = ( m_iSourceHeight%m_maxCUHeight ) ? m_iSourceHeight/m_maxCUHeight + 1 : m_iSourceHeight/m_maxCUHeight; |
|---|
| 1632 | UInt uiCummulativeColumnWidth = 0; |
|---|
| 1633 | UInt uiCummulativeRowHeight = 0; |
|---|
| 1634 | |
|---|
| 1635 | //check the column relative parameters |
|---|
| 1636 | if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) ) |
|---|
| 1637 | { |
|---|
| 1638 | printf( "The number of columns is larger than the maximum allowed number of columns.\n" ); |
|---|
| 1639 | exit( EXIT_FAILURE ); |
|---|
| 1640 | } |
|---|
| 1641 | |
|---|
| 1642 | if( m_iNumColumnsMinus1 >= iWidthInCU ) |
|---|
| 1643 | { |
|---|
| 1644 | printf( "The current picture can not have so many columns.\n" ); |
|---|
| 1645 | exit( EXIT_FAILURE ); |
|---|
| 1646 | } |
|---|
| 1647 | |
|---|
| 1648 | if( m_iNumColumnsMinus1 && !m_tileUniformSpacingFlag ) |
|---|
| 1649 | { |
|---|
| 1650 | for(Int i=0; i<m_iNumColumnsMinus1; i++) |
|---|
| 1651 | { |
|---|
| 1652 | uiCummulativeColumnWidth += m_tileColumnWidth[i]; |
|---|
| 1653 | } |
|---|
| 1654 | |
|---|
| 1655 | if( uiCummulativeColumnWidth >= iWidthInCU ) |
|---|
| 1656 | { |
|---|
| 1657 | printf( "The width of the column is too large.\n" ); |
|---|
| 1658 | exit( EXIT_FAILURE ); |
|---|
| 1659 | } |
|---|
| 1660 | } |
|---|
| 1661 | |
|---|
| 1662 | //check the row relative parameters |
|---|
| 1663 | if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) ) |
|---|
| 1664 | { |
|---|
| 1665 | printf( "The number of rows is larger than the maximum allowed number of rows.\n" ); |
|---|
| 1666 | exit( EXIT_FAILURE ); |
|---|
| 1667 | } |
|---|
| 1668 | |
|---|
| 1669 | if( m_iNumRowsMinus1 >= iHeightInCU ) |
|---|
| 1670 | { |
|---|
| 1671 | printf( "The current picture can not have so many rows.\n" ); |
|---|
| 1672 | exit( EXIT_FAILURE ); |
|---|
| 1673 | } |
|---|
| 1674 | |
|---|
| 1675 | if( m_iNumRowsMinus1 && !m_tileUniformSpacingFlag ) |
|---|
| 1676 | { |
|---|
| 1677 | for(Int i=0; i<m_iNumRowsMinus1; i++) |
|---|
| 1678 | { |
|---|
| 1679 | uiCummulativeRowHeight += m_tileRowHeight[i]; |
|---|
| 1680 | } |
|---|
| 1681 | |
|---|
| 1682 | if( uiCummulativeRowHeight >= iHeightInCU ) |
|---|
| 1683 | { |
|---|
| 1684 | printf( "The height of the row is too large.\n" ); |
|---|
| 1685 | exit( EXIT_FAILURE ); |
|---|
| 1686 | } |
|---|
| 1687 | } |
|---|
| 1688 | } |
|---|
| 1689 | |
|---|
| 1690 | #if JCTVC_Y0038_PARAMS |
|---|
| 1691 | #if NH_MV |
|---|
| 1692 | Void TEncTop::setParamSetChanged(Int id, Bool isPps ) |
|---|
| 1693 | { |
|---|
| 1694 | if ( isPps ) |
|---|
| 1695 | { |
|---|
| 1696 | m_ppsMap.setChangedFlag(id); |
|---|
| 1697 | } |
|---|
| 1698 | else |
|---|
| 1699 | { |
|---|
| 1700 | m_spsMap.setChangedFlag(id); |
|---|
| 1701 | } |
|---|
| 1702 | } |
|---|
| 1703 | #else |
|---|
| 1704 | |
|---|
| 1705 | Void TEncTop::setParamSetChanged(Int spsId, Int ppsId) |
|---|
| 1706 | { |
|---|
| 1707 | m_ppsMap.setChangedFlag(ppsId); |
|---|
| 1708 | m_spsMap.setChangedFlag(spsId); |
|---|
| 1709 | } |
|---|
| 1710 | #endif |
|---|
| 1711 | #endif |
|---|
| 1712 | |
|---|
| 1713 | Bool TEncTop::PPSNeedsWriting(Int ppsId) |
|---|
| 1714 | { |
|---|
| 1715 | Bool bChanged=m_ppsMap.getChangedFlag(ppsId); |
|---|
| 1716 | m_ppsMap.clearChangedFlag(ppsId); |
|---|
| 1717 | return bChanged; |
|---|
| 1718 | } |
|---|
| 1719 | |
|---|
| 1720 | Bool TEncTop::SPSNeedsWriting(Int spsId) |
|---|
| 1721 | { |
|---|
| 1722 | Bool bChanged=m_spsMap.getChangedFlag(spsId); |
|---|
| 1723 | m_spsMap.clearChangedFlag(spsId); |
|---|
| 1724 | return bChanged; |
|---|
| 1725 | } |
|---|
| 1726 | |
|---|
| 1727 | #if X0038_LAMBDA_FROM_QP_CAPABILITY |
|---|
| 1728 | Int TEncCfg::getQPForPicture(const UInt gopIndex, const TComSlice *pSlice) const |
|---|
| 1729 | { |
|---|
| 1730 | const Int lumaQpBDOffset = pSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); |
|---|
| 1731 | Int qp; |
|---|
| 1732 | |
|---|
| 1733 | if (getCostMode()==COST_LOSSLESS_CODING) |
|---|
| 1734 | { |
|---|
| 1735 | qp=LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP; |
|---|
| 1736 | } |
|---|
| 1737 | else |
|---|
| 1738 | { |
|---|
| 1739 | const SliceType sliceType=pSlice->getSliceType(); |
|---|
| 1740 | |
|---|
| 1741 | qp = getBaseQP(); |
|---|
| 1742 | |
|---|
| 1743 | #if JVET_G0101_QP_SWITCHING |
|---|
| 1744 | // modify QP if a fractional QP was originally specified, cause dQPs to be 0 or 1. |
|---|
| 1745 | const Int* pdQPs = getdQPs(); |
|---|
| 1746 | if ( pdQPs ) |
|---|
| 1747 | { |
|---|
| 1748 | qp += pdQPs[ pSlice->getPOC() ]; |
|---|
| 1749 | } |
|---|
| 1750 | #endif |
|---|
| 1751 | |
|---|
| 1752 | if(sliceType==I_SLICE) |
|---|
| 1753 | { |
|---|
| 1754 | qp += getIntraQPOffset(); |
|---|
| 1755 | } |
|---|
| 1756 | else |
|---|
| 1757 | { |
|---|
| 1758 | // Only adjust QP when not lossless |
|---|
| 1759 | if (!(( getMaxDeltaQP() == 0 ) && (!getLumaLevelToDeltaQPMapping().isEnabled()) && (qp == -lumaQpBDOffset ) && (pSlice->getPPS()->getTransquantBypassEnabledFlag()))) |
|---|
| 1760 | { |
|---|
| 1761 | const GOPEntry &gopEntry=getGOPEntry(gopIndex); |
|---|
| 1762 | // adjust QP according to the QP offset for the GOP entry. |
|---|
| 1763 | qp +=gopEntry.m_QPOffset; |
|---|
| 1764 | |
|---|
| 1765 | // adjust QP according to QPOffsetModel for the GOP entry. |
|---|
| 1766 | Double dqpOffset=qp*gopEntry.m_QPOffsetModelScale+gopEntry.m_QPOffsetModelOffset+0.5; |
|---|
| 1767 | Int qpOffset = (Int)floor(Clip3<Double>(0.0, 3.0, dqpOffset)); |
|---|
| 1768 | qp += qpOffset ; |
|---|
| 1769 | } |
|---|
| 1770 | } |
|---|
| 1771 | |
|---|
| 1772 | #if !JVET_G0101_QP_SWITCHING |
|---|
| 1773 | // modify QP if a fractional QP was originally specified, cause dQPs to be 0 or 1. |
|---|
| 1774 | const Int* pdQPs = getdQPs(); |
|---|
| 1775 | if ( pdQPs ) |
|---|
| 1776 | { |
|---|
| 1777 | qp += pdQPs[ pSlice->getPOC() ]; |
|---|
| 1778 | } |
|---|
| 1779 | #endif |
|---|
| 1780 | } |
|---|
| 1781 | qp = Clip3( -lumaQpBDOffset, MAX_QP, qp ); |
|---|
| 1782 | return qp; |
|---|
| 1783 | } |
|---|
| 1784 | #endif |
|---|
| 1785 | |
|---|
| 1786 | |
|---|
| 1787 | #if NH_MV |
|---|
| 1788 | Int TEncTop::getFrameId(Int iGOPid) |
|---|
| 1789 | { |
|---|
| 1790 | if(m_iPOCLast == 0) |
|---|
| 1791 | { |
|---|
| 1792 | return(0 ); |
|---|
| 1793 | } |
|---|
| 1794 | else |
|---|
| 1795 | { |
|---|
| 1796 | return m_iPOCLast -m_iNumPicRcvd+ getGOPEntry(iGOPid).m_POC ; |
|---|
| 1797 | } |
|---|
| 1798 | } |
|---|
| 1799 | |
|---|
| 1800 | TComPic* TEncTop::getPic( Int poc ) |
|---|
| 1801 | { |
|---|
| 1802 | TComList<TComPic*>* listPic = getListPic(); |
|---|
| 1803 | TComPic* pcPic = NULL; |
|---|
| 1804 | for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++) |
|---|
| 1805 | { |
|---|
| 1806 | if( (*it)->getPOC() == poc ) |
|---|
| 1807 | { |
|---|
| 1808 | pcPic = *it ; |
|---|
| 1809 | break ; |
|---|
| 1810 | } |
|---|
| 1811 | } |
|---|
| 1812 | return pcPic; |
|---|
| 1813 | } |
|---|
| 1814 | |
|---|
| 1815 | |
|---|
| 1816 | Int TEncTop::xGetPsIdAndPsLayerId( ) |
|---|
| 1817 | { |
|---|
| 1818 | // LayerId of the parameter set and the Parameter set id are always equal in HTM |
|---|
| 1819 | return ( m_sendParameterSets ? ( getLayerId() == 0 ? 0 : 1 ) : getLayerId() ); |
|---|
| 1820 | } |
|---|
| 1821 | |
|---|
| 1822 | #endif |
|---|
| 1823 | |
|---|
| 1824 | #if NH_3D_VSO |
|---|
| 1825 | Void TEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset, Int maxCuHeight ) |
|---|
| 1826 | { |
|---|
| 1827 | TRenModel* rendererModel = m_cRdCost.getRenModel(); |
|---|
| 1828 | rendererModel->setupPart( iHorOffset, std::min( maxCuHeight, (Int) ( m_iSourceHeight - iHorOffset ) )) ; |
|---|
| 1829 | |
|---|
| 1830 | Int iEncViewSIdx = m_cameraParameters->getBaseId2SortedId()[ iEncViewIdx ]; |
|---|
| 1831 | |
|---|
| 1832 | // setup base views |
|---|
| 1833 | Int iNumOfBV = m_renderModelParameters->getNumOfBaseViewsForView( iEncViewSIdx, iEncContent ); |
|---|
| 1834 | |
|---|
| 1835 | for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ ) |
|---|
| 1836 | { |
|---|
| 1837 | Int iBaseViewSIdx; |
|---|
| 1838 | Int iVideoDistMode; |
|---|
| 1839 | Int iDepthDistMode; |
|---|
| 1840 | |
|---|
| 1841 | m_renderModelParameters->getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode ); |
|---|
| 1842 | |
|---|
| 1843 | AOT( iVideoDistMode < 0 || iVideoDistMode > 2 ); |
|---|
| 1844 | |
|---|
| 1845 | Int iBaseViewIdx = m_cameraParameters->getBaseSortedId2Id()[ iBaseViewSIdx ]; |
|---|
| 1846 | |
|---|
| 1847 | Int auxId = getVPS()->getAuxId ( getLayerId() ); |
|---|
| 1848 | Bool depthFlag = ( getVPS()->getDepthId( getLayerId() ) == 1 ); |
|---|
| 1849 | |
|---|
| 1850 | if( auxId == 0 && !depthFlag ) |
|---|
| 1851 | { |
|---|
| 1852 | // Defaults for texture layers |
|---|
| 1853 | #if NH_3D |
|---|
| 1854 | depthFlag = true; |
|---|
| 1855 | auxId = 0; |
|---|
| 1856 | #else |
|---|
| 1857 | depthFlag = false; |
|---|
| 1858 | auxId = 2; |
|---|
| 1859 | #endif |
|---|
| 1860 | } |
|---|
| 1861 | |
|---|
| 1862 | TComPicYuv* pcPicYuvVideoRec = m_ivPicLists->getPicYuv( iBaseViewIdx, false , 0 , iPoc, true ); |
|---|
| 1863 | TComPicYuv* pcPicYuvDepthRec = m_ivPicLists->getPicYuv( iBaseViewIdx, depthFlag, auxId, iPoc, true ); |
|---|
| 1864 | TComPicYuv* pcPicYuvVideoOrg = m_ivPicLists->getPicYuv( iBaseViewIdx, false, 0 , iPoc, false ); |
|---|
| 1865 | TComPicYuv* pcPicYuvDepthOrg = m_ivPicLists->getPicYuv( iBaseViewIdx, depthFlag, auxId, iPoc, false ); |
|---|
| 1866 | |
|---|
| 1867 | TComPicYuv* pcPicYuvVideoRef = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg : NULL; |
|---|
| 1868 | TComPicYuv* pcPicYuvDepthRef = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg : NULL; |
|---|
| 1869 | |
|---|
| 1870 | TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg : pcPicYuvVideoRec; |
|---|
| 1871 | TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg : pcPicYuvDepthRec; |
|---|
| 1872 | |
|---|
| 1873 | AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) ); |
|---|
| 1874 | AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) ); |
|---|
| 1875 | AOT( pcPicYuvDepthTest == NULL ); |
|---|
| 1876 | AOT( pcPicYuvVideoTest == NULL ); |
|---|
| 1877 | |
|---|
| 1878 | rendererModel->setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef ); |
|---|
| 1879 | } |
|---|
| 1880 | |
|---|
| 1881 | rendererModel->setErrorMode( iEncViewSIdx, iEncContent, 0 ); |
|---|
| 1882 | // setup virtual views |
|---|
| 1883 | Int iNumOfSV = m_renderModelParameters->getNumOfModelsForView( iEncViewSIdx, iEncContent ); |
|---|
| 1884 | for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ ) |
|---|
| 1885 | { |
|---|
| 1886 | Int iOrgRefBaseViewSIdx; |
|---|
| 1887 | Int iLeftBaseViewSIdx; |
|---|
| 1888 | Int iRightBaseViewSIdx; |
|---|
| 1889 | Int iSynthViewRelNum; |
|---|
| 1890 | Int iModelNum; |
|---|
| 1891 | Int iBlendMode; |
|---|
| 1892 | m_renderModelParameters->getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum ); |
|---|
| 1893 | |
|---|
| 1894 | Int iLeftBaseViewIdx = -1; |
|---|
| 1895 | Int iRightBaseViewIdx = -1; |
|---|
| 1896 | |
|---|
| 1897 | TComPicYuv* pcPicYuvOrgRef = NULL; |
|---|
| 1898 | Int** ppiShiftLUTLeft = NULL; |
|---|
| 1899 | Int** ppiShiftLUTRight = NULL; |
|---|
| 1900 | Int** ppiBaseShiftLUTLeft = NULL; |
|---|
| 1901 | Int** ppiBaseShiftLUTRight = NULL; |
|---|
| 1902 | |
|---|
| 1903 | |
|---|
| 1904 | Int iDistToLeft = -1; |
|---|
| 1905 | |
|---|
| 1906 | Int iSynthViewIdx = m_cameraParameters->synthRelNum2Idx( iSynthViewRelNum ); |
|---|
| 1907 | |
|---|
| 1908 | if ( iLeftBaseViewSIdx != -1 ) |
|---|
| 1909 | { |
|---|
| 1910 | iLeftBaseViewIdx = m_cameraParameters->getBaseSortedId2Id() [ iLeftBaseViewSIdx ]; |
|---|
| 1911 | ppiShiftLUTLeft = m_cameraParameters->getSynthViewShiftLUTI()[ iLeftBaseViewIdx ][ iSynthViewIdx ]; |
|---|
| 1912 | } |
|---|
| 1913 | |
|---|
| 1914 | if ( iRightBaseViewSIdx != -1 ) |
|---|
| 1915 | { |
|---|
| 1916 | iRightBaseViewIdx = m_cameraParameters->getBaseSortedId2Id() [iRightBaseViewSIdx ]; |
|---|
| 1917 | ppiShiftLUTRight = m_cameraParameters->getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ]; |
|---|
| 1918 | } |
|---|
| 1919 | |
|---|
| 1920 | if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 ) |
|---|
| 1921 | { |
|---|
| 1922 | iDistToLeft = m_cameraParameters->getRelDistLeft( iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx); |
|---|
| 1923 | ppiBaseShiftLUTLeft = m_cameraParameters->getBaseViewShiftLUTI() [ iLeftBaseViewIdx ][ iRightBaseViewIdx ]; |
|---|
| 1924 | ppiBaseShiftLUTRight = m_cameraParameters->getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx ]; |
|---|
| 1925 | |
|---|
| 1926 | } |
|---|
| 1927 | |
|---|
| 1928 | if ( iOrgRefBaseViewSIdx != -1 ) |
|---|
| 1929 | { |
|---|
| 1930 | pcPicYuvOrgRef = m_ivPicLists->getPicYuv( m_cameraParameters->getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , false, 0, iPoc, false ); |
|---|
| 1931 | AOF ( pcPicYuvOrgRef ); |
|---|
| 1932 | } |
|---|
| 1933 | |
|---|
| 1934 | rendererModel->setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef, iEncViewSIdx ); |
|---|
| 1935 | } |
|---|
| 1936 | } |
|---|
| 1937 | |
|---|
| 1938 | |
|---|
| 1939 | #endif |
|---|
| 1940 | |
|---|
| 1941 | |
|---|
| 1942 | //! \} |
|---|