[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 |
---|
[1313] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1313] | 6 | * Copyright (c) 2010-2015, 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 | |
---|
| 34 | /** \file TEncTop.cpp |
---|
| 35 | \brief encoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
[56] | 38 | #include "TLibCommon/CommonDef.h" |
---|
[2] | 39 | #include "TEncTop.h" |
---|
[56] | 40 | #include "TEncPic.h" |
---|
[1313] | 41 | #include "TLibCommon/TComChromaFormat.h" |
---|
[56] | 42 | #if FAST_BIT_EST |
---|
| 43 | #include "TLibCommon/ContextModel.h" |
---|
| 44 | #endif |
---|
[1313] | 45 | #if NH_MV |
---|
[608] | 46 | #include "../../App/TAppEncoder/TAppEncTop.h" |
---|
| 47 | #endif |
---|
[2] | 48 | |
---|
[56] | 49 | //! \ingroup TLibEncoder |
---|
| 50 | //! \{ |
---|
| 51 | |
---|
[2] | 52 | // ==================================================================================================================== |
---|
| 53 | // Constructor / destructor / create / destroy |
---|
| 54 | // ==================================================================================================================== |
---|
| 55 | |
---|
| 56 | TEncTop::TEncTop() |
---|
| 57 | { |
---|
| 58 | m_iPOCLast = -1; |
---|
| 59 | m_iNumPicRcvd = 0; |
---|
| 60 | m_uiNumAllPicCoded = 0; |
---|
| 61 | m_pppcRDSbacCoder = NULL; |
---|
| 62 | m_pppcBinCoderCABAC = NULL; |
---|
| 63 | m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC ); |
---|
| 64 | #if ENC_DEC_TRACE |
---|
[1313] | 65 | if (g_hTrace == NULL) |
---|
| 66 | { |
---|
| 67 | g_hTrace = fopen( "TraceEnc.txt", "wb" ); |
---|
| 68 | } |
---|
[2] | 69 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 70 | g_nSymbolCounter = 0; |
---|
| 71 | #endif |
---|
[56] | 72 | |
---|
| 73 | m_iMaxRefPicNum = 0; |
---|
| 74 | |
---|
| 75 | #if FAST_BIT_EST |
---|
| 76 | ContextModel::buildNextStateTable(); |
---|
| 77 | #endif |
---|
[1313] | 78 | #if NH_MV |
---|
[608] | 79 | m_ivPicLists = NULL; |
---|
| 80 | #endif |
---|
[1313] | 81 | #if NH_3D_IC |
---|
[1066] | 82 | m_aICEnableCandidate = NULL; |
---|
| 83 | m_aICEnableNum = NULL; |
---|
| 84 | #endif |
---|
[1321] | 85 | #if NH_MV |
---|
[1179] | 86 | m_cCavlcCoder.setEncTop(this); |
---|
| 87 | #endif |
---|
[1313] | 88 | |
---|
[2] | 89 | } |
---|
| 90 | |
---|
| 91 | TEncTop::~TEncTop() |
---|
| 92 | { |
---|
| 93 | #if ENC_DEC_TRACE |
---|
[1313] | 94 | if (g_hTrace != stdout) |
---|
| 95 | { |
---|
| 96 | fclose( g_hTrace ); |
---|
| 97 | } |
---|
[2] | 98 | #endif |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | Void TEncTop::create () |
---|
| 102 | { |
---|
[1313] | 103 | #if !NH_MV |
---|
[2] | 104 | // initialize global variables |
---|
[608] | 105 | initROM(); |
---|
| 106 | #endif |
---|
[1313] | 107 | |
---|
[2] | 108 | // create processing unit classes |
---|
[1313] | 109 | m_cGOPEncoder. create( ); |
---|
| 110 | m_cSliceEncoder. create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth ); |
---|
| 111 | m_cCuEncoder. create( m_maxTotalCUDepth, m_maxCUWidth, m_maxCUHeight, m_chromaFormatIDC ); |
---|
[2] | 112 | if (m_bUseSAO) |
---|
| 113 | { |
---|
[1313] | 114 | m_cEncSAO.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA], m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] ); |
---|
| 115 | m_cEncSAO.createEncData(getSaoCtuBoundary()); |
---|
[2] | 116 | } |
---|
[56] | 117 | #if ADAPTIVE_QP_SELECTION |
---|
| 118 | if (m_bUseAdaptQpSelect) |
---|
| 119 | { |
---|
| 120 | m_cTrQuant.initSliceQpDelta(); |
---|
| 121 | } |
---|
[2] | 122 | #endif |
---|
| 123 | |
---|
[1313] | 124 | m_cLoopFilter.create( m_maxTotalCUDepth ); |
---|
| 125 | |
---|
[608] | 126 | if ( m_RCEnableRateControl ) |
---|
[2] | 127 | { |
---|
[655] | 128 | #if KWU_RC_MADPRED_E0227 |
---|
[608] | 129 | m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight, |
---|
[655] | 130 | g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList, getLayerId() ); |
---|
| 131 | #else |
---|
| 132 | m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight, |
---|
[1313] | 133 | m_maxCUWidth, m_maxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList ); |
---|
[655] | 134 | #endif |
---|
[2] | 135 | } |
---|
[1313] | 136 | |
---|
| 137 | m_pppcRDSbacCoder = new TEncSbac** [m_maxTotalCUDepth+1]; |
---|
[56] | 138 | #if FAST_BIT_EST |
---|
[1313] | 139 | m_pppcBinCoderCABAC = new TEncBinCABACCounter** [m_maxTotalCUDepth+1]; |
---|
[56] | 140 | #else |
---|
[1313] | 141 | m_pppcBinCoderCABAC = new TEncBinCABAC** [m_maxTotalCUDepth+1]; |
---|
[56] | 142 | #endif |
---|
[1313] | 143 | |
---|
| 144 | for ( Int iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ ) |
---|
| 145 | { |
---|
| 146 | m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM]; |
---|
[56] | 147 | #if FAST_BIT_EST |
---|
[1313] | 148 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM]; |
---|
[56] | 149 | #else |
---|
[1313] | 150 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM]; |
---|
[56] | 151 | #endif |
---|
[1313] | 152 | |
---|
| 153 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 154 | { |
---|
| 155 | m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac; |
---|
[56] | 156 | #if FAST_BIT_EST |
---|
[1313] | 157 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; |
---|
[56] | 158 | #else |
---|
[1313] | 159 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; |
---|
[56] | 160 | #endif |
---|
[1313] | 161 | m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); |
---|
[2] | 162 | } |
---|
| 163 | } |
---|
[1313] | 164 | } |
---|
[2] | 165 | |
---|
| 166 | Void TEncTop::destroy () |
---|
| 167 | { |
---|
| 168 | // destroy processing unit classes |
---|
[56] | 169 | m_cGOPEncoder. destroy(); |
---|
[2] | 170 | m_cSliceEncoder. destroy(); |
---|
| 171 | m_cCuEncoder. destroy(); |
---|
[1313] | 172 | m_cEncSAO. destroyEncData(); |
---|
| 173 | m_cEncSAO. destroy(); |
---|
[2] | 174 | m_cLoopFilter. destroy(); |
---|
[608] | 175 | m_cRateCtrl. destroy(); |
---|
[1313] | 176 | m_cSearch. destroy(); |
---|
| 177 | Int iDepth; |
---|
| 178 | for ( iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ ) |
---|
| 179 | { |
---|
| 180 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
[2] | 181 | { |
---|
[1313] | 182 | delete m_pppcRDSbacCoder[iDepth][iCIIdx]; |
---|
| 183 | delete m_pppcBinCoderCABAC[iDepth][iCIIdx]; |
---|
[2] | 184 | } |
---|
[1313] | 185 | } |
---|
[1066] | 186 | |
---|
[1313] | 187 | for ( iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ ) |
---|
| 188 | { |
---|
| 189 | delete [] m_pppcRDSbacCoder[iDepth]; |
---|
| 190 | delete [] m_pppcBinCoderCABAC[iDepth]; |
---|
| 191 | } |
---|
[56] | 192 | |
---|
[1313] | 193 | delete [] m_pppcRDSbacCoder; |
---|
| 194 | delete [] m_pppcBinCoderCABAC; |
---|
[1066] | 195 | |
---|
[1313] | 196 | #if !NH_MV |
---|
| 197 | // destroy ROM |
---|
[56] | 198 | destroyROM(); |
---|
[608] | 199 | #endif |
---|
| 200 | |
---|
[2] | 201 | return; |
---|
| 202 | } |
---|
| 203 | |
---|
[655] | 204 | #if KWU_RC_MADPRED_E0227 |
---|
| 205 | Void TEncTop::init(TAppEncTop* pcTAppEncTop, Bool isFieldCoding) |
---|
| 206 | #else |
---|
| 207 | Void TEncTop::init(Bool isFieldCoding) |
---|
| 208 | #endif |
---|
[2] | 209 | { |
---|
| 210 | // initialize SPS |
---|
[773] | 211 | #if H_3D |
---|
[758] | 212 | // Assuming that all PPS indirectly refer to the same VPS via different SPS |
---|
| 213 | m_cSPS.setVPS(m_cVPS); |
---|
| 214 | #endif |
---|
[2] | 215 | xInitSPS(); |
---|
[1313] | 216 | xInitVPS(); |
---|
| 217 | |
---|
| 218 | m_cRdCost.setCostMode(m_costMode); |
---|
| 219 | |
---|
| 220 | #if NH_MV |
---|
[608] | 221 | // This seems to be incorrect, but irrelevant for the MV-HEVC |
---|
| 222 | *(m_cVPS->getPTL()) = *m_cSPS.getPTL(); |
---|
| 223 | m_cVPS->getTimingInfo()->setTimingInfoPresentFlag ( false ); |
---|
| 224 | #endif |
---|
[2] | 225 | // initialize PPS |
---|
| 226 | xInitPPS(); |
---|
[655] | 227 | xInitRPS(isFieldCoding); |
---|
[2] | 228 | |
---|
[56] | 229 | xInitPPSforTiles(); |
---|
[1313] | 230 | #if NH_3D_IC |
---|
[1066] | 231 | m_aICEnableCandidate = new Int[ 10 ]; |
---|
| 232 | m_aICEnableNum = new Int[ 10 ]; |
---|
[56] | 233 | |
---|
[1066] | 234 | for(int i=0;i<10;i++) |
---|
| 235 | { |
---|
| 236 | m_aICEnableCandidate[i]=0; |
---|
| 237 | m_aICEnableNum[i]=0; |
---|
| 238 | } |
---|
| 239 | #endif |
---|
[1179] | 240 | |
---|
[2] | 241 | // initialize processing unit classes |
---|
[56] | 242 | m_cGOPEncoder. init( this ); |
---|
[2] | 243 | m_cSliceEncoder.init( this ); |
---|
| 244 | m_cCuEncoder. init( this ); |
---|
[1313] | 245 | |
---|
[655] | 246 | #if KWU_RC_MADPRED_E0227 |
---|
| 247 | m_pcTAppEncTop = pcTAppEncTop; |
---|
| 248 | #endif |
---|
[2] | 249 | // initialize transform & quantization class |
---|
| 250 | m_pcCavlcCoder = getCavlcCoder(); |
---|
[1313] | 251 | |
---|
[608] | 252 | m_cTrQuant.init( 1 << m_uiQuadtreeTULog2MaxSize, |
---|
[1313] | 253 | m_useRDOQ, |
---|
| 254 | m_useRDOQTS, |
---|
| 255 | #if T0196_SELECTIVE_RDOQ |
---|
| 256 | m_useSelectiveRDOQ, |
---|
| 257 | #endif |
---|
| 258 | true |
---|
[608] | 259 | ,m_useTransformSkipFast |
---|
[1313] | 260 | #if ADAPTIVE_QP_SELECTION |
---|
| 261 | ,m_bUseAdaptQpSelect |
---|
[2] | 262 | #endif |
---|
[56] | 263 | ); |
---|
[1313] | 264 | |
---|
[2] | 265 | // initialize encoder search class |
---|
[1313] | 266 | m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); |
---|
[56] | 267 | |
---|
| 268 | m_iMaxRefPicNum = 0; |
---|
[1313] | 269 | |
---|
| 270 | xInitScalingLists(); |
---|
[2] | 271 | } |
---|
| 272 | |
---|
[1313] | 273 | Void TEncTop::xInitScalingLists() |
---|
| 274 | { |
---|
| 275 | // Initialise scaling lists |
---|
| 276 | // The encoder will only use the SPS scaling lists. The PPS will never be marked present. |
---|
| 277 | const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] = |
---|
| 278 | { |
---|
| 279 | m_cSPS.getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA), |
---|
| 280 | m_cSPS.getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA) |
---|
| 281 | }; |
---|
| 282 | if(getUseScalingListId() == SCALING_LIST_OFF) |
---|
| 283 | { |
---|
| 284 | getTrQuant()->setFlatScalingList(maxLog2TrDynamicRange, m_cSPS.getBitDepths()); |
---|
| 285 | getTrQuant()->setUseScalingList(false); |
---|
| 286 | m_cSPS.setScalingListPresentFlag(false); |
---|
| 287 | m_cPPS.setScalingListPresentFlag(false); |
---|
| 288 | } |
---|
| 289 | else if(getUseScalingListId() == SCALING_LIST_DEFAULT) |
---|
| 290 | { |
---|
| 291 | m_cSPS.getScalingList().setDefaultScalingList (); |
---|
| 292 | m_cSPS.setScalingListPresentFlag(false); |
---|
| 293 | m_cPPS.setScalingListPresentFlag(false); |
---|
| 294 | |
---|
| 295 | getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), maxLog2TrDynamicRange, m_cSPS.getBitDepths()); |
---|
| 296 | getTrQuant()->setUseScalingList(true); |
---|
| 297 | } |
---|
| 298 | else if(getUseScalingListId() == SCALING_LIST_FILE_READ) |
---|
| 299 | { |
---|
| 300 | m_cSPS.getScalingList().setDefaultScalingList (); |
---|
| 301 | if(m_cSPS.getScalingList().xParseScalingList(getScalingListFile())) |
---|
| 302 | { |
---|
| 303 | Bool bParsedScalingList=false; // Use of boolean so that assertion outputs useful string |
---|
| 304 | assert(bParsedScalingList); |
---|
| 305 | exit(1); |
---|
| 306 | } |
---|
| 307 | m_cSPS.getScalingList().checkDcOfMatrix(); |
---|
| 308 | m_cSPS.setScalingListPresentFlag(m_cSPS.getScalingList().checkDefaultScalingList()); |
---|
| 309 | m_cPPS.setScalingListPresentFlag(false); |
---|
| 310 | getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), maxLog2TrDynamicRange, m_cSPS.getBitDepths()); |
---|
| 311 | getTrQuant()->setUseScalingList(true); |
---|
| 312 | } |
---|
| 313 | else |
---|
| 314 | { |
---|
| 315 | printf("error : ScalingList == %d not supported\n",getUseScalingListId()); |
---|
| 316 | assert(0); |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | if (getUseScalingListId() != SCALING_LIST_OFF) |
---|
| 320 | { |
---|
| 321 | // Prepare delta's: |
---|
| 322 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 323 | { |
---|
| 324 | const Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
| 325 | |
---|
| 326 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep) |
---|
| 327 | { |
---|
| 328 | m_cSPS.getScalingList().checkPredMode( sizeId, listId ); |
---|
| 329 | } |
---|
| 330 | } |
---|
| 331 | } |
---|
| 332 | } |
---|
| 333 | |
---|
[2] | 334 | // ==================================================================================================================== |
---|
| 335 | // Public member functions |
---|
| 336 | // ==================================================================================================================== |
---|
| 337 | |
---|
[1313] | 338 | #if NH_MV |
---|
[608] | 339 | Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg ) |
---|
[56] | 340 | { |
---|
| 341 | TComPic* pcPicCurr = NULL; |
---|
| 342 | |
---|
| 343 | // get original YUV |
---|
| 344 | xGetNewPicBuffer( pcPicCurr ); |
---|
| 345 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
| 346 | |
---|
| 347 | // compute image characteristics |
---|
| 348 | if ( getUseAdaptiveQP() ) |
---|
| 349 | { |
---|
| 350 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
| 351 | } |
---|
[608] | 352 | pcPicCurr->setLayerId( getLayerId()); |
---|
[1313] | 353 | #if NH_3D |
---|
[1179] | 354 | pcPicCurr->setScaleOffset( m_cameraParameters->getCodedScale(), m_cameraParameters->getCodedOffset() ); |
---|
[608] | 355 | #endif |
---|
[56] | 356 | } |
---|
[608] | 357 | #endif |
---|
[1313] | 358 | |
---|
[2] | 359 | Void TEncTop::deletePicBuffer() |
---|
| 360 | { |
---|
[1321] | 361 | |
---|
| 362 | #if !NH_MV |
---|
[2] | 363 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 364 | Int iSize = Int( m_cListPic.size() ); |
---|
| 365 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 366 | { |
---|
| 367 | TComPic* pcPic = *(iterPic++); |
---|
[1313] | 368 | |
---|
[2] | 369 | pcPic->destroy(); |
---|
| 370 | delete pcPic; |
---|
| 371 | pcPic = NULL; |
---|
| 372 | } |
---|
[1321] | 373 | #endif |
---|
[2] | 374 | } |
---|
| 375 | |
---|
| 376 | /** |
---|
| 377 | - Application has picture buffer list with size of GOP + 1 |
---|
| 378 | - Picture buffer list acts like as ring buffer |
---|
| 379 | - End of the list has the latest picture |
---|
| 380 | . |
---|
[608] | 381 | \param flush cause encoder to encode a partial GOP |
---|
[2] | 382 | \param pcPicYuvOrg original YUV picture |
---|
[1313] | 383 | \param pcPicYuvTrueOrg |
---|
| 384 | \param snrCSC |
---|
[2] | 385 | \retval rcListPicYuvRecOut list of reconstruction YUV pictures |
---|
[1313] | 386 | \retval accessUnitsOut list of output access units |
---|
[2] | 387 | \retval iNumEncoded number of encoded pictures |
---|
| 388 | */ |
---|
[1313] | 389 | #if NH_MV |
---|
| 390 | Void TEncTop::encode( Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId ) |
---|
[608] | 391 | { |
---|
| 392 | #else |
---|
[1313] | 393 | Void TEncTop::encode( Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ) |
---|
[608] | 394 | { |
---|
| 395 | #endif |
---|
[1313] | 396 | #if NH_3D |
---|
[608] | 397 | TComPic* picLastCoded = getPic( getGOPEncoder()->getPocLastCoded() ); |
---|
| 398 | if( picLastCoded ) |
---|
| 399 | { |
---|
| 400 | picLastCoded->compressMotion(1); |
---|
| 401 | } |
---|
| 402 | #endif |
---|
[1313] | 403 | #if NH_MV |
---|
[56] | 404 | if( gopId == 0) |
---|
[2] | 405 | { |
---|
[1321] | 406 | m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb( getLayerId(), false )), rcListPicYuvRecOut, accessUnitsOut); |
---|
[608] | 407 | #else |
---|
[1313] | 408 | if (pcPicYuvOrg != NULL) |
---|
| 409 | { |
---|
[608] | 410 | // get original YUV |
---|
| 411 | TComPic* pcPicCurr = NULL; |
---|
[1313] | 412 | |
---|
[608] | 413 | xGetNewPicBuffer( pcPicCurr ); |
---|
| 414 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
[1313] | 415 | pcPicYuvTrueOrg->copyToPic( pcPicCurr->getPicYuvTrueOrg() ); |
---|
[608] | 416 | |
---|
| 417 | // compute image characteristics |
---|
| 418 | if ( getUseAdaptiveQP() ) |
---|
| 419 | { |
---|
| 420 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
| 421 | } |
---|
[2] | 422 | } |
---|
[1313] | 423 | |
---|
| 424 | if ((m_iNumPicRcvd == 0) || (!flush && (m_iPOCLast != 0) && (m_iNumPicRcvd != m_iGOPSize) && (m_iGOPSize != 0))) |
---|
[2] | 425 | { |
---|
[608] | 426 | iNumEncoded = 0; |
---|
| 427 | return; |
---|
[2] | 428 | } |
---|
[608] | 429 | #endif |
---|
| 430 | if ( m_RCEnableRateControl ) |
---|
[2] | 431 | { |
---|
[608] | 432 | m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); |
---|
[2] | 433 | } |
---|
[1313] | 434 | #if NH_MV |
---|
[608] | 435 | } |
---|
[1321] | 436 | m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb(getLayerId(), false) ), rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, gopId); |
---|
[2] | 437 | |
---|
[608] | 438 | if( gopId + 1 == m_cGOPEncoder.getGOPSize() ) |
---|
[2] | 439 | { |
---|
[608] | 440 | #else |
---|
| 441 | // compress GOP |
---|
[1313] | 442 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE); |
---|
[5] | 443 | #endif |
---|
[608] | 444 | if ( m_RCEnableRateControl ) |
---|
[2] | 445 | { |
---|
[608] | 446 | m_cRateCtrl.destroyRCGOP(); |
---|
[2] | 447 | } |
---|
[1313] | 448 | |
---|
[608] | 449 | iNumEncoded = m_iNumPicRcvd; |
---|
| 450 | m_iNumPicRcvd = 0; |
---|
| 451 | m_uiNumAllPicCoded += iNumEncoded; |
---|
[1313] | 452 | #if NH_MV |
---|
[2] | 453 | } |
---|
[608] | 454 | #endif |
---|
| 455 | } |
---|
[1313] | 456 | |
---|
[655] | 457 | /**------------------------------------------------ |
---|
| 458 | Separate interlaced frame into two fields |
---|
| 459 | -------------------------------------------------**/ |
---|
[1313] | 460 | Void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, Bool isTop) |
---|
[655] | 461 | { |
---|
| 462 | if (!isTop) |
---|
| 463 | { |
---|
| 464 | org += stride; |
---|
| 465 | } |
---|
| 466 | for (Int y = 0; y < height>>1; y++) |
---|
| 467 | { |
---|
| 468 | for (Int x = 0; x < width; x++) |
---|
| 469 | { |
---|
| 470 | dstField[x] = org[x]; |
---|
| 471 | } |
---|
[1313] | 472 | |
---|
[655] | 473 | dstField += stride; |
---|
| 474 | org += stride*2; |
---|
| 475 | } |
---|
[1313] | 476 | |
---|
[655] | 477 | } |
---|
[1313] | 478 | #if NH_MV |
---|
| 479 | 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 ) |
---|
[655] | 480 | { |
---|
[1124] | 481 | assert( 0 ); // Field coding and multiview need to be further harmonized. |
---|
[655] | 482 | } |
---|
| 483 | #else |
---|
[1313] | 484 | Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff) |
---|
[655] | 485 | { |
---|
[1313] | 486 | iNumEncoded = 0; |
---|
| 487 | |
---|
| 488 | for (Int fieldNum=0; fieldNum<2; fieldNum++) |
---|
[655] | 489 | { |
---|
[1313] | 490 | if (pcPicYuvOrg) |
---|
[872] | 491 | { |
---|
[1313] | 492 | |
---|
| 493 | /* -- field initialization -- */ |
---|
| 494 | const Bool isTopField=isTff==(fieldNum==0); |
---|
| 495 | |
---|
| 496 | TComPic *pcField; |
---|
| 497 | xGetNewPicBuffer( pcField ); |
---|
| 498 | pcField->setReconMark (false); // where is this normally? |
---|
| 499 | |
---|
| 500 | if (fieldNum==1) // where is this normally? |
---|
| 501 | { |
---|
| 502 | TComPicYuv* rpcPicYuvRec; |
---|
| 503 | |
---|
| 504 | // org. buffer |
---|
| 505 | 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. |
---|
| 506 | { |
---|
| 507 | rpcPicYuvRec = rcListPicYuvRecOut.popFront(); |
---|
| 508 | } |
---|
| 509 | else |
---|
| 510 | { |
---|
| 511 | rpcPicYuvRec = new TComPicYuv; |
---|
| 512 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, true); |
---|
| 513 | } |
---|
| 514 | rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); |
---|
| 515 | } |
---|
| 516 | |
---|
| 517 | pcField->getSlice(0)->setPOC( m_iPOCLast ); // superfluous? |
---|
| 518 | pcField->getPicYuvRec()->setBorderExtension(false);// where is this normally? |
---|
| 519 | |
---|
| 520 | pcField->setTopField(isTopField); // interlaced requirement |
---|
| 521 | |
---|
| 522 | for (UInt componentIndex = 0; componentIndex < pcPicYuvOrg->getNumberValidComponents(); componentIndex++) |
---|
| 523 | { |
---|
| 524 | const ComponentID component = ComponentID(componentIndex); |
---|
| 525 | const UInt stride = pcPicYuvOrg->getStride(component); |
---|
| 526 | |
---|
| 527 | separateFields((pcPicYuvOrg->getBuf(component) + pcPicYuvOrg->getMarginX(component) + (pcPicYuvOrg->getMarginY(component) * stride)), |
---|
| 528 | pcField->getPicYuvOrg()->getAddr(component), |
---|
| 529 | pcPicYuvOrg->getStride(component), |
---|
| 530 | pcPicYuvOrg->getWidth(component), |
---|
| 531 | pcPicYuvOrg->getHeight(component), |
---|
| 532 | isTopField); |
---|
| 533 | |
---|
| 534 | separateFields((pcPicYuvTrueOrg->getBuf(component) + pcPicYuvTrueOrg->getMarginX(component) + (pcPicYuvTrueOrg->getMarginY(component) * stride)), |
---|
| 535 | pcField->getPicYuvTrueOrg()->getAddr(component), |
---|
| 536 | pcPicYuvTrueOrg->getStride(component), |
---|
| 537 | pcPicYuvTrueOrg->getWidth(component), |
---|
| 538 | pcPicYuvTrueOrg->getHeight(component), |
---|
| 539 | isTopField); |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | // compute image characteristics |
---|
| 543 | if ( getUseAdaptiveQP() ) |
---|
| 544 | { |
---|
| 545 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcField ) ); |
---|
| 546 | } |
---|
[655] | 547 | } |
---|
[1313] | 548 | |
---|
| 549 | if ( m_iNumPicRcvd && ((flush&&fieldNum==1) || (m_iPOCLast/2)==0 || m_iNumPicRcvd==m_iGOPSize ) ) |
---|
[655] | 550 | { |
---|
[1313] | 551 | // compress GOP |
---|
| 552 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff, snrCSC, m_printFrameMSE); |
---|
| 553 | |
---|
| 554 | iNumEncoded += m_iNumPicRcvd; |
---|
| 555 | m_uiNumAllPicCoded += m_iNumPicRcvd; |
---|
| 556 | m_iNumPicRcvd = 0; |
---|
[655] | 557 | } |
---|
| 558 | } |
---|
| 559 | } |
---|
| 560 | #endif |
---|
[2] | 561 | // ==================================================================================================================== |
---|
| 562 | // Protected member functions |
---|
| 563 | // ==================================================================================================================== |
---|
| 564 | |
---|
| 565 | /** |
---|
| 566 | - Application has picture buffer list with size of GOP + 1 |
---|
| 567 | - Picture buffer list acts like as ring buffer |
---|
| 568 | - End of the list has the latest picture |
---|
| 569 | . |
---|
| 570 | \retval rpcPic obtained picture buffer |
---|
| 571 | */ |
---|
| 572 | Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic ) |
---|
| 573 | { |
---|
[1313] | 574 | // At this point, the SPS and PPS can be considered activated - they are copied to the new TComPic. |
---|
| 575 | |
---|
[1321] | 576 | #if NH_MV |
---|
| 577 | TComList<TComPic*>& cListPic = *(m_ivPicLists->getSubDpb(getLayerId(), false) ); |
---|
| 578 | TComSlice::sortPicList(cListPic); |
---|
| 579 | #else |
---|
[2] | 580 | TComSlice::sortPicList(m_cListPic); |
---|
[1321] | 581 | #endif |
---|
[1313] | 582 | |
---|
| 583 | |
---|
[1321] | 584 | #if NH_MV |
---|
| 585 | if (cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
---|
| 586 | { |
---|
| 587 | TComList<TComPic*>::iterator iterPic = cListPic.begin(); |
---|
| 588 | Int iSize = Int( cListPic.size() ); |
---|
| 589 | #else |
---|
[56] | 590 | if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
---|
[2] | 591 | { |
---|
[56] | 592 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 593 | Int iSize = Int( m_cListPic.size() ); |
---|
[1321] | 594 | #endif |
---|
[56] | 595 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 596 | { |
---|
[608] | 597 | rpcPic = *(iterPic++); |
---|
[56] | 598 | if(rpcPic->getSlice(0)->isReferenced() == false) |
---|
[608] | 599 | { |
---|
| 600 | break; |
---|
| 601 | } |
---|
[56] | 602 | } |
---|
[2] | 603 | } |
---|
| 604 | else |
---|
| 605 | { |
---|
[608] | 606 | if ( getUseAdaptiveQP() ) |
---|
| 607 | { |
---|
| 608 | TEncPic* pcEPic = new TEncPic; |
---|
[1313] | 609 | pcEPic->create( m_cSPS, m_cPPS, m_cPPS.getMaxCuDQPDepth()+1, false); |
---|
[608] | 610 | rpcPic = pcEPic; |
---|
| 611 | } |
---|
| 612 | else |
---|
| 613 | { |
---|
| 614 | rpcPic = new TComPic; |
---|
[1313] | 615 | rpcPic->create( m_cSPS, m_cPPS, false ); |
---|
| 616 | } |
---|
[608] | 617 | |
---|
[1321] | 618 | #if NH_MV |
---|
| 619 | cListPic.pushBack( rpcPic ); |
---|
| 620 | #else |
---|
[56] | 621 | m_cListPic.pushBack( rpcPic ); |
---|
[1321] | 622 | #endif |
---|
[2] | 623 | } |
---|
| 624 | rpcPic->setReconMark (false); |
---|
[1313] | 625 | |
---|
[2] | 626 | m_iPOCLast++; |
---|
| 627 | m_iNumPicRcvd++; |
---|
[1313] | 628 | |
---|
[2] | 629 | rpcPic->getSlice(0)->setPOC( m_iPOCLast ); |
---|
| 630 | // mark it should be extended |
---|
| 631 | rpcPic->getPicYuvRec()->setBorderExtension(false); |
---|
[1313] | 632 | #if NH_MV |
---|
[608] | 633 | rpcPic->getPicYuvOrg()->setBorderExtension(false); |
---|
[622] | 634 | #endif |
---|
[1313] | 635 | |
---|
[2] | 636 | } |
---|
| 637 | |
---|
[1313] | 638 | Void TEncTop::xInitVPS() |
---|
| 639 | { |
---|
| 640 | // The SPS must have already been set up. |
---|
| 641 | // set the VPS profile information. |
---|
| 642 | #if NH_MV |
---|
| 643 | // Do initialization in TAppEncTop |
---|
| 644 | #else |
---|
| 645 | *m_cVPS.getPTL() = *m_cSPS.getPTL(); |
---|
| 646 | m_cVPS.setMaxOpSets(1); |
---|
| 647 | m_cVPS.getTimingInfo()->setTimingInfoPresentFlag ( false ); |
---|
| 648 | m_cVPS.setNumHrdParameters( 0 ); |
---|
| 649 | |
---|
| 650 | m_cVPS.createHrdParamBuffer(); |
---|
| 651 | for( UInt i = 0; i < m_cVPS.getNumHrdParameters(); i ++ ) |
---|
| 652 | { |
---|
| 653 | m_cVPS.setHrdOpSetIdx( 0, i ); |
---|
| 654 | m_cVPS.setCprmsPresentFlag( false, i ); |
---|
| 655 | // Set up HrdParameters here. |
---|
| 656 | } |
---|
| 657 | #endif |
---|
| 658 | } |
---|
| 659 | |
---|
[2] | 660 | Void TEncTop::xInitSPS() |
---|
| 661 | { |
---|
[1313] | 662 | #if NH_MV |
---|
[608] | 663 | m_cSPS.setSPSId( getLayerIdInVps() ); |
---|
| 664 | m_cSPS.setLayerId( getLayerId() ); |
---|
[872] | 665 | // Code below needs to be moved to VPS |
---|
| 666 | #endif |
---|
[608] | 667 | ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL(); |
---|
| 668 | profileTierLevel.setLevelIdc(m_level); |
---|
| 669 | profileTierLevel.setTierFlag(m_levelTier); |
---|
| 670 | profileTierLevel.setProfileIdc(m_profile); |
---|
| 671 | profileTierLevel.setProfileCompatibilityFlag(m_profile, 1); |
---|
| 672 | profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
| 673 | profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
| 674 | profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
| 675 | profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
[1313] | 676 | profileTierLevel.setBitDepthConstraint(m_bitDepthConstraintValue); |
---|
| 677 | profileTierLevel.setChromaFormatConstraint(m_chromaFormatConstraintValue); |
---|
| 678 | profileTierLevel.setIntraConstraintFlag(m_intraConstraintFlag); |
---|
| 679 | profileTierLevel.setOnePictureOnlyConstraintFlag(m_onePictureOnlyConstraintFlag); |
---|
| 680 | profileTierLevel.setLowerBitRateConstraintFlag(m_lowerBitRateConstraintFlag); |
---|
| 681 | |
---|
| 682 | if ((m_profile == Profile::MAIN10) && (m_bitDepth[CHANNEL_TYPE_LUMA] == 8) && (m_bitDepth[CHANNEL_TYPE_CHROMA] == 8)) |
---|
[608] | 683 | { |
---|
| 684 | /* The above constraint is equal to Profile::MAIN */ |
---|
| 685 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN, 1); |
---|
| 686 | } |
---|
| 687 | if (m_profile == Profile::MAIN) |
---|
| 688 | { |
---|
| 689 | /* A Profile::MAIN10 decoder can always decode Profile::MAIN */ |
---|
| 690 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN10, 1); |
---|
| 691 | } |
---|
| 692 | /* XXX: should Main be marked as compatible with still picture? */ |
---|
| 693 | /* XXX: may be a good idea to refactor the above into a function |
---|
| 694 | * that chooses the actual compatibility based upon options */ |
---|
[1313] | 695 | #if NH_MV |
---|
[738] | 696 | m_cSPS.setUpdateRepFormatFlag ( false ); |
---|
[1066] | 697 | Bool multiLayerExtensionFlag = ( getLayerId() > 0 ) && ( m_cVPS->getNumRefLayers( getLayerId() ) > 0 ); |
---|
| 698 | |
---|
| 699 | m_cSPS.setSpsExtOrMaxSubLayersMinus1( multiLayerExtensionFlag ? 7 : m_maxTempLayer - 1 ); |
---|
| 700 | if ( multiLayerExtensionFlag ) |
---|
| 701 | { |
---|
| 702 | m_cSPS.setSpsInferScalingListFlag ( true ); |
---|
| 703 | m_cSPS.setSpsScalingListRefLayerId( m_cVPS->getIdRefLayer( getLayerId(), 0 ) ); |
---|
[1313] | 704 | #if NH_MV |
---|
[1179] | 705 | if ( m_bUseDisparitySearchRangeRestriction ) |
---|
| 706 | { |
---|
| 707 | m_cSPS.setInterViewMvVertConstraintFlag ( true ) ; |
---|
| 708 | } |
---|
| 709 | #endif |
---|
| 710 | } |
---|
[1066] | 711 | m_cSPS.setSpsExtensionPresentFlag ( true ); |
---|
[964] | 712 | m_cSPS.setSpsMultilayerExtensionFlag ( true ); |
---|
[1313] | 713 | #if NH_3D |
---|
[964] | 714 | m_cSPS.setSps3dExtensionFlag ( true ); |
---|
[622] | 715 | #endif |
---|
[738] | 716 | #endif |
---|
[1313] | 717 | |
---|
| 718 | m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth ); |
---|
| 719 | m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight ); |
---|
| 720 | m_cSPS.setConformanceWindow ( m_conformanceWindow ); |
---|
| 721 | m_cSPS.setMaxCUWidth ( m_maxCUWidth ); |
---|
| 722 | m_cSPS.setMaxCUHeight ( m_maxCUHeight ); |
---|
| 723 | m_cSPS.setMaxTotalCUDepth ( m_maxTotalCUDepth ); |
---|
| 724 | #if NH_3D |
---|
| 725 | assert( !getIsDepth() || m_chromaFormatIDC == CHROMA_400 ); |
---|
[1179] | 726 | #endif |
---|
[1313] | 727 | m_cSPS.setChromaFormatIdc( m_chromaFormatIDC); |
---|
| 728 | m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize); |
---|
[608] | 729 | |
---|
[1313] | 730 | Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getLog2DiffMaxMinCodingBlockSize() ); |
---|
[608] | 731 | Int log2MinCUSize = 0; |
---|
| 732 | while(minCUSize > 1) |
---|
| 733 | { |
---|
| 734 | minCUSize >>= 1; |
---|
| 735 | log2MinCUSize++; |
---|
| 736 | } |
---|
| 737 | |
---|
| 738 | m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize); |
---|
[1313] | 739 | |
---|
[56] | 740 | m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize); |
---|
| 741 | m_cSPS.setUsePCM ( m_usePCM ); |
---|
| 742 | m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize ); |
---|
[2] | 743 | |
---|
| 744 | m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); |
---|
| 745 | m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize ); |
---|
| 746 | m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter ); |
---|
| 747 | m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra ); |
---|
[608] | 748 | |
---|
[1313] | 749 | m_cSPS.setTMVPFlagsPresent((getTMVPModeId() == 2 || getTMVPModeId() == 1)); |
---|
| 750 | |
---|
[56] | 751 | m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
[2] | 752 | |
---|
[56] | 753 | m_cSPS.setUseAMP ( m_useAMP ); |
---|
[2] | 754 | |
---|
[1313] | 755 | for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++) |
---|
[56] | 756 | { |
---|
[1313] | 757 | m_cSPS.setBitDepth (ChannelType(channelType), m_bitDepth[channelType] ); |
---|
| 758 | #if O0043_BEST_EFFORT_DECODING |
---|
| 759 | m_cSPS.setStreamBitDepth(ChannelType(channelType), m_bitDepth[channelType] ); |
---|
| 760 | #endif |
---|
| 761 | m_cSPS.setQpBDOffset (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8))); |
---|
| 762 | m_cSPS.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType] ); |
---|
[56] | 763 | } |
---|
[1313] | 764 | #if NH_MV |
---|
| 765 | m_cSPS.inferRepFormat( m_cVPS, getLayerId(), true ); |
---|
| 766 | #endif |
---|
| 767 | m_cSPS.setUseSAO( m_bUseSAO ); |
---|
[56] | 768 | |
---|
| 769 | m_cSPS.setMaxTLayers( m_maxTempLayer ); |
---|
[608] | 770 | m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false ); |
---|
[1313] | 771 | |
---|
| 772 | for (Int i = 0; i < min(m_cSPS.getMaxTLayers(),(UInt) MAX_TLAYER); i++ ) |
---|
[56] | 773 | { |
---|
| 774 | m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); |
---|
| 775 | m_cSPS.setNumReorderPics(m_numReorderPics[i], i); |
---|
| 776 | } |
---|
[1313] | 777 | #if NH_MV |
---|
[964] | 778 | for ( Int ols = 0; ols < m_cVPS->getNumOutputLayerSets(); ols++) |
---|
| 779 | { |
---|
| 780 | // Check MaxDecPicBuffering |
---|
| 781 | const std::vector<Int>& targetDecLayerIdList = m_cVPS->getTargetDecLayerIdList( m_cVPS->olsIdxToLsIdx( ols )); |
---|
| 782 | for( Int is = 0; is < targetDecLayerIdList.size(); is++ ) |
---|
| 783 | { |
---|
[1066] | 784 | if ( m_cVPS->getNecessaryLayerFlag( ols, is ) ) |
---|
| 785 | { |
---|
| 786 | m_cSPS.inferSpsMaxDecPicBufferingMinus1( m_cVPS, ols, targetDecLayerIdList[is], true ); |
---|
| 787 | } |
---|
[964] | 788 | } |
---|
| 789 | } |
---|
| 790 | #endif |
---|
[42] | 791 | |
---|
[56] | 792 | |
---|
[1313] | 793 | m_cSPS.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag ); |
---|
| 794 | m_cSPS.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 ); |
---|
[608] | 795 | m_cSPS.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
[1313] | 796 | m_cSPS.setVuiParametersPresentFlag(getVuiParametersPresentFlag()); |
---|
[210] | 797 | |
---|
[608] | 798 | if (m_cSPS.getVuiParametersPresentFlag()) |
---|
[56] | 799 | { |
---|
[608] | 800 | TComVUI* pcVUI = m_cSPS.getVuiParameters(); |
---|
[1084] | 801 | pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag()); |
---|
[608] | 802 | pcVUI->setAspectRatioIdc(getAspectRatioIdc()); |
---|
| 803 | pcVUI->setSarWidth(getSarWidth()); |
---|
| 804 | pcVUI->setSarHeight(getSarHeight()); |
---|
| 805 | pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag()); |
---|
| 806 | pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag()); |
---|
[1313] | 807 | #if NH_MV |
---|
[738] | 808 | pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag() && getLayerId() == 0 ); |
---|
| 809 | #else |
---|
[1313] | 810 | pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag()); |
---|
[738] | 811 | #endif |
---|
[608] | 812 | pcVUI->setVideoFormat(getVideoFormat()); |
---|
| 813 | pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag()); |
---|
| 814 | pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag()); |
---|
| 815 | pcVUI->setColourPrimaries(getColourPrimaries()); |
---|
| 816 | pcVUI->setTransferCharacteristics(getTransferCharacteristics()); |
---|
| 817 | pcVUI->setMatrixCoefficients(getMatrixCoefficients()); |
---|
| 818 | pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag()); |
---|
| 819 | pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField()); |
---|
| 820 | pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField()); |
---|
| 821 | pcVUI->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag()); |
---|
| 822 | pcVUI->setDefaultDisplayWindow(getDefaultDisplayWindow()); |
---|
| 823 | pcVUI->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag()); |
---|
| 824 | pcVUI->setFieldSeqFlag(false); |
---|
| 825 | pcVUI->setHrdParametersPresentFlag(false); |
---|
| 826 | pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag()); |
---|
| 827 | pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1 (getNumTicksPocDiffOneMinus1() ); |
---|
| 828 | pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag()); |
---|
| 829 | pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag()); |
---|
| 830 | pcVUI->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag()); |
---|
| 831 | pcVUI->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc()); |
---|
| 832 | pcVUI->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom()); |
---|
| 833 | pcVUI->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom()); |
---|
| 834 | pcVUI->setLog2MaxMvLengthHorizontal(getLog2MaxMvLengthHorizontal()); |
---|
| 835 | pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical()); |
---|
[2] | 836 | } |
---|
[1313] | 837 | m_cSPS.setNumLongTermRefPicSPS(NUM_LONG_TERM_REF_PIC_SPS); |
---|
| 838 | assert (NUM_LONG_TERM_REF_PIC_SPS <= MAX_NUM_LONG_TERM_REF_PICS); |
---|
| 839 | for (Int k = 0; k < NUM_LONG_TERM_REF_PIC_SPS; k++) |
---|
| 840 | { |
---|
| 841 | m_cSPS.setLtRefPicPocLsbSps(k, 0); |
---|
| 842 | m_cSPS.setUsedByCurrPicLtSPSFlag(k, 0); |
---|
| 843 | } |
---|
| 844 | if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() ) |
---|
| 845 | { |
---|
| 846 | xInitHrdParameters(); |
---|
| 847 | } |
---|
| 848 | if( getBufferingPeriodSEIEnabled() || getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() ) |
---|
| 849 | { |
---|
| 850 | m_cSPS.getVuiParameters()->setHrdParametersPresentFlag( true ); |
---|
| 851 | } |
---|
| 852 | |
---|
| 853 | // Set up SPS range extension settings |
---|
| 854 | m_cSPS.getSpsRangeExtension().setTransformSkipRotationEnabledFlag(m_transformSkipRotationEnabledFlag); |
---|
| 855 | m_cSPS.getSpsRangeExtension().setTransformSkipContextEnabledFlag(m_transformSkipContextEnabledFlag); |
---|
| 856 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
| 857 | { |
---|
| 858 | m_cSPS.getSpsRangeExtension().setRdpcmEnabledFlag(RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]); |
---|
| 859 | } |
---|
| 860 | m_cSPS.getSpsRangeExtension().setExtendedPrecisionProcessingFlag(m_extendedPrecisionProcessingFlag); |
---|
| 861 | m_cSPS.getSpsRangeExtension().setIntraSmoothingDisabledFlag( m_intraSmoothingDisabledFlag ); |
---|
| 862 | m_cSPS.getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag(m_highPrecisionOffsetsEnabledFlag); |
---|
| 863 | m_cSPS.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag); |
---|
| 864 | m_cSPS.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag); |
---|
| 865 | #if NH_MV |
---|
| 866 | m_cSPS.setSpsRangeExtensionsFlag( m_cSPS.getSpsRangeExtension().settingsDifferFromDefaults() ); |
---|
| 867 | #endif |
---|
| 868 | |
---|
[56] | 869 | } |
---|
[2] | 870 | |
---|
[1313] | 871 | Void TEncTop::xInitHrdParameters() |
---|
| 872 | { |
---|
| 873 | Bool useSubCpbParams = (getSliceMode() > 0) || (getSliceSegmentMode() > 0); |
---|
| 874 | Int bitRate = getTargetBitrate(); |
---|
| 875 | Bool isRandomAccess = getIntraPeriod() > 0; |
---|
| 876 | |
---|
| 877 | if( !getVuiParametersPresentFlag() ) |
---|
| 878 | { |
---|
| 879 | return; |
---|
| 880 | } |
---|
| 881 | |
---|
| 882 | TComVUI *vui = m_cSPS.getVuiParameters(); |
---|
| 883 | TComHRD *hrd = vui->getHrdParameters(); |
---|
| 884 | |
---|
| 885 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
| 886 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
| 887 | switch( getFrameRate() ) |
---|
| 888 | { |
---|
| 889 | case 24: |
---|
| 890 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 891 | break; |
---|
| 892 | case 25: |
---|
| 893 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 894 | break; |
---|
| 895 | case 30: |
---|
| 896 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 897 | break; |
---|
| 898 | case 50: |
---|
| 899 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 900 | break; |
---|
| 901 | case 60: |
---|
| 902 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 903 | break; |
---|
| 904 | default: |
---|
| 905 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
| 906 | break; |
---|
| 907 | } |
---|
| 908 | |
---|
| 909 | Bool rateCnt = ( bitRate > 0 ); |
---|
| 910 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
| 911 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
| 912 | |
---|
| 913 | hrd->setSubPicCpbParamsPresentFlag( useSubCpbParams ); |
---|
| 914 | |
---|
| 915 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 916 | { |
---|
| 917 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
| 918 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
| 919 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
| 920 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
| 921 | } |
---|
| 922 | else |
---|
| 923 | { |
---|
| 924 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
| 925 | } |
---|
| 926 | |
---|
| 927 | hrd->setBitRateScale( 4 ); // in units of 2^( 6 + 4 ) = 1,024 bps |
---|
| 928 | hrd->setCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit |
---|
| 929 | hrd->setDuCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit |
---|
| 930 | |
---|
| 931 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
| 932 | if( isRandomAccess ) |
---|
| 933 | { |
---|
| 934 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
| 935 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
| 936 | } |
---|
| 937 | else |
---|
| 938 | { |
---|
| 939 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
| 940 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
| 941 | } |
---|
| 942 | |
---|
| 943 | // Note: parameters for all temporal layers are initialized with the same values |
---|
| 944 | Int i, j; |
---|
| 945 | UInt bitrateValue, cpbSizeValue; |
---|
| 946 | UInt duCpbSizeValue; |
---|
| 947 | UInt duBitRateValue = 0; |
---|
| 948 | |
---|
| 949 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
| 950 | { |
---|
| 951 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
| 952 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
| 953 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
| 954 | hrd->setCpbCntMinus1( i, 0 ); |
---|
| 955 | |
---|
| 956 | //! \todo check for possible PTL violations |
---|
| 957 | // BitRate[ i ] = ( bit_rate_value_minus1[ i ] + 1 ) * 2^( 6 + bit_rate_scale ) |
---|
| 958 | bitrateValue = bitRate / (1 << (6 + hrd->getBitRateScale()) ); // bitRate is in bits, so it needs to be scaled down |
---|
| 959 | // CpbSize[ i ] = ( cpb_size_value_minus1[ i ] + 1 ) * 2^( 4 + cpb_size_scale ) |
---|
| 960 | cpbSizeValue = bitRate / (1 << (4 + hrd->getCpbSizeScale()) ); // using bitRate results in 1 second CPB size |
---|
| 961 | |
---|
| 962 | // DU CPB size could be smaller (i.e. bitrateValue / number of DUs), but we don't know |
---|
| 963 | // in how many DUs the slice segment settings will result |
---|
| 964 | duCpbSizeValue = bitrateValue; |
---|
| 965 | duBitRateValue = cpbSizeValue; |
---|
| 966 | |
---|
| 967 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
| 968 | { |
---|
| 969 | hrd->setBitRateValueMinus1( i, j, 0, ( bitrateValue - 1 ) ); |
---|
| 970 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
| 971 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( duCpbSizeValue - 1 ) ); |
---|
| 972 | hrd->setDuBitRateValueMinus1( i, j, 0, ( duBitRateValue - 1 ) ); |
---|
| 973 | hrd->setCbrFlag( i, j, 0, false ); |
---|
| 974 | |
---|
| 975 | hrd->setBitRateValueMinus1( i, j, 1, ( bitrateValue - 1) ); |
---|
| 976 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
| 977 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( duCpbSizeValue - 1 ) ); |
---|
| 978 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
| 979 | hrd->setCbrFlag( i, j, 1, false ); |
---|
| 980 | } |
---|
| 981 | } |
---|
| 982 | } |
---|
| 983 | |
---|
| 984 | |
---|
[56] | 985 | Void TEncTop::xInitPPS() |
---|
| 986 | { |
---|
[1313] | 987 | #if NH_MV |
---|
[622] | 988 | m_cPPS.setLayerId( getLayerId() ); |
---|
[1313] | 989 | #if NH_3D |
---|
[1124] | 990 | // Check if this condition is still correct |
---|
| 991 | if( getVPS()->getNumRefListLayers( getLayerId() ) > 0 ) |
---|
| 992 | #else |
---|
[622] | 993 | if( getVPS()->getNumDirectRefLayers( getLayerId() ) > 0 ) |
---|
[1124] | 994 | #endif |
---|
[608] | 995 | { |
---|
| 996 | m_cPPS.setListsModificationPresentFlag( true ); |
---|
| 997 | } |
---|
| 998 | m_cPPS.setPPSId( getLayerIdInVps() ); |
---|
| 999 | m_cPPS.setSPSId( getLayerIdInVps() ); |
---|
[964] | 1000 | m_cPPS.setPpsMultilayerExtensionFlag ( true ); |
---|
[1313] | 1001 | #if NH_3D |
---|
| 1002 | // Might be used for DLT |
---|
| 1003 | m_cPPS.setPps3dExtensionFlag ( getIsDepth() ); |
---|
[964] | 1004 | #endif |
---|
[608] | 1005 | #endif |
---|
[758] | 1006 | |
---|
[1313] | 1007 | #if NH_3D_DLT |
---|
| 1008 | // create mapping from depth layer indexes to layer ids |
---|
| 1009 | Int j=0; |
---|
| 1010 | for( Int i=0; i<=getVPS()->getMaxLayersMinus1(); i++ ) |
---|
| 1011 | { |
---|
| 1012 | Int layerId = getVPS()->getLayerIdInNuh(i); |
---|
| 1013 | if( getVPS()->getDepthId(layerId) ) |
---|
| 1014 | m_cDLT.setDepthIdxToLayerId(j++, layerId); |
---|
| 1015 | } |
---|
| 1016 | m_cPPS.setDLT( m_cDLT ); |
---|
[758] | 1017 | #endif |
---|
[1313] | 1018 | |
---|
[56] | 1019 | m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); |
---|
| 1020 | Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; |
---|
[2] | 1021 | |
---|
[1313] | 1022 | if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) |
---|
| 1023 | { |
---|
| 1024 | bUseDQP = true; |
---|
| 1025 | } |
---|
[56] | 1026 | |
---|
[1313] | 1027 | if (m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING) |
---|
[56] | 1028 | { |
---|
[1313] | 1029 | bUseDQP=false; |
---|
| 1030 | } |
---|
| 1031 | |
---|
| 1032 | |
---|
| 1033 | if ( m_RCEnableRateControl ) |
---|
| 1034 | { |
---|
[56] | 1035 | m_cPPS.setUseDQP(true); |
---|
[1313] | 1036 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
| 1037 | } |
---|
| 1038 | else if(bUseDQP) |
---|
| 1039 | { |
---|
| 1040 | m_cPPS.setUseDQP(true); |
---|
[56] | 1041 | m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth ); |
---|
| 1042 | } |
---|
| 1043 | else |
---|
| 1044 | { |
---|
| 1045 | m_cPPS.setUseDQP(false); |
---|
| 1046 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
| 1047 | } |
---|
[2] | 1048 | |
---|
[1313] | 1049 | if ( m_diffCuChromaQpOffsetDepth >= 0 ) |
---|
[608] | 1050 | { |
---|
[1313] | 1051 | m_cPPS.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(m_diffCuChromaQpOffsetDepth); |
---|
| 1052 | m_cPPS.getPpsRangeExtension().clearChromaQpOffsetList(); |
---|
| 1053 | m_cPPS.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6); |
---|
| 1054 | /* todo, insert table entries from command line (NB, 0 should not be touched) */ |
---|
[655] | 1055 | } |
---|
[1313] | 1056 | else |
---|
| 1057 | { |
---|
| 1058 | m_cPPS.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(0); |
---|
| 1059 | m_cPPS.getPpsRangeExtension().clearChromaQpOffsetList(); |
---|
| 1060 | } |
---|
| 1061 | m_cPPS.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag); |
---|
| 1062 | m_cPPS.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA ]); |
---|
| 1063 | m_cPPS.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]); |
---|
[2] | 1064 | |
---|
[1313] | 1065 | m_cPPS.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset ); |
---|
| 1066 | m_cPPS.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset ); |
---|
[608] | 1067 | |
---|
| 1068 | m_cPPS.setEntropyCodingSyncEnabledFlag( m_iWaveFrontSynchro > 0 ); |
---|
| 1069 | m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) ); |
---|
| 1070 | m_cPPS.setUseWP( m_useWeightedPred ); |
---|
| 1071 | m_cPPS.setWPBiPred( m_useWeightedBiPred ); |
---|
[56] | 1072 | m_cPPS.setOutputFlagPresentFlag( false ); |
---|
[1313] | 1073 | #if NH_MV |
---|
| 1074 | m_cPPS.setNumExtraSliceHeaderBits( 2 ); |
---|
[608] | 1075 | #endif |
---|
[56] | 1076 | m_cPPS.setSignHideFlag(getSignHideFlag()); |
---|
[655] | 1077 | if ( getDeblockingFilterMetric() ) |
---|
| 1078 | { |
---|
| 1079 | m_cPPS.setDeblockingFilterOverrideEnabledFlag(true); |
---|
| 1080 | m_cPPS.setPicDisableDeblockingFilterFlag(false); |
---|
[1313] | 1081 | } |
---|
[655] | 1082 | else |
---|
| 1083 | { |
---|
[1313] | 1084 | m_cPPS.setDeblockingFilterOverrideEnabledFlag( !getLoopFilterOffsetInPPS() ); |
---|
| 1085 | m_cPPS.setPicDisableDeblockingFilterFlag( getLoopFilterDisable() ); |
---|
| 1086 | } |
---|
| 1087 | |
---|
| 1088 | if (! m_cPPS.getPicDisableDeblockingFilterFlag()) |
---|
| 1089 | { |
---|
| 1090 | m_cPPS.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() ); |
---|
| 1091 | m_cPPS.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() ); |
---|
[655] | 1092 | } |
---|
[1313] | 1093 | else |
---|
| 1094 | { |
---|
| 1095 | m_cPPS.setDeblockingFilterBetaOffsetDiv2(0); |
---|
| 1096 | m_cPPS.setDeblockingFilterTcOffsetDiv2(0); |
---|
| 1097 | } |
---|
| 1098 | |
---|
| 1099 | // deblockingFilterControlPresentFlag is true if any of the settings differ from the inferred values: |
---|
| 1100 | const Bool deblockingFilterControlPresentFlag = m_cPPS.getDeblockingFilterOverrideEnabledFlag() || |
---|
| 1101 | m_cPPS.getPicDisableDeblockingFilterFlag() || |
---|
| 1102 | m_cPPS.getDeblockingFilterBetaOffsetDiv2() != 0 || |
---|
| 1103 | m_cPPS.getDeblockingFilterTcOffsetDiv2() != 0; |
---|
| 1104 | |
---|
| 1105 | m_cPPS.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag); |
---|
| 1106 | |
---|
[608] | 1107 | m_cPPS.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 ); |
---|
[56] | 1108 | m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); |
---|
[608] | 1109 | m_cPPS.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
[1313] | 1110 | |
---|
| 1111 | |
---|
[608] | 1112 | Int histogram[MAX_NUM_REF + 1]; |
---|
| 1113 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
---|
| 1114 | { |
---|
| 1115 | histogram[i]=0; |
---|
| 1116 | } |
---|
[1313] | 1117 | for( Int i = 0; i < getGOPSize(); i++) |
---|
[608] | 1118 | { |
---|
| 1119 | assert(getGOPEntry(i).m_numRefPicsActive >= 0 && getGOPEntry(i).m_numRefPicsActive <= MAX_NUM_REF); |
---|
| 1120 | histogram[getGOPEntry(i).m_numRefPicsActive]++; |
---|
| 1121 | } |
---|
[1313] | 1122 | |
---|
[608] | 1123 | Int maxHist=-1; |
---|
| 1124 | Int bestPos=0; |
---|
| 1125 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
---|
| 1126 | { |
---|
| 1127 | if(histogram[i]>maxHist) |
---|
| 1128 | { |
---|
| 1129 | maxHist=histogram[i]; |
---|
| 1130 | bestPos=i; |
---|
| 1131 | } |
---|
| 1132 | } |
---|
| 1133 | assert(bestPos <= 15); |
---|
| 1134 | m_cPPS.setNumRefIdxL0DefaultActive(bestPos); |
---|
| 1135 | m_cPPS.setNumRefIdxL1DefaultActive(bestPos); |
---|
| 1136 | m_cPPS.setTransquantBypassEnableFlag(getTransquantBypassEnableFlag()); |
---|
| 1137 | m_cPPS.setUseTransformSkip( m_useTransformSkip ); |
---|
[1313] | 1138 | m_cPPS.getPpsRangeExtension().setLog2MaxTransformSkipBlockSize( m_log2MaxTransformSkipBlockSize ); |
---|
| 1139 | |
---|
| 1140 | if (m_sliceSegmentMode != NO_SLICES) |
---|
[608] | 1141 | { |
---|
| 1142 | m_cPPS.setDependentSliceSegmentsEnabledFlag( true ); |
---|
| 1143 | } |
---|
[2] | 1144 | } |
---|
| 1145 | |
---|
[56] | 1146 | //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. |
---|
[655] | 1147 | Void TEncTop::xInitRPS(Bool isFieldCoding) |
---|
[2] | 1148 | { |
---|
[56] | 1149 | TComReferencePictureSet* rps; |
---|
[1313] | 1150 | |
---|
| 1151 | m_cSPS.createRPSList(getGOPSize() + m_extraRPSs + 1); |
---|
[608] | 1152 | TComRPSList* rpsList = m_cSPS.getRPSList(); |
---|
| 1153 | |
---|
[1313] | 1154 | for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) |
---|
[56] | 1155 | { |
---|
[608] | 1156 | GOPEntry ge = getGOPEntry(i); |
---|
| 1157 | rps = rpsList->getReferencePictureSet(i); |
---|
[56] | 1158 | rps->setNumberOfPictures(ge.m_numRefPics); |
---|
| 1159 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
| 1160 | Int numNeg = 0; |
---|
| 1161 | Int numPos = 0; |
---|
| 1162 | for( Int j = 0; j < ge.m_numRefPics; j++) |
---|
[2] | 1163 | { |
---|
[56] | 1164 | rps->setDeltaPOC(j,ge.m_referencePics[j]); |
---|
| 1165 | rps->setUsed(j,ge.m_usedByCurrPic[j]); |
---|
| 1166 | if(ge.m_referencePics[j]>0) |
---|
| 1167 | { |
---|
| 1168 | numPos++; |
---|
| 1169 | } |
---|
| 1170 | else |
---|
| 1171 | { |
---|
| 1172 | numNeg++; |
---|
| 1173 | } |
---|
[2] | 1174 | } |
---|
[56] | 1175 | rps->setNumberOfNegativePictures(numNeg); |
---|
| 1176 | rps->setNumberOfPositivePictures(numPos); |
---|
[608] | 1177 | |
---|
| 1178 | // handle inter RPS intialization from the config file. |
---|
| 1179 | rps->setInterRPSPrediction(ge.m_interRPSPrediction > 0); // not very clean, converting anything > 0 to true. |
---|
| 1180 | rps->setDeltaRIdxMinus1(0); // index to the Reference RPS is always the previous one. |
---|
[1313] | 1181 | TComReferencePictureSet* RPSRef = i>0 ? rpsList->getReferencePictureSet(i-1): NULL; // get the reference RPS |
---|
[608] | 1182 | |
---|
| 1183 | if (ge.m_interRPSPrediction == 2) // Automatic generation of the inter RPS idc based on the RIdx provided. |
---|
| 1184 | { |
---|
[1313] | 1185 | assert (RPSRef!=NULL); |
---|
[608] | 1186 | Int deltaRPS = getGOPEntry(i-1).m_POC - ge.m_POC; // the ref POC - current POC |
---|
| 1187 | Int numRefDeltaPOC = RPSRef->getNumberOfPictures(); |
---|
| 1188 | |
---|
| 1189 | rps->setDeltaRPS(deltaRPS); // set delta RPS |
---|
| 1190 | rps->setNumRefIdc(numRefDeltaPOC+1); // set the numRefIdc to the number of pictures in the reference RPS + 1. |
---|
| 1191 | Int count=0; |
---|
| 1192 | for (Int j = 0; j <= numRefDeltaPOC; j++ ) // cycle through pics in reference RPS. |
---|
| 1193 | { |
---|
| 1194 | Int RefDeltaPOC = (j<numRefDeltaPOC)? RPSRef->getDeltaPOC(j): 0; // if it is the last decoded picture, set RefDeltaPOC = 0 |
---|
| 1195 | rps->setRefIdc(j, 0); |
---|
| 1196 | for (Int k = 0; k < rps->getNumberOfPictures(); k++ ) // cycle through pics in current RPS. |
---|
| 1197 | { |
---|
[1313] | 1198 | if (rps->getDeltaPOC(k) == ( RefDeltaPOC + deltaRPS)) // if the current RPS has a same picture as the reference RPS. |
---|
[608] | 1199 | { |
---|
| 1200 | rps->setRefIdc(j, (rps->getUsed(k)?1:2)); |
---|
| 1201 | count++; |
---|
| 1202 | break; |
---|
| 1203 | } |
---|
| 1204 | } |
---|
| 1205 | } |
---|
| 1206 | if (count != rps->getNumberOfPictures()) |
---|
| 1207 | { |
---|
| 1208 | 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"); |
---|
| 1209 | rps->setInterRPSPrediction(0); |
---|
| 1210 | } |
---|
| 1211 | } |
---|
| 1212 | else if (ge.m_interRPSPrediction == 1) // inter RPS idc based on the RefIdc values provided in config file. |
---|
| 1213 | { |
---|
[1313] | 1214 | assert (RPSRef!=NULL); |
---|
[608] | 1215 | rps->setDeltaRPS(ge.m_deltaRPS); |
---|
| 1216 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
| 1217 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1218 | { |
---|
| 1219 | rps->setRefIdc(j, ge.m_refIdc[j]); |
---|
| 1220 | } |
---|
[1313] | 1221 | // the following code overwrite the deltaPOC and Used by current values read from the config file with the ones |
---|
[608] | 1222 | // computed from the RefIdc. A warning is printed if they are not identical. |
---|
| 1223 | numNeg = 0; |
---|
| 1224 | numPos = 0; |
---|
| 1225 | TComReferencePictureSet RPSTemp; // temporary variable |
---|
| 1226 | |
---|
| 1227 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1228 | { |
---|
| 1229 | if (ge.m_refIdc[j]) |
---|
| 1230 | { |
---|
| 1231 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
---|
| 1232 | RPSTemp.setDeltaPOC((numNeg+numPos),deltaPOC); |
---|
| 1233 | RPSTemp.setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
---|
| 1234 | if (deltaPOC<0) |
---|
| 1235 | { |
---|
| 1236 | numNeg++; |
---|
| 1237 | } |
---|
| 1238 | else |
---|
| 1239 | { |
---|
| 1240 | numPos++; |
---|
| 1241 | } |
---|
| 1242 | } |
---|
| 1243 | } |
---|
| 1244 | if (numNeg != rps->getNumberOfNegativePictures()) |
---|
| 1245 | { |
---|
| 1246 | printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
| 1247 | rps->setNumberOfNegativePictures(numNeg); |
---|
[655] | 1248 | rps->setNumberOfPictures(numNeg+numPos); |
---|
[608] | 1249 | } |
---|
| 1250 | if (numPos != rps->getNumberOfPositivePictures()) |
---|
| 1251 | { |
---|
| 1252 | printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
| 1253 | rps->setNumberOfPositivePictures(numPos); |
---|
[655] | 1254 | rps->setNumberOfPictures(numNeg+numPos); |
---|
[608] | 1255 | } |
---|
| 1256 | RPSTemp.setNumberOfPictures(numNeg+numPos); |
---|
| 1257 | RPSTemp.setNumberOfNegativePictures(numNeg); |
---|
| 1258 | RPSTemp.sortDeltaPOC(); // sort the created delta POC before comparing |
---|
[1313] | 1259 | // check if Delta POC and Used are the same |
---|
[608] | 1260 | // print warning if they are not. |
---|
| 1261 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1262 | { |
---|
| 1263 | if (RPSTemp.getDeltaPOC(j) != rps->getDeltaPOC(j)) |
---|
| 1264 | { |
---|
| 1265 | printf("Warning: delta POC is different between intra RPS and inter RPS specified in the config file.\n"); |
---|
| 1266 | rps->setDeltaPOC(j,RPSTemp.getDeltaPOC(j)); |
---|
| 1267 | } |
---|
| 1268 | if (RPSTemp.getUsed(j) != rps->getUsed(j)) |
---|
| 1269 | { |
---|
| 1270 | printf("Warning: Used by Current in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
| 1271 | rps->setUsed(j,RPSTemp.getUsed(j)); |
---|
| 1272 | } |
---|
| 1273 | } |
---|
| 1274 | } |
---|
[56] | 1275 | } |
---|
[1313] | 1276 | //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. |
---|
| 1277 | //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS. |
---|
| 1278 | if (isFieldCoding) |
---|
[655] | 1279 | { |
---|
| 1280 | rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs); |
---|
| 1281 | rps->setNumberOfPictures(1); |
---|
| 1282 | rps->setNumberOfNegativePictures(1); |
---|
| 1283 | rps->setNumberOfPositivePictures(0); |
---|
| 1284 | rps->setNumberOfLongtermPictures(0); |
---|
| 1285 | rps->setDeltaPOC(0,-1); |
---|
| 1286 | rps->setPOC(0,0); |
---|
| 1287 | rps->setUsed(0,true); |
---|
| 1288 | rps->setInterRPSPrediction(false); |
---|
| 1289 | rps->setDeltaRIdxMinus1(0); |
---|
| 1290 | rps->setDeltaRPS(0); |
---|
| 1291 | rps->setNumRefIdc(0); |
---|
[1313] | 1292 | } |
---|
[56] | 1293 | } |
---|
[2] | 1294 | |
---|
[1313] | 1295 | // This is a function that |
---|
| 1296 | // determines what Reference Picture Set to use |
---|
[56] | 1297 | // for a specific slice (with POC = POCCurr) |
---|
[608] | 1298 | Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid ) |
---|
[56] | 1299 | { |
---|
[1313] | 1300 | #if NH_MV |
---|
[608] | 1301 | if( slice->getRapPicFlag() == true && getLayerId() > 0 && POCCurr == 0 ) |
---|
[56] | 1302 | { |
---|
| 1303 | TComReferencePictureSet* rps = slice->getLocalRPS(); |
---|
| 1304 | rps->setNumberOfNegativePictures(0); |
---|
| 1305 | rps->setNumberOfPositivePictures(0); |
---|
| 1306 | rps->setNumberOfLongtermPictures(0); |
---|
| 1307 | rps->setNumberOfPictures(0); |
---|
| 1308 | slice->setRPS(rps); |
---|
| 1309 | } |
---|
| 1310 | else |
---|
| 1311 | { |
---|
[608] | 1312 | #endif |
---|
| 1313 | slice->setRPSidx(GOPid); |
---|
[2] | 1314 | |
---|
[608] | 1315 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
[1313] | 1316 | { |
---|
[608] | 1317 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
---|
| 1318 | { |
---|
| 1319 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
---|
| 1320 | if(POCIndex == 0) |
---|
[56] | 1321 | { |
---|
[608] | 1322 | POCIndex = m_uiIntraPeriod; |
---|
[56] | 1323 | } |
---|
[608] | 1324 | if(POCIndex == m_GOPList[extraNum].m_POC) |
---|
[56] | 1325 | { |
---|
[608] | 1326 | slice->setRPSidx(extraNum); |
---|
[56] | 1327 | } |
---|
| 1328 | } |
---|
[608] | 1329 | else |
---|
| 1330 | { |
---|
| 1331 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
| 1332 | { |
---|
| 1333 | slice->setRPSidx(extraNum); |
---|
| 1334 | } |
---|
| 1335 | } |
---|
| 1336 | } |
---|
[1313] | 1337 | |
---|
[655] | 1338 | if(POCCurr == 1 && slice->getPic()->isField()) |
---|
| 1339 | { |
---|
| 1340 | slice->setRPSidx(m_iGOPSize+m_extraRPSs); |
---|
| 1341 | } |
---|
[2] | 1342 | |
---|
[1313] | 1343 | const TComReferencePictureSet *rps = (slice->getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); |
---|
| 1344 | slice->setRPS(rps); |
---|
| 1345 | #if NH_MV |
---|
[56] | 1346 | } |
---|
[608] | 1347 | #endif |
---|
| 1348 | |
---|
[2] | 1349 | } |
---|
| 1350 | |
---|
[1313] | 1351 | Int TEncTop::getReferencePictureSetIdxForSOP(Int POCCurr, Int GOPid ) |
---|
[2] | 1352 | { |
---|
[1313] | 1353 | Int rpsIdx = GOPid; |
---|
[2] | 1354 | |
---|
[608] | 1355 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
[1313] | 1356 | { |
---|
[608] | 1357 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
---|
[2] | 1358 | { |
---|
[608] | 1359 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
---|
| 1360 | if(POCIndex == 0) |
---|
[2] | 1361 | { |
---|
[608] | 1362 | POCIndex = m_uiIntraPeriod; |
---|
[2] | 1363 | } |
---|
[608] | 1364 | if(POCIndex == m_GOPList[extraNum].m_POC) |
---|
[2] | 1365 | { |
---|
[608] | 1366 | rpsIdx = extraNum; |
---|
[2] | 1367 | } |
---|
| 1368 | } |
---|
[608] | 1369 | else |
---|
[56] | 1370 | { |
---|
[608] | 1371 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
[56] | 1372 | { |
---|
[608] | 1373 | rpsIdx = extraNum; |
---|
[56] | 1374 | } |
---|
| 1375 | } |
---|
[2] | 1376 | } |
---|
[56] | 1377 | |
---|
[608] | 1378 | return rpsIdx; |
---|
[56] | 1379 | } |
---|
| 1380 | |
---|
| 1381 | Void TEncTop::xInitPPSforTiles() |
---|
| 1382 | { |
---|
[1084] | 1383 | m_cPPS.setTileUniformSpacingFlag( m_tileUniformSpacingFlag ); |
---|
| 1384 | m_cPPS.setNumTileColumnsMinus1( m_iNumColumnsMinus1 ); |
---|
| 1385 | m_cPPS.setNumTileRowsMinus1( m_iNumRowsMinus1 ); |
---|
| 1386 | if( !m_tileUniformSpacingFlag ) |
---|
[608] | 1387 | { |
---|
[1084] | 1388 | m_cPPS.setTileColumnWidth( m_tileColumnWidth ); |
---|
| 1389 | m_cPPS.setTileRowHeight( m_tileRowHeight ); |
---|
[608] | 1390 | } |
---|
| 1391 | m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag ); |
---|
[56] | 1392 | |
---|
[608] | 1393 | // # substreams is "per tile" when tiles are independent. |
---|
[2] | 1394 | } |
---|
| 1395 | |
---|
[56] | 1396 | Void TEncCfg::xCheckGSParameters() |
---|
[2] | 1397 | { |
---|
[1313] | 1398 | Int iWidthInCU = ( m_iSourceWidth%m_maxCUWidth ) ? m_iSourceWidth/m_maxCUWidth + 1 : m_iSourceWidth/m_maxCUWidth; |
---|
| 1399 | Int iHeightInCU = ( m_iSourceHeight%m_maxCUHeight ) ? m_iSourceHeight/m_maxCUHeight + 1 : m_iSourceHeight/m_maxCUHeight; |
---|
[56] | 1400 | UInt uiCummulativeColumnWidth = 0; |
---|
| 1401 | UInt uiCummulativeRowHeight = 0; |
---|
| 1402 | |
---|
| 1403 | //check the column relative parameters |
---|
| 1404 | if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) ) |
---|
[2] | 1405 | { |
---|
[56] | 1406 | printf( "The number of columns is larger than the maximum allowed number of columns.\n" ); |
---|
| 1407 | exit( EXIT_FAILURE ); |
---|
[2] | 1408 | } |
---|
[56] | 1409 | |
---|
| 1410 | if( m_iNumColumnsMinus1 >= iWidthInCU ) |
---|
[2] | 1411 | { |
---|
[56] | 1412 | printf( "The current picture can not have so many columns.\n" ); |
---|
| 1413 | exit( EXIT_FAILURE ); |
---|
[2] | 1414 | } |
---|
[56] | 1415 | |
---|
[1084] | 1416 | if( m_iNumColumnsMinus1 && !m_tileUniformSpacingFlag ) |
---|
[2] | 1417 | { |
---|
[56] | 1418 | for(Int i=0; i<m_iNumColumnsMinus1; i++) |
---|
[608] | 1419 | { |
---|
[1084] | 1420 | uiCummulativeColumnWidth += m_tileColumnWidth[i]; |
---|
[608] | 1421 | } |
---|
[56] | 1422 | |
---|
| 1423 | if( uiCummulativeColumnWidth >= iWidthInCU ) |
---|
| 1424 | { |
---|
| 1425 | printf( "The width of the column is too large.\n" ); |
---|
| 1426 | exit( EXIT_FAILURE ); |
---|
| 1427 | } |
---|
[2] | 1428 | } |
---|
[56] | 1429 | |
---|
| 1430 | //check the row relative parameters |
---|
| 1431 | if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) ) |
---|
[2] | 1432 | { |
---|
[56] | 1433 | printf( "The number of rows is larger than the maximum allowed number of rows.\n" ); |
---|
| 1434 | exit( EXIT_FAILURE ); |
---|
[2] | 1435 | } |
---|
[56] | 1436 | |
---|
| 1437 | if( m_iNumRowsMinus1 >= iHeightInCU ) |
---|
[2] | 1438 | { |
---|
[56] | 1439 | printf( "The current picture can not have so many rows.\n" ); |
---|
| 1440 | exit( EXIT_FAILURE ); |
---|
[2] | 1441 | } |
---|
| 1442 | |
---|
[1084] | 1443 | if( m_iNumRowsMinus1 && !m_tileUniformSpacingFlag ) |
---|
[56] | 1444 | { |
---|
| 1445 | for(Int i=0; i<m_iNumRowsMinus1; i++) |
---|
[1313] | 1446 | { |
---|
[1084] | 1447 | uiCummulativeRowHeight += m_tileRowHeight[i]; |
---|
[1313] | 1448 | } |
---|
[56] | 1449 | |
---|
| 1450 | if( uiCummulativeRowHeight >= iHeightInCU ) |
---|
| 1451 | { |
---|
| 1452 | printf( "The height of the row is too large.\n" ); |
---|
| 1453 | exit( EXIT_FAILURE ); |
---|
| 1454 | } |
---|
| 1455 | } |
---|
[2] | 1456 | } |
---|
| 1457 | |
---|
[1313] | 1458 | #if NH_MV |
---|
[608] | 1459 | Int TEncTop::getFrameId(Int iGOPid) |
---|
| 1460 | { |
---|
| 1461 | if(m_iPOCLast == 0) |
---|
| 1462 | { |
---|
| 1463 | return(0 ); |
---|
| 1464 | } |
---|
| 1465 | else |
---|
| 1466 | { |
---|
| 1467 | return m_iPOCLast -m_iNumPicRcvd+ getGOPEntry(iGOPid).m_POC ; |
---|
| 1468 | } |
---|
| 1469 | } |
---|
| 1470 | |
---|
| 1471 | TComPic* TEncTop::getPic( Int poc ) |
---|
| 1472 | { |
---|
| 1473 | TComList<TComPic*>* listPic = getListPic(); |
---|
| 1474 | TComPic* pcPic = NULL; |
---|
| 1475 | for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++) |
---|
| 1476 | { |
---|
| 1477 | if( (*it)->getPOC() == poc ) |
---|
| 1478 | { |
---|
| 1479 | pcPic = *it ; |
---|
| 1480 | break ; |
---|
| 1481 | } |
---|
| 1482 | } |
---|
| 1483 | return pcPic; |
---|
| 1484 | } |
---|
[1313] | 1485 | |
---|
[608] | 1486 | #endif |
---|
| 1487 | |
---|
[1313] | 1488 | #if NH_3D_VSO |
---|
| 1489 | Void TEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset, Int maxCuHeight ) |
---|
[608] | 1490 | { |
---|
| 1491 | TRenModel* rendererModel = m_cRdCost.getRenModel(); |
---|
[1313] | 1492 | rendererModel->setupPart( iHorOffset, std::min( maxCuHeight, (Int) ( m_iSourceHeight - iHorOffset ) )) ; |
---|
[608] | 1493 | |
---|
| 1494 | Int iEncViewSIdx = m_cameraParameters->getBaseId2SortedId()[ iEncViewIdx ]; |
---|
| 1495 | |
---|
| 1496 | // setup base views |
---|
| 1497 | Int iNumOfBV = m_renderModelParameters->getNumOfBaseViewsForView( iEncViewSIdx, iEncContent ); |
---|
| 1498 | |
---|
| 1499 | for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ ) |
---|
| 1500 | { |
---|
| 1501 | Int iBaseViewSIdx; |
---|
| 1502 | Int iVideoDistMode; |
---|
| 1503 | Int iDepthDistMode; |
---|
| 1504 | |
---|
| 1505 | m_renderModelParameters->getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode ); |
---|
| 1506 | |
---|
| 1507 | AOT( iVideoDistMode < 0 || iVideoDistMode > 2 ); |
---|
| 1508 | |
---|
| 1509 | Int iBaseViewIdx = m_cameraParameters->getBaseSortedId2Id()[ iBaseViewSIdx ]; |
---|
| 1510 | |
---|
| 1511 | TComPicYuv* pcPicYuvVideoRec = m_ivPicLists->getPicYuv( iBaseViewIdx, false, iPoc, true ); |
---|
| 1512 | TComPicYuv* pcPicYuvDepthRec = m_ivPicLists->getPicYuv( iBaseViewIdx, true , iPoc, true ); |
---|
| 1513 | TComPicYuv* pcPicYuvVideoOrg = m_ivPicLists->getPicYuv( iBaseViewIdx, false, iPoc, false ); |
---|
| 1514 | TComPicYuv* pcPicYuvDepthOrg = m_ivPicLists->getPicYuv( iBaseViewIdx, true , iPoc, false ); |
---|
| 1515 | |
---|
| 1516 | TComPicYuv* pcPicYuvVideoRef = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg : NULL; |
---|
| 1517 | TComPicYuv* pcPicYuvDepthRef = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg : NULL; |
---|
| 1518 | |
---|
| 1519 | TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg : pcPicYuvVideoRec; |
---|
| 1520 | TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg : pcPicYuvDepthRec; |
---|
| 1521 | |
---|
| 1522 | AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) ); |
---|
| 1523 | AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) ); |
---|
| 1524 | AOT( pcPicYuvDepthTest == NULL ); |
---|
| 1525 | AOT( pcPicYuvVideoTest == NULL ); |
---|
| 1526 | |
---|
| 1527 | rendererModel->setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef ); |
---|
| 1528 | } |
---|
| 1529 | |
---|
| 1530 | rendererModel->setErrorMode( iEncViewSIdx, iEncContent, 0 ); |
---|
| 1531 | // setup virtual views |
---|
| 1532 | Int iNumOfSV = m_renderModelParameters->getNumOfModelsForView( iEncViewSIdx, iEncContent ); |
---|
| 1533 | for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ ) |
---|
| 1534 | { |
---|
| 1535 | Int iOrgRefBaseViewSIdx; |
---|
| 1536 | Int iLeftBaseViewSIdx; |
---|
| 1537 | Int iRightBaseViewSIdx; |
---|
| 1538 | Int iSynthViewRelNum; |
---|
| 1539 | Int iModelNum; |
---|
| 1540 | Int iBlendMode; |
---|
| 1541 | m_renderModelParameters->getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum ); |
---|
| 1542 | |
---|
| 1543 | Int iLeftBaseViewIdx = -1; |
---|
| 1544 | Int iRightBaseViewIdx = -1; |
---|
| 1545 | |
---|
| 1546 | TComPicYuv* pcPicYuvOrgRef = NULL; |
---|
| 1547 | Int** ppiShiftLUTLeft = NULL; |
---|
| 1548 | Int** ppiShiftLUTRight = NULL; |
---|
| 1549 | Int** ppiBaseShiftLUTLeft = NULL; |
---|
| 1550 | Int** ppiBaseShiftLUTRight = NULL; |
---|
| 1551 | |
---|
| 1552 | |
---|
| 1553 | Int iDistToLeft = -1; |
---|
| 1554 | |
---|
| 1555 | Int iSynthViewIdx = m_cameraParameters->synthRelNum2Idx( iSynthViewRelNum ); |
---|
| 1556 | |
---|
| 1557 | if ( iLeftBaseViewSIdx != -1 ) |
---|
| 1558 | { |
---|
| 1559 | iLeftBaseViewIdx = m_cameraParameters->getBaseSortedId2Id() [ iLeftBaseViewSIdx ]; |
---|
| 1560 | ppiShiftLUTLeft = m_cameraParameters->getSynthViewShiftLUTI()[ iLeftBaseViewIdx ][ iSynthViewIdx ]; |
---|
| 1561 | } |
---|
| 1562 | |
---|
| 1563 | if ( iRightBaseViewSIdx != -1 ) |
---|
| 1564 | { |
---|
| 1565 | iRightBaseViewIdx = m_cameraParameters->getBaseSortedId2Id() [iRightBaseViewSIdx ]; |
---|
| 1566 | ppiShiftLUTRight = m_cameraParameters->getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ]; |
---|
| 1567 | } |
---|
| 1568 | |
---|
| 1569 | if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 ) |
---|
| 1570 | { |
---|
| 1571 | iDistToLeft = m_cameraParameters->getRelDistLeft( iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx); |
---|
| 1572 | ppiBaseShiftLUTLeft = m_cameraParameters->getBaseViewShiftLUTI() [ iLeftBaseViewIdx ][ iRightBaseViewIdx ]; |
---|
| 1573 | ppiBaseShiftLUTRight = m_cameraParameters->getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx ]; |
---|
| 1574 | |
---|
| 1575 | } |
---|
| 1576 | |
---|
| 1577 | if ( iOrgRefBaseViewSIdx != -1 ) |
---|
| 1578 | { |
---|
| 1579 | pcPicYuvOrgRef = m_ivPicLists->getPicYuv( m_cameraParameters->getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , false, iPoc, false ); |
---|
| 1580 | AOF ( pcPicYuvOrgRef ); |
---|
| 1581 | } |
---|
| 1582 | |
---|
| 1583 | rendererModel->setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef ); |
---|
| 1584 | } |
---|
| 1585 | } |
---|
| 1586 | #endif |
---|
[1313] | 1587 | |
---|
[56] | 1588 | //! \} |
---|