[191] | 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-2013, 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 | #if FAST_BIT_EST |
---|
| 42 | #include "TLibCommon/ContextModel.h" |
---|
| 43 | #endif |
---|
| 44 | |
---|
| 45 | //! \ingroup TLibEncoder |
---|
| 46 | //! \{ |
---|
| 47 | #if SVC_EXTENSION |
---|
| 48 | Int TEncTop::m_iSPSIdCnt = 0; |
---|
| 49 | Int TEncTop::m_iPPSIdCnt = 0; |
---|
| 50 | TComVPS TEncCfg::m_cVPS; |
---|
| 51 | #endif |
---|
| 52 | |
---|
| 53 | // ==================================================================================================================== |
---|
| 54 | // Constructor / destructor / create / destroy |
---|
| 55 | // ==================================================================================================================== |
---|
| 56 | |
---|
| 57 | TEncTop::TEncTop() |
---|
| 58 | { |
---|
| 59 | m_iPOCLast = -1; |
---|
| 60 | m_iNumPicRcvd = 0; |
---|
| 61 | m_uiNumAllPicCoded = 0; |
---|
| 62 | m_pppcRDSbacCoder = NULL; |
---|
| 63 | m_pppcBinCoderCABAC = NULL; |
---|
| 64 | m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC ); |
---|
| 65 | #if ENC_DEC_TRACE |
---|
| 66 | g_hTrace = fopen( "TraceEnc.txt", "wb" ); |
---|
| 67 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 68 | g_nSymbolCounter = 0; |
---|
| 69 | #endif |
---|
| 70 | |
---|
| 71 | m_iMaxRefPicNum = 0; |
---|
| 72 | |
---|
| 73 | #if FAST_BIT_EST |
---|
| 74 | ContextModel::buildNextStateTable(); |
---|
| 75 | #endif |
---|
| 76 | |
---|
| 77 | m_pcSbacCoders = NULL; |
---|
| 78 | m_pcBinCoderCABACs = NULL; |
---|
| 79 | m_ppppcRDSbacCoders = NULL; |
---|
| 80 | m_ppppcBinCodersCABAC = NULL; |
---|
| 81 | m_pcRDGoOnSbacCoders = NULL; |
---|
| 82 | m_pcRDGoOnBinCodersCABAC = NULL; |
---|
| 83 | m_pcBitCounters = NULL; |
---|
| 84 | m_pcRdCosts = NULL; |
---|
| 85 | #if REF_IDX_FRAMEWORK |
---|
| 86 | memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); |
---|
| 87 | #endif |
---|
| 88 | #if REF_IDX_MFM |
---|
| 89 | m_bMFMEnabledFlag = false; |
---|
| 90 | #endif |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | TEncTop::~TEncTop() |
---|
| 94 | { |
---|
| 95 | #if ENC_DEC_TRACE |
---|
| 96 | fclose( g_hTrace ); |
---|
| 97 | #endif |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | Void TEncTop::create () |
---|
| 101 | { |
---|
| 102 | #if !SVC_EXTENSION |
---|
| 103 | // initialize global variables |
---|
| 104 | initROM(); |
---|
| 105 | #endif |
---|
| 106 | |
---|
| 107 | // create processing unit classes |
---|
| 108 | #if SVC_EXTENSION |
---|
| 109 | m_cGOPEncoder. create( m_layerId ); |
---|
| 110 | #else |
---|
| 111 | m_cGOPEncoder. create(); |
---|
| 112 | #endif |
---|
| 113 | m_cSliceEncoder. create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 114 | m_cCuEncoder. create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 115 | if (m_bUseSAO) |
---|
| 116 | { |
---|
| 117 | m_cEncSAO.setSaoLcuBoundary(getSaoLcuBoundary()); |
---|
| 118 | m_cEncSAO.setSaoLcuBasedOptimization(getSaoLcuBasedOptimization()); |
---|
| 119 | m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic()); |
---|
| 120 | m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 121 | m_cEncSAO.createEncBuffer(); |
---|
| 122 | } |
---|
| 123 | #if ADAPTIVE_QP_SELECTION |
---|
| 124 | if (m_bUseAdaptQpSelect) |
---|
| 125 | { |
---|
| 126 | m_cTrQuant.initSliceQpDelta(); |
---|
| 127 | } |
---|
| 128 | #endif |
---|
| 129 | m_cLoopFilter. create( g_uiMaxCUDepth ); |
---|
| 130 | |
---|
| 131 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 132 | if ( m_RCEnableRateControl ) |
---|
| 133 | { |
---|
| 134 | m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight, |
---|
| 135 | g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList ); |
---|
| 136 | } |
---|
| 137 | #else |
---|
| 138 | m_cRateCtrl.create(getIntraPeriod(), getGOPSize(), getFrameRate(), getTargetBitrate(), getQP(), getNumLCUInUnit(), getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight); |
---|
| 139 | #endif |
---|
| 140 | // if SBAC-based RD optimization is used |
---|
| 141 | if( m_bUseSBACRD ) |
---|
| 142 | { |
---|
| 143 | m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1]; |
---|
| 144 | #if FAST_BIT_EST |
---|
| 145 | m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1]; |
---|
| 146 | #else |
---|
| 147 | m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1]; |
---|
| 148 | #endif |
---|
| 149 | |
---|
| 150 | for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 151 | { |
---|
| 152 | m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM]; |
---|
| 153 | #if FAST_BIT_EST |
---|
| 154 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM]; |
---|
| 155 | #else |
---|
| 156 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM]; |
---|
| 157 | #endif |
---|
| 158 | |
---|
| 159 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 160 | { |
---|
| 161 | m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac; |
---|
| 162 | #if FAST_BIT_EST |
---|
| 163 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; |
---|
| 164 | #else |
---|
| 165 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; |
---|
| 166 | #endif |
---|
| 167 | m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | } |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | /** |
---|
| 174 | - Allocate coders required for wavefront for the nominated number of substreams. |
---|
| 175 | . |
---|
| 176 | \param iNumSubstreams Determines how much information to allocate. |
---|
| 177 | */ |
---|
| 178 | Void TEncTop::createWPPCoders(Int iNumSubstreams) |
---|
| 179 | { |
---|
| 180 | if (m_pcSbacCoders != NULL) |
---|
| 181 | { |
---|
| 182 | return; // already generated. |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | m_iNumSubstreams = iNumSubstreams; |
---|
| 186 | m_pcSbacCoders = new TEncSbac [iNumSubstreams]; |
---|
| 187 | m_pcBinCoderCABACs = new TEncBinCABAC [iNumSubstreams]; |
---|
| 188 | m_pcRDGoOnSbacCoders = new TEncSbac [iNumSubstreams]; |
---|
| 189 | m_pcRDGoOnBinCodersCABAC = new TEncBinCABAC [iNumSubstreams]; |
---|
| 190 | m_pcBitCounters = new TComBitCounter [iNumSubstreams]; |
---|
| 191 | m_pcRdCosts = new TComRdCost [iNumSubstreams]; |
---|
| 192 | |
---|
| 193 | for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ ) |
---|
| 194 | { |
---|
| 195 | m_pcRDGoOnSbacCoders[ui].init( &m_pcRDGoOnBinCodersCABAC[ui] ); |
---|
| 196 | m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] ); |
---|
| 197 | } |
---|
| 198 | if( m_bUseSBACRD ) |
---|
| 199 | { |
---|
| 200 | m_ppppcRDSbacCoders = new TEncSbac*** [iNumSubstreams]; |
---|
| 201 | m_ppppcBinCodersCABAC = new TEncBinCABAC***[iNumSubstreams]; |
---|
| 202 | for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) |
---|
| 203 | { |
---|
| 204 | m_ppppcRDSbacCoders[ui] = new TEncSbac** [g_uiMaxCUDepth+1]; |
---|
| 205 | m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1]; |
---|
| 206 | |
---|
| 207 | for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 208 | { |
---|
| 209 | m_ppppcRDSbacCoders[ui][iDepth] = new TEncSbac* [CI_NUM]; |
---|
| 210 | m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM]; |
---|
| 211 | |
---|
| 212 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 213 | { |
---|
| 214 | m_ppppcRDSbacCoders [ui][iDepth][iCIIdx] = new TEncSbac; |
---|
| 215 | m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC; |
---|
| 216 | m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] ); |
---|
| 217 | } |
---|
| 218 | } |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | } |
---|
| 222 | |
---|
| 223 | Void TEncTop::destroy () |
---|
| 224 | { |
---|
| 225 | // destroy processing unit classes |
---|
| 226 | m_cGOPEncoder. destroy(); |
---|
| 227 | m_cSliceEncoder. destroy(); |
---|
| 228 | m_cCuEncoder. destroy(); |
---|
| 229 | if (m_cSPS.getUseSAO()) |
---|
| 230 | { |
---|
| 231 | m_cEncSAO.destroy(); |
---|
| 232 | m_cEncSAO.destroyEncBuffer(); |
---|
| 233 | } |
---|
| 234 | m_cLoopFilter. destroy(); |
---|
| 235 | m_cRateCtrl. destroy(); |
---|
| 236 | // SBAC RD |
---|
| 237 | if( m_bUseSBACRD ) |
---|
| 238 | { |
---|
| 239 | Int iDepth; |
---|
| 240 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 241 | { |
---|
| 242 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 243 | { |
---|
| 244 | delete m_pppcRDSbacCoder[iDepth][iCIIdx]; |
---|
| 245 | delete m_pppcBinCoderCABAC[iDepth][iCIIdx]; |
---|
| 246 | } |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 250 | { |
---|
| 251 | delete [] m_pppcRDSbacCoder[iDepth]; |
---|
| 252 | delete [] m_pppcBinCoderCABAC[iDepth]; |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | delete [] m_pppcRDSbacCoder; |
---|
| 256 | delete [] m_pppcBinCoderCABAC; |
---|
| 257 | |
---|
| 258 | for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ ) |
---|
| 259 | { |
---|
| 260 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 261 | { |
---|
| 262 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 263 | { |
---|
| 264 | delete m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]; |
---|
| 265 | delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx]; |
---|
| 266 | } |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 270 | { |
---|
| 271 | delete [] m_ppppcRDSbacCoders [ui][iDepth]; |
---|
| 272 | delete [] m_ppppcBinCodersCABAC[ui][iDepth]; |
---|
| 273 | } |
---|
| 274 | delete[] m_ppppcRDSbacCoders [ui]; |
---|
| 275 | delete[] m_ppppcBinCodersCABAC[ui]; |
---|
| 276 | } |
---|
| 277 | delete[] m_ppppcRDSbacCoders; |
---|
| 278 | delete[] m_ppppcBinCodersCABAC; |
---|
| 279 | } |
---|
| 280 | delete[] m_pcSbacCoders; |
---|
| 281 | delete[] m_pcBinCoderCABACs; |
---|
| 282 | delete[] m_pcRDGoOnSbacCoders; |
---|
| 283 | delete[] m_pcRDGoOnBinCodersCABAC; |
---|
| 284 | delete[] m_pcBitCounters; |
---|
| 285 | delete[] m_pcRdCosts; |
---|
| 286 | |
---|
| 287 | #if !SVC_EXTENSION |
---|
| 288 | // destroy ROM |
---|
| 289 | destroyROM(); |
---|
| 290 | #endif |
---|
| 291 | #if REF_IDX_FRAMEWORK |
---|
| 292 | for(Int i=0; i<MAX_NUM_REF; i++) |
---|
| 293 | { |
---|
| 294 | if(m_cIlpPic[i]) |
---|
| 295 | { |
---|
| 296 | m_cIlpPic[i]->destroy(); |
---|
| 297 | delete m_cIlpPic[i]; |
---|
| 298 | m_cIlpPic[i] = NULL; |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | #endif |
---|
| 302 | return; |
---|
| 303 | } |
---|
| 304 | |
---|
| 305 | Void TEncTop::init() |
---|
| 306 | { |
---|
| 307 | // initialize SPS |
---|
| 308 | xInitSPS(); |
---|
| 309 | |
---|
| 310 | /* set the VPS profile information */ |
---|
| 311 | *m_cVPS.getPTL() = *m_cSPS.getPTL(); |
---|
| 312 | #if L0043_TIMING_INFO |
---|
| 313 | m_cVPS.getTimingInfo()->setTimingInfoPresentFlag ( false ); |
---|
| 314 | #endif |
---|
| 315 | // initialize PPS |
---|
| 316 | m_cPPS.setSPS(&m_cSPS); |
---|
| 317 | xInitPPS(); |
---|
| 318 | xInitRPS(); |
---|
| 319 | |
---|
| 320 | xInitPPSforTiles(); |
---|
| 321 | |
---|
| 322 | // initialize processing unit classes |
---|
| 323 | m_cGOPEncoder. init( this ); |
---|
| 324 | m_cSliceEncoder.init( this ); |
---|
| 325 | m_cCuEncoder. init( this ); |
---|
| 326 | |
---|
| 327 | // initialize transform & quantization class |
---|
| 328 | m_pcCavlcCoder = getCavlcCoder(); |
---|
| 329 | |
---|
| 330 | m_cTrQuant.init( 1 << m_uiQuadtreeTULog2MaxSize, |
---|
| 331 | m_useRDOQ, |
---|
| 332 | m_useRDOQTS, |
---|
| 333 | true |
---|
| 334 | ,m_useTransformSkipFast |
---|
| 335 | #if ADAPTIVE_QP_SELECTION |
---|
| 336 | , m_bUseAdaptQpSelect |
---|
| 337 | #endif |
---|
| 338 | ); |
---|
| 339 | |
---|
| 340 | // initialize encoder search class |
---|
| 341 | m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); |
---|
| 342 | |
---|
| 343 | m_iMaxRefPicNum = 0; |
---|
| 344 | #if SVC_EXTENSION |
---|
| 345 | m_iSPSIdCnt ++; |
---|
| 346 | m_iPPSIdCnt ++; |
---|
| 347 | #endif |
---|
| 348 | #if REF_IDX_FRAMEWORK |
---|
| 349 | xInitILRP(); |
---|
| 350 | #endif |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | // ==================================================================================================================== |
---|
| 354 | // Public member functions |
---|
| 355 | // ==================================================================================================================== |
---|
| 356 | |
---|
| 357 | Void TEncTop::deletePicBuffer() |
---|
| 358 | { |
---|
| 359 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 360 | Int iSize = Int( m_cListPic.size() ); |
---|
| 361 | |
---|
| 362 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 363 | { |
---|
| 364 | TComPic* pcPic = *(iterPic++); |
---|
| 365 | |
---|
| 366 | pcPic->destroy(); |
---|
| 367 | delete pcPic; |
---|
| 368 | pcPic = NULL; |
---|
| 369 | } |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | /** |
---|
| 373 | - Application has picture buffer list with size of GOP + 1 |
---|
| 374 | - Picture buffer list acts like as ring buffer |
---|
| 375 | - End of the list has the latest picture |
---|
| 376 | . |
---|
| 377 | \param flush cause encoder to encode a partial GOP |
---|
| 378 | \param pcPicYuvOrg original YUV picture |
---|
| 379 | \retval rcListPicYuvRecOut list of reconstruction YUV pictures |
---|
| 380 | \retval rcListBitstreamOut list of output bitstreams |
---|
| 381 | \retval iNumEncoded number of encoded pictures |
---|
| 382 | */ |
---|
| 383 | #if SVC_EXTENSION |
---|
| 384 | Void TEncTop::encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP ) |
---|
| 385 | { |
---|
| 386 | // compress GOP |
---|
| 387 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
[211] | 388 | #if !RC_SHVC_HARMONIZATION |
---|
[191] | 389 | if ( m_RCEnableRateControl ) |
---|
| 390 | { |
---|
| 391 | m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); |
---|
| 392 | } |
---|
| 393 | #endif |
---|
[211] | 394 | #endif |
---|
[191] | 395 | |
---|
| 396 | // compress GOP |
---|
| 397 | m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); |
---|
| 398 | |
---|
| 399 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
[211] | 400 | #if !RC_SHVC_HARMONIZATION |
---|
[191] | 401 | if ( m_RCEnableRateControl ) |
---|
| 402 | { |
---|
| 403 | m_cRateCtrl.destroyRCGOP(); |
---|
| 404 | } |
---|
| 405 | #endif |
---|
[211] | 406 | #endif |
---|
[191] | 407 | |
---|
| 408 | m_uiNumAllPicCoded ++; |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg ) |
---|
| 412 | { |
---|
| 413 | if (pcPicYuvOrg) |
---|
| 414 | { |
---|
| 415 | // get original YUV |
---|
| 416 | TComPic* pcPicCurr = NULL; |
---|
| 417 | xGetNewPicBuffer( pcPicCurr ); |
---|
| 418 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
| 419 | |
---|
| 420 | // compute image characteristics |
---|
| 421 | if ( getUseAdaptiveQP() ) |
---|
| 422 | { |
---|
| 423 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
| 424 | } |
---|
| 425 | } |
---|
| 426 | } |
---|
| 427 | #else |
---|
| 428 | Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ) |
---|
| 429 | { |
---|
| 430 | if (pcPicYuvOrg) { |
---|
| 431 | // get original YUV |
---|
| 432 | TComPic* pcPicCurr = NULL; |
---|
| 433 | xGetNewPicBuffer( pcPicCurr ); |
---|
| 434 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
| 435 | |
---|
| 436 | // compute image characteristics |
---|
| 437 | if ( getUseAdaptiveQP() ) |
---|
| 438 | { |
---|
| 439 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
| 440 | } |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | if (!m_iNumPicRcvd || (!flush && m_iPOCLast != 0 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) |
---|
| 444 | { |
---|
| 445 | iNumEncoded = 0; |
---|
| 446 | return; |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 450 | if ( m_RCEnableRateControl ) |
---|
| 451 | { |
---|
| 452 | m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); |
---|
| 453 | } |
---|
| 454 | #endif |
---|
| 455 | |
---|
| 456 | // compress GOP |
---|
| 457 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); |
---|
| 458 | |
---|
| 459 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 460 | if ( m_RCEnableRateControl ) |
---|
| 461 | { |
---|
| 462 | m_cRateCtrl.destroyRCGOP(); |
---|
| 463 | } |
---|
| 464 | #endif |
---|
| 465 | |
---|
| 466 | iNumEncoded = m_iNumPicRcvd; |
---|
| 467 | m_iNumPicRcvd = 0; |
---|
| 468 | m_uiNumAllPicCoded += iNumEncoded; |
---|
| 469 | } |
---|
| 470 | #endif |
---|
| 471 | |
---|
| 472 | // ==================================================================================================================== |
---|
| 473 | // Protected member functions |
---|
| 474 | // ==================================================================================================================== |
---|
| 475 | |
---|
| 476 | /** |
---|
| 477 | - Application has picture buffer list with size of GOP + 1 |
---|
| 478 | - Picture buffer list acts like as ring buffer |
---|
| 479 | - End of the list has the latest picture |
---|
| 480 | . |
---|
| 481 | \retval rpcPic obtained picture buffer |
---|
| 482 | */ |
---|
| 483 | Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic ) |
---|
| 484 | { |
---|
| 485 | TComSlice::sortPicList(m_cListPic); |
---|
| 486 | |
---|
| 487 | if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
---|
| 488 | { |
---|
| 489 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 490 | Int iSize = Int( m_cListPic.size() ); |
---|
| 491 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 492 | { |
---|
| 493 | rpcPic = *(iterPic++); |
---|
| 494 | if(rpcPic->getSlice(0)->isReferenced() == false) |
---|
| 495 | { |
---|
| 496 | break; |
---|
| 497 | } |
---|
| 498 | } |
---|
| 499 | } |
---|
| 500 | else |
---|
| 501 | { |
---|
| 502 | if ( getUseAdaptiveQP() ) |
---|
| 503 | { |
---|
| 504 | TEncPic* pcEPic = new TEncPic; |
---|
| 505 | |
---|
| 506 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
| 507 | if(m_layerId > 0) |
---|
| 508 | { |
---|
[253] | 509 | for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) |
---|
| 510 | { |
---|
| 511 | const Window scalEL = getSPS()->getScaledRefLayerWindow(); |
---|
| 512 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
---|
| 513 | |
---|
[238] | 514 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
[253] | 515 | TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i ); |
---|
[191] | 516 | #else |
---|
[253] | 517 | TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); |
---|
[191] | 518 | #endif |
---|
[253] | 519 | if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets ) |
---|
| 520 | { |
---|
| 521 | pcEPic->setSpatialEnhLayerFlag( i, true ); |
---|
[245] | 522 | |
---|
[253] | 523 | //only for scalable extension |
---|
| 524 | assert( m_cVPS.getScalabilityMask(1) == true ); |
---|
| 525 | } |
---|
[191] | 526 | } |
---|
| 527 | } |
---|
| 528 | #endif |
---|
| 529 | |
---|
| 530 | #if SVC_UPSAMPLING |
---|
| 531 | pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 , |
---|
| 532 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS); |
---|
| 533 | #else |
---|
| 534 | pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 , |
---|
| 535 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics); |
---|
| 536 | #endif |
---|
| 537 | rpcPic = pcEPic; |
---|
| 538 | } |
---|
| 539 | else |
---|
| 540 | { |
---|
| 541 | rpcPic = new TComPic; |
---|
| 542 | |
---|
| 543 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
| 544 | if(m_layerId > 0) |
---|
| 545 | { |
---|
[253] | 546 | for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) |
---|
| 547 | { |
---|
| 548 | const Window scalEL = getSPS()->getScaledRefLayerWindow(); |
---|
| 549 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
---|
| 550 | |
---|
[238] | 551 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
[253] | 552 | TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i ); |
---|
[191] | 553 | #else |
---|
[253] | 554 | TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); |
---|
[191] | 555 | #endif |
---|
[253] | 556 | if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets ) |
---|
| 557 | { |
---|
| 558 | rpcPic->setSpatialEnhLayerFlag( i, true ); |
---|
[245] | 559 | |
---|
[253] | 560 | //only for scalable extension |
---|
| 561 | assert( m_cVPS.getScalabilityMask(1) == true ); |
---|
| 562 | } |
---|
[191] | 563 | } |
---|
| 564 | } |
---|
| 565 | #endif |
---|
| 566 | |
---|
| 567 | #if SVC_UPSAMPLING |
---|
| 568 | rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 569 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS); |
---|
| 570 | #else |
---|
| 571 | rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 572 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics); |
---|
| 573 | #endif |
---|
| 574 | } |
---|
| 575 | |
---|
| 576 | if (getUseSAO()) |
---|
| 577 | { |
---|
| 578 | rpcPic->getPicSym()->allocSaoParam(&m_cEncSAO); |
---|
| 579 | } |
---|
| 580 | m_cListPic.pushBack( rpcPic ); |
---|
| 581 | } |
---|
| 582 | rpcPic->setReconMark (false); |
---|
| 583 | |
---|
| 584 | m_iPOCLast++; |
---|
| 585 | m_iNumPicRcvd++; |
---|
| 586 | |
---|
| 587 | rpcPic->getSlice(0)->setPOC( m_iPOCLast ); |
---|
| 588 | // mark it should be extended |
---|
| 589 | rpcPic->getPicYuvRec()->setBorderExtension(false); |
---|
| 590 | } |
---|
| 591 | |
---|
| 592 | Void TEncTop::xInitSPS() |
---|
| 593 | { |
---|
| 594 | #if SVC_EXTENSION |
---|
| 595 | m_cSPS.setLayerId(m_layerId); |
---|
| 596 | #endif |
---|
| 597 | #if REF_IDX_MFM |
---|
| 598 | m_cSPS.setMFMEnabledFlag(m_bMFMEnabledFlag); |
---|
| 599 | #endif |
---|
| 600 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 601 | m_cSPS.getScaledRefLayerWindow() = m_scaledRefLayerWindow; |
---|
| 602 | #endif |
---|
| 603 | ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL(); |
---|
| 604 | profileTierLevel.setLevelIdc(m_level); |
---|
| 605 | profileTierLevel.setTierFlag(m_levelTier); |
---|
| 606 | profileTierLevel.setProfileIdc(m_profile); |
---|
| 607 | profileTierLevel.setProfileCompatibilityFlag(m_profile, 1); |
---|
| 608 | #if L0046_CONSTRAINT_FLAGS |
---|
| 609 | profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
| 610 | profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
| 611 | profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
| 612 | profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
| 613 | #endif |
---|
| 614 | |
---|
| 615 | if (m_profile == Profile::MAIN10 && g_bitDepthY == 8 && g_bitDepthC == 8) |
---|
| 616 | { |
---|
| 617 | /* The above constraint is equal to Profile::MAIN */ |
---|
| 618 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN, 1); |
---|
| 619 | } |
---|
| 620 | if (m_profile == Profile::MAIN) |
---|
| 621 | { |
---|
| 622 | /* A Profile::MAIN10 decoder can always decode Profile::MAIN */ |
---|
| 623 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN10, 1); |
---|
| 624 | } |
---|
| 625 | /* XXX: should Main be marked as compatible with still picture? */ |
---|
| 626 | /* XXX: may be a good idea to refactor the above into a function |
---|
| 627 | * that chooses the actual compatibility based upon options */ |
---|
| 628 | |
---|
| 629 | m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth ); |
---|
| 630 | m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight ); |
---|
| 631 | m_cSPS.setConformanceWindow ( m_conformanceWindow ); |
---|
| 632 | m_cSPS.setMaxCUWidth ( g_uiMaxCUWidth ); |
---|
| 633 | m_cSPS.setMaxCUHeight ( g_uiMaxCUHeight ); |
---|
| 634 | m_cSPS.setMaxCUDepth ( g_uiMaxCUDepth ); |
---|
| 635 | |
---|
| 636 | Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getMaxCUDepth()-g_uiAddCUDepth ); |
---|
| 637 | Int log2MinCUSize = 0; |
---|
| 638 | while(minCUSize > 1) |
---|
| 639 | { |
---|
| 640 | minCUSize >>= 1; |
---|
| 641 | log2MinCUSize++; |
---|
| 642 | } |
---|
| 643 | |
---|
| 644 | m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize); |
---|
| 645 | m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_cSPS.getMaxCUDepth()-g_uiAddCUDepth); |
---|
| 646 | #if SVC_EXTENSION |
---|
| 647 | m_cSPS.setSPSId ( m_iSPSIdCnt ); |
---|
| 648 | #endif |
---|
| 649 | |
---|
| 650 | m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize); |
---|
| 651 | m_cSPS.setUsePCM ( m_usePCM ); |
---|
| 652 | m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize ); |
---|
| 653 | |
---|
| 654 | m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); |
---|
| 655 | m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize ); |
---|
| 656 | m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter ); |
---|
| 657 | m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra ); |
---|
| 658 | |
---|
| 659 | m_cSPS.setTMVPFlagsPresent(false); |
---|
| 660 | m_cSPS.setUseLossless ( m_useLossless ); |
---|
| 661 | |
---|
| 662 | m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
| 663 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
| 664 | m_cSPS.setUseLComb ( m_bUseLComb ); |
---|
| 665 | #endif |
---|
| 666 | |
---|
| 667 | Int i; |
---|
| 668 | |
---|
| 669 | for (i = 0; i < g_uiMaxCUDepth-g_uiAddCUDepth; i++ ) |
---|
| 670 | { |
---|
| 671 | m_cSPS.setAMPAcc( i, m_useAMP ); |
---|
| 672 | //m_cSPS.setAMPAcc( i, 1 ); |
---|
| 673 | } |
---|
| 674 | |
---|
| 675 | m_cSPS.setUseAMP ( m_useAMP ); |
---|
| 676 | |
---|
| 677 | for (i = g_uiMaxCUDepth-g_uiAddCUDepth; i < g_uiMaxCUDepth; i++ ) |
---|
| 678 | { |
---|
| 679 | m_cSPS.setAMPAcc(i, 0); |
---|
| 680 | } |
---|
| 681 | |
---|
| 682 | m_cSPS.setBitDepthY( g_bitDepthY ); |
---|
| 683 | m_cSPS.setBitDepthC( g_bitDepthC ); |
---|
| 684 | |
---|
| 685 | m_cSPS.setQpBDOffsetY ( 6*(g_bitDepthY - 8) ); |
---|
| 686 | m_cSPS.setQpBDOffsetC ( 6*(g_bitDepthC - 8) ); |
---|
| 687 | |
---|
| 688 | m_cSPS.setUseSAO( m_bUseSAO ); |
---|
| 689 | |
---|
| 690 | m_cSPS.setMaxTLayers( m_maxTempLayer ); |
---|
| 691 | m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false ); |
---|
| 692 | for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ ) |
---|
| 693 | { |
---|
| 694 | m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); |
---|
| 695 | m_cSPS.setNumReorderPics(m_numReorderPics[i], i); |
---|
| 696 | } |
---|
| 697 | m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma); |
---|
| 698 | m_cSPS.setPCMBitDepthChroma (g_uiPCMBitDepthChroma); |
---|
| 699 | m_cSPS.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag ); |
---|
| 700 | |
---|
| 701 | m_cSPS.setScalingListFlag ( (m_useScalingListId == 0) ? 0 : 1 ); |
---|
| 702 | |
---|
| 703 | m_cSPS.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
| 704 | |
---|
| 705 | m_cSPS.setVuiParametersPresentFlag(getVuiParametersPresentFlag()); |
---|
| 706 | if (m_cSPS.getVuiParametersPresentFlag()) |
---|
| 707 | { |
---|
| 708 | TComVUI* pcVUI = m_cSPS.getVuiParameters(); |
---|
| 709 | pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioIdc() != -1); |
---|
| 710 | pcVUI->setAspectRatioIdc(getAspectRatioIdc()); |
---|
| 711 | pcVUI->setSarWidth(getSarWidth()); |
---|
| 712 | pcVUI->setSarHeight(getSarHeight()); |
---|
| 713 | pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag()); |
---|
| 714 | pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag()); |
---|
| 715 | pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag()); |
---|
| 716 | pcVUI->setVideoFormat(getVideoFormat()); |
---|
| 717 | pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag()); |
---|
| 718 | pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag()); |
---|
| 719 | pcVUI->setColourPrimaries(getColourPrimaries()); |
---|
| 720 | pcVUI->setTransferCharacteristics(getTransferCharacteristics()); |
---|
| 721 | pcVUI->setMatrixCoefficients(getMatrixCoefficients()); |
---|
| 722 | pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag()); |
---|
| 723 | pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField()); |
---|
| 724 | pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField()); |
---|
| 725 | pcVUI->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag()); |
---|
| 726 | pcVUI->setDefaultDisplayWindow(getDefaultDisplayWindow()); |
---|
| 727 | pcVUI->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag()); |
---|
| 728 | pcVUI->setFieldSeqFlag(false); |
---|
| 729 | pcVUI->setHrdParametersPresentFlag(false); |
---|
| 730 | #if L0043_TIMING_INFO |
---|
| 731 | pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag()); |
---|
| 732 | pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1 (getNumTicksPocDiffOneMinus1() ); |
---|
| 733 | #else |
---|
| 734 | pcVUI->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag()); |
---|
| 735 | pcVUI->setNumTicksPocDiffOneMinus1 (getNumTicksPocDiffOneMinus1() ); |
---|
| 736 | #endif |
---|
| 737 | pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag()); |
---|
| 738 | pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag()); |
---|
| 739 | pcVUI->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag()); |
---|
| 740 | pcVUI->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc()); |
---|
| 741 | pcVUI->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom()); |
---|
| 742 | pcVUI->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom()); |
---|
| 743 | pcVUI->setLog2MaxMvLengthHorizontal(getLog2MaxMvLengthHorizontal()); |
---|
| 744 | pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical()); |
---|
| 745 | } |
---|
| 746 | } |
---|
| 747 | |
---|
| 748 | Void TEncTop::xInitPPS() |
---|
| 749 | { |
---|
| 750 | m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); |
---|
| 751 | Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; |
---|
| 752 | |
---|
| 753 | Int lowestQP = - m_cSPS.getQpBDOffsetY(); |
---|
| 754 | |
---|
| 755 | if(getUseLossless()) |
---|
| 756 | { |
---|
| 757 | if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) ) |
---|
| 758 | { |
---|
| 759 | bUseDQP = false; |
---|
| 760 | } |
---|
| 761 | else |
---|
| 762 | { |
---|
| 763 | bUseDQP = true; |
---|
| 764 | } |
---|
| 765 | } |
---|
| 766 | else |
---|
| 767 | { |
---|
| 768 | if(bUseDQP == false) |
---|
| 769 | { |
---|
| 770 | if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) |
---|
| 771 | { |
---|
| 772 | bUseDQP = true; |
---|
| 773 | } |
---|
| 774 | } |
---|
| 775 | } |
---|
| 776 | |
---|
| 777 | if(bUseDQP) |
---|
| 778 | { |
---|
| 779 | m_cPPS.setUseDQP(true); |
---|
| 780 | m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth ); |
---|
| 781 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
| 782 | } |
---|
| 783 | else |
---|
| 784 | { |
---|
| 785 | m_cPPS.setUseDQP(false); |
---|
| 786 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
| 787 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
| 788 | } |
---|
| 789 | |
---|
| 790 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 791 | if ( m_RCEnableRateControl ) |
---|
| 792 | { |
---|
| 793 | m_cPPS.setUseDQP(true); |
---|
| 794 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
| 795 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
| 796 | } |
---|
| 797 | #endif |
---|
| 798 | |
---|
| 799 | m_cPPS.setChromaCbQpOffset( m_chromaCbQpOffset ); |
---|
| 800 | m_cPPS.setChromaCrQpOffset( m_chromaCrQpOffset ); |
---|
| 801 | |
---|
| 802 | m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams); |
---|
| 803 | m_cPPS.setEntropyCodingSyncEnabledFlag( m_iWaveFrontSynchro > 0 ); |
---|
| 804 | m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) ); |
---|
| 805 | m_cPPS.setUseWP( m_useWeightedPred ); |
---|
| 806 | m_cPPS.setWPBiPred( m_useWeightedBiPred ); |
---|
| 807 | m_cPPS.setOutputFlagPresentFlag( false ); |
---|
| 808 | m_cPPS.setSignHideFlag(getSignHideFlag()); |
---|
| 809 | #if L0386_DB_METRIC |
---|
| 810 | if ( getDeblockingFilterMetric() ) |
---|
| 811 | { |
---|
| 812 | m_cPPS.setDeblockingFilterControlPresentFlag (true); |
---|
| 813 | m_cPPS.setDeblockingFilterOverrideEnabledFlag(true); |
---|
| 814 | m_cPPS.setPicDisableDeblockingFilterFlag(false); |
---|
| 815 | m_cPPS.setDeblockingFilterBetaOffsetDiv2(0); |
---|
| 816 | m_cPPS.setDeblockingFilterTcOffsetDiv2(0); |
---|
| 817 | } |
---|
| 818 | else |
---|
| 819 | { |
---|
| 820 | m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent ); |
---|
| 821 | } |
---|
| 822 | #else |
---|
| 823 | m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent ); |
---|
| 824 | #endif |
---|
| 825 | m_cPPS.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 ); |
---|
| 826 | m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); |
---|
| 827 | m_cPPS.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
| 828 | Int histogram[MAX_NUM_REF + 1]; |
---|
| 829 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
---|
| 830 | { |
---|
| 831 | histogram[i]=0; |
---|
| 832 | } |
---|
| 833 | for( Int i = 0; i < getGOPSize(); i++ ) |
---|
| 834 | { |
---|
| 835 | assert(getGOPEntry(i).m_numRefPicsActive >= 0 && getGOPEntry(i).m_numRefPicsActive <= MAX_NUM_REF); |
---|
| 836 | histogram[getGOPEntry(i).m_numRefPicsActive]++; |
---|
| 837 | } |
---|
| 838 | Int maxHist=-1; |
---|
| 839 | Int bestPos=0; |
---|
| 840 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
---|
| 841 | { |
---|
| 842 | if(histogram[i]>maxHist) |
---|
| 843 | { |
---|
| 844 | maxHist=histogram[i]; |
---|
| 845 | bestPos=i; |
---|
| 846 | } |
---|
| 847 | } |
---|
| 848 | #if L0323_LIMIT_DEFAULT_LIST_SIZE |
---|
| 849 | assert(bestPos <= 15); |
---|
| 850 | #endif |
---|
| 851 | m_cPPS.setNumRefIdxL0DefaultActive(bestPos); |
---|
| 852 | m_cPPS.setNumRefIdxL1DefaultActive(bestPos); |
---|
| 853 | m_cPPS.setTransquantBypassEnableFlag(getTransquantBypassEnableFlag()); |
---|
| 854 | m_cPPS.setUseTransformSkip( m_useTransformSkip ); |
---|
| 855 | if (m_sliceSegmentMode) |
---|
| 856 | { |
---|
| 857 | m_cPPS.setDependentSliceSegmentsEnabledFlag( true ); |
---|
| 858 | } |
---|
| 859 | if( m_cPPS.getDependentSliceSegmentsEnabledFlag() ) |
---|
| 860 | { |
---|
| 861 | Int NumCtx = m_cPPS.getEntropyCodingSyncEnabledFlag()?2:1; |
---|
| 862 | m_cSliceEncoder.initCtxMem( NumCtx ); |
---|
| 863 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
| 864 | { |
---|
| 865 | TEncSbac* ctx = NULL; |
---|
| 866 | ctx = new TEncSbac; |
---|
| 867 | ctx->init( &m_cBinCoderCABAC ); |
---|
| 868 | m_cSliceEncoder.setCtxMem( ctx, st ); |
---|
| 869 | } |
---|
| 870 | } |
---|
| 871 | #if REF_IDX_FRAMEWORK |
---|
| 872 | if (!m_layerId) |
---|
| 873 | { |
---|
| 874 | m_cPPS.setListsModificationPresentFlag(false); |
---|
| 875 | } |
---|
| 876 | else |
---|
| 877 | { |
---|
| 878 | m_cPPS.setListsModificationPresentFlag(true); |
---|
| 879 | } |
---|
| 880 | #endif |
---|
| 881 | #if SVC_EXTENSION |
---|
| 882 | m_cPPS.setPPSId ( m_iPPSIdCnt ); |
---|
| 883 | m_cPPS.setSPSId ( m_iSPSIdCnt ); |
---|
| 884 | #endif |
---|
| 885 | } |
---|
| 886 | |
---|
| 887 | //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. |
---|
| 888 | Void TEncTop::xInitRPS() |
---|
| 889 | { |
---|
| 890 | TComReferencePictureSet* rps; |
---|
| 891 | |
---|
| 892 | m_cSPS.createRPSList(getGOPSize()+m_extraRPSs); |
---|
| 893 | TComRPSList* rpsList = m_cSPS.getRPSList(); |
---|
| 894 | |
---|
| 895 | for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) |
---|
| 896 | { |
---|
| 897 | GOPEntry ge = getGOPEntry(i); |
---|
| 898 | rps = rpsList->getReferencePictureSet(i); |
---|
| 899 | rps->setNumberOfPictures(ge.m_numRefPics); |
---|
| 900 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
| 901 | Int numNeg = 0; |
---|
| 902 | Int numPos = 0; |
---|
| 903 | for( Int j = 0; j < ge.m_numRefPics; j++) |
---|
| 904 | { |
---|
| 905 | rps->setDeltaPOC(j,ge.m_referencePics[j]); |
---|
| 906 | rps->setUsed(j,ge.m_usedByCurrPic[j]); |
---|
| 907 | if(ge.m_referencePics[j]>0) |
---|
| 908 | { |
---|
| 909 | numPos++; |
---|
| 910 | } |
---|
| 911 | else |
---|
| 912 | { |
---|
| 913 | numNeg++; |
---|
| 914 | } |
---|
| 915 | } |
---|
| 916 | rps->setNumberOfNegativePictures(numNeg); |
---|
| 917 | rps->setNumberOfPositivePictures(numPos); |
---|
| 918 | |
---|
| 919 | // handle inter RPS intialization from the config file. |
---|
| 920 | #if AUTO_INTER_RPS |
---|
| 921 | rps->setInterRPSPrediction(ge.m_interRPSPrediction > 0); // not very clean, converting anything > 0 to true. |
---|
| 922 | rps->setDeltaRIdxMinus1(0); // index to the Reference RPS is always the previous one. |
---|
| 923 | TComReferencePictureSet* RPSRef = rpsList->getReferencePictureSet(i-1); // get the reference RPS |
---|
| 924 | |
---|
| 925 | if (ge.m_interRPSPrediction == 2) // Automatic generation of the inter RPS idc based on the RIdx provided. |
---|
| 926 | { |
---|
| 927 | Int deltaRPS = getGOPEntry(i-1).m_POC - ge.m_POC; // the ref POC - current POC |
---|
| 928 | Int numRefDeltaPOC = RPSRef->getNumberOfPictures(); |
---|
| 929 | |
---|
| 930 | rps->setDeltaRPS(deltaRPS); // set delta RPS |
---|
| 931 | rps->setNumRefIdc(numRefDeltaPOC+1); // set the numRefIdc to the number of pictures in the reference RPS + 1. |
---|
| 932 | Int count=0; |
---|
| 933 | for (Int j = 0; j <= numRefDeltaPOC; j++ ) // cycle through pics in reference RPS. |
---|
| 934 | { |
---|
| 935 | Int RefDeltaPOC = (j<numRefDeltaPOC)? RPSRef->getDeltaPOC(j): 0; // if it is the last decoded picture, set RefDeltaPOC = 0 |
---|
| 936 | rps->setRefIdc(j, 0); |
---|
| 937 | for (Int k = 0; k < rps->getNumberOfPictures(); k++ ) // cycle through pics in current RPS. |
---|
| 938 | { |
---|
| 939 | if (rps->getDeltaPOC(k) == ( RefDeltaPOC + deltaRPS)) // if the current RPS has a same picture as the reference RPS. |
---|
| 940 | { |
---|
| 941 | rps->setRefIdc(j, (rps->getUsed(k)?1:2)); |
---|
| 942 | count++; |
---|
| 943 | break; |
---|
| 944 | } |
---|
| 945 | } |
---|
| 946 | } |
---|
| 947 | if (count != rps->getNumberOfPictures()) |
---|
| 948 | { |
---|
| 949 | 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"); |
---|
| 950 | rps->setInterRPSPrediction(0); |
---|
| 951 | } |
---|
| 952 | } |
---|
| 953 | else if (ge.m_interRPSPrediction == 1) // inter RPS idc based on the RefIdc values provided in config file. |
---|
| 954 | { |
---|
| 955 | rps->setDeltaRPS(ge.m_deltaRPS); |
---|
| 956 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
| 957 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 958 | { |
---|
| 959 | rps->setRefIdc(j, ge.m_refIdc[j]); |
---|
| 960 | } |
---|
| 961 | #if WRITE_BACK |
---|
| 962 | // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones |
---|
| 963 | // computed from the RefIdc. A warning is printed if they are not identical. |
---|
| 964 | numNeg = 0; |
---|
| 965 | numPos = 0; |
---|
| 966 | TComReferencePictureSet RPSTemp; // temporary variable |
---|
| 967 | |
---|
| 968 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 969 | { |
---|
| 970 | if (ge.m_refIdc[j]) |
---|
| 971 | { |
---|
| 972 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
---|
| 973 | RPSTemp.setDeltaPOC((numNeg+numPos),deltaPOC); |
---|
| 974 | RPSTemp.setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
---|
| 975 | if (deltaPOC<0) |
---|
| 976 | { |
---|
| 977 | numNeg++; |
---|
| 978 | } |
---|
| 979 | else |
---|
| 980 | { |
---|
| 981 | numPos++; |
---|
| 982 | } |
---|
| 983 | } |
---|
| 984 | } |
---|
| 985 | if (numNeg != rps->getNumberOfNegativePictures()) |
---|
| 986 | { |
---|
| 987 | printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
| 988 | rps->setNumberOfNegativePictures(numNeg); |
---|
| 989 | rps->setNumberOfPositivePictures(numNeg+numPos); |
---|
| 990 | } |
---|
| 991 | if (numPos != rps->getNumberOfPositivePictures()) |
---|
| 992 | { |
---|
| 993 | printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
| 994 | rps->setNumberOfPositivePictures(numPos); |
---|
| 995 | rps->setNumberOfPositivePictures(numNeg+numPos); |
---|
| 996 | } |
---|
| 997 | RPSTemp.setNumberOfPictures(numNeg+numPos); |
---|
| 998 | RPSTemp.setNumberOfNegativePictures(numNeg); |
---|
| 999 | RPSTemp.sortDeltaPOC(); // sort the created delta POC before comparing |
---|
| 1000 | // check if Delta POC and Used are the same |
---|
| 1001 | // print warning if they are not. |
---|
| 1002 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1003 | { |
---|
| 1004 | if (RPSTemp.getDeltaPOC(j) != rps->getDeltaPOC(j)) |
---|
| 1005 | { |
---|
| 1006 | printf("Warning: delta POC is different between intra RPS and inter RPS specified in the config file.\n"); |
---|
| 1007 | rps->setDeltaPOC(j,RPSTemp.getDeltaPOC(j)); |
---|
| 1008 | } |
---|
| 1009 | if (RPSTemp.getUsed(j) != rps->getUsed(j)) |
---|
| 1010 | { |
---|
| 1011 | printf("Warning: Used by Current in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
| 1012 | rps->setUsed(j,RPSTemp.getUsed(j)); |
---|
| 1013 | } |
---|
| 1014 | } |
---|
| 1015 | #endif |
---|
| 1016 | } |
---|
| 1017 | #else |
---|
| 1018 | rps->setInterRPSPrediction(ge.m_interRPSPrediction); |
---|
| 1019 | if (ge.m_interRPSPrediction) |
---|
| 1020 | { |
---|
| 1021 | rps->setDeltaRIdxMinus1(0); |
---|
| 1022 | rps->setDeltaRPS(ge.m_deltaRPS); |
---|
| 1023 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
| 1024 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1025 | { |
---|
| 1026 | rps->setRefIdc(j, ge.m_refIdc[j]); |
---|
| 1027 | } |
---|
| 1028 | #if WRITE_BACK |
---|
| 1029 | // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones |
---|
| 1030 | // computed from the RefIdc. This is not necessary if both are identical. Currently there is no check to see if they are identical. |
---|
| 1031 | numNeg = 0; |
---|
| 1032 | numPos = 0; |
---|
| 1033 | TComReferencePictureSet* RPSRef = m_RPSList.getReferencePictureSet(i-1); |
---|
| 1034 | |
---|
| 1035 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1036 | { |
---|
| 1037 | if (ge.m_refIdc[j]) |
---|
| 1038 | { |
---|
| 1039 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
---|
| 1040 | rps->setDeltaPOC((numNeg+numPos),deltaPOC); |
---|
| 1041 | rps->setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
---|
| 1042 | if (deltaPOC<0) |
---|
| 1043 | { |
---|
| 1044 | numNeg++; |
---|
| 1045 | } |
---|
| 1046 | else |
---|
| 1047 | { |
---|
| 1048 | numPos++; |
---|
| 1049 | } |
---|
| 1050 | } |
---|
| 1051 | } |
---|
| 1052 | rps->setNumberOfNegativePictures(numNeg); |
---|
| 1053 | rps->setNumberOfPositivePictures(numPos); |
---|
| 1054 | rps->sortDeltaPOC(); |
---|
| 1055 | #endif |
---|
| 1056 | } |
---|
| 1057 | #endif //INTER_RPS_AUTO |
---|
| 1058 | } |
---|
| 1059 | |
---|
| 1060 | } |
---|
| 1061 | |
---|
| 1062 | // This is a function that |
---|
| 1063 | // determines what Reference Picture Set to use |
---|
| 1064 | // for a specific slice (with POC = POCCurr) |
---|
| 1065 | Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid ) |
---|
| 1066 | { |
---|
| 1067 | slice->setRPSidx(GOPid); |
---|
| 1068 | |
---|
| 1069 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
| 1070 | { |
---|
| 1071 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
---|
| 1072 | { |
---|
| 1073 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
---|
| 1074 | if(POCIndex == 0) |
---|
| 1075 | { |
---|
| 1076 | POCIndex = m_uiIntraPeriod; |
---|
| 1077 | } |
---|
| 1078 | if(POCIndex == m_GOPList[extraNum].m_POC) |
---|
| 1079 | { |
---|
| 1080 | slice->setRPSidx(extraNum); |
---|
| 1081 | } |
---|
| 1082 | } |
---|
| 1083 | else |
---|
| 1084 | { |
---|
| 1085 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
| 1086 | { |
---|
| 1087 | slice->setRPSidx(extraNum); |
---|
| 1088 | } |
---|
| 1089 | } |
---|
| 1090 | } |
---|
| 1091 | |
---|
| 1092 | slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); |
---|
| 1093 | slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures()); |
---|
| 1094 | |
---|
| 1095 | } |
---|
| 1096 | |
---|
| 1097 | #if L0208_SOP_DESCRIPTION_SEI |
---|
| 1098 | Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid ) |
---|
| 1099 | { |
---|
| 1100 | int rpsIdx = GOPid; |
---|
| 1101 | |
---|
| 1102 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
| 1103 | { |
---|
| 1104 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
---|
| 1105 | { |
---|
| 1106 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
---|
| 1107 | if(POCIndex == 0) |
---|
| 1108 | { |
---|
| 1109 | POCIndex = m_uiIntraPeriod; |
---|
| 1110 | } |
---|
| 1111 | if(POCIndex == m_GOPList[extraNum].m_POC) |
---|
| 1112 | { |
---|
| 1113 | rpsIdx = extraNum; |
---|
| 1114 | } |
---|
| 1115 | } |
---|
| 1116 | else |
---|
| 1117 | { |
---|
| 1118 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
| 1119 | { |
---|
| 1120 | rpsIdx = extraNum; |
---|
| 1121 | } |
---|
| 1122 | } |
---|
| 1123 | } |
---|
| 1124 | |
---|
| 1125 | return rpsIdx; |
---|
| 1126 | } |
---|
| 1127 | #endif |
---|
| 1128 | |
---|
| 1129 | Void TEncTop::xInitPPSforTiles() |
---|
| 1130 | { |
---|
| 1131 | m_cPPS.setUniformSpacingFlag( m_iUniformSpacingIdr ); |
---|
| 1132 | m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 ); |
---|
| 1133 | m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 ); |
---|
| 1134 | if( m_iUniformSpacingIdr == 0 ) |
---|
| 1135 | { |
---|
| 1136 | m_cPPS.setColumnWidth( m_puiColumnWidth ); |
---|
| 1137 | m_cPPS.setRowHeight( m_puiRowHeight ); |
---|
| 1138 | } |
---|
| 1139 | m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag ); |
---|
| 1140 | |
---|
| 1141 | // # substreams is "per tile" when tiles are independent. |
---|
| 1142 | if (m_iWaveFrontSynchro |
---|
| 1143 | ) |
---|
| 1144 | { |
---|
| 1145 | m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)); |
---|
| 1146 | } |
---|
| 1147 | } |
---|
| 1148 | |
---|
| 1149 | Void TEncCfg::xCheckGSParameters() |
---|
| 1150 | { |
---|
| 1151 | Int iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth; |
---|
| 1152 | Int iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight; |
---|
| 1153 | UInt uiCummulativeColumnWidth = 0; |
---|
| 1154 | UInt uiCummulativeRowHeight = 0; |
---|
| 1155 | |
---|
| 1156 | //check the column relative parameters |
---|
| 1157 | if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) ) |
---|
| 1158 | { |
---|
| 1159 | printf( "The number of columns is larger than the maximum allowed number of columns.\n" ); |
---|
| 1160 | exit( EXIT_FAILURE ); |
---|
| 1161 | } |
---|
| 1162 | |
---|
| 1163 | if( m_iNumColumnsMinus1 >= iWidthInCU ) |
---|
| 1164 | { |
---|
| 1165 | printf( "The current picture can not have so many columns.\n" ); |
---|
| 1166 | exit( EXIT_FAILURE ); |
---|
| 1167 | } |
---|
| 1168 | |
---|
| 1169 | if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 ) |
---|
| 1170 | { |
---|
| 1171 | for(Int i=0; i<m_iNumColumnsMinus1; i++) |
---|
| 1172 | { |
---|
| 1173 | uiCummulativeColumnWidth += m_puiColumnWidth[i]; |
---|
| 1174 | } |
---|
| 1175 | |
---|
| 1176 | if( uiCummulativeColumnWidth >= iWidthInCU ) |
---|
| 1177 | { |
---|
| 1178 | printf( "The width of the column is too large.\n" ); |
---|
| 1179 | exit( EXIT_FAILURE ); |
---|
| 1180 | } |
---|
| 1181 | } |
---|
| 1182 | |
---|
| 1183 | //check the row relative parameters |
---|
| 1184 | if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) ) |
---|
| 1185 | { |
---|
| 1186 | printf( "The number of rows is larger than the maximum allowed number of rows.\n" ); |
---|
| 1187 | exit( EXIT_FAILURE ); |
---|
| 1188 | } |
---|
| 1189 | |
---|
| 1190 | if( m_iNumRowsMinus1 >= iHeightInCU ) |
---|
| 1191 | { |
---|
| 1192 | printf( "The current picture can not have so many rows.\n" ); |
---|
| 1193 | exit( EXIT_FAILURE ); |
---|
| 1194 | } |
---|
| 1195 | |
---|
| 1196 | if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 ) |
---|
| 1197 | { |
---|
| 1198 | for(Int i=0; i<m_iNumRowsMinus1; i++) |
---|
| 1199 | { |
---|
| 1200 | uiCummulativeRowHeight += m_puiRowHeight[i]; |
---|
| 1201 | } |
---|
| 1202 | |
---|
| 1203 | if( uiCummulativeRowHeight >= iHeightInCU ) |
---|
| 1204 | { |
---|
| 1205 | printf( "The height of the row is too large.\n" ); |
---|
| 1206 | exit( EXIT_FAILURE ); |
---|
| 1207 | } |
---|
| 1208 | } |
---|
| 1209 | } |
---|
| 1210 | |
---|
| 1211 | #if SVC_EXTENSION |
---|
[238] | 1212 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
[250] | 1213 | TEncTop* TEncTop::getRefLayerEnc( UInt refLayerIdc ) |
---|
[191] | 1214 | { |
---|
[189] | 1215 | if( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() <= 0 ) |
---|
| 1216 | { |
---|
| 1217 | #if ZERO_NUM_DIRECT_LAYERS |
---|
| 1218 | return (TEncTop *)getLayerEnc( 0 ); |
---|
| 1219 | #else |
---|
| 1220 | return NULL; |
---|
| 1221 | #endif |
---|
[191] | 1222 | } |
---|
| 1223 | |
---|
[260] | 1224 | return (TEncTop *)getLayerEnc( m_cVPS.getRefLayerId( m_layerId, refLayerIdc ) ); |
---|
[191] | 1225 | } |
---|
| 1226 | #endif |
---|
| 1227 | |
---|
| 1228 | #if REF_IDX_FRAMEWORK |
---|
| 1229 | Void TEncTop::xInitILRP() |
---|
| 1230 | { |
---|
| 1231 | if(m_layerId>0) |
---|
| 1232 | { |
---|
| 1233 | g_bitDepthY = m_cSPS.getBitDepthY(); |
---|
| 1234 | g_bitDepthC = m_cSPS.getBitDepthC(); |
---|
| 1235 | g_uiMaxCUWidth = m_cSPS.getMaxCUWidth(); |
---|
| 1236 | g_uiMaxCUHeight = m_cSPS.getMaxCUHeight(); |
---|
| 1237 | g_uiMaxCUDepth = m_cSPS.getMaxCUDepth(); |
---|
| 1238 | g_uiAddCUDepth = max (0, m_cSPS.getLog2MinCodingBlockSize() - (Int)m_cSPS.getQuadtreeTULog2MinSize() ); |
---|
| 1239 | |
---|
| 1240 | Int numReorderPics[MAX_TLAYER]; |
---|
| 1241 | Window &conformanceWindow = m_cSPS.getConformanceWindow(); |
---|
| 1242 | Window defaultDisplayWindow = m_cSPS.getVuiParametersPresentFlag() ? m_cSPS.getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
| 1243 | |
---|
| 1244 | if (m_cIlpPic[0] == NULL) |
---|
| 1245 | { |
---|
[257] | 1246 | for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] |
---|
[191] | 1247 | { |
---|
| 1248 | m_cIlpPic[j] = new TComPic; |
---|
| 1249 | #if SVC_UPSAMPLING |
---|
| 1250 | m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true); |
---|
| 1251 | #else |
---|
| 1252 | m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 1253 | #endif |
---|
| 1254 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) |
---|
| 1255 | { |
---|
| 1256 | m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); |
---|
| 1257 | } |
---|
| 1258 | } |
---|
| 1259 | } |
---|
| 1260 | } |
---|
| 1261 | } |
---|
| 1262 | |
---|
| 1263 | Void TEncTop::setILRPic(TComPic *pcPic) |
---|
| 1264 | { |
---|
[253] | 1265 | for( Int i = 0; i < pcPic->getSlice(0)->getActiveNumILRRefIdx(); i++ ) |
---|
[191] | 1266 | { |
---|
[253] | 1267 | Int refLayerIdc = pcPic->getSlice(0)->getInterLayerPredLayerIdc(i); |
---|
| 1268 | |
---|
| 1269 | if(m_cIlpPic[refLayerIdc]) |
---|
| 1270 | { |
---|
| 1271 | m_cIlpPic[refLayerIdc]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(refLayerIdc), m_cIlpPic[refLayerIdc]->getPicYuvRec()); |
---|
| 1272 | m_cIlpPic[refLayerIdc]->getSlice(0)->setPOC(pcPic->getPOC()); |
---|
| 1273 | m_cIlpPic[refLayerIdc]->setLayerId(pcPic->getSlice(0)->getBaseColPic(refLayerIdc)->getLayerId()); //set reference layerId |
---|
| 1274 | m_cIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension(false); |
---|
| 1275 | m_cIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); |
---|
| 1276 | } |
---|
[191] | 1277 | } |
---|
| 1278 | } |
---|
| 1279 | #endif |
---|
| 1280 | #endif |
---|
| 1281 | //! \} |
---|