[313] | 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; |
---|
[442] | 85 | #if SVC_EXTENSION |
---|
[313] | 86 | memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); |
---|
| 87 | #if REF_IDX_MFM |
---|
| 88 | m_bMFMEnabledFlag = false; |
---|
| 89 | #endif |
---|
| 90 | m_numScaledRefLayerOffsets = 0; |
---|
[442] | 91 | #if POC_RESET_FLAG |
---|
| 92 | m_pocAdjustmentValue = 0; |
---|
| 93 | #endif |
---|
[467] | 94 | #endif //SVC_EXTENSION |
---|
[313] | 95 | } |
---|
| 96 | |
---|
| 97 | TEncTop::~TEncTop() |
---|
| 98 | { |
---|
| 99 | #if ENC_DEC_TRACE |
---|
| 100 | fclose( g_hTrace ); |
---|
| 101 | #endif |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | Void TEncTop::create () |
---|
| 105 | { |
---|
| 106 | #if !SVC_EXTENSION |
---|
| 107 | // initialize global variables |
---|
| 108 | initROM(); |
---|
| 109 | #endif |
---|
[442] | 110 | |
---|
[313] | 111 | // create processing unit classes |
---|
| 112 | #if SVC_EXTENSION |
---|
| 113 | m_cGOPEncoder. create( m_layerId ); |
---|
| 114 | #else |
---|
| 115 | m_cGOPEncoder. create(); |
---|
| 116 | #endif |
---|
[475] | 117 | #if AUXILIARY_PICTURES |
---|
| 118 | m_cSliceEncoder. create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 119 | #else |
---|
[313] | 120 | m_cSliceEncoder. create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
[475] | 121 | #endif |
---|
[313] | 122 | m_cCuEncoder. create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 123 | if (m_bUseSAO) |
---|
| 124 | { |
---|
| 125 | m_cEncSAO.setSaoLcuBoundary(getSaoLcuBoundary()); |
---|
| 126 | m_cEncSAO.setSaoLcuBasedOptimization(getSaoLcuBasedOptimization()); |
---|
| 127 | m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic()); |
---|
| 128 | m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 129 | m_cEncSAO.createEncBuffer(); |
---|
| 130 | } |
---|
| 131 | #if ADAPTIVE_QP_SELECTION |
---|
| 132 | if (m_bUseAdaptQpSelect) |
---|
| 133 | { |
---|
| 134 | m_cTrQuant.initSliceQpDelta(); |
---|
| 135 | } |
---|
| 136 | #endif |
---|
| 137 | m_cLoopFilter. create( g_uiMaxCUDepth ); |
---|
| 138 | |
---|
| 139 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 140 | if ( m_RCEnableRateControl ) |
---|
| 141 | { |
---|
| 142 | m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight, |
---|
| 143 | g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList ); |
---|
| 144 | } |
---|
| 145 | #else |
---|
| 146 | m_cRateCtrl.create(getIntraPeriod(), getGOPSize(), getFrameRate(), getTargetBitrate(), getQP(), getNumLCUInUnit(), getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight); |
---|
| 147 | #endif |
---|
| 148 | // if SBAC-based RD optimization is used |
---|
| 149 | if( m_bUseSBACRD ) |
---|
| 150 | { |
---|
| 151 | m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1]; |
---|
| 152 | #if FAST_BIT_EST |
---|
| 153 | m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1]; |
---|
| 154 | #else |
---|
| 155 | m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1]; |
---|
| 156 | #endif |
---|
| 157 | |
---|
| 158 | for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 159 | { |
---|
| 160 | m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM]; |
---|
| 161 | #if FAST_BIT_EST |
---|
| 162 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM]; |
---|
| 163 | #else |
---|
| 164 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM]; |
---|
| 165 | #endif |
---|
| 166 | |
---|
| 167 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 168 | { |
---|
| 169 | m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac; |
---|
| 170 | #if FAST_BIT_EST |
---|
| 171 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; |
---|
| 172 | #else |
---|
| 173 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; |
---|
| 174 | #endif |
---|
| 175 | m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); |
---|
| 176 | } |
---|
| 177 | } |
---|
| 178 | } |
---|
[467] | 179 | |
---|
| 180 | #if LAYER_CTB |
---|
| 181 | memcpy(g_auiLayerZscanToRaster[m_layerId], g_auiZscanToRaster, sizeof( g_auiZscanToRaster ) ); |
---|
| 182 | memcpy(g_auiLayerRasterToZscan[m_layerId], g_auiRasterToZscan, sizeof( g_auiRasterToZscan ) ); |
---|
| 183 | memcpy(g_auiLayerRasterToPelX[m_layerId], g_auiRasterToPelX, sizeof( g_auiRasterToPelX ) ); |
---|
| 184 | memcpy(g_auiLayerRasterToPelY[m_layerId], g_auiRasterToPelY, sizeof( g_auiRasterToPelY ) ); |
---|
| 185 | #endif |
---|
[313] | 186 | } |
---|
| 187 | |
---|
| 188 | /** |
---|
| 189 | - Allocate coders required for wavefront for the nominated number of substreams. |
---|
| 190 | . |
---|
| 191 | \param iNumSubstreams Determines how much information to allocate. |
---|
| 192 | */ |
---|
| 193 | Void TEncTop::createWPPCoders(Int iNumSubstreams) |
---|
| 194 | { |
---|
| 195 | if (m_pcSbacCoders != NULL) |
---|
| 196 | { |
---|
| 197 | return; // already generated. |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | m_iNumSubstreams = iNumSubstreams; |
---|
| 201 | m_pcSbacCoders = new TEncSbac [iNumSubstreams]; |
---|
| 202 | m_pcBinCoderCABACs = new TEncBinCABAC [iNumSubstreams]; |
---|
| 203 | m_pcRDGoOnSbacCoders = new TEncSbac [iNumSubstreams]; |
---|
| 204 | m_pcRDGoOnBinCodersCABAC = new TEncBinCABAC [iNumSubstreams]; |
---|
| 205 | m_pcBitCounters = new TComBitCounter [iNumSubstreams]; |
---|
| 206 | m_pcRdCosts = new TComRdCost [iNumSubstreams]; |
---|
| 207 | |
---|
| 208 | for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ ) |
---|
| 209 | { |
---|
| 210 | m_pcRDGoOnSbacCoders[ui].init( &m_pcRDGoOnBinCodersCABAC[ui] ); |
---|
| 211 | m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] ); |
---|
| 212 | } |
---|
| 213 | if( m_bUseSBACRD ) |
---|
| 214 | { |
---|
| 215 | m_ppppcRDSbacCoders = new TEncSbac*** [iNumSubstreams]; |
---|
| 216 | m_ppppcBinCodersCABAC = new TEncBinCABAC***[iNumSubstreams]; |
---|
| 217 | for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) |
---|
| 218 | { |
---|
| 219 | m_ppppcRDSbacCoders[ui] = new TEncSbac** [g_uiMaxCUDepth+1]; |
---|
| 220 | m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1]; |
---|
| 221 | |
---|
| 222 | for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 223 | { |
---|
| 224 | m_ppppcRDSbacCoders[ui][iDepth] = new TEncSbac* [CI_NUM]; |
---|
| 225 | m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM]; |
---|
| 226 | |
---|
| 227 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 228 | { |
---|
| 229 | m_ppppcRDSbacCoders [ui][iDepth][iCIIdx] = new TEncSbac; |
---|
| 230 | m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC; |
---|
| 231 | m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] ); |
---|
| 232 | } |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | } |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | Void TEncTop::destroy () |
---|
| 239 | { |
---|
| 240 | // destroy processing unit classes |
---|
| 241 | m_cGOPEncoder. destroy(); |
---|
| 242 | m_cSliceEncoder. destroy(); |
---|
| 243 | m_cCuEncoder. destroy(); |
---|
| 244 | if (m_cSPS.getUseSAO()) |
---|
| 245 | { |
---|
| 246 | m_cEncSAO.destroy(); |
---|
| 247 | m_cEncSAO.destroyEncBuffer(); |
---|
| 248 | } |
---|
| 249 | m_cLoopFilter. destroy(); |
---|
| 250 | m_cRateCtrl. destroy(); |
---|
| 251 | // SBAC RD |
---|
| 252 | if( m_bUseSBACRD ) |
---|
| 253 | { |
---|
| 254 | Int iDepth; |
---|
| 255 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 256 | { |
---|
| 257 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 258 | { |
---|
| 259 | delete m_pppcRDSbacCoder[iDepth][iCIIdx]; |
---|
| 260 | delete m_pppcBinCoderCABAC[iDepth][iCIIdx]; |
---|
| 261 | } |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 265 | { |
---|
| 266 | delete [] m_pppcRDSbacCoder[iDepth]; |
---|
| 267 | delete [] m_pppcBinCoderCABAC[iDepth]; |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | delete [] m_pppcRDSbacCoder; |
---|
| 271 | delete [] m_pppcBinCoderCABAC; |
---|
| 272 | |
---|
| 273 | for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ ) |
---|
| 274 | { |
---|
| 275 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 276 | { |
---|
| 277 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 278 | { |
---|
| 279 | delete m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]; |
---|
| 280 | delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx]; |
---|
| 281 | } |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 285 | { |
---|
| 286 | delete [] m_ppppcRDSbacCoders [ui][iDepth]; |
---|
| 287 | delete [] m_ppppcBinCodersCABAC[ui][iDepth]; |
---|
| 288 | } |
---|
| 289 | delete[] m_ppppcRDSbacCoders [ui]; |
---|
| 290 | delete[] m_ppppcBinCodersCABAC[ui]; |
---|
| 291 | } |
---|
| 292 | delete[] m_ppppcRDSbacCoders; |
---|
| 293 | delete[] m_ppppcBinCodersCABAC; |
---|
| 294 | } |
---|
| 295 | delete[] m_pcSbacCoders; |
---|
| 296 | delete[] m_pcBinCoderCABACs; |
---|
| 297 | delete[] m_pcRDGoOnSbacCoders; |
---|
| 298 | delete[] m_pcRDGoOnBinCodersCABAC; |
---|
| 299 | delete[] m_pcBitCounters; |
---|
| 300 | delete[] m_pcRdCosts; |
---|
| 301 | |
---|
[442] | 302 | #if SVC_EXTENSION |
---|
[313] | 303 | for(Int i=0; i<MAX_NUM_REF; i++) |
---|
| 304 | { |
---|
| 305 | if(m_cIlpPic[i]) |
---|
| 306 | { |
---|
| 307 | m_cIlpPic[i]->destroy(); |
---|
| 308 | delete m_cIlpPic[i]; |
---|
| 309 | m_cIlpPic[i] = NULL; |
---|
| 310 | } |
---|
[442] | 311 | } |
---|
| 312 | #else |
---|
| 313 | // destroy ROM |
---|
| 314 | destroyROM(); |
---|
[313] | 315 | #endif |
---|
| 316 | return; |
---|
| 317 | } |
---|
| 318 | |
---|
[442] | 319 | Void TEncTop::init(Bool isFieldCoding) |
---|
[313] | 320 | { |
---|
| 321 | // initialize SPS |
---|
| 322 | xInitSPS(); |
---|
| 323 | |
---|
| 324 | /* set the VPS profile information */ |
---|
| 325 | *m_cVPS.getPTL() = *m_cSPS.getPTL(); |
---|
| 326 | m_cVPS.getTimingInfo()->setTimingInfoPresentFlag ( false ); |
---|
| 327 | // initialize PPS |
---|
| 328 | m_cPPS.setSPS(&m_cSPS); |
---|
| 329 | xInitPPS(); |
---|
[442] | 330 | xInitRPS(isFieldCoding); |
---|
[313] | 331 | |
---|
| 332 | xInitPPSforTiles(); |
---|
| 333 | |
---|
| 334 | // initialize processing unit classes |
---|
| 335 | m_cGOPEncoder. init( this ); |
---|
| 336 | m_cSliceEncoder.init( this ); |
---|
| 337 | m_cCuEncoder. init( this ); |
---|
| 338 | |
---|
| 339 | // initialize transform & quantization class |
---|
| 340 | m_pcCavlcCoder = getCavlcCoder(); |
---|
| 341 | |
---|
| 342 | m_cTrQuant.init( 1 << m_uiQuadtreeTULog2MaxSize, |
---|
| 343 | m_useRDOQ, |
---|
| 344 | m_useRDOQTS, |
---|
| 345 | true |
---|
| 346 | ,m_useTransformSkipFast |
---|
| 347 | #if ADAPTIVE_QP_SELECTION |
---|
| 348 | , m_bUseAdaptQpSelect |
---|
| 349 | #endif |
---|
| 350 | ); |
---|
| 351 | |
---|
| 352 | // initialize encoder search class |
---|
| 353 | m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); |
---|
| 354 | |
---|
| 355 | m_iMaxRefPicNum = 0; |
---|
| 356 | #if SVC_EXTENSION |
---|
| 357 | m_iSPSIdCnt ++; |
---|
| 358 | m_iPPSIdCnt ++; |
---|
| 359 | xInitILRP(); |
---|
| 360 | #endif |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | // ==================================================================================================================== |
---|
| 364 | // Public member functions |
---|
| 365 | // ==================================================================================================================== |
---|
| 366 | |
---|
| 367 | Void TEncTop::deletePicBuffer() |
---|
| 368 | { |
---|
| 369 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 370 | Int iSize = Int( m_cListPic.size() ); |
---|
| 371 | |
---|
| 372 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 373 | { |
---|
| 374 | TComPic* pcPic = *(iterPic++); |
---|
| 375 | |
---|
| 376 | pcPic->destroy(); |
---|
| 377 | delete pcPic; |
---|
| 378 | pcPic = NULL; |
---|
| 379 | } |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | /** |
---|
| 383 | - Application has picture buffer list with size of GOP + 1 |
---|
| 384 | - Picture buffer list acts like as ring buffer |
---|
| 385 | - End of the list has the latest picture |
---|
| 386 | . |
---|
| 387 | \param flush cause encoder to encode a partial GOP |
---|
| 388 | \param pcPicYuvOrg original YUV picture |
---|
| 389 | \retval rcListPicYuvRecOut list of reconstruction YUV pictures |
---|
| 390 | \retval rcListBitstreamOut list of output bitstreams |
---|
| 391 | \retval iNumEncoded number of encoded pictures |
---|
| 392 | */ |
---|
| 393 | #if SVC_EXTENSION |
---|
| 394 | Void TEncTop::encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP ) |
---|
| 395 | { |
---|
| 396 | // compress GOP |
---|
| 397 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 398 | #if !RC_SHVC_HARMONIZATION |
---|
| 399 | if ( m_RCEnableRateControl ) |
---|
| 400 | { |
---|
| 401 | m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); |
---|
| 402 | } |
---|
| 403 | #endif |
---|
| 404 | #endif |
---|
| 405 | |
---|
| 406 | // compress GOP |
---|
[442] | 407 | m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); |
---|
[313] | 408 | |
---|
| 409 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 410 | #if !RC_SHVC_HARMONIZATION |
---|
| 411 | if ( m_RCEnableRateControl ) |
---|
| 412 | { |
---|
| 413 | m_cRateCtrl.destroyRCGOP(); |
---|
| 414 | } |
---|
| 415 | #endif |
---|
| 416 | #endif |
---|
| 417 | |
---|
| 418 | m_uiNumAllPicCoded ++; |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg ) |
---|
| 422 | { |
---|
| 423 | if (pcPicYuvOrg) |
---|
| 424 | { |
---|
| 425 | // get original YUV |
---|
| 426 | TComPic* pcPicCurr = NULL; |
---|
| 427 | xGetNewPicBuffer( pcPicCurr ); |
---|
| 428 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
| 429 | |
---|
| 430 | // compute image characteristics |
---|
| 431 | if ( getUseAdaptiveQP() ) |
---|
| 432 | { |
---|
| 433 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
| 434 | } |
---|
| 435 | } |
---|
| 436 | } |
---|
| 437 | #else |
---|
| 438 | Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ) |
---|
| 439 | { |
---|
| 440 | if (pcPicYuvOrg) { |
---|
| 441 | // get original YUV |
---|
| 442 | TComPic* pcPicCurr = NULL; |
---|
| 443 | xGetNewPicBuffer( pcPicCurr ); |
---|
| 444 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
| 445 | |
---|
| 446 | // compute image characteristics |
---|
| 447 | if ( getUseAdaptiveQP() ) |
---|
| 448 | { |
---|
| 449 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
| 450 | } |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | if (!m_iNumPicRcvd || (!flush && m_iPOCLast != 0 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) |
---|
| 454 | { |
---|
| 455 | iNumEncoded = 0; |
---|
| 456 | return; |
---|
| 457 | } |
---|
| 458 | |
---|
| 459 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 460 | if ( m_RCEnableRateControl ) |
---|
| 461 | { |
---|
| 462 | m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); |
---|
| 463 | } |
---|
| 464 | #endif |
---|
| 465 | |
---|
| 466 | // compress GOP |
---|
| 467 | |
---|
[442] | 468 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); |
---|
| 469 | |
---|
[313] | 470 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 471 | if ( m_RCEnableRateControl ) |
---|
| 472 | { |
---|
| 473 | m_cRateCtrl.destroyRCGOP(); |
---|
| 474 | } |
---|
| 475 | #endif |
---|
| 476 | |
---|
| 477 | iNumEncoded = m_iNumPicRcvd; |
---|
| 478 | m_iNumPicRcvd = 0; |
---|
| 479 | m_uiNumAllPicCoded += iNumEncoded; |
---|
| 480 | } |
---|
| 481 | #endif |
---|
| 482 | |
---|
[442] | 483 | /**------------------------------------------------ |
---|
| 484 | Separate interlaced frame into two fields |
---|
| 485 | -------------------------------------------------**/ |
---|
| 486 | void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, Bool isTop) |
---|
| 487 | { |
---|
| 488 | if (!isTop) |
---|
| 489 | { |
---|
| 490 | org += stride; |
---|
| 491 | } |
---|
| 492 | for (Int y = 0; y < height>>1; y++) |
---|
| 493 | { |
---|
| 494 | for (Int x = 0; x < width; x++) |
---|
| 495 | { |
---|
| 496 | dstField[x] = org[x]; |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | dstField += stride; |
---|
| 500 | org += stride*2; |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | } |
---|
| 504 | |
---|
| 505 | #if SVC_EXTENSION |
---|
| 506 | Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg, Bool isTff ) |
---|
| 507 | { |
---|
| 508 | if (pcPicYuvOrg) |
---|
| 509 | { |
---|
| 510 | /* -- TOP FIELD -- */ |
---|
| 511 | /* -- Top field initialization -- */ |
---|
| 512 | |
---|
| 513 | TComPic *pcTopField; |
---|
| 514 | xGetNewPicBuffer( pcTopField ); |
---|
| 515 | pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); |
---|
| 516 | pcTopField->setReconMark (false); |
---|
| 517 | |
---|
| 518 | pcTopField->getSlice(0)->setPOC( m_iPOCLast ); |
---|
| 519 | pcTopField->getPicYuvRec()->setBorderExtension(false); |
---|
| 520 | pcTopField->setTopField(isTff); |
---|
| 521 | |
---|
| 522 | Int nHeight = pcPicYuvOrg->getHeight(); |
---|
| 523 | Int nWidth = pcPicYuvOrg->getWidth(); |
---|
| 524 | Int nStride = pcPicYuvOrg->getStride(); |
---|
| 525 | Int nPadLuma = pcPicYuvOrg->getLumaMargin(); |
---|
| 526 | Int nPadChroma = pcPicYuvOrg->getChromaMargin(); |
---|
| 527 | |
---|
| 528 | // Get pointers |
---|
| 529 | Pel * PicBufY = pcPicYuvOrg->getBufY(); |
---|
| 530 | Pel * PicBufU = pcPicYuvOrg->getBufU(); |
---|
| 531 | Pel * PicBufV = pcPicYuvOrg->getBufV(); |
---|
| 532 | |
---|
| 533 | Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); |
---|
| 534 | Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); |
---|
| 535 | Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); |
---|
| 536 | |
---|
| 537 | // compute image characteristics |
---|
| 538 | if ( getUseAdaptiveQP() ) |
---|
| 539 | { |
---|
| 540 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); |
---|
| 541 | } |
---|
| 542 | |
---|
| 543 | /* -- Defield -- */ |
---|
| 544 | |
---|
| 545 | Bool isTop = isTff; |
---|
| 546 | |
---|
| 547 | separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); |
---|
| 548 | separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); |
---|
| 549 | separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); |
---|
| 550 | |
---|
| 551 | /* -- BOTTOM FIELD -- */ |
---|
| 552 | /* -- Bottom field initialization -- */ |
---|
| 553 | |
---|
| 554 | TComPic* pcBottomField; |
---|
| 555 | xGetNewPicBuffer( pcBottomField ); |
---|
| 556 | pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); |
---|
| 557 | pcBottomField->setReconMark (false); |
---|
| 558 | |
---|
| 559 | pcBottomField->getSlice(0)->setPOC( m_iPOCLast); |
---|
| 560 | pcBottomField->getPicYuvRec()->setBorderExtension(false); |
---|
| 561 | pcBottomField->setTopField(!isTff); |
---|
| 562 | |
---|
| 563 | nHeight = pcPicYuvOrg->getHeight(); |
---|
| 564 | nWidth = pcPicYuvOrg->getWidth(); |
---|
| 565 | nStride = pcPicYuvOrg->getStride(); |
---|
| 566 | nPadLuma = pcPicYuvOrg->getLumaMargin(); |
---|
| 567 | nPadChroma = pcPicYuvOrg->getChromaMargin(); |
---|
| 568 | |
---|
| 569 | // Get pointers |
---|
| 570 | PicBufY = pcPicYuvOrg->getBufY(); |
---|
| 571 | PicBufU = pcPicYuvOrg->getBufU(); |
---|
| 572 | PicBufV = pcPicYuvOrg->getBufV(); |
---|
| 573 | |
---|
| 574 | Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); |
---|
| 575 | Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); |
---|
| 576 | Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); |
---|
| 577 | |
---|
| 578 | // Compute image characteristics |
---|
| 579 | if ( getUseAdaptiveQP() ) |
---|
| 580 | { |
---|
| 581 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | /* -- Defield -- */ |
---|
| 585 | |
---|
| 586 | isTop = !isTff; |
---|
| 587 | |
---|
| 588 | separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); |
---|
| 589 | separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); |
---|
| 590 | separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); |
---|
| 591 | |
---|
| 592 | } |
---|
| 593 | } |
---|
| 594 | |
---|
| 595 | Void TEncTop::encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff ) |
---|
| 596 | { |
---|
| 597 | // compress GOP |
---|
| 598 | if (m_iPOCLast == 0) // compress field 0 |
---|
| 599 | { |
---|
| 600 | m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); |
---|
| 601 | } |
---|
| 602 | |
---|
| 603 | if (pcPicYuvOrg) |
---|
| 604 | { |
---|
| 605 | TComPicYuv* rpcPicYuvRec = new TComPicYuv; |
---|
| 606 | if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) |
---|
| 607 | { |
---|
| 608 | rpcPicYuvRec = rcListPicYuvRecOut.popFront(); |
---|
| 609 | } |
---|
| 610 | else |
---|
| 611 | { |
---|
[475] | 612 | #if AUXILIARY_PICTURES |
---|
| 613 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 614 | #else |
---|
[442] | 615 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
[475] | 616 | #endif |
---|
[442] | 617 | } |
---|
| 618 | rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); |
---|
| 619 | } |
---|
| 620 | |
---|
| 621 | // compress GOP |
---|
| 622 | m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); |
---|
| 623 | |
---|
| 624 | m_uiNumAllPicCoded ++; |
---|
| 625 | } |
---|
| 626 | #else |
---|
| 627 | Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff) |
---|
| 628 | { |
---|
| 629 | /* -- TOP FIELD -- */ |
---|
| 630 | |
---|
| 631 | if (pcPicYuvOrg) |
---|
| 632 | { |
---|
| 633 | |
---|
| 634 | /* -- Top field initialization -- */ |
---|
| 635 | |
---|
| 636 | TComPic *pcTopField; |
---|
| 637 | xGetNewPicBuffer( pcTopField ); |
---|
| 638 | pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); |
---|
| 639 | pcTopField->setReconMark (false); |
---|
| 640 | |
---|
| 641 | pcTopField->getSlice(0)->setPOC( m_iPOCLast ); |
---|
| 642 | pcTopField->getPicYuvRec()->setBorderExtension(false); |
---|
| 643 | pcTopField->setTopField(isTff); |
---|
| 644 | |
---|
| 645 | Int nHeight = pcPicYuvOrg->getHeight(); |
---|
| 646 | Int nWidth = pcPicYuvOrg->getWidth(); |
---|
| 647 | Int nStride = pcPicYuvOrg->getStride(); |
---|
| 648 | Int nPadLuma = pcPicYuvOrg->getLumaMargin(); |
---|
| 649 | Int nPadChroma = pcPicYuvOrg->getChromaMargin(); |
---|
| 650 | |
---|
| 651 | // Get pointers |
---|
| 652 | Pel * PicBufY = pcPicYuvOrg->getBufY(); |
---|
| 653 | Pel * PicBufU = pcPicYuvOrg->getBufU(); |
---|
| 654 | Pel * PicBufV = pcPicYuvOrg->getBufV(); |
---|
| 655 | |
---|
| 656 | Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); |
---|
| 657 | Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); |
---|
| 658 | Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); |
---|
| 659 | |
---|
| 660 | // compute image characteristics |
---|
| 661 | if ( getUseAdaptiveQP() ) |
---|
| 662 | { |
---|
| 663 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); |
---|
| 664 | } |
---|
| 665 | |
---|
| 666 | /* -- Defield -- */ |
---|
| 667 | |
---|
| 668 | Bool isTop = isTff; |
---|
| 669 | |
---|
| 670 | separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); |
---|
| 671 | separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); |
---|
| 672 | separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); |
---|
| 673 | |
---|
| 674 | } |
---|
| 675 | |
---|
| 676 | if (m_iPOCLast == 0) // compress field 0 |
---|
| 677 | { |
---|
| 678 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); |
---|
| 679 | } |
---|
| 680 | |
---|
| 681 | /* -- BOTTOM FIELD -- */ |
---|
| 682 | |
---|
| 683 | if (pcPicYuvOrg) |
---|
| 684 | { |
---|
| 685 | |
---|
| 686 | /* -- Bottom field initialization -- */ |
---|
| 687 | |
---|
| 688 | TComPic* pcBottomField; |
---|
| 689 | xGetNewPicBuffer( pcBottomField ); |
---|
| 690 | pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); |
---|
| 691 | pcBottomField->setReconMark (false); |
---|
| 692 | |
---|
| 693 | TComPicYuv* rpcPicYuvRec = new TComPicYuv; |
---|
| 694 | if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) |
---|
| 695 | { |
---|
| 696 | rpcPicYuvRec = rcListPicYuvRecOut.popFront(); |
---|
| 697 | } |
---|
| 698 | else |
---|
| 699 | { |
---|
| 700 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 701 | } |
---|
| 702 | rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); |
---|
| 703 | |
---|
| 704 | pcBottomField->getSlice(0)->setPOC( m_iPOCLast); |
---|
| 705 | pcBottomField->getPicYuvRec()->setBorderExtension(false); |
---|
| 706 | pcBottomField->setTopField(!isTff); |
---|
| 707 | |
---|
| 708 | int nHeight = pcPicYuvOrg->getHeight(); |
---|
| 709 | int nWidth = pcPicYuvOrg->getWidth(); |
---|
| 710 | int nStride = pcPicYuvOrg->getStride(); |
---|
| 711 | int nPadLuma = pcPicYuvOrg->getLumaMargin(); |
---|
| 712 | int nPadChroma = pcPicYuvOrg->getChromaMargin(); |
---|
| 713 | |
---|
| 714 | // Get pointers |
---|
| 715 | Pel * PicBufY = pcPicYuvOrg->getBufY(); |
---|
| 716 | Pel * PicBufU = pcPicYuvOrg->getBufU(); |
---|
| 717 | Pel * PicBufV = pcPicYuvOrg->getBufV(); |
---|
| 718 | |
---|
| 719 | Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); |
---|
| 720 | Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); |
---|
| 721 | Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); |
---|
| 722 | |
---|
| 723 | // Compute image characteristics |
---|
| 724 | if ( getUseAdaptiveQP() ) |
---|
| 725 | { |
---|
| 726 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); |
---|
| 727 | } |
---|
| 728 | |
---|
| 729 | /* -- Defield -- */ |
---|
| 730 | |
---|
| 731 | Bool isTop = !isTff; |
---|
| 732 | |
---|
| 733 | separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); |
---|
| 734 | separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); |
---|
| 735 | separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); |
---|
| 736 | |
---|
| 737 | } |
---|
| 738 | |
---|
| 739 | if ( ( !(m_iNumPicRcvd) || (!flush && m_iPOCLast != 1 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) ) |
---|
| 740 | { |
---|
| 741 | iNumEncoded = 0; |
---|
| 742 | return; |
---|
| 743 | } |
---|
| 744 | |
---|
| 745 | // compress GOP |
---|
| 746 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); |
---|
| 747 | |
---|
| 748 | iNumEncoded = m_iNumPicRcvd; |
---|
| 749 | m_iNumPicRcvd = 0; |
---|
| 750 | m_uiNumAllPicCoded += iNumEncoded; |
---|
| 751 | } |
---|
| 752 | #endif |
---|
| 753 | |
---|
[313] | 754 | // ==================================================================================================================== |
---|
| 755 | // Protected member functions |
---|
| 756 | // ==================================================================================================================== |
---|
| 757 | |
---|
| 758 | /** |
---|
| 759 | - Application has picture buffer list with size of GOP + 1 |
---|
| 760 | - Picture buffer list acts like as ring buffer |
---|
| 761 | - End of the list has the latest picture |
---|
| 762 | . |
---|
| 763 | \retval rpcPic obtained picture buffer |
---|
| 764 | */ |
---|
| 765 | Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic ) |
---|
| 766 | { |
---|
| 767 | TComSlice::sortPicList(m_cListPic); |
---|
| 768 | |
---|
| 769 | if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
---|
| 770 | { |
---|
| 771 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 772 | Int iSize = Int( m_cListPic.size() ); |
---|
| 773 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 774 | { |
---|
| 775 | rpcPic = *(iterPic++); |
---|
| 776 | if(rpcPic->getSlice(0)->isReferenced() == false) |
---|
| 777 | { |
---|
| 778 | break; |
---|
| 779 | } |
---|
| 780 | } |
---|
| 781 | } |
---|
| 782 | else |
---|
| 783 | { |
---|
| 784 | if ( getUseAdaptiveQP() ) |
---|
| 785 | { |
---|
| 786 | TEncPic* pcEPic = new TEncPic; |
---|
| 787 | |
---|
| 788 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
| 789 | if(m_layerId > 0) |
---|
| 790 | { |
---|
| 791 | for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) |
---|
| 792 | { |
---|
| 793 | const Window scalEL = getSPS()->getScaledRefLayerWindow(i); |
---|
| 794 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
---|
| 795 | |
---|
| 796 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 797 | TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i ); |
---|
| 798 | #else |
---|
| 799 | TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); |
---|
| 800 | #endif |
---|
| 801 | if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets ) |
---|
| 802 | { |
---|
| 803 | pcEPic->setSpatialEnhLayerFlag( i, true ); |
---|
| 804 | |
---|
| 805 | //only for scalable extension |
---|
[442] | 806 | #if SCALABILITY_MASK_E0104 |
---|
| 807 | assert( m_cVPS.getScalabilityMask(2) == true ); |
---|
| 808 | #else |
---|
[313] | 809 | assert( m_cVPS.getScalabilityMask(1) == true ); |
---|
[442] | 810 | #endif |
---|
[313] | 811 | } |
---|
| 812 | } |
---|
| 813 | } |
---|
| 814 | #endif |
---|
| 815 | |
---|
[475] | 816 | #if AUXILIARY_PICTURES |
---|
[313] | 817 | #if SVC_UPSAMPLING |
---|
[475] | 818 | pcEPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 , |
---|
| 819 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS); |
---|
| 820 | #else |
---|
| 821 | pcEPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 , |
---|
| 822 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics); |
---|
| 823 | #endif |
---|
| 824 | #else |
---|
| 825 | #if SVC_UPSAMPLING |
---|
[313] | 826 | pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 , |
---|
| 827 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS); |
---|
| 828 | #else |
---|
| 829 | pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 , |
---|
| 830 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics); |
---|
| 831 | #endif |
---|
[475] | 832 | #endif |
---|
[313] | 833 | rpcPic = pcEPic; |
---|
| 834 | } |
---|
| 835 | else |
---|
| 836 | { |
---|
| 837 | rpcPic = new TComPic; |
---|
| 838 | |
---|
| 839 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
| 840 | if(m_layerId > 0) |
---|
| 841 | { |
---|
| 842 | for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) |
---|
| 843 | { |
---|
| 844 | const Window scalEL = getSPS()->getScaledRefLayerWindow(i); |
---|
| 845 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
---|
| 846 | |
---|
| 847 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 848 | TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i ); |
---|
| 849 | #else |
---|
| 850 | TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); |
---|
| 851 | #endif |
---|
| 852 | if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets ) |
---|
| 853 | { |
---|
| 854 | rpcPic->setSpatialEnhLayerFlag( i, true ); |
---|
| 855 | |
---|
| 856 | //only for scalable extension |
---|
[442] | 857 | #if SCALABILITY_MASK_E0104 |
---|
| 858 | assert( m_cVPS.getScalabilityMask(2) == true ); |
---|
| 859 | #else |
---|
[313] | 860 | assert( m_cVPS.getScalabilityMask(1) == true ); |
---|
[442] | 861 | #endif |
---|
[313] | 862 | } |
---|
| 863 | } |
---|
| 864 | } |
---|
| 865 | #endif |
---|
| 866 | |
---|
[475] | 867 | #if AUXILIARY_PICTURES |
---|
[313] | 868 | #if SVC_UPSAMPLING |
---|
[475] | 869 | rpcPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 870 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS); |
---|
| 871 | #else |
---|
| 872 | rpcPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 873 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics); |
---|
| 874 | #endif |
---|
| 875 | #else |
---|
| 876 | #if SVC_UPSAMPLING |
---|
[313] | 877 | rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 878 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS); |
---|
| 879 | #else |
---|
| 880 | rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 881 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics); |
---|
| 882 | #endif |
---|
[475] | 883 | #endif |
---|
[313] | 884 | } |
---|
| 885 | |
---|
| 886 | if (getUseSAO()) |
---|
| 887 | { |
---|
| 888 | rpcPic->getPicSym()->allocSaoParam(&m_cEncSAO); |
---|
| 889 | } |
---|
| 890 | m_cListPic.pushBack( rpcPic ); |
---|
| 891 | } |
---|
| 892 | rpcPic->setReconMark (false); |
---|
| 893 | |
---|
| 894 | m_iPOCLast++; |
---|
| 895 | m_iNumPicRcvd++; |
---|
| 896 | |
---|
| 897 | rpcPic->getSlice(0)->setPOC( m_iPOCLast ); |
---|
| 898 | // mark it should be extended |
---|
| 899 | rpcPic->getPicYuvRec()->setBorderExtension(false); |
---|
| 900 | } |
---|
| 901 | |
---|
| 902 | Void TEncTop::xInitSPS() |
---|
| 903 | { |
---|
| 904 | #if SVC_EXTENSION |
---|
| 905 | m_cSPS.setLayerId(m_layerId); |
---|
| 906 | #if REF_IDX_MFM |
---|
| 907 | #if !M0457_COL_PICTURE_SIGNALING |
---|
| 908 | m_cSPS.setMFMEnabledFlag(m_bMFMEnabledFlag); |
---|
| 909 | #endif |
---|
| 910 | #endif |
---|
| 911 | m_cSPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets); |
---|
| 912 | for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++) |
---|
| 913 | { |
---|
| 914 | m_cSPS.getScaledRefLayerWindow(i) = m_scaledRefLayerWindow[i]; |
---|
| 915 | } |
---|
[467] | 916 | #endif //SVC_EXTENSION |
---|
[313] | 917 | ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL(); |
---|
| 918 | profileTierLevel.setLevelIdc(m_level); |
---|
| 919 | profileTierLevel.setTierFlag(m_levelTier); |
---|
| 920 | profileTierLevel.setProfileIdc(m_profile); |
---|
| 921 | profileTierLevel.setProfileCompatibilityFlag(m_profile, 1); |
---|
| 922 | profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
| 923 | profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
| 924 | profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
| 925 | profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
| 926 | |
---|
| 927 | if (m_profile == Profile::MAIN10 && g_bitDepthY == 8 && g_bitDepthC == 8) |
---|
| 928 | { |
---|
| 929 | /* The above constraint is equal to Profile::MAIN */ |
---|
| 930 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN, 1); |
---|
| 931 | } |
---|
| 932 | if (m_profile == Profile::MAIN) |
---|
| 933 | { |
---|
| 934 | /* A Profile::MAIN10 decoder can always decode Profile::MAIN */ |
---|
| 935 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN10, 1); |
---|
| 936 | } |
---|
| 937 | /* XXX: should Main be marked as compatible with still picture? */ |
---|
| 938 | /* XXX: may be a good idea to refactor the above into a function |
---|
| 939 | * that chooses the actual compatibility based upon options */ |
---|
| 940 | |
---|
| 941 | m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth ); |
---|
| 942 | m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight ); |
---|
| 943 | m_cSPS.setConformanceWindow ( m_conformanceWindow ); |
---|
| 944 | m_cSPS.setMaxCUWidth ( g_uiMaxCUWidth ); |
---|
| 945 | m_cSPS.setMaxCUHeight ( g_uiMaxCUHeight ); |
---|
| 946 | m_cSPS.setMaxCUDepth ( g_uiMaxCUDepth ); |
---|
[475] | 947 | #if AUXILIARY_PICTURES |
---|
| 948 | m_cSPS.setChromaFormatIdc( m_chromaFormatIDC); |
---|
| 949 | #endif |
---|
[313] | 950 | |
---|
| 951 | Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getMaxCUDepth()-g_uiAddCUDepth ); |
---|
| 952 | Int log2MinCUSize = 0; |
---|
| 953 | while(minCUSize > 1) |
---|
| 954 | { |
---|
| 955 | minCUSize >>= 1; |
---|
| 956 | log2MinCUSize++; |
---|
| 957 | } |
---|
| 958 | |
---|
| 959 | m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize); |
---|
| 960 | m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_cSPS.getMaxCUDepth()-g_uiAddCUDepth); |
---|
| 961 | #if SVC_EXTENSION |
---|
| 962 | m_cSPS.setSPSId ( m_iSPSIdCnt ); |
---|
| 963 | #endif |
---|
| 964 | |
---|
| 965 | m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize); |
---|
| 966 | m_cSPS.setUsePCM ( m_usePCM ); |
---|
| 967 | m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize ); |
---|
| 968 | |
---|
| 969 | m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); |
---|
| 970 | m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize ); |
---|
| 971 | m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter ); |
---|
| 972 | m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra ); |
---|
| 973 | |
---|
| 974 | m_cSPS.setTMVPFlagsPresent(false); |
---|
| 975 | m_cSPS.setUseLossless ( m_useLossless ); |
---|
| 976 | |
---|
| 977 | m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
| 978 | |
---|
| 979 | Int i; |
---|
| 980 | |
---|
| 981 | for (i = 0; i < g_uiMaxCUDepth-g_uiAddCUDepth; i++ ) |
---|
| 982 | { |
---|
| 983 | m_cSPS.setAMPAcc( i, m_useAMP ); |
---|
| 984 | //m_cSPS.setAMPAcc( i, 1 ); |
---|
| 985 | } |
---|
| 986 | |
---|
| 987 | m_cSPS.setUseAMP ( m_useAMP ); |
---|
| 988 | |
---|
| 989 | for (i = g_uiMaxCUDepth-g_uiAddCUDepth; i < g_uiMaxCUDepth; i++ ) |
---|
| 990 | { |
---|
| 991 | m_cSPS.setAMPAcc(i, 0); |
---|
| 992 | } |
---|
| 993 | |
---|
[442] | 994 | #if REPN_FORMAT_IN_VPS |
---|
| 995 | m_cSPS.setBitDepthY( m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsLuma() ); |
---|
| 996 | m_cSPS.setBitDepthC( m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsChroma() ); |
---|
| 997 | |
---|
| 998 | m_cSPS.setQpBDOffsetY ( 6*(m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsLuma() - 8) ); |
---|
| 999 | m_cSPS.setQpBDOffsetC ( 6*(m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsChroma() - 8) ); |
---|
| 1000 | #else |
---|
[313] | 1001 | m_cSPS.setBitDepthY( g_bitDepthY ); |
---|
| 1002 | m_cSPS.setBitDepthC( g_bitDepthC ); |
---|
| 1003 | |
---|
| 1004 | m_cSPS.setQpBDOffsetY ( 6*(g_bitDepthY - 8) ); |
---|
| 1005 | m_cSPS.setQpBDOffsetC ( 6*(g_bitDepthC - 8) ); |
---|
[442] | 1006 | #endif |
---|
[313] | 1007 | |
---|
| 1008 | m_cSPS.setUseSAO( m_bUseSAO ); |
---|
| 1009 | |
---|
| 1010 | m_cSPS.setMaxTLayers( m_maxTempLayer ); |
---|
| 1011 | m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false ); |
---|
| 1012 | for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ ) |
---|
| 1013 | { |
---|
| 1014 | m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); |
---|
| 1015 | m_cSPS.setNumReorderPics(m_numReorderPics[i], i); |
---|
| 1016 | } |
---|
| 1017 | m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma); |
---|
| 1018 | m_cSPS.setPCMBitDepthChroma (g_uiPCMBitDepthChroma); |
---|
| 1019 | m_cSPS.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag ); |
---|
| 1020 | |
---|
| 1021 | m_cSPS.setScalingListFlag ( (m_useScalingListId == 0) ? 0 : 1 ); |
---|
| 1022 | |
---|
| 1023 | m_cSPS.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
| 1024 | |
---|
| 1025 | m_cSPS.setVuiParametersPresentFlag(getVuiParametersPresentFlag()); |
---|
| 1026 | if (m_cSPS.getVuiParametersPresentFlag()) |
---|
| 1027 | { |
---|
| 1028 | TComVUI* pcVUI = m_cSPS.getVuiParameters(); |
---|
| 1029 | pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioIdc() != -1); |
---|
| 1030 | pcVUI->setAspectRatioIdc(getAspectRatioIdc()); |
---|
| 1031 | pcVUI->setSarWidth(getSarWidth()); |
---|
| 1032 | pcVUI->setSarHeight(getSarHeight()); |
---|
| 1033 | pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag()); |
---|
| 1034 | pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag()); |
---|
| 1035 | pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag()); |
---|
| 1036 | pcVUI->setVideoFormat(getVideoFormat()); |
---|
| 1037 | pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag()); |
---|
| 1038 | pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag()); |
---|
| 1039 | pcVUI->setColourPrimaries(getColourPrimaries()); |
---|
| 1040 | pcVUI->setTransferCharacteristics(getTransferCharacteristics()); |
---|
| 1041 | pcVUI->setMatrixCoefficients(getMatrixCoefficients()); |
---|
| 1042 | pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag()); |
---|
| 1043 | pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField()); |
---|
| 1044 | pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField()); |
---|
| 1045 | pcVUI->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag()); |
---|
| 1046 | pcVUI->setDefaultDisplayWindow(getDefaultDisplayWindow()); |
---|
| 1047 | pcVUI->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag()); |
---|
| 1048 | pcVUI->setFieldSeqFlag(false); |
---|
| 1049 | pcVUI->setHrdParametersPresentFlag(false); |
---|
| 1050 | pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag()); |
---|
| 1051 | pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1 (getNumTicksPocDiffOneMinus1() ); |
---|
| 1052 | pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag()); |
---|
| 1053 | pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag()); |
---|
| 1054 | pcVUI->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag()); |
---|
| 1055 | pcVUI->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc()); |
---|
| 1056 | pcVUI->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom()); |
---|
| 1057 | pcVUI->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom()); |
---|
| 1058 | pcVUI->setLog2MaxMvLengthHorizontal(getLog2MaxMvLengthHorizontal()); |
---|
| 1059 | pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical()); |
---|
| 1060 | } |
---|
| 1061 | } |
---|
| 1062 | |
---|
| 1063 | Void TEncTop::xInitPPS() |
---|
| 1064 | { |
---|
[442] | 1065 | #if IL_SL_SIGNALLING_N0371 |
---|
| 1066 | m_cPPS.setLayerId(m_layerId); |
---|
| 1067 | #endif |
---|
| 1068 | |
---|
[313] | 1069 | m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); |
---|
| 1070 | Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; |
---|
| 1071 | |
---|
[442] | 1072 | #if REPN_FORMAT_IN_VPS |
---|
| 1073 | Int lowestQP; |
---|
| 1074 | if( m_layerId == 0 || m_cSPS.getUpdateRepFormatFlag() ) |
---|
| 1075 | { |
---|
| 1076 | lowestQP = - m_cSPS.getQpBDOffsetY(); |
---|
| 1077 | } |
---|
| 1078 | else |
---|
| 1079 | { |
---|
| 1080 | lowestQP = - (m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsLuma() - 8) * 6; |
---|
| 1081 | } |
---|
| 1082 | #else |
---|
[313] | 1083 | Int lowestQP = - m_cSPS.getQpBDOffsetY(); |
---|
[442] | 1084 | #endif |
---|
[313] | 1085 | |
---|
| 1086 | if(getUseLossless()) |
---|
| 1087 | { |
---|
| 1088 | if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) ) |
---|
| 1089 | { |
---|
| 1090 | bUseDQP = false; |
---|
| 1091 | } |
---|
| 1092 | else |
---|
| 1093 | { |
---|
| 1094 | bUseDQP = true; |
---|
| 1095 | } |
---|
| 1096 | } |
---|
| 1097 | else |
---|
| 1098 | { |
---|
| 1099 | if(bUseDQP == false) |
---|
| 1100 | { |
---|
| 1101 | if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) |
---|
| 1102 | { |
---|
| 1103 | bUseDQP = true; |
---|
| 1104 | } |
---|
| 1105 | } |
---|
| 1106 | } |
---|
| 1107 | |
---|
| 1108 | if(bUseDQP) |
---|
| 1109 | { |
---|
| 1110 | m_cPPS.setUseDQP(true); |
---|
| 1111 | m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth ); |
---|
| 1112 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
| 1113 | } |
---|
| 1114 | else |
---|
| 1115 | { |
---|
| 1116 | m_cPPS.setUseDQP(false); |
---|
| 1117 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
| 1118 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
| 1119 | } |
---|
| 1120 | |
---|
| 1121 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 1122 | if ( m_RCEnableRateControl ) |
---|
| 1123 | { |
---|
| 1124 | m_cPPS.setUseDQP(true); |
---|
| 1125 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
| 1126 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
| 1127 | } |
---|
| 1128 | #endif |
---|
| 1129 | |
---|
| 1130 | m_cPPS.setChromaCbQpOffset( m_chromaCbQpOffset ); |
---|
| 1131 | m_cPPS.setChromaCrQpOffset( m_chromaCrQpOffset ); |
---|
| 1132 | |
---|
| 1133 | m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams); |
---|
| 1134 | m_cPPS.setEntropyCodingSyncEnabledFlag( m_iWaveFrontSynchro > 0 ); |
---|
| 1135 | m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) ); |
---|
| 1136 | m_cPPS.setUseWP( m_useWeightedPred ); |
---|
| 1137 | m_cPPS.setWPBiPred( m_useWeightedBiPred ); |
---|
| 1138 | m_cPPS.setOutputFlagPresentFlag( false ); |
---|
| 1139 | m_cPPS.setSignHideFlag(getSignHideFlag()); |
---|
| 1140 | if ( getDeblockingFilterMetric() ) |
---|
| 1141 | { |
---|
| 1142 | m_cPPS.setDeblockingFilterControlPresentFlag (true); |
---|
| 1143 | m_cPPS.setDeblockingFilterOverrideEnabledFlag(true); |
---|
| 1144 | m_cPPS.setPicDisableDeblockingFilterFlag(false); |
---|
| 1145 | m_cPPS.setDeblockingFilterBetaOffsetDiv2(0); |
---|
| 1146 | m_cPPS.setDeblockingFilterTcOffsetDiv2(0); |
---|
| 1147 | } |
---|
| 1148 | else |
---|
| 1149 | { |
---|
| 1150 | m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent ); |
---|
| 1151 | } |
---|
| 1152 | m_cPPS.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 ); |
---|
| 1153 | m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); |
---|
| 1154 | m_cPPS.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
| 1155 | Int histogram[MAX_NUM_REF + 1]; |
---|
| 1156 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
---|
| 1157 | { |
---|
| 1158 | histogram[i]=0; |
---|
| 1159 | } |
---|
| 1160 | for( Int i = 0; i < getGOPSize(); i++ ) |
---|
| 1161 | { |
---|
| 1162 | assert(getGOPEntry(i).m_numRefPicsActive >= 0 && getGOPEntry(i).m_numRefPicsActive <= MAX_NUM_REF); |
---|
| 1163 | histogram[getGOPEntry(i).m_numRefPicsActive]++; |
---|
| 1164 | } |
---|
| 1165 | Int maxHist=-1; |
---|
| 1166 | Int bestPos=0; |
---|
| 1167 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
---|
| 1168 | { |
---|
| 1169 | if(histogram[i]>maxHist) |
---|
| 1170 | { |
---|
| 1171 | maxHist=histogram[i]; |
---|
| 1172 | bestPos=i; |
---|
| 1173 | } |
---|
| 1174 | } |
---|
| 1175 | assert(bestPos <= 15); |
---|
| 1176 | m_cPPS.setNumRefIdxL0DefaultActive(bestPos); |
---|
| 1177 | m_cPPS.setNumRefIdxL1DefaultActive(bestPos); |
---|
| 1178 | m_cPPS.setTransquantBypassEnableFlag(getTransquantBypassEnableFlag()); |
---|
| 1179 | m_cPPS.setUseTransformSkip( m_useTransformSkip ); |
---|
| 1180 | if (m_sliceSegmentMode) |
---|
| 1181 | { |
---|
| 1182 | m_cPPS.setDependentSliceSegmentsEnabledFlag( true ); |
---|
| 1183 | } |
---|
| 1184 | if( m_cPPS.getDependentSliceSegmentsEnabledFlag() ) |
---|
| 1185 | { |
---|
| 1186 | Int NumCtx = m_cPPS.getEntropyCodingSyncEnabledFlag()?2:1; |
---|
| 1187 | m_cSliceEncoder.initCtxMem( NumCtx ); |
---|
| 1188 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
| 1189 | { |
---|
| 1190 | TEncSbac* ctx = NULL; |
---|
| 1191 | ctx = new TEncSbac; |
---|
| 1192 | ctx->init( &m_cBinCoderCABAC ); |
---|
| 1193 | m_cSliceEncoder.setCtxMem( ctx, st ); |
---|
| 1194 | } |
---|
| 1195 | } |
---|
[442] | 1196 | #if SVC_EXTENSION |
---|
[313] | 1197 | if (!m_layerId) |
---|
| 1198 | { |
---|
| 1199 | m_cPPS.setListsModificationPresentFlag(false); |
---|
| 1200 | } |
---|
| 1201 | else |
---|
| 1202 | { |
---|
| 1203 | m_cPPS.setListsModificationPresentFlag(true); |
---|
| 1204 | } |
---|
[442] | 1205 | |
---|
[313] | 1206 | m_cPPS.setPPSId ( m_iPPSIdCnt ); |
---|
| 1207 | m_cPPS.setSPSId ( m_iSPSIdCnt ); |
---|
| 1208 | #endif |
---|
[442] | 1209 | #if POC_RESET_FLAG |
---|
| 1210 | m_cPPS.setNumExtraSliceHeaderBits( 2 ); |
---|
| 1211 | #endif |
---|
[313] | 1212 | } |
---|
| 1213 | |
---|
| 1214 | //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. |
---|
[442] | 1215 | Void TEncTop::xInitRPS(Bool isFieldCoding) |
---|
[313] | 1216 | { |
---|
| 1217 | TComReferencePictureSet* rps; |
---|
| 1218 | |
---|
[442] | 1219 | m_cSPS.createRPSList(getGOPSize()+m_extraRPSs+1); |
---|
[313] | 1220 | TComRPSList* rpsList = m_cSPS.getRPSList(); |
---|
| 1221 | |
---|
| 1222 | for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) |
---|
| 1223 | { |
---|
| 1224 | GOPEntry ge = getGOPEntry(i); |
---|
| 1225 | rps = rpsList->getReferencePictureSet(i); |
---|
| 1226 | rps->setNumberOfPictures(ge.m_numRefPics); |
---|
| 1227 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
| 1228 | Int numNeg = 0; |
---|
| 1229 | Int numPos = 0; |
---|
| 1230 | for( Int j = 0; j < ge.m_numRefPics; j++) |
---|
| 1231 | { |
---|
| 1232 | rps->setDeltaPOC(j,ge.m_referencePics[j]); |
---|
| 1233 | rps->setUsed(j,ge.m_usedByCurrPic[j]); |
---|
| 1234 | if(ge.m_referencePics[j]>0) |
---|
| 1235 | { |
---|
| 1236 | numPos++; |
---|
| 1237 | } |
---|
| 1238 | else |
---|
| 1239 | { |
---|
| 1240 | numNeg++; |
---|
| 1241 | } |
---|
| 1242 | } |
---|
| 1243 | rps->setNumberOfNegativePictures(numNeg); |
---|
| 1244 | rps->setNumberOfPositivePictures(numPos); |
---|
| 1245 | |
---|
| 1246 | // handle inter RPS intialization from the config file. |
---|
| 1247 | #if AUTO_INTER_RPS |
---|
| 1248 | rps->setInterRPSPrediction(ge.m_interRPSPrediction > 0); // not very clean, converting anything > 0 to true. |
---|
| 1249 | rps->setDeltaRIdxMinus1(0); // index to the Reference RPS is always the previous one. |
---|
| 1250 | TComReferencePictureSet* RPSRef = rpsList->getReferencePictureSet(i-1); // get the reference RPS |
---|
| 1251 | |
---|
| 1252 | if (ge.m_interRPSPrediction == 2) // Automatic generation of the inter RPS idc based on the RIdx provided. |
---|
| 1253 | { |
---|
| 1254 | Int deltaRPS = getGOPEntry(i-1).m_POC - ge.m_POC; // the ref POC - current POC |
---|
| 1255 | Int numRefDeltaPOC = RPSRef->getNumberOfPictures(); |
---|
| 1256 | |
---|
| 1257 | rps->setDeltaRPS(deltaRPS); // set delta RPS |
---|
| 1258 | rps->setNumRefIdc(numRefDeltaPOC+1); // set the numRefIdc to the number of pictures in the reference RPS + 1. |
---|
| 1259 | Int count=0; |
---|
| 1260 | for (Int j = 0; j <= numRefDeltaPOC; j++ ) // cycle through pics in reference RPS. |
---|
| 1261 | { |
---|
| 1262 | Int RefDeltaPOC = (j<numRefDeltaPOC)? RPSRef->getDeltaPOC(j): 0; // if it is the last decoded picture, set RefDeltaPOC = 0 |
---|
| 1263 | rps->setRefIdc(j, 0); |
---|
| 1264 | for (Int k = 0; k < rps->getNumberOfPictures(); k++ ) // cycle through pics in current RPS. |
---|
| 1265 | { |
---|
| 1266 | if (rps->getDeltaPOC(k) == ( RefDeltaPOC + deltaRPS)) // if the current RPS has a same picture as the reference RPS. |
---|
| 1267 | { |
---|
| 1268 | rps->setRefIdc(j, (rps->getUsed(k)?1:2)); |
---|
| 1269 | count++; |
---|
| 1270 | break; |
---|
| 1271 | } |
---|
| 1272 | } |
---|
| 1273 | } |
---|
| 1274 | if (count != rps->getNumberOfPictures()) |
---|
| 1275 | { |
---|
| 1276 | 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"); |
---|
| 1277 | rps->setInterRPSPrediction(0); |
---|
| 1278 | } |
---|
| 1279 | } |
---|
| 1280 | else if (ge.m_interRPSPrediction == 1) // inter RPS idc based on the RefIdc values provided in config file. |
---|
| 1281 | { |
---|
| 1282 | rps->setDeltaRPS(ge.m_deltaRPS); |
---|
| 1283 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
| 1284 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1285 | { |
---|
| 1286 | rps->setRefIdc(j, ge.m_refIdc[j]); |
---|
| 1287 | } |
---|
| 1288 | #if WRITE_BACK |
---|
| 1289 | // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones |
---|
| 1290 | // computed from the RefIdc. A warning is printed if they are not identical. |
---|
| 1291 | numNeg = 0; |
---|
| 1292 | numPos = 0; |
---|
| 1293 | TComReferencePictureSet RPSTemp; // temporary variable |
---|
| 1294 | |
---|
| 1295 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1296 | { |
---|
| 1297 | if (ge.m_refIdc[j]) |
---|
| 1298 | { |
---|
| 1299 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
---|
| 1300 | RPSTemp.setDeltaPOC((numNeg+numPos),deltaPOC); |
---|
| 1301 | RPSTemp.setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
---|
| 1302 | if (deltaPOC<0) |
---|
| 1303 | { |
---|
| 1304 | numNeg++; |
---|
| 1305 | } |
---|
| 1306 | else |
---|
| 1307 | { |
---|
| 1308 | numPos++; |
---|
| 1309 | } |
---|
| 1310 | } |
---|
| 1311 | } |
---|
| 1312 | if (numNeg != rps->getNumberOfNegativePictures()) |
---|
| 1313 | { |
---|
| 1314 | printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
| 1315 | rps->setNumberOfNegativePictures(numNeg); |
---|
[442] | 1316 | rps->setNumberOfPictures(numNeg+numPos); |
---|
[313] | 1317 | } |
---|
| 1318 | if (numPos != rps->getNumberOfPositivePictures()) |
---|
| 1319 | { |
---|
| 1320 | printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
| 1321 | rps->setNumberOfPositivePictures(numPos); |
---|
[442] | 1322 | rps->setNumberOfPictures(numNeg+numPos); |
---|
[313] | 1323 | } |
---|
| 1324 | RPSTemp.setNumberOfPictures(numNeg+numPos); |
---|
| 1325 | RPSTemp.setNumberOfNegativePictures(numNeg); |
---|
| 1326 | RPSTemp.sortDeltaPOC(); // sort the created delta POC before comparing |
---|
| 1327 | // check if Delta POC and Used are the same |
---|
| 1328 | // print warning if they are not. |
---|
| 1329 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1330 | { |
---|
| 1331 | if (RPSTemp.getDeltaPOC(j) != rps->getDeltaPOC(j)) |
---|
| 1332 | { |
---|
| 1333 | printf("Warning: delta POC is different between intra RPS and inter RPS specified in the config file.\n"); |
---|
| 1334 | rps->setDeltaPOC(j,RPSTemp.getDeltaPOC(j)); |
---|
| 1335 | } |
---|
| 1336 | if (RPSTemp.getUsed(j) != rps->getUsed(j)) |
---|
| 1337 | { |
---|
| 1338 | printf("Warning: Used by Current in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
| 1339 | rps->setUsed(j,RPSTemp.getUsed(j)); |
---|
| 1340 | } |
---|
| 1341 | } |
---|
| 1342 | #endif |
---|
| 1343 | } |
---|
| 1344 | #else |
---|
| 1345 | rps->setInterRPSPrediction(ge.m_interRPSPrediction); |
---|
| 1346 | if (ge.m_interRPSPrediction) |
---|
| 1347 | { |
---|
| 1348 | rps->setDeltaRIdxMinus1(0); |
---|
| 1349 | rps->setDeltaRPS(ge.m_deltaRPS); |
---|
| 1350 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
| 1351 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1352 | { |
---|
| 1353 | rps->setRefIdc(j, ge.m_refIdc[j]); |
---|
| 1354 | } |
---|
| 1355 | #if WRITE_BACK |
---|
| 1356 | // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones |
---|
| 1357 | // computed from the RefIdc. This is not necessary if both are identical. Currently there is no check to see if they are identical. |
---|
| 1358 | numNeg = 0; |
---|
| 1359 | numPos = 0; |
---|
| 1360 | TComReferencePictureSet* RPSRef = m_RPSList.getReferencePictureSet(i-1); |
---|
| 1361 | |
---|
| 1362 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1363 | { |
---|
| 1364 | if (ge.m_refIdc[j]) |
---|
| 1365 | { |
---|
| 1366 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
---|
| 1367 | rps->setDeltaPOC((numNeg+numPos),deltaPOC); |
---|
| 1368 | rps->setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
---|
| 1369 | if (deltaPOC<0) |
---|
| 1370 | { |
---|
| 1371 | numNeg++; |
---|
| 1372 | } |
---|
| 1373 | else |
---|
| 1374 | { |
---|
| 1375 | numPos++; |
---|
| 1376 | } |
---|
| 1377 | } |
---|
| 1378 | } |
---|
| 1379 | rps->setNumberOfNegativePictures(numNeg); |
---|
| 1380 | rps->setNumberOfPositivePictures(numPos); |
---|
| 1381 | rps->sortDeltaPOC(); |
---|
| 1382 | #endif |
---|
| 1383 | } |
---|
| 1384 | #endif //INTER_RPS_AUTO |
---|
| 1385 | } |
---|
[442] | 1386 | //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. |
---|
| 1387 | //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS. |
---|
| 1388 | if (isFieldCoding) |
---|
| 1389 | { |
---|
| 1390 | rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs); |
---|
| 1391 | rps->setNumberOfPictures(1); |
---|
| 1392 | rps->setNumberOfNegativePictures(1); |
---|
| 1393 | rps->setNumberOfPositivePictures(0); |
---|
| 1394 | rps->setNumberOfLongtermPictures(0); |
---|
| 1395 | rps->setDeltaPOC(0,-1); |
---|
| 1396 | rps->setPOC(0,0); |
---|
| 1397 | rps->setUsed(0,true); |
---|
| 1398 | rps->setInterRPSPrediction(false); |
---|
| 1399 | rps->setDeltaRIdxMinus1(0); |
---|
| 1400 | rps->setDeltaRPS(0); |
---|
| 1401 | rps->setNumRefIdc(0); |
---|
[313] | 1402 | } |
---|
[442] | 1403 | } |
---|
[313] | 1404 | |
---|
| 1405 | // This is a function that |
---|
| 1406 | // determines what Reference Picture Set to use |
---|
| 1407 | // for a specific slice (with POC = POCCurr) |
---|
| 1408 | Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid ) |
---|
| 1409 | { |
---|
| 1410 | slice->setRPSidx(GOPid); |
---|
| 1411 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
| 1412 | { |
---|
| 1413 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
---|
| 1414 | { |
---|
| 1415 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
---|
| 1416 | if(POCIndex == 0) |
---|
| 1417 | { |
---|
| 1418 | POCIndex = m_uiIntraPeriod; |
---|
| 1419 | } |
---|
| 1420 | if(POCIndex == m_GOPList[extraNum].m_POC) |
---|
| 1421 | { |
---|
| 1422 | slice->setRPSidx(extraNum); |
---|
| 1423 | } |
---|
| 1424 | } |
---|
| 1425 | else |
---|
| 1426 | { |
---|
| 1427 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
| 1428 | { |
---|
| 1429 | slice->setRPSidx(extraNum); |
---|
| 1430 | } |
---|
| 1431 | } |
---|
| 1432 | } |
---|
| 1433 | |
---|
[442] | 1434 | if(POCCurr == 1 && slice->getPic()->isField()) |
---|
| 1435 | { |
---|
| 1436 | slice->setRPSidx(m_iGOPSize+m_extraRPSs); |
---|
| 1437 | } |
---|
| 1438 | |
---|
[313] | 1439 | slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); |
---|
| 1440 | slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures()); |
---|
| 1441 | } |
---|
| 1442 | |
---|
| 1443 | Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid ) |
---|
| 1444 | { |
---|
| 1445 | int rpsIdx = GOPid; |
---|
| 1446 | |
---|
| 1447 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
| 1448 | { |
---|
| 1449 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
---|
| 1450 | { |
---|
| 1451 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
---|
| 1452 | if(POCIndex == 0) |
---|
| 1453 | { |
---|
| 1454 | POCIndex = m_uiIntraPeriod; |
---|
| 1455 | } |
---|
| 1456 | if(POCIndex == m_GOPList[extraNum].m_POC) |
---|
| 1457 | { |
---|
| 1458 | rpsIdx = extraNum; |
---|
| 1459 | } |
---|
| 1460 | } |
---|
| 1461 | else |
---|
| 1462 | { |
---|
| 1463 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
| 1464 | { |
---|
| 1465 | rpsIdx = extraNum; |
---|
| 1466 | } |
---|
| 1467 | } |
---|
| 1468 | } |
---|
| 1469 | |
---|
| 1470 | return rpsIdx; |
---|
| 1471 | } |
---|
| 1472 | |
---|
| 1473 | Void TEncTop::xInitPPSforTiles() |
---|
| 1474 | { |
---|
| 1475 | m_cPPS.setUniformSpacingFlag( m_iUniformSpacingIdr ); |
---|
| 1476 | m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 ); |
---|
| 1477 | m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 ); |
---|
| 1478 | if( m_iUniformSpacingIdr == 0 ) |
---|
| 1479 | { |
---|
| 1480 | m_cPPS.setColumnWidth( m_puiColumnWidth ); |
---|
| 1481 | m_cPPS.setRowHeight( m_puiRowHeight ); |
---|
| 1482 | } |
---|
| 1483 | m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag ); |
---|
| 1484 | |
---|
| 1485 | // # substreams is "per tile" when tiles are independent. |
---|
| 1486 | if (m_iWaveFrontSynchro |
---|
| 1487 | ) |
---|
| 1488 | { |
---|
| 1489 | m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)); |
---|
| 1490 | } |
---|
| 1491 | } |
---|
| 1492 | |
---|
| 1493 | Void TEncCfg::xCheckGSParameters() |
---|
| 1494 | { |
---|
| 1495 | Int iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth; |
---|
| 1496 | Int iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight; |
---|
| 1497 | UInt uiCummulativeColumnWidth = 0; |
---|
| 1498 | UInt uiCummulativeRowHeight = 0; |
---|
| 1499 | |
---|
| 1500 | //check the column relative parameters |
---|
| 1501 | if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) ) |
---|
| 1502 | { |
---|
| 1503 | printf( "The number of columns is larger than the maximum allowed number of columns.\n" ); |
---|
| 1504 | exit( EXIT_FAILURE ); |
---|
| 1505 | } |
---|
| 1506 | |
---|
| 1507 | if( m_iNumColumnsMinus1 >= iWidthInCU ) |
---|
| 1508 | { |
---|
| 1509 | printf( "The current picture can not have so many columns.\n" ); |
---|
| 1510 | exit( EXIT_FAILURE ); |
---|
| 1511 | } |
---|
| 1512 | |
---|
| 1513 | if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 ) |
---|
| 1514 | { |
---|
| 1515 | for(Int i=0; i<m_iNumColumnsMinus1; i++) |
---|
| 1516 | { |
---|
| 1517 | uiCummulativeColumnWidth += m_puiColumnWidth[i]; |
---|
| 1518 | } |
---|
| 1519 | |
---|
| 1520 | if( uiCummulativeColumnWidth >= iWidthInCU ) |
---|
| 1521 | { |
---|
| 1522 | printf( "The width of the column is too large.\n" ); |
---|
| 1523 | exit( EXIT_FAILURE ); |
---|
| 1524 | } |
---|
| 1525 | } |
---|
| 1526 | |
---|
| 1527 | //check the row relative parameters |
---|
| 1528 | if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) ) |
---|
| 1529 | { |
---|
| 1530 | printf( "The number of rows is larger than the maximum allowed number of rows.\n" ); |
---|
| 1531 | exit( EXIT_FAILURE ); |
---|
| 1532 | } |
---|
| 1533 | |
---|
| 1534 | if( m_iNumRowsMinus1 >= iHeightInCU ) |
---|
| 1535 | { |
---|
| 1536 | printf( "The current picture can not have so many rows.\n" ); |
---|
| 1537 | exit( EXIT_FAILURE ); |
---|
| 1538 | } |
---|
| 1539 | |
---|
| 1540 | if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 ) |
---|
| 1541 | { |
---|
| 1542 | for(Int i=0; i<m_iNumRowsMinus1; i++) |
---|
| 1543 | { |
---|
| 1544 | uiCummulativeRowHeight += m_puiRowHeight[i]; |
---|
| 1545 | } |
---|
| 1546 | |
---|
| 1547 | if( uiCummulativeRowHeight >= iHeightInCU ) |
---|
| 1548 | { |
---|
| 1549 | printf( "The height of the row is too large.\n" ); |
---|
| 1550 | exit( EXIT_FAILURE ); |
---|
| 1551 | } |
---|
| 1552 | } |
---|
| 1553 | } |
---|
| 1554 | |
---|
| 1555 | #if SVC_EXTENSION |
---|
| 1556 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1557 | TEncTop* TEncTop::getRefLayerEnc( UInt refLayerIdc ) |
---|
| 1558 | { |
---|
| 1559 | if( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() <= 0 ) |
---|
| 1560 | { |
---|
| 1561 | return (TEncTop *)getLayerEnc( 0 ); |
---|
| 1562 | } |
---|
| 1563 | |
---|
| 1564 | return (TEncTop *)getLayerEnc( m_cVPS.getRefLayerId( m_layerId, refLayerIdc ) ); |
---|
| 1565 | } |
---|
| 1566 | #endif |
---|
| 1567 | |
---|
[442] | 1568 | #if !REPN_FORMAT_IN_VPS |
---|
[313] | 1569 | Void TEncTop::xInitILRP() |
---|
| 1570 | { |
---|
| 1571 | if(m_layerId>0) |
---|
| 1572 | { |
---|
| 1573 | g_bitDepthY = m_cSPS.getBitDepthY(); |
---|
| 1574 | g_bitDepthC = m_cSPS.getBitDepthC(); |
---|
| 1575 | g_uiMaxCUWidth = m_cSPS.getMaxCUWidth(); |
---|
| 1576 | g_uiMaxCUHeight = m_cSPS.getMaxCUHeight(); |
---|
| 1577 | g_uiMaxCUDepth = m_cSPS.getMaxCUDepth(); |
---|
| 1578 | g_uiAddCUDepth = max (0, m_cSPS.getLog2MinCodingBlockSize() - (Int)m_cSPS.getQuadtreeTULog2MinSize() ); |
---|
| 1579 | |
---|
| 1580 | Int numReorderPics[MAX_TLAYER]; |
---|
| 1581 | Window &conformanceWindow = m_cSPS.getConformanceWindow(); |
---|
| 1582 | Window defaultDisplayWindow = m_cSPS.getVuiParametersPresentFlag() ? m_cSPS.getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
| 1583 | |
---|
| 1584 | if (m_cIlpPic[0] == NULL) |
---|
| 1585 | { |
---|
| 1586 | for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] |
---|
| 1587 | { |
---|
| 1588 | m_cIlpPic[j] = new TComPic; |
---|
| 1589 | #if SVC_UPSAMPLING |
---|
[475] | 1590 | #if AUXILIARY_PICTURES |
---|
| 1591 | m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true); |
---|
| 1592 | #else |
---|
[313] | 1593 | m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true); |
---|
[475] | 1594 | #endif |
---|
[313] | 1595 | #else |
---|
| 1596 | m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 1597 | #endif |
---|
| 1598 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) |
---|
| 1599 | { |
---|
| 1600 | m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); |
---|
| 1601 | } |
---|
| 1602 | } |
---|
| 1603 | } |
---|
| 1604 | } |
---|
| 1605 | } |
---|
[442] | 1606 | #else |
---|
| 1607 | Void TEncTop::xInitILRP() |
---|
| 1608 | { |
---|
| 1609 | RepFormat *repFormat = m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) ); |
---|
| 1610 | Int bitDepthY,bitDepthC,picWidth,picHeight; |
---|
[313] | 1611 | |
---|
[442] | 1612 | if( m_cSPS.getUpdateRepFormatFlag() ) |
---|
| 1613 | { |
---|
| 1614 | bitDepthY = m_cSPS.getBitDepthY(); |
---|
| 1615 | bitDepthC = m_cSPS.getBitDepthC(); |
---|
| 1616 | picWidth = m_cSPS.getPicWidthInLumaSamples(); |
---|
| 1617 | picHeight = m_cSPS.getPicHeightInLumaSamples(); |
---|
| 1618 | } |
---|
| 1619 | else |
---|
| 1620 | { |
---|
| 1621 | bitDepthY = repFormat->getBitDepthVpsLuma(); |
---|
| 1622 | bitDepthC = repFormat->getBitDepthVpsChroma(); |
---|
| 1623 | picWidth = repFormat->getPicWidthVpsInLumaSamples(); |
---|
| 1624 | picHeight = repFormat->getPicHeightVpsInLumaSamples(); |
---|
| 1625 | } |
---|
| 1626 | |
---|
| 1627 | if(m_layerId > 0) |
---|
| 1628 | { |
---|
| 1629 | g_bitDepthY = bitDepthY; |
---|
| 1630 | g_bitDepthC = bitDepthC; |
---|
| 1631 | g_uiMaxCUWidth = m_cSPS.getMaxCUWidth(); |
---|
| 1632 | g_uiMaxCUHeight = m_cSPS.getMaxCUHeight(); |
---|
| 1633 | g_uiMaxCUDepth = m_cSPS.getMaxCUDepth(); |
---|
| 1634 | g_uiAddCUDepth = max (0, m_cSPS.getLog2MinCodingBlockSize() - (Int)m_cSPS.getQuadtreeTULog2MinSize() ); |
---|
| 1635 | |
---|
| 1636 | Int numReorderPics[MAX_TLAYER]; |
---|
| 1637 | Window &conformanceWindow = m_cSPS.getConformanceWindow(); |
---|
| 1638 | Window defaultDisplayWindow = m_cSPS.getVuiParametersPresentFlag() ? m_cSPS.getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
| 1639 | |
---|
| 1640 | if (m_cIlpPic[0] == NULL) |
---|
| 1641 | { |
---|
| 1642 | for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] |
---|
| 1643 | { |
---|
| 1644 | m_cIlpPic[j] = new TComPic; |
---|
| 1645 | #if SVC_UPSAMPLING |
---|
[475] | 1646 | #if AUXILIARY_PICTURES |
---|
| 1647 | m_cIlpPic[j]->create(picWidth, picHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true); |
---|
| 1648 | #else |
---|
[442] | 1649 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true); |
---|
[475] | 1650 | #endif |
---|
[442] | 1651 | #else |
---|
| 1652 | m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 1653 | #endif |
---|
| 1654 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) |
---|
| 1655 | { |
---|
| 1656 | m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); |
---|
| 1657 | } |
---|
| 1658 | } |
---|
| 1659 | } |
---|
| 1660 | } |
---|
| 1661 | } |
---|
| 1662 | #endif |
---|
[460] | 1663 | #endif //SVC_EXTENSION |
---|
[313] | 1664 | //! \} |
---|