[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 |
---|
[494] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[313] | 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 TAppEncTop.cpp |
---|
| 35 | \brief Encoder application class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include <list> |
---|
| 39 | #include <fstream> |
---|
| 40 | #include <stdlib.h> |
---|
| 41 | #include <stdio.h> |
---|
| 42 | #include <fcntl.h> |
---|
| 43 | #include <assert.h> |
---|
| 44 | |
---|
| 45 | #include "TAppEncTop.h" |
---|
| 46 | #include "TLibEncoder/AnnexBwrite.h" |
---|
| 47 | |
---|
| 48 | using namespace std; |
---|
| 49 | |
---|
| 50 | //! \ingroup TAppEncoder |
---|
| 51 | //! \{ |
---|
| 52 | |
---|
| 53 | // ==================================================================================================================== |
---|
| 54 | // Constructor / destructor / initialization / destroy |
---|
| 55 | // ==================================================================================================================== |
---|
| 56 | |
---|
| 57 | TAppEncTop::TAppEncTop() |
---|
| 58 | { |
---|
| 59 | m_iFrameRcvd = 0; |
---|
| 60 | m_totalBytes = 0; |
---|
| 61 | m_essentialBytes = 0; |
---|
| 62 | #if SVC_EXTENSION |
---|
| 63 | for(UInt layer=0; layer < MAX_LAYERS; layer++) |
---|
| 64 | { |
---|
| 65 | m_apcTEncTop[layer] = &m_acTEncTop[layer]; |
---|
| 66 | } |
---|
| 67 | #endif |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | TAppEncTop::~TAppEncTop() |
---|
| 71 | { |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | #if SVC_EXTENSION |
---|
| 75 | Void TAppEncTop::xInitLibCfg() |
---|
| 76 | { |
---|
| 77 | TComVPS* vps = m_acTEncTop[0].getVPS(); |
---|
| 78 | |
---|
[903] | 79 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
| 80 | vps->setVpsPocLsbAlignedFlag(false); |
---|
| 81 | #endif |
---|
[313] | 82 | vps->setMaxTLayers ( m_maxTempLayer ); |
---|
| 83 | if (m_maxTempLayer == 1) |
---|
| 84 | { |
---|
| 85 | vps->setTemporalNestingFlag(true); |
---|
| 86 | } |
---|
| 87 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 88 | { |
---|
| 89 | vps->setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 90 | vps->setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 91 | } |
---|
[540] | 92 | |
---|
[713] | 93 | #if REPN_FORMAT_IN_VPS |
---|
[442] | 94 | Int maxRepFormatIdx = -1; |
---|
| 95 | Int formatIdx = -1; |
---|
| 96 | for(UInt layer=0; layer < m_numLayers; layer++) |
---|
| 97 | { |
---|
| 98 | // Auto generation of the format index |
---|
| 99 | if( m_acLayerCfg[layer].getRepFormatIdx() == -1 ) |
---|
[494] | 100 | { |
---|
[442] | 101 | Bool found = false; |
---|
| 102 | for( UInt idx = 0; idx < layer; idx++ ) |
---|
| 103 | { |
---|
[494] | 104 | if( m_acLayerCfg[layer].getSourceWidth() == m_acLayerCfg[idx].getSourceWidth() && m_acLayerCfg[layer].getSourceHeight() == m_acLayerCfg[idx].getSourceHeight() |
---|
| 105 | #if AUXILIARY_PICTURES |
---|
| 106 | && m_acLayerCfg[layer].getChromaFormatIDC() == m_acLayerCfg[idx].getChromaFormatIDC() |
---|
| 107 | #endif |
---|
| 108 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 109 | && m_acLayerCfg[layer].m_internalBitDepthY == m_acLayerCfg[idx].m_internalBitDepthY && m_acLayerCfg[layer].m_internalBitDepthC == m_acLayerCfg[idx].m_internalBitDepthC |
---|
| 110 | #endif |
---|
| 111 | ) |
---|
[442] | 112 | { |
---|
| 113 | found = true; |
---|
| 114 | break; |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | if( !found ) |
---|
| 118 | { |
---|
| 119 | formatIdx++; |
---|
| 120 | } |
---|
[313] | 121 | |
---|
[442] | 122 | m_acLayerCfg[layer].setRepFormatIdx( formatIdx ); |
---|
| 123 | } |
---|
| 124 | |
---|
[494] | 125 | assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" ); |
---|
[713] | 126 | |
---|
[442] | 127 | vps->setVpsRepFormatIdx( layer, m_acLayerCfg[layer].getRepFormatIdx() ); |
---|
[713] | 128 | |
---|
[442] | 129 | maxRepFormatIdx = std::max( m_acLayerCfg[layer].getRepFormatIdx(), maxRepFormatIdx ); |
---|
| 130 | } |
---|
[713] | 131 | |
---|
[442] | 132 | assert( vps->getVpsRepFormatIdx( 0 ) == 0 ); // Base layer should point to the first one. |
---|
[713] | 133 | |
---|
[442] | 134 | Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1]; |
---|
[713] | 135 | |
---|
[442] | 136 | // Check that all the indices from 0 to maxRepFormatIdx are used in the VPS |
---|
| 137 | for(Int i = 0; i <= maxRepFormatIdx; i++) |
---|
| 138 | { |
---|
| 139 | mapIdxToLayer[i] = -1; |
---|
| 140 | UInt layer; |
---|
| 141 | for(layer=0; layer < m_numLayers; layer++) |
---|
| 142 | { |
---|
| 143 | if( vps->getVpsRepFormatIdx(layer) == i ) |
---|
| 144 | { |
---|
| 145 | mapIdxToLayer[i] = layer; |
---|
| 146 | break; |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | assert( layer != m_numLayers ); // One of the VPS Rep format indices not set |
---|
| 150 | } |
---|
[713] | 151 | |
---|
[442] | 152 | vps->setVpsNumRepFormats( maxRepFormatIdx + 1 ); |
---|
[713] | 153 | |
---|
| 154 | #if Q0195_REP_FORMAT_CLEANUP |
---|
| 155 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
| 156 | vps->setRepFormatIdxPresentFlag( vps->getVpsNumRepFormats() > 1 ? true : false ); |
---|
| 157 | #else |
---|
| 158 | vps->setRepFormatIdxPresentFlag( true ); |
---|
| 159 | #endif |
---|
| 160 | |
---|
[442] | 161 | for(UInt idx=0; idx < vps->getVpsNumRepFormats(); idx++) |
---|
| 162 | { |
---|
[494] | 163 | RepFormat *repFormat = vps->getVpsRepFormat( idx ); |
---|
[540] | 164 | #if REPN_FORMAT_CONTROL_FLAG |
---|
| 165 | repFormat->setChromaAndBitDepthVpsPresentFlag( true ); |
---|
| 166 | if (idx==0) |
---|
| 167 | { |
---|
| 168 | assert(repFormat->getChromaAndBitDepthVpsPresentFlag() == true); |
---|
| 169 | } |
---|
| 170 | #endif |
---|
[442] | 171 | repFormat->setPicWidthVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceWidth() ); |
---|
| 172 | repFormat->setPicHeightVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceHeight() ); |
---|
[494] | 173 | #if AUXILIARY_PICTURES |
---|
| 174 | repFormat->setChromaFormatVpsIdc ( m_acLayerCfg[mapIdxToLayer[idx]].getChromaFormatIDC() ); |
---|
| 175 | #else |
---|
[442] | 176 | repFormat->setChromaFormatVpsIdc ( 1 ); // Need modification to change for each layer - corresponds to 420 |
---|
[494] | 177 | #endif |
---|
[442] | 178 | repFormat->setSeparateColourPlaneVpsFlag( 0 ); // Need modification to change for each layer |
---|
[494] | 179 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 180 | repFormat->setBitDepthVpsLuma ( getInternalBitDepthY(mapIdxToLayer[idx]) ); // Need modification to change for each layer |
---|
| 181 | repFormat->setBitDepthVpsChroma ( getInternalBitDepthC(mapIdxToLayer[idx]) ); // Need modification to change for each layer |
---|
| 182 | #else |
---|
[442] | 183 | repFormat->setBitDepthVpsLuma ( getInternalBitDepthY() ); // Need modification to change for each layer |
---|
| 184 | repFormat->setBitDepthVpsChroma ( getInternalBitDepthC() ); // Need modification to change for each layer |
---|
[494] | 185 | #endif |
---|
[869] | 186 | |
---|
| 187 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
| 188 | repFormat->getConformanceWindowVps().setWindow( |
---|
| 189 | m_acLayerCfg[mapIdxToLayer[idx]].m_confWinLeft, |
---|
| 190 | m_acLayerCfg[mapIdxToLayer[idx]].m_confWinRight, |
---|
| 191 | m_acLayerCfg[mapIdxToLayer[idx]].m_confWinTop, |
---|
| 192 | m_acLayerCfg[mapIdxToLayer[idx]].m_confWinBottom ); |
---|
| 193 | #endif |
---|
| 194 | |
---|
[540] | 195 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
| 196 | m_acTEncTop[mapIdxToLayer[idx]].setSkipPictureAtArcSwitch( m_skipPictureAtArcSwitch ); |
---|
| 197 | #endif |
---|
[442] | 198 | } |
---|
| 199 | delete [] mapIdxToLayer; |
---|
| 200 | #endif |
---|
[588] | 201 | |
---|
[941] | 202 | #if MULTIPLE_PTL_SUPPORT |
---|
| 203 | //Populate PTL in VPS |
---|
| 204 | TComVPS *pVPS = m_acTEncTop[0].getVPS(); |
---|
| 205 | ProfileTierLevel& profileTierLevel = *(pVPS->getPTL(0)->getGeneralPTL()); |
---|
| 206 | for (int ii = 0; ii < m_numPTLInfo; ii++) |
---|
| 207 | { |
---|
| 208 | profileTierLevel = *(pVPS->getPTL(ii)->getGeneralPTL()); |
---|
| 209 | |
---|
| 210 | profileTierLevel.setLevelIdc(m_levelList[ii]); |
---|
| 211 | profileTierLevel.setTierFlag(m_levelTierList[ii]); |
---|
| 212 | profileTierLevel.setProfileIdc(m_profileList[ii]); |
---|
[951] | 213 | profileTierLevel.setProfileCompatibilityFlag(m_profileCompatibility[ii], 1); |
---|
[941] | 214 | profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlagList[ii]); |
---|
| 215 | profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlagList[ii]); |
---|
| 216 | profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlagList[ii]); |
---|
| 217 | profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlagList[ii]); |
---|
| 218 | } |
---|
| 219 | pVPS->setNumProfileTierLevel(m_numPTLInfo); |
---|
| 220 | |
---|
| 221 | std::vector<int> myvector; |
---|
| 222 | vps->getProfileLevelTierIdx()->resize(m_numOutputLayerSets); |
---|
| 223 | for (int ii = 0; ii < m_numOutputLayerSets; ii++) |
---|
| 224 | { |
---|
| 225 | myvector = m_listOfLayerPTLofOlss[ii]; |
---|
| 226 | for (std::vector<int>::iterator it = myvector.begin() ; it != myvector.end(); ++it) |
---|
| 227 | { |
---|
| 228 | pVPS->addProfileLevelTierIdx(ii, it[0]); |
---|
| 229 | } |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | //pVPS->setProfileLevelTierIdx( |
---|
| 233 | #endif |
---|
| 234 | |
---|
[815] | 235 | assert( m_numLayers <= MAX_LAYERS ); |
---|
| 236 | |
---|
[313] | 237 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 238 | { |
---|
[494] | 239 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 240 | //1 |
---|
| 241 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 242 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 243 | |
---|
| 244 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 245 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 246 | |
---|
| 247 | // Set this to be used in Upsampling filter in function "TComUpsampleFilter::upsampleBasePic" |
---|
| 248 | g_bitDepthYLayer[layer] = g_bitDepthY; |
---|
| 249 | g_bitDepthCLayer[layer] = g_bitDepthC; |
---|
[588] | 250 | |
---|
| 251 | #if O0194_WEIGHTED_PREDICTION_CGS |
---|
| 252 | m_acTEncTop[layer].setInterLayerWeightedPredFlag( m_useInterLayerWeightedPred ); |
---|
[494] | 253 | #endif |
---|
[588] | 254 | #endif |
---|
[313] | 255 | //m_acTEncTop[layer].setVPS(&vps); |
---|
| 256 | m_acTEncTop[layer].setFrameRate ( m_acLayerCfg[layer].getFrameRate() ); |
---|
| 257 | m_acTEncTop[layer].setFrameSkip ( m_FrameSkip ); |
---|
| 258 | m_acTEncTop[layer].setSourceWidth ( m_acLayerCfg[layer].getSourceWidth() ); |
---|
| 259 | m_acTEncTop[layer].setSourceHeight ( m_acLayerCfg[layer].getSourceHeight() ); |
---|
[823] | 260 | m_acTEncTop[layer].setConformanceWindow ( m_acLayerCfg[layer].m_confWinLeft, m_acLayerCfg[layer].m_confWinRight, m_acLayerCfg[layer].m_confWinTop, m_acLayerCfg[layer].m_confWinBottom ); |
---|
[313] | 261 | m_acTEncTop[layer].setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
| 262 | |
---|
[942] | 263 | #if SVC_EXTENSION && MULTIPLE_PTL_SUPPORT |
---|
| 264 | m_acTEncTop[layer].setProfile(m_profileList[m_layerPTLIdx[layer]]); |
---|
| 265 | m_acTEncTop[layer].setLevel(m_levelTierList[m_layerPTLIdx[layer]], m_levelList[m_layerPTLIdx[layer]]); |
---|
| 266 | m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlagList[m_layerPTLIdx[layer]]); |
---|
| 267 | m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlagList[m_layerPTLIdx[layer]]); |
---|
| 268 | m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlagList[m_layerPTLIdx[layer]]); |
---|
| 269 | m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlagList[m_layerPTLIdx[layer]]); |
---|
| 270 | #else |
---|
[313] | 271 | m_acTEncTop[layer].setProfile(m_profile); |
---|
| 272 | m_acTEncTop[layer].setLevel(m_levelTier, m_level); |
---|
| 273 | m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
| 274 | m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
| 275 | m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
| 276 | m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
[941] | 277 | #endif |
---|
[313] | 278 | |
---|
| 279 | #if REF_IDX_MFM |
---|
| 280 | #if AVC_BASE |
---|
[874] | 281 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
| 282 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_nonHEVCBaseLayerFlag ? false : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers()); |
---|
| 283 | #else |
---|
[820] | 284 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? false : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers()); |
---|
[874] | 285 | #endif |
---|
[313] | 286 | #else |
---|
| 287 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_acLayerCfg[layer].getNumMotionPredRefLayers() > 0 ) ); |
---|
| 288 | #endif |
---|
| 289 | #endif |
---|
[494] | 290 | // set layer ID |
---|
| 291 | m_acTEncTop[layer].setLayerId ( layer ); |
---|
[313] | 292 | m_acTEncTop[layer].setNumLayer ( m_numLayers ); |
---|
| 293 | m_acTEncTop[layer].setLayerEnc(m_apcTEncTop); |
---|
| 294 | |
---|
| 295 | //====== Coding Structure ======== |
---|
| 296 | m_acTEncTop[layer].setIntraPeriod ( m_acLayerCfg[layer].m_iIntraPeriod ); |
---|
| 297 | m_acTEncTop[layer].setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
| 298 | m_acTEncTop[layer].setGOPSize ( m_iGOPSize ); |
---|
[815] | 299 | #if Q0108_TSA_STSA |
---|
| 300 | m_acTEncTop[layer].setGopList ( layer ? m_EhGOPList[layer] : m_GOPList ); |
---|
| 301 | #else |
---|
[313] | 302 | m_acTEncTop[layer].setGopList ( m_GOPList ); |
---|
[815] | 303 | #endif |
---|
[494] | 304 | |
---|
[815] | 305 | #if !Q0108_TSA_STSA |
---|
[313] | 306 | m_acTEncTop[layer].setExtraRPSs ( m_extraRPSs ); |
---|
[815] | 307 | #else |
---|
| 308 | m_acTEncTop[layer].setExtraRPSs ( m_extraRPSs[layer] ); |
---|
| 309 | #endif |
---|
[313] | 310 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 311 | { |
---|
| 312 | m_acTEncTop[layer].setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 313 | m_acTEncTop[layer].setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 314 | } |
---|
| 315 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
| 316 | { |
---|
| 317 | m_acTEncTop[layer].setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
| 318 | } |
---|
| 319 | m_acTEncTop[layer].setQP ( m_acLayerCfg[layer].getIntQP() ); |
---|
| 320 | |
---|
| 321 | m_acTEncTop[layer].setPad ( m_acLayerCfg[layer].getPad() ); |
---|
[815] | 322 | #if !Q0108_TSA_STSA |
---|
[313] | 323 | m_acTEncTop[layer].setMaxTempLayer ( m_maxTempLayer ); |
---|
[815] | 324 | #else |
---|
| 325 | if (layer== 0) |
---|
| 326 | { |
---|
| 327 | m_acTEncTop[layer].setMaxTempLayer ( m_maxTempLayer ); |
---|
| 328 | } |
---|
| 329 | else |
---|
| 330 | { |
---|
| 331 | m_acTEncTop[layer].setMaxTempLayer ( m_EhMaxTempLayer[layer] ); |
---|
| 332 | } |
---|
| 333 | #endif |
---|
[313] | 334 | m_acTEncTop[layer].setUseAMP( m_enableAMP ); |
---|
[815] | 335 | |
---|
| 336 | if( layer < m_numLayers - 1 ) |
---|
[442] | 337 | { |
---|
[494] | 338 | m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1()); |
---|
[442] | 339 | } |
---|
[815] | 340 | |
---|
[313] | 341 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 342 | if(layer) |
---|
| 343 | { |
---|
| 344 | for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++) |
---|
| 345 | { |
---|
| 346 | m_acTEncTop[layer].setSamplePredEnabledFlag(i, false); |
---|
| 347 | m_acTEncTop[layer].setMotionPredEnabledFlag(i, false); |
---|
| 348 | } |
---|
| 349 | if(m_acLayerCfg[layer].getNumSamplePredRefLayers() == -1) |
---|
| 350 | { |
---|
| 351 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
| 352 | m_acTEncTop[layer].setNumSamplePredRefLayers (1); // One sample pred ref. layer |
---|
| 353 | m_acTEncTop[layer].setSamplePredRefLayerId (0, layer - 1); // Previous layer |
---|
| 354 | m_acTEncTop[layer].setSamplePredEnabledFlag (layer - 1, true); |
---|
| 355 | } |
---|
| 356 | else |
---|
| 357 | { |
---|
[494] | 358 | m_acTEncTop[layer].setNumSamplePredRefLayers ( m_acLayerCfg[layer].getNumSamplePredRefLayers() ); |
---|
[313] | 359 | for(Int i = 0; i < m_acTEncTop[layer].getNumSamplePredRefLayers(); i++) |
---|
| 360 | { |
---|
| 361 | m_acTEncTop[layer].setSamplePredRefLayerId ( i, m_acLayerCfg[layer].getSamplePredRefLayerId(i)); |
---|
| 362 | m_acTEncTop[layer].setSamplePredEnabledFlag (m_acLayerCfg[layer].getSamplePredRefLayerId(i), true); |
---|
[494] | 363 | } |
---|
[313] | 364 | } |
---|
| 365 | if(m_acLayerCfg[layer].getNumMotionPredRefLayers() == -1) |
---|
| 366 | { |
---|
| 367 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
| 368 | m_acTEncTop[layer].setNumMotionPredRefLayers (1); // One motion pred ref. layer |
---|
| 369 | m_acTEncTop[layer].setMotionPredRefLayerId (0, layer - 1); // Previous layer |
---|
| 370 | m_acTEncTop[layer].setMotionPredEnabledFlag (layer - 1, true); |
---|
| 371 | } |
---|
| 372 | else |
---|
| 373 | { |
---|
[494] | 374 | m_acTEncTop[layer].setNumMotionPredRefLayers ( m_acLayerCfg[layer].getNumMotionPredRefLayers() ); |
---|
[313] | 375 | for(Int i = 0; i < m_acTEncTop[layer].getNumMotionPredRefLayers(); i++) |
---|
| 376 | { |
---|
| 377 | m_acTEncTop[layer].setMotionPredRefLayerId ( i, m_acLayerCfg[layer].getMotionPredRefLayerId(i)); |
---|
[442] | 378 | m_acTEncTop[layer].setMotionPredEnabledFlag (m_acLayerCfg[layer].getMotionPredRefLayerId(i), true); |
---|
[494] | 379 | } |
---|
[313] | 380 | } |
---|
| 381 | Int numDirectRefLayers = 0; |
---|
[815] | 382 | |
---|
| 383 | assert( layer < MAX_LAYERS ); |
---|
| 384 | |
---|
[313] | 385 | for (Int i = 0; i < layer; i++) |
---|
| 386 | { |
---|
| 387 | if (m_acTEncTop[layer].getSamplePredEnabledFlag(i) || m_acTEncTop[layer].getMotionPredEnabledFlag(i)) |
---|
| 388 | { |
---|
| 389 | m_acTEncTop[layer].setRefLayerId(numDirectRefLayers, i); |
---|
| 390 | numDirectRefLayers++; |
---|
| 391 | } |
---|
| 392 | } |
---|
| 393 | m_acTEncTop[layer].setNumDirectRefLayers(numDirectRefLayers); |
---|
[588] | 394 | |
---|
[313] | 395 | if(m_acLayerCfg[layer].getNumActiveRefLayers() == -1) |
---|
| 396 | { |
---|
| 397 | m_acTEncTop[layer].setNumActiveRefLayers( m_acTEncTop[layer].getNumDirectRefLayers() ); |
---|
| 398 | for( Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++ ) |
---|
| 399 | { |
---|
| 400 | m_acTEncTop[layer].setPredLayerId(i, i); |
---|
| 401 | } |
---|
| 402 | } |
---|
| 403 | else |
---|
| 404 | { |
---|
[494] | 405 | m_acTEncTop[layer].setNumActiveRefLayers ( m_acLayerCfg[layer].getNumActiveRefLayers() ); |
---|
[313] | 406 | for(Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++) |
---|
| 407 | { |
---|
| 408 | m_acTEncTop[layer].setPredLayerId ( i, m_acLayerCfg[layer].getPredLayerId(i)); |
---|
| 409 | } |
---|
| 410 | } |
---|
[849] | 411 | #if REF_REGION_OFFSET |
---|
| 412 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
| 413 | { |
---|
| 414 | #if AUXILIARY_PICTURES |
---|
| 415 | Int cf = m_acLayerCfg[i].m_chromaFormatIDC; |
---|
| 416 | Int rlSubWidthC = ( cf == CHROMA_420 || cf == CHROMA_422 ) ? 2 : 1; |
---|
| 417 | Int rlSubHeightC = ( cf == CHROMA_420 ) ? 2 : 1; |
---|
| 418 | #else |
---|
| 419 | Int rlSubWidthC = 2; |
---|
| 420 | Int rlSubHeightC = 2; |
---|
| 421 | #endif |
---|
| 422 | m_acTEncTop[layer].setRefRegionOffsetPresentFlag( i, m_acLayerCfg[layer].m_refRegionOffsetPresentFlag ); |
---|
| 423 | m_acTEncTop[layer].getRefLayerWindow(i).setWindow( rlSubWidthC * m_acLayerCfg[layer].m_refRegionLeftOffset[i], rlSubWidthC * m_acLayerCfg[layer].m_refRegionRightOffset[i], |
---|
| 424 | rlSubHeightC * m_acLayerCfg[layer].m_refRegionTopOffset[i], rlSubHeightC * m_acLayerCfg[layer].m_refRegionBottomOffset[i]); |
---|
| 425 | } |
---|
| 426 | #endif |
---|
[313] | 427 | } |
---|
[830] | 428 | else |
---|
| 429 | { |
---|
| 430 | assert( layer == 0 ); |
---|
| 431 | m_acTEncTop[layer].setNumDirectRefLayers(0); |
---|
| 432 | } |
---|
[588] | 433 | #endif //VPS_EXTN_DIRECT_REF_LAYERS |
---|
[313] | 434 | //===== Slice ======== |
---|
| 435 | |
---|
| 436 | //====== Loop/Deblock Filter ======== |
---|
| 437 | m_acTEncTop[layer].setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
| 438 | m_acTEncTop[layer].setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
| 439 | m_acTEncTop[layer].setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
| 440 | m_acTEncTop[layer].setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
| 441 | m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
| 442 | m_acTEncTop[layer].setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
| 443 | |
---|
| 444 | //====== Motion search ======== |
---|
| 445 | m_acTEncTop[layer].setFastSearch ( m_iFastSearch ); |
---|
| 446 | m_acTEncTop[layer].setSearchRange ( m_iSearchRange ); |
---|
| 447 | m_acTEncTop[layer].setBipredSearchRange ( m_bipredSearchRange ); |
---|
| 448 | |
---|
| 449 | //====== Quality control ======== |
---|
| 450 | m_acTEncTop[layer].setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
| 451 | m_acTEncTop[layer].setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
| 452 | |
---|
| 453 | m_acTEncTop[layer].setChromaCbQpOffset ( m_cbQpOffset ); |
---|
| 454 | m_acTEncTop[layer].setChromaCrQpOffset ( m_crQpOffset ); |
---|
| 455 | |
---|
| 456 | #if ADAPTIVE_QP_SELECTION |
---|
| 457 | m_acTEncTop[layer].setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
| 458 | #endif |
---|
[595] | 459 | |
---|
[313] | 460 | m_acTEncTop[layer].setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
| 461 | m_acTEncTop[layer].setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
| 462 | |
---|
[595] | 463 | //====== Tool list ======== |
---|
[313] | 464 | m_acTEncTop[layer].setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
| 465 | m_acTEncTop[layer].setUseASR ( m_bUseASR ); |
---|
[595] | 466 | m_acTEncTop[layer].setUseHADME ( m_bUseHADME ); |
---|
[313] | 467 | m_acTEncTop[layer].setdQPs ( m_acLayerCfg[layer].getdQPs() ); |
---|
| 468 | m_acTEncTop[layer].setUseRDOQ ( m_useRDOQ ); |
---|
| 469 | m_acTEncTop[layer].setUseRDOQTS ( m_useRDOQTS ); |
---|
| 470 | m_acTEncTop[layer].setRDpenalty ( m_rdPenalty ); |
---|
[494] | 471 | #if LAYER_CTB |
---|
| 472 | m_acTEncTop[layer].setQuadtreeTULog2MaxSize ( m_acLayerCfg[layer].m_uiQuadtreeTULog2MaxSize ); |
---|
| 473 | m_acTEncTop[layer].setQuadtreeTULog2MinSize ( m_acLayerCfg[layer].m_uiQuadtreeTULog2MinSize ); |
---|
| 474 | m_acTEncTop[layer].setQuadtreeTUMaxDepthInter ( m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthInter ); |
---|
| 475 | m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra ( m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthIntra ); |
---|
| 476 | #else |
---|
[313] | 477 | m_acTEncTop[layer].setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
| 478 | m_acTEncTop[layer].setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
| 479 | m_acTEncTop[layer].setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
| 480 | m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
[494] | 481 | #endif |
---|
[313] | 482 | m_acTEncTop[layer].setUseFastEnc ( m_bUseFastEnc ); |
---|
[494] | 483 | m_acTEncTop[layer].setUseEarlyCU ( m_bUseEarlyCU ); |
---|
[313] | 484 | m_acTEncTop[layer].setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
| 485 | m_acTEncTop[layer].setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
| 486 | m_acTEncTop[layer].setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
| 487 | #if FAST_INTRA_SHVC |
---|
| 488 | m_acTEncTop[layer].setUseFastIntraScalable ( m_useFastIntraScalable ); |
---|
| 489 | #endif |
---|
| 490 | |
---|
| 491 | m_acTEncTop[layer].setUseTransformSkip ( m_useTransformSkip ); |
---|
| 492 | m_acTEncTop[layer].setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
| 493 | m_acTEncTop[layer].setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
| 494 | m_acTEncTop[layer].setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
| 495 | m_acTEncTop[layer].setUsePCM ( m_usePCM ); |
---|
| 496 | m_acTEncTop[layer].setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
| 497 | m_acTEncTop[layer].setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
| 498 | |
---|
| 499 | |
---|
| 500 | //====== Weighted Prediction ======== |
---|
| 501 | m_acTEncTop[layer].setUseWP ( m_useWeightedPred ); |
---|
| 502 | m_acTEncTop[layer].setWPBiPred ( m_useWeightedBiPred ); |
---|
[494] | 503 | #if O0194_WEIGHTED_PREDICTION_CGS |
---|
[588] | 504 | if( layer != 0 && m_useInterLayerWeightedPred ) |
---|
[494] | 505 | { |
---|
| 506 | // Enable weighted prediction for enhancement layer |
---|
| 507 | m_acTEncTop[layer].setUseWP ( true ); |
---|
| 508 | m_acTEncTop[layer].setWPBiPred ( true ); |
---|
| 509 | } |
---|
| 510 | #endif |
---|
[313] | 511 | //====== Parallel Merge Estimation ======== |
---|
| 512 | m_acTEncTop[layer].setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
| 513 | |
---|
| 514 | //====== Slice ======== |
---|
| 515 | m_acTEncTop[layer].setSliceMode ( m_sliceMode ); |
---|
| 516 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument ); |
---|
| 517 | |
---|
| 518 | //====== Dependent Slice ======== |
---|
| 519 | m_acTEncTop[layer].setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
| 520 | m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
[494] | 521 | #if LAYER_CTB |
---|
| 522 | Int iNumPartInCU = 1<<(m_acLayerCfg[layer].m_uiMaxCUDepth<<1); |
---|
| 523 | #else |
---|
[313] | 524 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
[494] | 525 | #endif |
---|
[313] | 526 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
| 527 | { |
---|
| 528 | m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
| 529 | } |
---|
| 530 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
| 531 | { |
---|
| 532 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
| 533 | } |
---|
| 534 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
| 535 | { |
---|
| 536 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument ); |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | if(m_sliceMode == 0 ) |
---|
| 540 | { |
---|
| 541 | m_bLFCrossSliceBoundaryFlag = true; |
---|
| 542 | } |
---|
| 543 | m_acTEncTop[layer].setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
| 544 | m_acTEncTop[layer].setUseSAO ( m_bUseSAO ); |
---|
| 545 | m_acTEncTop[layer].setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
| 546 | |
---|
| 547 | m_acTEncTop[layer].setSaoLcuBoundary (m_saoLcuBoundary); |
---|
[494] | 548 | m_acTEncTop[layer].setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
| 549 | m_acTEncTop[layer].setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
[313] | 550 | |
---|
| 551 | m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
| 552 | m_acTEncTop[layer].setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
| 553 | m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
| 554 | m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
| 555 | m_acTEncTop[layer].setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
| 556 | m_acTEncTop[layer].setTMISEIToneMapId ( m_toneMapId ); |
---|
| 557 | m_acTEncTop[layer].setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
| 558 | m_acTEncTop[layer].setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
| 559 | m_acTEncTop[layer].setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
| 560 | m_acTEncTop[layer].setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
| 561 | m_acTEncTop[layer].setTMISEIModelID ( m_toneMapModelId ); |
---|
| 562 | m_acTEncTop[layer].setTMISEIMinValue ( m_toneMapMinValue ); |
---|
| 563 | m_acTEncTop[layer].setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
| 564 | m_acTEncTop[layer].setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
| 565 | m_acTEncTop[layer].setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
| 566 | m_acTEncTop[layer].setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
| 567 | m_acTEncTop[layer].setTMISEINumPivots ( m_numPivots ); |
---|
| 568 | m_acTEncTop[layer].setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
| 569 | m_acTEncTop[layer].setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
| 570 | m_acTEncTop[layer].setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
| 571 | m_acTEncTop[layer].setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
| 572 | m_acTEncTop[layer].setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
| 573 | m_acTEncTop[layer].setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
| 574 | m_acTEncTop[layer].setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
| 575 | m_acTEncTop[layer].setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
| 576 | m_acTEncTop[layer].setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
| 577 | m_acTEncTop[layer].setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
| 578 | m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
| 579 | m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
[815] | 580 | #if P0050_KNEE_FUNCTION_SEI |
---|
| 581 | m_acTEncTop[layer].setKneeSEIEnabled ( m_kneeSEIEnabled ); |
---|
| 582 | m_acTEncTop[layer].setKneeSEIId ( m_kneeSEIId ); |
---|
| 583 | m_acTEncTop[layer].setKneeSEICancelFlag ( m_kneeSEICancelFlag ); |
---|
| 584 | m_acTEncTop[layer].setKneeSEIPersistenceFlag ( m_kneeSEIPersistenceFlag ); |
---|
| 585 | m_acTEncTop[layer].setKneeSEIMappingFlag ( m_kneeSEIMappingFlag ); |
---|
| 586 | m_acTEncTop[layer].setKneeSEIInputDrange ( m_kneeSEIInputDrange ); |
---|
| 587 | m_acTEncTop[layer].setKneeSEIInputDispLuminance ( m_kneeSEIInputDispLuminance ); |
---|
| 588 | m_acTEncTop[layer].setKneeSEIOutputDrange ( m_kneeSEIOutputDrange ); |
---|
| 589 | m_acTEncTop[layer].setKneeSEIOutputDispLuminance ( m_kneeSEIOutputDispLuminance ); |
---|
| 590 | m_acTEncTop[layer].setKneeSEINumKneePointsMinus1 ( m_kneeSEINumKneePointsMinus1 ); |
---|
| 591 | m_acTEncTop[layer].setKneeSEIInputKneePoint ( m_kneeSEIInputKneePoint ); |
---|
| 592 | m_acTEncTop[layer].setKneeSEIOutputKneePoint ( m_kneeSEIOutputKneePoint ); |
---|
| 593 | #endif |
---|
[912] | 594 | #if Q0096_OVERLAY_SEI |
---|
| 595 | m_acTEncTop[layer].setOverlaySEIEnabled ( m_overlaySEIEnabled ); |
---|
| 596 | m_acTEncTop[layer].setOverlaySEICancelFlag ( m_overlayInfoCancelFlag ); |
---|
| 597 | m_acTEncTop[layer].setOverlaySEIContentAuxIdMinus128 ( m_overlayContentAuxIdMinus128 ); |
---|
| 598 | m_acTEncTop[layer].setOverlaySEILabelAuxIdMinus128 ( m_overlayLabelAuxIdMinus128 ); |
---|
| 599 | m_acTEncTop[layer].setOverlaySEIAlphaAuxIdMinus128 ( m_overlayAlphaAuxIdMinus128 ); |
---|
| 600 | m_acTEncTop[layer].setOverlaySEIElementLabelValueLengthMinus8 ( m_overlayElementLabelValueLengthMinus8 ); |
---|
| 601 | m_acTEncTop[layer].setOverlaySEINumOverlaysMinus1 ( m_numOverlaysMinus1 ); |
---|
| 602 | m_acTEncTop[layer].setOverlaySEIIdx ( m_overlayIdx ); |
---|
| 603 | m_acTEncTop[layer].setOverlaySEILanguagePresentFlag ( m_overlayLanguagePresentFlag ); |
---|
| 604 | m_acTEncTop[layer].setOverlaySEIContentLayerId ( m_overlayContentLayerId ); |
---|
| 605 | m_acTEncTop[layer].setOverlaySEILabelPresentFlag ( m_overlayLabelPresentFlag ); |
---|
| 606 | m_acTEncTop[layer].setOverlaySEILabelLayerId ( m_overlayLabelLayerId ); |
---|
| 607 | m_acTEncTop[layer].setOverlaySEIAlphaPresentFlag ( m_overlayAlphaPresentFlag ); |
---|
| 608 | m_acTEncTop[layer].setOverlaySEIAlphaLayerId ( m_overlayAlphaLayerId ); |
---|
| 609 | m_acTEncTop[layer].setOverlaySEINumElementsMinus1 ( m_numOverlayElementsMinus1 ); |
---|
| 610 | m_acTEncTop[layer].setOverlaySEIElementLabelMin ( m_overlayElementLabelMin ); |
---|
| 611 | m_acTEncTop[layer].setOverlaySEIElementLabelMax ( m_overlayElementLabelMax ); |
---|
| 612 | m_acTEncTop[layer].setOverlaySEILanguage ( m_overlayLanguage ); |
---|
| 613 | m_acTEncTop[layer].setOverlaySEIName ( m_overlayName ); |
---|
| 614 | m_acTEncTop[layer].setOverlaySEIElementName ( m_overlayElementName ); |
---|
| 615 | m_acTEncTop[layer].setOverlaySEIPersistenceFlag ( m_overlayInfoPersistenceFlag ); |
---|
| 616 | #endif |
---|
[856] | 617 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
| 618 | m_acTEncTop[layer].setCRISEIFile ( const_cast<Char*>(m_acLayerCfg[layer].m_colourRemapSEIFile.c_str()) ); |
---|
| 619 | m_acTEncTop[layer].setCRISEIId ( m_acLayerCfg[layer].m_colourRemapSEIId ); |
---|
| 620 | m_acTEncTop[layer].setCRISEICancelFlag ( m_acLayerCfg[layer].m_colourRemapSEICancelFlag ); |
---|
| 621 | m_acTEncTop[layer].setCRISEIPersistenceFlag ( m_acLayerCfg[layer].m_colourRemapSEIPersistenceFlag ); |
---|
[868] | 622 | m_acTEncTop[layer].setCRISEIVideoSignalInfoPresentFlag ( m_acLayerCfg[layer].m_colourRemapSEIVideoSignalInfoPresentFlag ); |
---|
| 623 | m_acTEncTop[layer].setCRISEIFullRangeFlag ( m_acLayerCfg[layer].m_colourRemapSEIFullRangeFlag ); |
---|
[856] | 624 | m_acTEncTop[layer].setCRISEIPrimaries ( m_acLayerCfg[layer].m_colourRemapSEIPrimaries ); |
---|
[868] | 625 | m_acTEncTop[layer].setCRISEITransferFunction ( m_acLayerCfg[layer].m_colourRemapSEITransferFunction ); |
---|
| 626 | m_acTEncTop[layer].setCRISEIMatrixCoefficients ( m_acLayerCfg[layer].m_colourRemapSEIMatrixCoefficients ); |
---|
| 627 | m_acTEncTop[layer].setCRISEIInputBitDepth ( m_acLayerCfg[layer].m_colourRemapSEIInputBitDepth ); |
---|
| 628 | m_acTEncTop[layer].setCRISEIBitDepth ( m_acLayerCfg[layer].m_colourRemapSEIBitDepth ); |
---|
[856] | 629 | m_acTEncTop[layer].setCRISEIPreLutNumValMinus1 ( m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1 ); |
---|
| 630 | m_acTEncTop[layer].setCRISEIPreLutCodedValue ( m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue ); |
---|
| 631 | m_acTEncTop[layer].setCRISEIPreLutTargetValue ( m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue ); |
---|
| 632 | m_acTEncTop[layer].setCRISEIMatrixPresentFlag ( m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag ); |
---|
| 633 | m_acTEncTop[layer].setCRISEILog2MatrixDenom ( m_acLayerCfg[layer].m_colourRemapSEILog2MatrixDenom ); |
---|
| 634 | m_acTEncTop[layer].setCRISEICoeffs ( m_acLayerCfg[layer].m_colourRemapSEICoeffs ); |
---|
| 635 | m_acTEncTop[layer].setCRISEIPostLutNumValMinus1 ( m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1 ); |
---|
| 636 | m_acTEncTop[layer].setCRISEIPostLutCodedValue ( m_acLayerCfg[layer]. m_colourRemapSEIPostLutCodedValue ); |
---|
| 637 | m_acTEncTop[layer].setCRISEIPostLutTargetValue ( m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue ); |
---|
[713] | 638 | #endif |
---|
[313] | 639 | m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
| 640 | m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
| 641 | m_acTEncTop[layer].setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
| 642 | m_acTEncTop[layer].setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
| 643 | m_acTEncTop[layer].setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
| 644 | m_acTEncTop[layer].setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
| 645 | m_acTEncTop[layer].setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
| 646 | m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
| 647 | m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
[588] | 648 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 649 | m_acTEncTop[layer].setLayersNotPresentSEIEnabled( m_layersNotPresentSEIEnabled ); |
---|
[313] | 650 | #endif |
---|
| 651 | m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
| 652 | m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
[815] | 653 | #if Q0189_TMVP_CONSTRAINTS |
---|
| 654 | m_acTEncTop[layer].setTMVPConstraintsSEIEnabled( m_TMVPConstraintsSEIEnabled); |
---|
| 655 | #endif |
---|
[442] | 656 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 657 | m_acTEncTop[layer].setInterLayerConstrainedTileSetsSEIEnabled( m_interLayerConstrainedTileSetsSEIEnabled ); |
---|
| 658 | m_acTEncTop[layer].setIlNumSetsInMessage( m_ilNumSetsInMessage ); |
---|
| 659 | m_acTEncTop[layer].setSkippedTileSetPresentFlag( m_skippedTileSetPresentFlag ); |
---|
| 660 | m_acTEncTop[layer].setTopLeftTileIndex( m_topLeftTileIndex ); |
---|
| 661 | m_acTEncTop[layer].setBottomRightTileIndex( m_bottomRightTileIndex ); |
---|
| 662 | m_acTEncTop[layer].setIlcIdc( m_ilcIdc ); |
---|
| 663 | #endif |
---|
[823] | 664 | m_acTEncTop[layer].setTileUniformSpacingFlag ( m_tileUniformSpacingFlag ); |
---|
| 665 | m_acTEncTop[layer].setNumColumnsMinus1 ( m_numTileColumnsMinus1 ); |
---|
| 666 | m_acTEncTop[layer].setNumRowsMinus1 ( m_numTileRowsMinus1 ); |
---|
| 667 | if(!m_tileUniformSpacingFlag) |
---|
[313] | 668 | { |
---|
[823] | 669 | m_acTEncTop[layer].setColumnWidth ( m_tileColumnWidth ); |
---|
| 670 | m_acTEncTop[layer].setRowHeight ( m_tileRowHeight ); |
---|
[313] | 671 | } |
---|
| 672 | m_acTEncTop[layer].xCheckGSParameters(); |
---|
[823] | 673 | Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1); |
---|
[313] | 674 | if(uiTilesCount == 1) |
---|
| 675 | { |
---|
[494] | 676 | m_bLFCrossTileBoundaryFlag = true; |
---|
[313] | 677 | } |
---|
| 678 | m_acTEncTop[layer].setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
[875] | 679 | m_acTEncTop[layer].setWaveFrontSynchro ( m_acLayerCfg[layer].m_waveFrontSynchro ); |
---|
[313] | 680 | m_acTEncTop[layer].setWaveFrontSubstreams ( m_acLayerCfg[layer].m_iWaveFrontSubstreams ); |
---|
| 681 | m_acTEncTop[layer].setTMVPModeId ( m_TMVPModeId ); |
---|
| 682 | m_acTEncTop[layer].setUseScalingListId ( m_useScalingListId ); |
---|
| 683 | m_acTEncTop[layer].setScalingListFile ( m_scalingListFile ); |
---|
| 684 | m_acTEncTop[layer].setSignHideFlag(m_signHideFlag); |
---|
| 685 | #if RC_SHVC_HARMONIZATION |
---|
| 686 | m_acTEncTop[layer].setUseRateCtrl (m_acLayerCfg[layer].getRCEnableRateControl()); |
---|
| 687 | m_acTEncTop[layer].setTargetBitrate (m_acLayerCfg[layer].getRCTargetBitrate()); |
---|
| 688 | m_acTEncTop[layer].setKeepHierBit (m_acLayerCfg[layer].getRCKeepHierarchicalBit()); |
---|
| 689 | m_acTEncTop[layer].setLCULevelRC (m_acLayerCfg[layer].getRCLCULevelRC()); |
---|
| 690 | m_acTEncTop[layer].setUseLCUSeparateModel (m_acLayerCfg[layer].getRCUseLCUSeparateModel()); |
---|
| 691 | m_acTEncTop[layer].setInitialQP (m_acLayerCfg[layer].getRCInitialQP()); |
---|
| 692 | m_acTEncTop[layer].setForceIntraQP (m_acLayerCfg[layer].getRCForceIntraQP()); |
---|
| 693 | #else |
---|
| 694 | m_acTEncTop[layer].setUseRateCtrl ( m_RCEnableRateControl ); |
---|
| 695 | m_acTEncTop[layer].setTargetBitrate ( m_RCTargetBitrate ); |
---|
| 696 | m_acTEncTop[layer].setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
| 697 | m_acTEncTop[layer].setLCULevelRC ( m_RCLCULevelRC ); |
---|
| 698 | m_acTEncTop[layer].setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
| 699 | m_acTEncTop[layer].setInitialQP ( m_RCInitialQP ); |
---|
| 700 | m_acTEncTop[layer].setForceIntraQP ( m_RCForceIntraQP ); |
---|
| 701 | #endif |
---|
| 702 | m_acTEncTop[layer].setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
[595] | 703 | m_acTEncTop[layer].setCUTransquantBypassFlagForceValue(m_CUTransquantBypassFlagForce); |
---|
[313] | 704 | m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
| 705 | m_acTEncTop[layer].setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
[494] | 706 | m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
[313] | 707 | m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
[823] | 708 | m_acTEncTop[layer].setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag); |
---|
[313] | 709 | m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc ); |
---|
| 710 | m_acTEncTop[layer].setSarWidth( m_sarWidth ); |
---|
| 711 | m_acTEncTop[layer].setSarHeight( m_sarHeight ); |
---|
| 712 | m_acTEncTop[layer].setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
| 713 | m_acTEncTop[layer].setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
| 714 | m_acTEncTop[layer].setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
| 715 | m_acTEncTop[layer].setVideoFormat( m_videoFormat ); |
---|
| 716 | m_acTEncTop[layer].setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
| 717 | m_acTEncTop[layer].setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
| 718 | m_acTEncTop[layer].setColourPrimaries( m_colourPrimaries ); |
---|
| 719 | m_acTEncTop[layer].setTransferCharacteristics( m_transferCharacteristics ); |
---|
| 720 | m_acTEncTop[layer].setMatrixCoefficients( m_matrixCoefficients ); |
---|
| 721 | m_acTEncTop[layer].setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
| 722 | m_acTEncTop[layer].setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
| 723 | m_acTEncTop[layer].setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
| 724 | m_acTEncTop[layer].setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
| 725 | m_acTEncTop[layer].setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
| 726 | m_acTEncTop[layer].setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
| 727 | m_acTEncTop[layer].setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
| 728 | m_acTEncTop[layer].setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
| 729 | m_acTEncTop[layer].setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
| 730 | m_acTEncTop[layer].setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
| 731 | m_acTEncTop[layer].setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
| 732 | m_acTEncTop[layer].setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
| 733 | m_acTEncTop[layer].setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
| 734 | m_acTEncTop[layer].setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
| 735 | m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
| 736 | m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
| 737 | m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled); |
---|
| 738 | if( layer > 0 ) |
---|
| 739 | { |
---|
[849] | 740 | #if REF_REGION_OFFSET |
---|
| 741 | #if AUXILIARY_PICTURES |
---|
| 742 | Int cf = m_acLayerCfg[layer].m_chromaFormatIDC; |
---|
| 743 | Int subWidthC = ( cf == CHROMA_420 || cf == CHROMA_422 ) ? 2 : 1; |
---|
| 744 | Int subHeightC = ( cf == CHROMA_420 ) ? 2 : 1; |
---|
| 745 | #else |
---|
| 746 | Int subWidthC = 2; |
---|
| 747 | Int subHeightC = 2; |
---|
| 748 | #endif |
---|
| 749 | #endif |
---|
[313] | 750 | m_acTEncTop[layer].setNumScaledRefLayerOffsets( m_acLayerCfg[layer].m_numScaledRefLayerOffsets ); |
---|
| 751 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
| 752 | { |
---|
[540] | 753 | #if O0098_SCALED_REF_LAYER_ID |
---|
| 754 | m_acTEncTop[layer].setScaledRefLayerId(i, m_acLayerCfg[layer].m_scaledRefLayerId[i]); |
---|
| 755 | #endif |
---|
[849] | 756 | #if REF_REGION_OFFSET |
---|
| 757 | m_acTEncTop[layer].setScaledRefLayerOffsetPresentFlag( i, m_acLayerCfg[layer].m_scaledRefLayerOffsetPresentFlag[i] ); |
---|
| 758 | m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( subWidthC * m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], subWidthC * m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i], |
---|
| 759 | subHeightC * m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], subHeightC * m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]); |
---|
| 760 | #else |
---|
[644] | 761 | #if P0312_VERT_PHASE_ADJ |
---|
| 762 | m_acTEncTop[layer].setVertPhasePositionEnableFlag( i, m_acLayerCfg[layer].m_vertPhasePositionEnableFlag[i] ); |
---|
[313] | 763 | m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i], |
---|
[644] | 764 | 2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i], m_acLayerCfg[layer].m_vertPhasePositionEnableFlag[i] ); |
---|
| 765 | #else |
---|
| 766 | m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i], |
---|
[494] | 767 | 2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]); |
---|
[644] | 768 | #endif |
---|
[849] | 769 | #endif |
---|
| 770 | #if R0209_GENERIC_PHASE |
---|
| 771 | m_acTEncTop[layer].setResamplePhaseSetPresentFlag( i, m_acLayerCfg[layer].m_resamplePhaseSetPresentFlag[i] ); |
---|
| 772 | m_acTEncTop[layer].setPhaseHorLuma( i, m_acLayerCfg[layer].m_phaseHorLuma[i] ); |
---|
| 773 | m_acTEncTop[layer].setPhaseVerLuma( i, m_acLayerCfg[layer].m_phaseVerLuma[i] ); |
---|
| 774 | m_acTEncTop[layer].setPhaseHorChroma( i, m_acLayerCfg[layer].m_phaseHorChroma[i] ); |
---|
| 775 | m_acTEncTop[layer].setPhaseVerChroma( i, m_acLayerCfg[layer].m_phaseVerChroma[i] ); |
---|
| 776 | #endif |
---|
[313] | 777 | } |
---|
| 778 | } |
---|
| 779 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 780 | m_acTEncTop[layer].setAdaptiveResolutionChange( m_adaptiveResolutionChange ); |
---|
| 781 | #endif |
---|
[494] | 782 | #if AUXILIARY_PICTURES |
---|
| 783 | m_acTEncTop[layer].setChromaFormatIDC( m_acLayerCfg[layer].m_chromaFormatIDC ); |
---|
| 784 | #endif |
---|
[540] | 785 | #if O0153_ALT_OUTPUT_LAYER_FLAG |
---|
| 786 | m_acTEncTop[layer].setAltOuputLayerFlag( m_altOutputLayerFlag ); |
---|
| 787 | #endif |
---|
| 788 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
| 789 | m_acTEncTop[layer].setCrossLayerBLAFlag( m_crossLayerBLAFlag ); |
---|
| 790 | #endif |
---|
[713] | 791 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 792 | m_acTEncTop[layer].setCGSFlag( layer == 0 ? 0 : m_nCGSFlag ); |
---|
| 793 | m_acTEncTop[layer].setCGSMaxOctantDepth( m_nCGSMaxOctantDepth ); |
---|
| 794 | m_acTEncTop[layer].setCGSMaxYPartNumLog2( m_nCGSMaxYPartNumLog2 ); |
---|
| 795 | m_acTEncTop[layer].setCGSLUTBit( m_nCGSLUTBit ); |
---|
[825] | 796 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
| 797 | m_acTEncTop[layer].setCGSAdaptChroma( m_nCGSAdaptiveChroma ); |
---|
[713] | 798 | #endif |
---|
[877] | 799 | #if R0179_ENC_OPT_3DLUT_SIZE |
---|
| 800 | m_acTEncTop[layer].setCGSLutSizeRDO( m_nCGSLutSizeRDO ); |
---|
[825] | 801 | #endif |
---|
[877] | 802 | #endif |
---|
[815] | 803 | #if Q0078_ADD_LAYER_SETS |
---|
| 804 | m_acTEncTop[layer].setNumAddLayerSets( m_numAddLayerSets ); |
---|
| 805 | #endif |
---|
[313] | 806 | } |
---|
| 807 | } |
---|
[494] | 808 | #else //SVC_EXTENSION |
---|
[313] | 809 | Void TAppEncTop::xInitLibCfg() |
---|
| 810 | { |
---|
| 811 | TComVPS vps; |
---|
| 812 | |
---|
| 813 | vps.setMaxTLayers ( m_maxTempLayer ); |
---|
| 814 | if (m_maxTempLayer == 1) |
---|
| 815 | { |
---|
| 816 | vps.setTemporalNestingFlag(true); |
---|
| 817 | } |
---|
| 818 | vps.setMaxLayers ( 1 ); |
---|
| 819 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 820 | { |
---|
| 821 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 822 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 823 | } |
---|
| 824 | m_cTEncTop.setVPS(&vps); |
---|
| 825 | |
---|
| 826 | m_cTEncTop.setProfile(m_profile); |
---|
| 827 | m_cTEncTop.setLevel(m_levelTier, m_level); |
---|
| 828 | m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
| 829 | m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
| 830 | m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
| 831 | m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
| 832 | |
---|
| 833 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
---|
| 834 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
---|
| 835 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
---|
| 836 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
---|
[823] | 837 | m_cTEncTop.setConformanceWindow ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
[313] | 838 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
| 839 | |
---|
| 840 | //====== Coding Structure ======== |
---|
| 841 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod ); |
---|
| 842 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
| 843 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
---|
| 844 | m_cTEncTop.setGopList ( m_GOPList ); |
---|
| 845 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
---|
| 846 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 847 | { |
---|
| 848 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 849 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 850 | } |
---|
| 851 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
| 852 | { |
---|
| 853 | m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
| 854 | } |
---|
| 855 | m_cTEncTop.setQP ( m_iQP ); |
---|
| 856 | |
---|
| 857 | m_cTEncTop.setPad ( m_aiPad ); |
---|
| 858 | |
---|
| 859 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
---|
| 860 | m_cTEncTop.setUseAMP( m_enableAMP ); |
---|
| 861 | |
---|
| 862 | //===== Slice ======== |
---|
| 863 | |
---|
| 864 | //====== Loop/Deblock Filter ======== |
---|
| 865 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
| 866 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
| 867 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
| 868 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
| 869 | m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
| 870 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
| 871 | |
---|
| 872 | //====== Motion search ======== |
---|
| 873 | m_cTEncTop.setFastSearch ( m_iFastSearch ); |
---|
| 874 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
---|
| 875 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
---|
| 876 | |
---|
| 877 | //====== Quality control ======== |
---|
| 878 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
| 879 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
| 880 | |
---|
| 881 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
---|
| 882 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
---|
| 883 | |
---|
| 884 | #if ADAPTIVE_QP_SELECTION |
---|
| 885 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
| 886 | #endif |
---|
| 887 | |
---|
| 888 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
| 889 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
| 890 | |
---|
| 891 | //====== Tool list ======== |
---|
| 892 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
| 893 | m_cTEncTop.setUseASR ( m_bUseASR ); |
---|
| 894 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
---|
| 895 | m_cTEncTop.setdQPs ( m_aidQP ); |
---|
| 896 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
---|
| 897 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
---|
| 898 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
---|
| 899 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
| 900 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
| 901 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
| 902 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
| 903 | m_cTEncTop.setUseFastEnc ( m_bUseFastEnc ); |
---|
[494] | 904 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
---|
[313] | 905 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
| 906 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
| 907 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
| 908 | #if FAST_INTRA_SHVC |
---|
| 909 | m_cTEncTop.setUseFastIntraScalable ( m_useFastIntraScalable ); |
---|
| 910 | #endif |
---|
| 911 | |
---|
| 912 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
---|
| 913 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
| 914 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
| 915 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
| 916 | m_cTEncTop.setUsePCM ( m_usePCM ); |
---|
| 917 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
| 918 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
| 919 | |
---|
| 920 | |
---|
| 921 | //====== Weighted Prediction ======== |
---|
| 922 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
---|
| 923 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
---|
| 924 | //====== Parallel Merge Estimation ======== |
---|
| 925 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
| 926 | |
---|
| 927 | //====== Slice ======== |
---|
| 928 | m_cTEncTop.setSliceMode ( m_sliceMode ); |
---|
| 929 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
| 930 | |
---|
| 931 | //====== Dependent Slice ======== |
---|
| 932 | m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
| 933 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
| 934 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
| 935 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
| 936 | { |
---|
| 937 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
| 938 | } |
---|
| 939 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
| 940 | { |
---|
| 941 | m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
| 942 | } |
---|
| 943 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
| 944 | { |
---|
| 945 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
| 946 | } |
---|
| 947 | |
---|
| 948 | if(m_sliceMode == 0 ) |
---|
| 949 | { |
---|
| 950 | m_bLFCrossSliceBoundaryFlag = true; |
---|
| 951 | } |
---|
| 952 | m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
| 953 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
---|
| 954 | m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
| 955 | |
---|
| 956 | m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary); |
---|
[494] | 957 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
| 958 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
[313] | 959 | |
---|
| 960 | m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
| 961 | m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
| 962 | m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
| 963 | m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
| 964 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
| 965 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
---|
| 966 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
| 967 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
| 968 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
| 969 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
| 970 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
---|
| 971 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
---|
| 972 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
| 973 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
| 974 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
| 975 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
| 976 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
---|
| 977 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
| 978 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
| 979 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
| 980 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
[713] | 981 | m_cTEncTop.setTMISEIExposureIndexIdc ( m_exposureIndexIdc ); |
---|
| 982 | m_cTEncTop.setTMISEIExposureIndexValue ( m_exposureIndexValue ); |
---|
[313] | 983 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
| 984 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
| 985 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
| 986 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
| 987 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
| 988 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
| 989 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
| 990 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
[815] | 991 | #if P0050_KNEE_FUNCTION_SEI |
---|
| 992 | m_cTEncTop.setKneeSEIEnabled ( m_kneeSEIEnabled ); |
---|
| 993 | m_cTEncTop.setKneeSEIId ( m_kneeSEIId ); |
---|
| 994 | m_cTEncTop.setKneeSEICancelFlag ( m_kneeSEICancelFlag ); |
---|
| 995 | m_cTEncTop.setKneeSEIPersistenceFlag ( m_kneeSEIPersistenceFlag ); |
---|
| 996 | m_cTEncTop.setKneeSEIMappingFlag ( m_kneeSEIMappingFlag ); |
---|
| 997 | m_cTEncTop.setKneeSEIInputDrange ( m_kneeSEIInputDrange ); |
---|
| 998 | m_cTEncTop.setKneeSEIInputDispLuminance ( m_kneeSEIInputDispLuminance ); |
---|
| 999 | m_cTEncTop.setKneeSEIOutputDrange ( m_kneeSEIOutputDrange ); |
---|
| 1000 | m_cTEncTop.setKneeSEIOutputDispLuminance ( m_kneeSEIOutputDispLuminance ); |
---|
| 1001 | m_cTEncTop.setKneeSEINumKneePointsMinus1 ( m_kneeSEINumKneePointsMinus1 ); |
---|
| 1002 | m_cTEncTop.setKneeSEIInputKneePoint ( m_kneeSEIInputKneePoint ); |
---|
| 1003 | m_cTEncTop.setKneeSEIOutputKneePoint ( m_kneeSEIOutputKneePoint ); |
---|
| 1004 | #endif |
---|
[856] | 1005 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
| 1006 | m_cTEncTop.setCRISEIFile ( const_cast<Char*>(m_colourRemapSEIFile.c_str()) ); |
---|
| 1007 | m_cTEncTop.setCRISEIId ( m_colourRemapSEIId ); |
---|
| 1008 | m_cTEncTop.setCRISEICancelFlag ( m_colourRemapSEICancelFlag ); |
---|
| 1009 | m_cTEncTop.setCRISEIPersistenceFlag ( m_colourRemapSEIPersistenceFlag ); |
---|
[868] | 1010 | m_cTEncTop.setCRISEIVideoSignalInfoPresentFlag ( m_colourRemapSEIVideoSignalInfoPresentFlag ); |
---|
| 1011 | m_cTEncTop.setCRISEIFullRangeFlag ( m_colourRemapSEIFullRangeFlag ); |
---|
[856] | 1012 | m_cTEncTop.setCRISEIPrimaries ( m_colourRemapSEIPrimaries ); |
---|
[868] | 1013 | m_cTEncTop.setCRISEITransferFunction ( m_colourRemapSEITransferFunction ); |
---|
| 1014 | m_cTEncTop.setCRISEIMatrixCoefficients ( m_colourRemapSEIMatrixCoefficients ); |
---|
| 1015 | m_cTEncTop.setCRISEIInputBitDepth ( m_colourRemapSEIInputBitDepth ); |
---|
| 1016 | m_cTEncTop.setCRISEIBitDepth ( m_colourRemapSEIBitDepth ); |
---|
[856] | 1017 | m_cTEncTop.setCRISEIPreLutNumValMinus1 ( m_colourRemapSEIPreLutNumValMinus1 ); |
---|
| 1018 | m_cTEncTop.setCRISEIPreLutCodedValue ( m_colourRemapSEIPreLutCodedValue ); |
---|
| 1019 | m_cTEncTop.setCRISEIPreLutTargetValue ( m_colourRemapSEIPreLutTargetValue ); |
---|
| 1020 | m_cTEncTop.setCRISEIMatrixPresentFlag ( m_colourRemapSEIMatrixPresentFlag ); |
---|
| 1021 | m_cTEncTop.setCRISEILog2MatrixDenom ( m_colourRemapSEILog2MatrixDenom ); |
---|
| 1022 | m_cTEncTop.setCRISEICoeffs ( m_colourRemapSEICoeffs ); |
---|
| 1023 | m_cTEncTop.setCRISEIPostLutNumValMinus1 ( m_colourRemapSEIPostLutNumValMinus1 ); |
---|
| 1024 | m_cTEncTop.setCRISEIPostLutCodedValue ( m_colourRemapSEIPostLutCodedValue ); |
---|
| 1025 | m_cTEncTop.setCRISEIPostLutTargetValue ( m_colourRemapSEIPostLutTargetValue ); |
---|
[713] | 1026 | #endif |
---|
[313] | 1027 | m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
| 1028 | m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
| 1029 | m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
| 1030 | m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
| 1031 | m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
| 1032 | m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
| 1033 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
| 1034 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
| 1035 | m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
[588] | 1036 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1037 | m_cTEncTop.setLayersNotPresentSEIEnabled( m_layersNotPresentSEIEnabled ); |
---|
[313] | 1038 | #endif |
---|
| 1039 | m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
| 1040 | m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
[823] | 1041 | m_cTEncTop.setTileUniformSpacingFlag ( m_tileUniformSpacingFlag ); |
---|
| 1042 | m_cTEncTop.setNumColumnsMinus1 ( m_numTileColumnsMinus1 ); |
---|
| 1043 | m_cTEncTop.setNumRowsMinus1 ( m_numTileRowsMinus1 ); |
---|
| 1044 | if(!m_tileUniformSpacingFlag) |
---|
[313] | 1045 | { |
---|
[823] | 1046 | m_cTEncTop.setColumnWidth ( m_tileColumnWidth ); |
---|
| 1047 | m_cTEncTop.setRowHeight ( m_tileRowHeight ); |
---|
[313] | 1048 | } |
---|
| 1049 | m_cTEncTop.xCheckGSParameters(); |
---|
[823] | 1050 | Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1); |
---|
[313] | 1051 | if(uiTilesCount == 1) |
---|
| 1052 | { |
---|
[494] | 1053 | m_bLFCrossTileBoundaryFlag = true; |
---|
[313] | 1054 | } |
---|
| 1055 | m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
| 1056 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
| 1057 | m_cTEncTop.setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
| 1058 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
---|
| 1059 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
---|
| 1060 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
---|
| 1061 | m_cTEncTop.setSignHideFlag(m_signHideFlag); |
---|
| 1062 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
| 1063 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
| 1064 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
| 1065 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
---|
| 1066 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
| 1067 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
---|
| 1068 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
---|
| 1069 | m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
[595] | 1070 | m_cTEncTop.setCUTransquantBypassFlagForceValue(m_CUTransquantBypassFlagForce); |
---|
[313] | 1071 | m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
| 1072 | m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
[494] | 1073 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
[313] | 1074 | m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
[823] | 1075 | m_cTEncTop.setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag); |
---|
[313] | 1076 | m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc ); |
---|
| 1077 | m_cTEncTop.setSarWidth( m_sarWidth ); |
---|
| 1078 | m_cTEncTop.setSarHeight( m_sarHeight ); |
---|
| 1079 | m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
| 1080 | m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
| 1081 | m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
| 1082 | m_cTEncTop.setVideoFormat( m_videoFormat ); |
---|
| 1083 | m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
| 1084 | m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
| 1085 | m_cTEncTop.setColourPrimaries( m_colourPrimaries ); |
---|
| 1086 | m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics ); |
---|
| 1087 | m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients ); |
---|
| 1088 | m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
| 1089 | m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
| 1090 | m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
| 1091 | m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
| 1092 | m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
| 1093 | m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
| 1094 | m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
| 1095 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
| 1096 | m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
| 1097 | m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
| 1098 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
| 1099 | m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
| 1100 | m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
| 1101 | m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
| 1102 | m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
| 1103 | m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
| 1104 | } |
---|
[494] | 1105 | #endif //SVC_EXTENSION |
---|
[313] | 1106 | |
---|
| 1107 | Void TAppEncTop::xCreateLib() |
---|
| 1108 | { |
---|
| 1109 | // Video I/O |
---|
| 1110 | #if SVC_EXTENSION |
---|
| 1111 | // initialize global variables |
---|
| 1112 | initROM(); |
---|
| 1113 | |
---|
| 1114 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1115 | { |
---|
[494] | 1116 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 1117 | //2 |
---|
| 1118 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1119 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 1120 | |
---|
| 1121 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1122 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 1123 | #endif |
---|
| 1124 | #if LAYER_CTB |
---|
| 1125 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
| 1126 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
| 1127 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
| 1128 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
| 1129 | #endif |
---|
| 1130 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 1131 | m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(), false, m_acLayerCfg[layer].m_inputBitDepthY, m_acLayerCfg[layer].m_inputBitDepthC, m_acLayerCfg[layer].m_internalBitDepthY, m_acLayerCfg[layer].m_internalBitDepthC ); // read mode |
---|
| 1132 | #else |
---|
[313] | 1133 | m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(), false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
[494] | 1134 | #endif |
---|
[313] | 1135 | m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1]); |
---|
| 1136 | |
---|
| 1137 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
| 1138 | { |
---|
[494] | 1139 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 1140 | m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_acLayerCfg[layer].m_outputBitDepthY, m_acLayerCfg[layer].m_outputBitDepthC, m_acLayerCfg[layer].m_internalBitDepthY, m_acLayerCfg[layer].m_internalBitDepthC ); // write mode |
---|
| 1141 | #else |
---|
[313] | 1142 | m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // write mode |
---|
[494] | 1143 | #endif |
---|
[313] | 1144 | } |
---|
| 1145 | |
---|
| 1146 | m_acTEncTop[layer].create(); |
---|
| 1147 | } |
---|
[494] | 1148 | #else //SVC_EXTENSION |
---|
[313] | 1149 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
| 1150 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
| 1151 | |
---|
| 1152 | if (m_pchReconFile) |
---|
| 1153 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
| 1154 | |
---|
| 1155 | // Neo Decoder |
---|
| 1156 | m_cTEncTop.create(); |
---|
[494] | 1157 | #endif //SVC_EXTENSION |
---|
[313] | 1158 | } |
---|
| 1159 | |
---|
| 1160 | Void TAppEncTop::xDestroyLib() |
---|
| 1161 | { |
---|
| 1162 | // Video I/O |
---|
| 1163 | #if SVC_EXTENSION |
---|
| 1164 | // destroy ROM |
---|
| 1165 | destroyROM(); |
---|
| 1166 | |
---|
| 1167 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1168 | { |
---|
[494] | 1169 | #if LAYER_CTB |
---|
| 1170 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
| 1171 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
| 1172 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
| 1173 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
| 1174 | #endif |
---|
| 1175 | |
---|
[313] | 1176 | m_acTVideoIOYuvInputFile[layer].close(); |
---|
| 1177 | m_acTVideoIOYuvReconFile[layer].close(); |
---|
| 1178 | |
---|
| 1179 | m_acTEncTop[layer].destroy(); |
---|
| 1180 | } |
---|
[494] | 1181 | #else //SVC_EXTENSION |
---|
[313] | 1182 | m_cTVideoIOYuvInputFile.close(); |
---|
| 1183 | m_cTVideoIOYuvReconFile.close(); |
---|
| 1184 | |
---|
| 1185 | // Neo Decoder |
---|
| 1186 | m_cTEncTop.destroy(); |
---|
[494] | 1187 | #endif //SVC_EXTENSION |
---|
[313] | 1188 | } |
---|
| 1189 | |
---|
[442] | 1190 | Void TAppEncTop::xInitLib(Bool isFieldCoding) |
---|
[313] | 1191 | { |
---|
| 1192 | #if SVC_EXTENSION |
---|
| 1193 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1194 | { |
---|
[494] | 1195 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 1196 | //3 |
---|
| 1197 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1198 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 1199 | |
---|
| 1200 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1201 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 1202 | #endif |
---|
| 1203 | #if LAYER_CTB |
---|
| 1204 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
| 1205 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
| 1206 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
| 1207 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
| 1208 | |
---|
| 1209 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
---|
| 1210 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
---|
| 1211 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
---|
| 1212 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
---|
| 1213 | #endif |
---|
[442] | 1214 | m_acTEncTop[layer].init(isFieldCoding); |
---|
[644] | 1215 | #if P0182_VPS_VUI_PS_FLAG |
---|
| 1216 | m_acTEncTop[layer].getVPS()->setSPSId(layer, m_acTEncTop[layer].getSPS()->getSPSId()); |
---|
| 1217 | m_acTEncTop[layer].getVPS()->setPPSId(layer, m_acTEncTop[layer].getPPS()->getPPSId()); |
---|
| 1218 | #endif |
---|
[313] | 1219 | } |
---|
| 1220 | m_acTEncTop[0].getVPS()->setMaxLayers( m_numLayers ); |
---|
| 1221 | #if VPS_EXTN_OP_LAYER_SETS |
---|
| 1222 | TComVPS* vps = m_acTEncTop[0].getVPS(); |
---|
| 1223 | vps->setMaxLayerId(m_numLayers - 1); // Set max-layer ID |
---|
| 1224 | |
---|
[713] | 1225 | vps->setVpsExtensionFlag( m_numLayers > 1 ? true : false ); |
---|
| 1226 | |
---|
[815] | 1227 | #if Q0078_ADD_LAYER_SETS |
---|
[861] | 1228 | #if OUTPUT_LAYER_SETS_CONFIG |
---|
| 1229 | if (m_numLayerSets > 1) |
---|
| 1230 | { |
---|
| 1231 | vps->setNumLayerSets(m_numLayerSets); |
---|
| 1232 | #else |
---|
[815] | 1233 | if (m_numLayerSets > 0) |
---|
[313] | 1234 | { |
---|
[815] | 1235 | vps->setNumLayerSets(m_numLayerSets+1); |
---|
[861] | 1236 | #endif |
---|
[815] | 1237 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
[313] | 1238 | { |
---|
[815] | 1239 | for (Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++) |
---|
| 1240 | { |
---|
| 1241 | vps->setLayerIdIncludedFlag(false, setId, layerId); |
---|
| 1242 | } |
---|
| 1243 | } |
---|
| 1244 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
| 1245 | { |
---|
[861] | 1246 | #if OUTPUT_LAYER_SETS_CONFIG |
---|
| 1247 | for (Int i = 0; i < m_numLayerInIdList[setId]; i++) |
---|
| 1248 | { |
---|
| 1249 | Int layerId = m_layerSetLayerIdList[setId][i]; |
---|
| 1250 | #else |
---|
[815] | 1251 | for (Int i = 0; i < m_numLayerInIdList[setId-1]; i++) |
---|
| 1252 | { |
---|
| 1253 | Int layerId = m_layerSetLayerIdList[setId-1][i]; |
---|
[861] | 1254 | #endif |
---|
[494] | 1255 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
[815] | 1256 | //4 |
---|
| 1257 | g_bitDepthY = m_acLayerCfg[layerId].m_internalBitDepthY; |
---|
| 1258 | g_bitDepthC = m_acLayerCfg[layerId].m_internalBitDepthC; |
---|
[494] | 1259 | |
---|
[815] | 1260 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthY : m_acLayerCfg[layerId].m_internalBitDepthY; |
---|
| 1261 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC; |
---|
[494] | 1262 | #endif |
---|
[815] | 1263 | |
---|
[597] | 1264 | vps->setLayerIdIncludedFlag(true, setId, layerId); |
---|
| 1265 | } |
---|
[815] | 1266 | } |
---|
| 1267 | } |
---|
| 1268 | else |
---|
| 1269 | { |
---|
| 1270 | // Default layer sets |
---|
| 1271 | #endif |
---|
| 1272 | vps->setNumLayerSets(m_numLayers); |
---|
| 1273 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
| 1274 | { |
---|
| 1275 | for (Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++) |
---|
[597] | 1276 | { |
---|
[815] | 1277 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 1278 | //4 |
---|
| 1279 | g_bitDepthY = m_acLayerCfg[layerId].m_internalBitDepthY; |
---|
| 1280 | g_bitDepthC = m_acLayerCfg[layerId].m_internalBitDepthC; |
---|
| 1281 | |
---|
| 1282 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthY : m_acLayerCfg[layerId].m_internalBitDepthY; |
---|
| 1283 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC; |
---|
| 1284 | #endif |
---|
| 1285 | if (layerId <= setId) |
---|
| 1286 | { |
---|
| 1287 | vps->setLayerIdIncludedFlag(true, setId, layerId); |
---|
| 1288 | } |
---|
| 1289 | else |
---|
| 1290 | { |
---|
| 1291 | vps->setLayerIdIncludedFlag(false, setId, layerId); |
---|
| 1292 | } |
---|
[597] | 1293 | } |
---|
[313] | 1294 | } |
---|
[815] | 1295 | #if Q0078_ADD_LAYER_SETS |
---|
[313] | 1296 | } |
---|
[815] | 1297 | #endif |
---|
| 1298 | #if Q0078_ADD_LAYER_SETS |
---|
| 1299 | vps->setVpsNumLayerSetsMinus1(vps->getNumLayerSets() - 1); |
---|
| 1300 | vps->setNumAddLayerSets(m_numAddLayerSets); |
---|
| 1301 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
---|
| 1302 | if (m_numAddLayerSets > 0) |
---|
| 1303 | { |
---|
| 1304 | for (Int setId = 0; setId < m_numAddLayerSets; setId++) |
---|
| 1305 | { |
---|
| 1306 | for (Int j = 0; j < m_numHighestLayerIdx[setId]; j++) |
---|
| 1307 | { |
---|
| 1308 | vps->setHighestLayerIdxPlus1(setId, j + 1, m_highestLayerIdx[setId][j] + 1); |
---|
| 1309 | } |
---|
| 1310 | } |
---|
| 1311 | } |
---|
| 1312 | #endif |
---|
[313] | 1313 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
| 1314 | UInt i = 0, dimIdLen = 0; |
---|
| 1315 | #if AVC_BASE |
---|
[874] | 1316 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
| 1317 | vps->setNonHEVCBaseLayerFlag( m_nonHEVCBaseLayerFlag ); |
---|
| 1318 | if ( m_nonHEVCBaseLayerFlag ) |
---|
| 1319 | { |
---|
| 1320 | vps->setBaseLayerInternalFlag (false); |
---|
| 1321 | } |
---|
| 1322 | #else |
---|
[313] | 1323 | vps->setAvcBaseLayerFlag(m_avcBaseLayerFlag); |
---|
[874] | 1324 | #endif |
---|
[313] | 1325 | #else |
---|
| 1326 | vps->setAvcBaseLayerFlag(false); |
---|
| 1327 | #endif |
---|
| 1328 | vps->setSplittingFlag(false); |
---|
| 1329 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
| 1330 | { |
---|
| 1331 | vps->setScalabilityMask(i, false); |
---|
| 1332 | } |
---|
[494] | 1333 | if(m_numLayers > 1) |
---|
[313] | 1334 | { |
---|
| 1335 | Int scalabilityTypes = 0; |
---|
| 1336 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
| 1337 | { |
---|
| 1338 | vps->setScalabilityMask(i, m_scalabilityMask[i]); |
---|
| 1339 | scalabilityTypes += m_scalabilityMask[i]; |
---|
| 1340 | } |
---|
[494] | 1341 | #if AUXILIARY_PICTURES |
---|
| 1342 | assert( scalabilityTypes <= 2 ); |
---|
| 1343 | #else |
---|
[313] | 1344 | assert( scalabilityTypes == 1 ); |
---|
[494] | 1345 | #endif |
---|
[313] | 1346 | vps->setNumScalabilityTypes(scalabilityTypes); |
---|
| 1347 | } |
---|
| 1348 | else |
---|
| 1349 | { |
---|
| 1350 | vps->setNumScalabilityTypes(0); |
---|
| 1351 | } |
---|
| 1352 | while((1 << dimIdLen) < m_numLayers) |
---|
| 1353 | { |
---|
| 1354 | dimIdLen++; |
---|
| 1355 | } |
---|
| 1356 | vps->setDimensionIdLen(0, dimIdLen); |
---|
| 1357 | vps->setNuhLayerIdPresentFlag(false); |
---|
| 1358 | vps->setLayerIdInNuh(0, 0); |
---|
| 1359 | vps->setLayerIdInVps(0, 0); |
---|
| 1360 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1361 | { |
---|
| 1362 | vps->setLayerIdInNuh(i, i); |
---|
| 1363 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
| 1364 | vps->setDimensionId(i, 0, i); |
---|
| 1365 | } |
---|
[494] | 1366 | #if AUXILIARY_PICTURES |
---|
| 1367 | if (m_scalabilityMask[3]) |
---|
| 1368 | { |
---|
| 1369 | UInt maxAuxId = 0; |
---|
[498] | 1370 | UInt auxDimIdLen = 1; |
---|
[494] | 1371 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1372 | { |
---|
| 1373 | if (m_acLayerCfg[i].getAuxId() > maxAuxId) |
---|
| 1374 | { |
---|
| 1375 | maxAuxId = m_acLayerCfg[i].getAuxId(); |
---|
| 1376 | } |
---|
| 1377 | } |
---|
| 1378 | while((1 << auxDimIdLen) < (maxAuxId + 1)) |
---|
| 1379 | { |
---|
| 1380 | auxDimIdLen++; |
---|
| 1381 | } |
---|
| 1382 | vps->setDimensionIdLen(1, auxDimIdLen); |
---|
| 1383 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1384 | { |
---|
| 1385 | vps->setDimensionId(i, 1, m_acLayerCfg[i].getAuxId()); |
---|
| 1386 | } |
---|
| 1387 | } |
---|
[313] | 1388 | #endif |
---|
[494] | 1389 | #endif |
---|
[540] | 1390 | #if VPS_TSLAYERS |
---|
[872] | 1391 | vps->setMaxTSLayersPresentFlag(true); |
---|
[815] | 1392 | |
---|
[872] | 1393 | for( i = 0; i < vps->getMaxLayers(); i++ ) |
---|
| 1394 | { |
---|
| 1395 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
| 1396 | } |
---|
[540] | 1397 | #endif |
---|
[442] | 1398 | vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag); |
---|
| 1399 | if (vps->getMaxTidRefPresentFlag()) |
---|
[345] | 1400 | { |
---|
[713] | 1401 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
[345] | 1402 | { |
---|
[494] | 1403 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
[713] | 1404 | for( Int j = i+1; j < vps->getMaxLayers(); j++) |
---|
[494] | 1405 | { |
---|
| 1406 | vps->setMaxTidIlRefPicsPlus1(i, j, m_acTEncTop[i].getMaxTidIlRefPicsPlus1()); |
---|
| 1407 | } |
---|
| 1408 | #else |
---|
| 1409 | vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1()); |
---|
| 1410 | #endif |
---|
[345] | 1411 | } |
---|
| 1412 | } |
---|
| 1413 | else |
---|
| 1414 | { |
---|
[713] | 1415 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
[345] | 1416 | { |
---|
[494] | 1417 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
[713] | 1418 | for( Int j = i+1; j < vps->getMaxLayers(); j++) |
---|
[494] | 1419 | { |
---|
| 1420 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
| 1421 | } |
---|
| 1422 | #else |
---|
[442] | 1423 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
[494] | 1424 | #endif |
---|
[345] | 1425 | } |
---|
| 1426 | } |
---|
[494] | 1427 | vps->setIlpSshSignalingEnabledFlag(false); |
---|
[313] | 1428 | #if VPS_EXTN_PROFILE_INFO |
---|
[941] | 1429 | #if !MULTIPLE_PTL_SUPPORT |
---|
[864] | 1430 | #if LIST_OF_PTL |
---|
| 1431 | vps->getPTLForExtnPtr()->resize(1); // Dummy object - unused. |
---|
| 1432 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
| 1433 | { |
---|
| 1434 | // TODO: The profile tier level have to be given support to be included in the configuration files |
---|
| 1435 | if(i == 0) |
---|
| 1436 | { |
---|
| 1437 | if( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ) |
---|
| 1438 | { |
---|
| 1439 | vps->setProfilePresentFlag(1, false); |
---|
| 1440 | vps->getPTLForExtnPtr()->push_back( *(m_acTEncTop[0].getSPS()->getPTL()) ); |
---|
| 1441 | } |
---|
| 1442 | } |
---|
| 1443 | else // i > 0 |
---|
| 1444 | { |
---|
| 1445 | vps->setProfilePresentFlag(i, true); |
---|
| 1446 | // Note - may need to be changed for other layer structures. |
---|
| 1447 | vps->getPTLForExtnPtr()->push_back( *(m_acTEncTop[0].getSPS()->getPTL()) ); |
---|
| 1448 | } |
---|
| 1449 | } |
---|
| 1450 | #else |
---|
[313] | 1451 | vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets()); |
---|
| 1452 | for(Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
| 1453 | { |
---|
| 1454 | vps->setProfilePresentFlag(setId, true); |
---|
| 1455 | // Note - may need to be changed for other layer structures. |
---|
| 1456 | *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL()); |
---|
| 1457 | } |
---|
| 1458 | #endif |
---|
[864] | 1459 | #endif |
---|
[941] | 1460 | #endif |
---|
[815] | 1461 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1462 | // Direct reference layers |
---|
| 1463 | UInt maxDirectRefLayers = 0; |
---|
| 1464 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
| 1465 | Bool isDefaultDirectDependencyTypeSet = false; |
---|
| 1466 | #endif |
---|
| 1467 | for (UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 1468 | { |
---|
| 1469 | vps->setNumDirectRefLayers(layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers()); |
---|
| 1470 | maxDirectRefLayers = max<UInt>(maxDirectRefLayers, vps->getNumDirectRefLayers(layerCtr)); |
---|
| 1471 | |
---|
| 1472 | for (i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++) |
---|
| 1473 | { |
---|
| 1474 | vps->setRefLayerId(layerCtr, i, m_acTEncTop[layerCtr].getRefLayerId(i)); |
---|
| 1475 | } |
---|
| 1476 | // Set direct dependency flag |
---|
| 1477 | // Initialize flag to 0 |
---|
| 1478 | for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1479 | { |
---|
| 1480 | vps->setDirectDependencyFlag(layerCtr, refLayerCtr, false); |
---|
| 1481 | } |
---|
| 1482 | for (i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++) |
---|
| 1483 | { |
---|
| 1484 | vps->setDirectDependencyFlag(layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true); |
---|
| 1485 | } |
---|
| 1486 | // prediction indications |
---|
| 1487 | vps->setDirectDepTypeLen(2); // sample and motion types are encoded |
---|
| 1488 | for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1489 | { |
---|
| 1490 | if (vps->getDirectDependencyFlag(layerCtr, refLayerCtr)) |
---|
| 1491 | { |
---|
| 1492 | assert(m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) || m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr)); |
---|
| 1493 | vps->setDirectDependencyType(layerCtr, refLayerCtr, ((m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) ? 1 : 0) | |
---|
| 1494 | (m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr) ? 2 : 0)) - 1); |
---|
| 1495 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
| 1496 | if (!isDefaultDirectDependencyTypeSet) |
---|
| 1497 | { |
---|
| 1498 | vps->setDefaultDirectDependecyTypeFlag(1); |
---|
| 1499 | vps->setDefaultDirectDependecyType(vps->getDirectDependencyType(layerCtr, refLayerCtr)); |
---|
| 1500 | isDefaultDirectDependencyTypeSet = true; |
---|
| 1501 | } |
---|
| 1502 | else if (vps->getDirectDependencyType(layerCtr, refLayerCtr) != vps->getDefaultDirectDependencyType()) |
---|
| 1503 | { |
---|
| 1504 | vps->setDefaultDirectDependecyTypeFlag(0); |
---|
| 1505 | } |
---|
| 1506 | #endif |
---|
| 1507 | } |
---|
| 1508 | else |
---|
| 1509 | { |
---|
| 1510 | vps->setDirectDependencyType(layerCtr, refLayerCtr, 0); |
---|
| 1511 | } |
---|
| 1512 | } |
---|
| 1513 | } |
---|
| 1514 | |
---|
| 1515 | #if O0092_0094_DEPENDENCY_CONSTRAINT |
---|
| 1516 | vps->setNumRefLayers(); |
---|
| 1517 | |
---|
| 1518 | if (vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
| 1519 | { |
---|
| 1520 | for (UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 1521 | { |
---|
| 1522 | assert(vps->getNumRefLayers(vps->getLayerIdInNuh(layerCtr)) <= MAX_REF_LAYERS); |
---|
| 1523 | } |
---|
| 1524 | } |
---|
| 1525 | #endif |
---|
[908] | 1526 | #if FIX_LAYER_ID_INIT |
---|
| 1527 | // The Layer ID List variables should be derived here. |
---|
| 1528 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
| 1529 | vps->deriveLayerIdListVariables(); |
---|
| 1530 | #endif |
---|
| 1531 | #endif |
---|
[815] | 1532 | #if Q0078_ADD_LAYER_SETS |
---|
| 1533 | vps->setPredictedLayerIds(); |
---|
| 1534 | vps->setTreePartitionLayerIdList(); |
---|
[908] | 1535 | #if FIX_LAYER_ID_INIT |
---|
| 1536 | vps->deriveLayerIdListVariablesForAddLayerSets(); |
---|
| 1537 | #else |
---|
[815] | 1538 | vps->setLayerIdIncludedFlagsForAddLayerSets(); |
---|
| 1539 | #endif |
---|
| 1540 | #endif |
---|
[908] | 1541 | #endif |
---|
[861] | 1542 | #if OUTPUT_LAYER_SETS_CONFIG |
---|
| 1543 | |
---|
| 1544 | vps->setDefaultTargetOutputLayerIdc( m_defaultTargetOutputLayerIdc ); // As per configuration file |
---|
| 1545 | |
---|
| 1546 | if( m_numOutputLayerSets == -1 ) // # of output layer sets not specified in the configuration file |
---|
| 1547 | { |
---|
| 1548 | vps->setNumOutputLayerSets(vps->getNumLayerSets()); |
---|
| 1549 | |
---|
| 1550 | for(i = 1; i < vps->getNumLayerSets(); i++) |
---|
| 1551 | { |
---|
| 1552 | vps->setOutputLayerSetIdx(i, i); |
---|
| 1553 | } |
---|
| 1554 | } |
---|
| 1555 | else |
---|
| 1556 | { |
---|
| 1557 | vps->setNumOutputLayerSets( m_numOutputLayerSets ); |
---|
| 1558 | for( Int olsCtr = 0; olsCtr < vps->getNumLayerSets(); olsCtr ++ ) // Default output layer sets |
---|
| 1559 | { |
---|
[865] | 1560 | vps->setOutputLayerSetIdx(olsCtr, olsCtr); |
---|
[861] | 1561 | } |
---|
| 1562 | for( Int olsCtr = vps->getNumLayerSets(); olsCtr < vps->getNumOutputLayerSets(); olsCtr ++ ) // Non-default output layer sets |
---|
| 1563 | { |
---|
[865] | 1564 | vps->setOutputLayerSetIdx(olsCtr, m_outputLayerSetIdx[olsCtr - vps->getNumLayerSets()]); |
---|
[861] | 1565 | } |
---|
| 1566 | } |
---|
| 1567 | #endif |
---|
[313] | 1568 | // Target output layer |
---|
[941] | 1569 | #if !MULTIPLE_PTL_SUPPORT |
---|
[864] | 1570 | #if LIST_OF_PTL |
---|
| 1571 | vps->setNumProfileTierLevel( vps->getPTLForExtnPtr()->size() ); // +1 for the base VPS PTL() |
---|
| 1572 | #else |
---|
[494] | 1573 | vps->setNumOutputLayerSets(vps->getNumLayerSets()); |
---|
| 1574 | vps->setNumProfileTierLevel(vps->getNumLayerSets()); |
---|
[864] | 1575 | #endif |
---|
[941] | 1576 | #endif |
---|
[861] | 1577 | #if !OUTPUT_LAYER_SETS_CONFIG // Taken care by configuration file parameter |
---|
[588] | 1578 | #if P0295_DEFAULT_OUT_LAYER_IDC |
---|
| 1579 | vps->setDefaultTargetOutputLayerIdc(1); |
---|
| 1580 | #else |
---|
[547] | 1581 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
| 1582 | vps->setDefaultOneTargetOutputLayerIdc(1); |
---|
| 1583 | #else |
---|
[313] | 1584 | vps->setDefaultOneTargetOutputLayerFlag(true); |
---|
[547] | 1585 | #endif |
---|
[588] | 1586 | #endif |
---|
[861] | 1587 | #endif |
---|
[866] | 1588 | #if !PER_LAYER_PTL |
---|
[313] | 1589 | for(i = 1; i < vps->getNumLayerSets(); i++) |
---|
| 1590 | { |
---|
| 1591 | vps->setProfileLevelTierIdx(i, i); |
---|
[861] | 1592 | #if !OUTPUT_LAYER_SETS_CONFIG |
---|
[494] | 1593 | vps->setOutputLayerSetIdx(i, i); |
---|
[861] | 1594 | #endif |
---|
[649] | 1595 | } |
---|
[313] | 1596 | #endif |
---|
[866] | 1597 | #endif |
---|
[540] | 1598 | #if VPS_DPB_SIZE_TABLE |
---|
[908] | 1599 | #if !FIX_LAYER_ID_INIT // must be derived earlier to not delete additional layer sets |
---|
[540] | 1600 | // The Layer ID List variables can be derived here. |
---|
| 1601 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
| 1602 | vps->deriveLayerIdListVariables(); |
---|
| 1603 | #endif |
---|
[908] | 1604 | #endif |
---|
[588] | 1605 | #if RESOLUTION_BASED_DPB |
---|
| 1606 | vps->assignSubDpbIndices(); |
---|
| 1607 | #else |
---|
[540] | 1608 | vps->deriveNumberOfSubDpbs(); |
---|
[588] | 1609 | #endif |
---|
[924] | 1610 | vps->setOutputLayerFlag( 0, 0, 1 ); |
---|
[649] | 1611 | // derive OutputLayerFlag[i][j] |
---|
[861] | 1612 | #if !OUTPUT_LAYER_SETS_CONFIG |
---|
[649] | 1613 | if( vps->getDefaultTargetOutputLayerIdc() == 1 ) |
---|
[861] | 1614 | #endif |
---|
[649] | 1615 | { |
---|
[815] | 1616 | // default_output_layer_idc equal to 1 specifies that only the layer with the highest value of nuh_layer_id such that nuh_layer_id equal to nuhLayerIdA and |
---|
[649] | 1617 | // AuxId[ nuhLayerIdA ] equal to 0 in each of the output layer sets with index in the range of 1 to vps_num_layer_sets_minus1, inclusive, is an output layer of its output layer set. |
---|
| 1618 | |
---|
| 1619 | // Include the highest layer as output layer for each layer set |
---|
| 1620 | for(Int lsIdx = 1; lsIdx < vps->getNumLayerSets(); lsIdx++) |
---|
| 1621 | { |
---|
| 1622 | for( UInt layer = 0; layer < vps->getNumLayersInIdList(lsIdx); layer++ ) |
---|
| 1623 | { |
---|
[815] | 1624 | #if !Q0078_ADD_LAYER_SETS // the following condition is incorrect and is not needed anyway |
---|
[649] | 1625 | if( vps->getLayerIdIncludedFlag(lsIdx, layer) ) |
---|
[815] | 1626 | #endif |
---|
[861] | 1627 | { |
---|
| 1628 | #if OUTPUT_LAYER_SETS_CONFIG |
---|
| 1629 | switch(vps->getDefaultTargetOutputLayerIdc()) |
---|
| 1630 | { |
---|
| 1631 | case 0: vps->setOutputLayerFlag( lsIdx, layer, 1 ); |
---|
| 1632 | break; |
---|
| 1633 | case 1: vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 ); |
---|
| 1634 | break; |
---|
| 1635 | case 2: |
---|
| 1636 | case 3: vps->setOutputLayerFlag( lsIdx, layer, std::find( m_listOfOutputLayers[lsIdx].begin(), m_listOfOutputLayers[lsIdx].end(), layer) != m_listOfOutputLayers[lsIdx].end() ); |
---|
| 1637 | break; |
---|
| 1638 | } |
---|
| 1639 | #else |
---|
[649] | 1640 | vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 ); |
---|
[861] | 1641 | #endif |
---|
[649] | 1642 | } |
---|
| 1643 | } |
---|
| 1644 | } |
---|
[861] | 1645 | #if OUTPUT_LAYER_SETS_CONFIG |
---|
| 1646 | for( Int olsIdx = vps->getNumLayerSets(); olsIdx < vps->getNumOutputLayerSets(); olsIdx++ ) |
---|
| 1647 | { |
---|
| 1648 | for( UInt layer = 0; layer < vps->getNumLayersInIdList(vps->getOutputLayerSetIdx(olsIdx)); layer++ ) |
---|
| 1649 | { |
---|
| 1650 | vps->setOutputLayerFlag( olsIdx, layer, std::find( m_listOfOutputLayers[olsIdx].begin(), m_listOfOutputLayers[olsIdx].end(), layer) != m_listOfOutputLayers[olsIdx].end()); |
---|
| 1651 | } |
---|
| 1652 | } |
---|
| 1653 | #endif |
---|
[649] | 1654 | } |
---|
[861] | 1655 | #if !OUTPUT_LAYER_SETS_CONFIG |
---|
[649] | 1656 | else |
---|
| 1657 | { |
---|
[815] | 1658 | // cases when default_output_layer_idc is not equal to 1 |
---|
| 1659 | assert(!"default_output_layer_idc not equal to 1 is not yet supported"); |
---|
[649] | 1660 | } |
---|
[861] | 1661 | #endif |
---|
[865] | 1662 | #if NECESSARY_LAYER_FLAG |
---|
| 1663 | vps->deriveNecessaryLayerFlag(); |
---|
| 1664 | vps->checkNecessaryLayerFlagCondition(); |
---|
| 1665 | #endif |
---|
[941] | 1666 | #if !MULTIPLE_PTL_SUPPORT |
---|
[866] | 1667 | #if PER_LAYER_PTL |
---|
| 1668 | vps->getProfileLevelTierIdx()->resize(vps->getNumOutputLayerSets()); |
---|
| 1669 | vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0 ); // Default 0-th output layer set |
---|
| 1670 | for(i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
| 1671 | { |
---|
| 1672 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
| 1673 | Int numLayerInLayerSet = vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); |
---|
| 1674 | for(Int j = 0; j < numLayerInLayerSet; j++) |
---|
| 1675 | { |
---|
| 1676 | Int layerIdxInVps = vps->getLayerIdInVps( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j) ); |
---|
| 1677 | if( vps->getNecessaryLayerFlag(i, j) ) |
---|
| 1678 | { |
---|
| 1679 | vps->getProfileLevelTierIdx(i)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? layerIdxInVps + 1 : layerIdxInVps); |
---|
| 1680 | } |
---|
| 1681 | else |
---|
| 1682 | { |
---|
| 1683 | vps->getProfileLevelTierIdx(i)->push_back( -1 ); |
---|
| 1684 | } |
---|
| 1685 | } |
---|
| 1686 | } |
---|
| 1687 | #endif |
---|
[941] | 1688 | #endif |
---|
[872] | 1689 | #if SUB_LAYERS_IN_LAYER_SET |
---|
| 1690 | vps->calculateMaxSLInLayerSets(); |
---|
| 1691 | #endif |
---|
[540] | 1692 | // Initialize dpb_size_table() for all ouput layer sets in the VPS extension |
---|
| 1693 | for(i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
| 1694 | { |
---|
[588] | 1695 | #if CHANGE_NUMSUBDPB_IDX |
---|
| 1696 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
| 1697 | #endif |
---|
[540] | 1698 | Int layerSetId = vps->getOutputLayerSetIdx(i); |
---|
| 1699 | |
---|
| 1700 | for(Int j = 0; j < vps->getMaxTLayers(); j++) |
---|
| 1701 | { |
---|
| 1702 | |
---|
| 1703 | Int maxNumReorderPics = -1; |
---|
[588] | 1704 | #if CHANGE_NUMSUBDPB_IDX |
---|
| 1705 | #if RESOLUTION_BASED_DPB |
---|
| 1706 | for(Int k = 0; k < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); k++) |
---|
| 1707 | #else |
---|
| 1708 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
| 1709 | #endif |
---|
| 1710 | #else |
---|
[540] | 1711 | for(Int k = 0; k < vps->getNumSubDpbs(i); k++) |
---|
[588] | 1712 | #endif |
---|
[540] | 1713 | { |
---|
| 1714 | Int layerId = vps->getLayerSetLayerIdList(layerSetId, k); // k-th layer in the output layer set |
---|
[588] | 1715 | #if RESOLUTION_BASED_DPB |
---|
| 1716 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 ); |
---|
| 1717 | // Add sub-DPB sizes of layers belonging to a sub-DPB. If a different sub-DPB size is calculated |
---|
| 1718 | // at the encoder, modify below |
---|
| 1719 | Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j ); |
---|
[644] | 1720 | oldValue += vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j ) + 1; |
---|
[588] | 1721 | vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue ); |
---|
| 1722 | #else |
---|
[540] | 1723 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 ); |
---|
[588] | 1724 | #endif |
---|
[540] | 1725 | maxNumReorderPics = std::max( maxNumReorderPics, m_acTEncTop[layerId].getNumReorderPics(j)); |
---|
| 1726 | } |
---|
[644] | 1727 | #if RESOLUTION_BASED_DPB |
---|
| 1728 | for(Int k = 0; k < vps->getNumSubDpbs(i); k++) |
---|
| 1729 | { |
---|
| 1730 | // Decrement m_maxVpsDecPicBufferingMinus1 |
---|
| 1731 | Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j ); |
---|
| 1732 | vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue - 1 ); |
---|
| 1733 | } |
---|
| 1734 | #endif |
---|
[540] | 1735 | vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics); |
---|
[588] | 1736 | vps->determineSubDpbInfoFlags(); |
---|
[540] | 1737 | } |
---|
| 1738 | } |
---|
| 1739 | #endif |
---|
[494] | 1740 | vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true); |
---|
| 1741 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
| 1742 | for(i = 1; i< vps->getMaxLayers(); i++) |
---|
| 1743 | { |
---|
| 1744 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
| 1745 | { |
---|
[815] | 1746 | #if Q0078_ADD_LAYER_SETS |
---|
| 1747 | vps->setPocLsbNotPresentFlag(i, true); // make independedent layers base-layer compliant |
---|
| 1748 | #else |
---|
[494] | 1749 | vps->setPocLsbNotPresentFlag(i, false); |
---|
[815] | 1750 | #endif |
---|
[494] | 1751 | } |
---|
| 1752 | } |
---|
| 1753 | #endif |
---|
[540] | 1754 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
| 1755 | vps->setCrossLayerPictureTypeAlignFlag( m_crossLayerPictureTypeAlignFlag ); |
---|
| 1756 | #endif |
---|
[644] | 1757 | #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG |
---|
| 1758 | vps->setCrossLayerAlignedIdrOnlyFlag( m_crossLayerAlignedIdrOnlyFlag ); |
---|
| 1759 | #endif |
---|
[540] | 1760 | vps->setCrossLayerIrapAlignFlag( m_crossLayerIrapAlignFlag ); |
---|
[442] | 1761 | for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 1762 | { |
---|
| 1763 | for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1764 | { |
---|
| 1765 | if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr)) |
---|
[494] | 1766 | { |
---|
[442] | 1767 | if(m_acTEncTop[layerCtr].getIntraPeriod() != m_acTEncTop[refLayerCtr].getIntraPeriod()) |
---|
| 1768 | { |
---|
| 1769 | vps->setCrossLayerIrapAlignFlag(false); |
---|
| 1770 | break; |
---|
| 1771 | } |
---|
| 1772 | } |
---|
| 1773 | } |
---|
| 1774 | } |
---|
[313] | 1775 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1776 | vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false); |
---|
[540] | 1777 | #endif |
---|
| 1778 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
| 1779 | vps->setHigherLayerIrapSkipFlag(m_skipPictureAtArcSwitch); |
---|
[313] | 1780 | #endif |
---|
[588] | 1781 | #if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED |
---|
[494] | 1782 | #if !VPS_EXTN_OFFSET_CALC |
---|
[442] | 1783 | #if VPS_EXTN_OFFSET |
---|
| 1784 | // to be updated according to the current semantics |
---|
| 1785 | vps->setExtensionOffset( 0xffff ); |
---|
[313] | 1786 | #endif |
---|
[494] | 1787 | #endif |
---|
[588] | 1788 | #endif |
---|
[494] | 1789 | |
---|
| 1790 | #if O0215_PHASE_ALIGNMENT |
---|
| 1791 | vps->setPhaseAlignFlag( m_phaseAlignFlag ); |
---|
| 1792 | #endif |
---|
| 1793 | |
---|
[644] | 1794 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
---|
| 1795 | for (Int k = 0; k < MAX_VPS_LAYER_SETS_PLUS1; k++) |
---|
| 1796 | { |
---|
| 1797 | vps->setAltOuputLayerFlag( k, m_altOutputLayerFlag ); |
---|
| 1798 | } |
---|
| 1799 | #else |
---|
[540] | 1800 | #if O0153_ALT_OUTPUT_LAYER_FLAG |
---|
| 1801 | vps->setAltOuputLayerFlag( m_altOutputLayerFlag ); |
---|
| 1802 | #endif |
---|
[644] | 1803 | #endif |
---|
[540] | 1804 | |
---|
[644] | 1805 | #if P0312_VERT_PHASE_ADJ |
---|
| 1806 | Bool vpsVuiVertPhaseInUseFlag = false; |
---|
| 1807 | for( UInt layerId = 1; layerId < m_numLayers; layerId++ ) |
---|
| 1808 | { |
---|
| 1809 | for( i = 0; i < m_acLayerCfg[layerId].m_numScaledRefLayerOffsets; i++ ) |
---|
| 1810 | { |
---|
| 1811 | if( m_acTEncTop[layerId].getVertPhasePositionEnableFlag(i) ) |
---|
| 1812 | { |
---|
| 1813 | vpsVuiVertPhaseInUseFlag = true; |
---|
| 1814 | break; |
---|
| 1815 | } |
---|
| 1816 | } |
---|
| 1817 | } |
---|
| 1818 | vps->setVpsVuiVertPhaseInUseFlag( vpsVuiVertPhaseInUseFlag ); |
---|
| 1819 | #endif |
---|
| 1820 | |
---|
[894] | 1821 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
| 1822 | vps->setVpsVuiBspHrdPresentFlag(false); |
---|
| 1823 | TEncTop *pcCfg = &m_acTEncTop[0]; |
---|
| 1824 | if( pcCfg->getBufferingPeriodSEIEnabled() ) |
---|
| 1825 | { |
---|
[897] | 1826 | Int j; |
---|
[894] | 1827 | vps->setVpsVuiBspHrdPresentFlag(true); |
---|
| 1828 | vps->setVpsNumAddHrdParams( vps->getMaxLayers() ); |
---|
| 1829 | vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams() + 1); |
---|
[897] | 1830 | for( i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) |
---|
[894] | 1831 | { |
---|
| 1832 | vps->setCprmsAddPresentFlag( j, true ); |
---|
| 1833 | vps->setNumSubLayerHrdMinus1( j, vps->getMaxTLayers() - 1 ); |
---|
| 1834 | |
---|
| 1835 | UInt layerId = j; |
---|
| 1836 | TEncTop *pcCfgLayer = &m_acTEncTop[layerId]; |
---|
| 1837 | |
---|
| 1838 | Int iPicWidth = pcCfgLayer->getSourceWidth(); |
---|
| 1839 | Int iPicHeight = pcCfgLayer->getSourceHeight(); |
---|
| 1840 | #if LAYER_CTB |
---|
| 1841 | UInt uiWidthInCU = ( iPicWidth % m_acLayerCfg[layerId].m_uiMaxCUWidth ) ? iPicWidth / m_acLayerCfg[layerId].m_uiMaxCUWidth + 1 : iPicWidth / m_acLayerCfg[layerId].m_uiMaxCUWidth; |
---|
| 1842 | UInt uiHeightInCU = ( iPicHeight % m_acLayerCfg[layerId].m_uiMaxCUHeight ) ? iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight + 1 : iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight; |
---|
| 1843 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_acLayerCfg[layerId].m_uiMaxCUDepth << 1); |
---|
| 1844 | #else |
---|
| 1845 | UInt uiWidthInCU = ( iPicWidth %m_uiMaxCUWidth ) ? iPicWidth /m_uiMaxCUWidth + 1 : iPicWidth /m_uiMaxCUWidth; |
---|
| 1846 | UInt uiHeightInCU = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight; |
---|
| 1847 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_uiMaxCUDepth << 1); |
---|
| 1848 | #endif |
---|
| 1849 | UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; |
---|
| 1850 | |
---|
| 1851 | UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 ); |
---|
| 1852 | if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 ) |
---|
| 1853 | { |
---|
| 1854 | numDU ++; |
---|
| 1855 | } |
---|
| 1856 | vps->getBspHrd(i)->setNumDU( numDU ); |
---|
| 1857 | vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) ); |
---|
| 1858 | } |
---|
| 1859 | |
---|
| 1860 | // Signalling of additional partitioning schemes |
---|
| 1861 | for(Int h = 1; h < vps->getNumOutputLayerSets(); h++) |
---|
| 1862 | { |
---|
| 1863 | Int lsIdx = vps->getOutputLayerSetIdx( h ); |
---|
| 1864 | vps->setNumSignalledPartitioningSchemes(h, 1); // Only the default per-layer partitioning scheme |
---|
[897] | 1865 | for( j = 1; j < vps->getNumSignalledPartitioningSchemes(h); j++ ) |
---|
[894] | 1866 | { |
---|
| 1867 | // ToDo: Add code for additional partitioning schemes here |
---|
| 1868 | // ToDo: Initialize num_partitions_in_scheme_minus1 and layer_included_in_partition_flag |
---|
| 1869 | } |
---|
| 1870 | |
---|
[897] | 1871 | for( i = 0; i < vps->getNumSignalledPartitioningSchemes(h); i++ ) |
---|
[894] | 1872 | { |
---|
| 1873 | if( i == 0 ) |
---|
| 1874 | { |
---|
| 1875 | for(Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1( lsIdx ); t++) |
---|
| 1876 | { |
---|
| 1877 | vps->setNumBspSchedulesMinus1( h, i, t, 0 ); |
---|
[897] | 1878 | for( j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ ) |
---|
[894] | 1879 | { |
---|
| 1880 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) |
---|
| 1881 | { |
---|
| 1882 | // Only for the default partition |
---|
| 1883 | Int nuhlayerId = vps->getLayerSetLayerIdList( lsIdx, k); |
---|
| 1884 | Int layerIdxInVps = vps->getLayerIdInVps( nuhlayerId ); |
---|
| 1885 | vps->setBspHrdIdx(h, i, t, j, k, layerIdxInVps + vps->getNumHrdParameters()); |
---|
| 1886 | |
---|
| 1887 | vps->setBspSchedIdx(h, i, t, j, k, 0); |
---|
| 1888 | } |
---|
| 1889 | } |
---|
| 1890 | } |
---|
| 1891 | } |
---|
| 1892 | else |
---|
| 1893 | { |
---|
| 1894 | assert(0); // Need to add support for additional partitioning schemes. |
---|
| 1895 | } |
---|
| 1896 | } |
---|
| 1897 | } |
---|
| 1898 | } |
---|
| 1899 | #else |
---|
| 1900 | |
---|
[644] | 1901 | #if O0164_MULTI_LAYER_HRD |
---|
| 1902 | vps->setVpsVuiBspHrdPresentFlag(false); |
---|
| 1903 | TEncTop *pcCfg = &m_acTEncTop[0]; |
---|
| 1904 | if( pcCfg->getBufferingPeriodSEIEnabled() ) |
---|
| 1905 | { |
---|
| 1906 | vps->setVpsVuiBspHrdPresentFlag(true); |
---|
[815] | 1907 | #if Q0078_ADD_LAYER_SETS |
---|
| 1908 | vps->setVpsNumBspHrdParametersMinus1(vps->getVpsNumLayerSetsMinus1() - 1); |
---|
| 1909 | #else |
---|
[644] | 1910 | vps->setVpsNumBspHrdParametersMinus1(vps->getNumLayerSets() - 2); |
---|
[815] | 1911 | #endif |
---|
[644] | 1912 | vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); |
---|
| 1913 | for ( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) |
---|
| 1914 | { |
---|
| 1915 | vps->setBspCprmsPresentFlag(i, true); |
---|
| 1916 | |
---|
| 1917 | UInt layerId = i + 1; |
---|
| 1918 | TEncTop *pcCfgLayer = &m_acTEncTop[layerId]; |
---|
| 1919 | |
---|
| 1920 | Int iPicWidth = pcCfgLayer->getSourceWidth(); |
---|
| 1921 | Int iPicHeight = pcCfgLayer->getSourceHeight(); |
---|
[713] | 1922 | #if LAYER_CTB |
---|
| 1923 | UInt uiWidthInCU = ( iPicWidth % m_acLayerCfg[layerId].m_uiMaxCUWidth ) ? iPicWidth / m_acLayerCfg[layerId].m_uiMaxCUWidth + 1 : iPicWidth / m_acLayerCfg[layerId].m_uiMaxCUWidth; |
---|
| 1924 | UInt uiHeightInCU = ( iPicHeight % m_acLayerCfg[layerId].m_uiMaxCUHeight ) ? iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight + 1 : iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight; |
---|
| 1925 | #else |
---|
[644] | 1926 | UInt uiWidthInCU = ( iPicWidth %m_uiMaxCUWidth ) ? iPicWidth /m_uiMaxCUWidth + 1 : iPicWidth /m_uiMaxCUWidth; |
---|
| 1927 | UInt uiHeightInCU = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight; |
---|
[713] | 1928 | #endif |
---|
[644] | 1929 | UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; |
---|
| 1930 | |
---|
[713] | 1931 | #if LAYER_CTB |
---|
| 1932 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_acLayerCfg[layerId].m_uiMaxCUDepth << 1); |
---|
| 1933 | #else |
---|
[644] | 1934 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_uiMaxCUDepth << 1); |
---|
[713] | 1935 | #endif |
---|
[644] | 1936 | UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 ); |
---|
| 1937 | if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 ) |
---|
| 1938 | { |
---|
| 1939 | numDU ++; |
---|
| 1940 | } |
---|
| 1941 | vps->getBspHrd(i)->setNumDU( numDU ); |
---|
| 1942 | vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) ); |
---|
| 1943 | } |
---|
[815] | 1944 | #if Q0078_ADD_LAYER_SETS |
---|
| 1945 | for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++) |
---|
| 1946 | #else |
---|
[644] | 1947 | for(UInt h = 1; h <= (vps->getNumLayerSets()-1); h++) |
---|
[815] | 1948 | #endif |
---|
[644] | 1949 | { |
---|
| 1950 | vps->setNumBitstreamPartitions(h, 1); |
---|
| 1951 | for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) |
---|
| 1952 | { |
---|
| 1953 | for( UInt j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
---|
| 1954 | { |
---|
| 1955 | if (vps->getLayerIdIncludedFlag(h, j) && h == j) |
---|
| 1956 | { |
---|
| 1957 | vps->setLayerInBspFlag(h, i, j, true); |
---|
| 1958 | } |
---|
| 1959 | } |
---|
| 1960 | } |
---|
| 1961 | vps->setNumBspSchedCombinations(h, 1); |
---|
| 1962 | for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) |
---|
| 1963 | { |
---|
| 1964 | for( UInt j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) |
---|
| 1965 | { |
---|
| 1966 | vps->setBspCombHrdIdx(h, i, j, 0); |
---|
| 1967 | vps->setBspCombSchedIdx(h, i, j, 0); |
---|
| 1968 | } |
---|
| 1969 | } |
---|
| 1970 | } |
---|
| 1971 | } |
---|
| 1972 | #endif |
---|
[894] | 1973 | #endif |
---|
[644] | 1974 | |
---|
[442] | 1975 | #else //SVC_EXTENSION |
---|
| 1976 | m_cTEncTop.init(isFieldCoding); |
---|
| 1977 | #endif //SVC_EXTENSION |
---|
[313] | 1978 | } |
---|
| 1979 | |
---|
| 1980 | // ==================================================================================================================== |
---|
| 1981 | // Public member functions |
---|
| 1982 | // ==================================================================================================================== |
---|
| 1983 | |
---|
| 1984 | /** |
---|
| 1985 | - create internal class |
---|
| 1986 | - initialize internal variable |
---|
| 1987 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
| 1988 | - delete allocated buffers |
---|
| 1989 | - destroy internal class |
---|
| 1990 | . |
---|
| 1991 | */ |
---|
| 1992 | #if SVC_EXTENSION |
---|
| 1993 | Void TAppEncTop::encode() |
---|
| 1994 | { |
---|
| 1995 | fstream bitstreamFile(m_pBitstreamFile, fstream::binary | fstream::out); |
---|
| 1996 | if (!bitstreamFile) |
---|
| 1997 | { |
---|
| 1998 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pBitstreamFile); |
---|
| 1999 | exit(EXIT_FAILURE); |
---|
| 2000 | } |
---|
| 2001 | |
---|
| 2002 | TComPicYuv* pcPicYuvOrg [MAX_LAYERS]; |
---|
| 2003 | TComPicYuv* pcPicYuvRec = NULL; |
---|
| 2004 | |
---|
| 2005 | // initialize internal class & member variables |
---|
| 2006 | xInitLibCfg(); |
---|
| 2007 | xCreateLib(); |
---|
[442] | 2008 | xInitLib(m_isField); |
---|
[313] | 2009 | |
---|
| 2010 | // main encoder loop |
---|
| 2011 | Int iNumEncoded = 0, iTotalNumEncoded = 0; |
---|
| 2012 | Bool bEos = false; |
---|
| 2013 | |
---|
| 2014 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
| 2015 | |
---|
| 2016 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 2017 | { |
---|
[494] | 2018 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 2019 | //5 |
---|
| 2020 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 2021 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 2022 | |
---|
| 2023 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 2024 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 2025 | #endif |
---|
[313] | 2026 | // allocate original YUV buffer |
---|
| 2027 | pcPicYuvOrg[layer] = new TComPicYuv; |
---|
[442] | 2028 | if( m_isField ) |
---|
| 2029 | { |
---|
[815] | 2030 | #if SVC_EXTENSION |
---|
[494] | 2031 | #if LAYER_CTB |
---|
| 2032 | #if AUXILIARY_PICTURES |
---|
| 2033 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
| 2034 | #else |
---|
| 2035 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
| 2036 | #endif |
---|
| 2037 | #else |
---|
| 2038 | #if AUXILIARY_PICTURES |
---|
| 2039 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
| 2040 | #else |
---|
[442] | 2041 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
[494] | 2042 | #endif |
---|
| 2043 | #endif |
---|
[313] | 2044 | #else |
---|
[442] | 2045 | pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
[313] | 2046 | #endif |
---|
[442] | 2047 | } |
---|
| 2048 | else |
---|
| 2049 | { |
---|
[815] | 2050 | #if SVC_EXTENSION |
---|
[494] | 2051 | #if LAYER_CTB |
---|
| 2052 | #if AUXILIARY_PICTURES |
---|
| 2053 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
| 2054 | #else |
---|
| 2055 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
| 2056 | #endif |
---|
| 2057 | #else |
---|
| 2058 | #if AUXILIARY_PICTURES |
---|
| 2059 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
| 2060 | #else |
---|
[442] | 2061 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
[494] | 2062 | #endif |
---|
| 2063 | #endif |
---|
[442] | 2064 | #else |
---|
| 2065 | pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 2066 | #endif |
---|
| 2067 | } |
---|
[313] | 2068 | } |
---|
| 2069 | |
---|
| 2070 | Bool bFirstFrame = true; |
---|
| 2071 | while ( !bEos ) |
---|
| 2072 | { |
---|
[494] | 2073 | // Read enough frames |
---|
[313] | 2074 | Bool bFramesReadyToCode = false; |
---|
| 2075 | while(!bFramesReadyToCode) |
---|
| 2076 | { |
---|
| 2077 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 2078 | { |
---|
[494] | 2079 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 2080 | //6 |
---|
| 2081 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 2082 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 2083 | |
---|
| 2084 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 2085 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 2086 | #endif |
---|
| 2087 | #if LAYER_CTB |
---|
| 2088 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
| 2089 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
| 2090 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
| 2091 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
| 2092 | #endif |
---|
| 2093 | |
---|
[313] | 2094 | // get buffers |
---|
| 2095 | xGetBuffer(pcPicYuvRec, layer); |
---|
| 2096 | |
---|
| 2097 | // read input YUV file |
---|
| 2098 | m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() ); |
---|
| 2099 | |
---|
[494] | 2100 | #if AUXILIARY_PICTURES |
---|
[910] | 2101 | #if R0062_AUX_PSEUDO_MONOCHROME |
---|
| 2102 | if ( m_acLayerCfg[layer].getChromaFormatIDC() == CHROMA_400 || |
---|
| 2103 | (m_apcTEncTop[0]->getVPS()->getScalabilityMask(3) && (m_acLayerCfg[layer].getAuxId() == 1 || m_acLayerCfg[layer].getAuxId() == 2)) ) |
---|
| 2104 | #else |
---|
[494] | 2105 | if (m_acLayerCfg[layer].getChromaFormatIDC() == CHROMA_400) |
---|
[910] | 2106 | #endif |
---|
[494] | 2107 | { |
---|
| 2108 | pcPicYuvOrg[layer]->convertToMonochrome(); |
---|
| 2109 | } |
---|
| 2110 | #endif |
---|
| 2111 | |
---|
[313] | 2112 | if(layer == m_numLayers-1) |
---|
| 2113 | { |
---|
| 2114 | // increase number of received frames |
---|
| 2115 | m_iFrameRcvd++; |
---|
| 2116 | // check end of file |
---|
[442] | 2117 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
[313] | 2118 | } |
---|
| 2119 | |
---|
[442] | 2120 | if ( m_isField ) |
---|
| 2121 | { |
---|
| 2122 | m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], m_isTopFieldFirst ); |
---|
| 2123 | } |
---|
| 2124 | else |
---|
| 2125 | { |
---|
| 2126 | m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] ); |
---|
| 2127 | } |
---|
[313] | 2128 | } |
---|
| 2129 | |
---|
| 2130 | bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos ); |
---|
| 2131 | } |
---|
| 2132 | Bool flush = 0; |
---|
| 2133 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
| 2134 | if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof()) |
---|
| 2135 | { |
---|
| 2136 | flush = true; |
---|
| 2137 | bEos = true; |
---|
| 2138 | m_iFrameRcvd--; |
---|
| 2139 | m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd); |
---|
| 2140 | } |
---|
| 2141 | |
---|
| 2142 | #if RC_SHVC_HARMONIZATION |
---|
| 2143 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 2144 | { |
---|
| 2145 | if ( m_acTEncTop[layer].getUseRateCtrl() ) |
---|
| 2146 | { |
---|
| 2147 | (m_acTEncTop[layer].getRateCtrl())->initRCGOP(m_acTEncTop[layer].getNumPicRcvd()); |
---|
| 2148 | } |
---|
| 2149 | } |
---|
| 2150 | #endif |
---|
| 2151 | |
---|
| 2152 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 2153 | if (m_adaptiveResolutionChange) |
---|
| 2154 | { |
---|
| 2155 | for(UInt layer = 0; layer < m_numLayers; layer++) |
---|
| 2156 | { |
---|
| 2157 | TComList<TComPicYuv*>::iterator iterPicYuvRec; |
---|
| 2158 | for (iterPicYuvRec = m_acListPicYuvRec[layer].begin(); iterPicYuvRec != m_acListPicYuvRec[layer].end(); iterPicYuvRec++) |
---|
| 2159 | { |
---|
| 2160 | TComPicYuv* recPic = *(iterPicYuvRec); |
---|
| 2161 | recPic->setReconstructed(false); |
---|
| 2162 | } |
---|
| 2163 | } |
---|
| 2164 | } |
---|
| 2165 | #endif |
---|
| 2166 | |
---|
[494] | 2167 | // loop through frames in one GOP |
---|
[313] | 2168 | for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ ) |
---|
| 2169 | { |
---|
| 2170 | // layer by layer for each frame |
---|
| 2171 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 2172 | { |
---|
[494] | 2173 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 2174 | //7 |
---|
| 2175 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 2176 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 2177 | |
---|
| 2178 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 2179 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 2180 | #endif |
---|
| 2181 | #if LAYER_CTB |
---|
| 2182 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
| 2183 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
| 2184 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
| 2185 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
| 2186 | |
---|
| 2187 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
---|
| 2188 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
---|
| 2189 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
---|
| 2190 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
---|
| 2191 | #endif |
---|
[313] | 2192 | // call encoding function for one frame |
---|
[442] | 2193 | if ( m_isField ) |
---|
| 2194 | { |
---|
| 2195 | m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst ); |
---|
| 2196 | } |
---|
| 2197 | else |
---|
| 2198 | { |
---|
| 2199 | m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP ); |
---|
| 2200 | } |
---|
[313] | 2201 | } |
---|
| 2202 | } |
---|
[884] | 2203 | #if R0247_SEI_ACTIVE |
---|
| 2204 | if(bFirstFrame) |
---|
| 2205 | { |
---|
| 2206 | list<AccessUnit>::iterator first_au = outputAccessUnits.begin(); |
---|
| 2207 | AccessUnit::iterator it_sps; |
---|
| 2208 | for (it_sps = first_au->begin(); it_sps != first_au->end(); it_sps++) |
---|
| 2209 | { |
---|
| 2210 | if( (*it_sps)->m_nalUnitType == NAL_UNIT_SPS ) |
---|
| 2211 | { |
---|
| 2212 | break; |
---|
| 2213 | } |
---|
| 2214 | } |
---|
[313] | 2215 | |
---|
[884] | 2216 | for (list<AccessUnit>::iterator it_au = ++outputAccessUnits.begin(); it_au != outputAccessUnits.end(); it_au++) |
---|
| 2217 | { |
---|
| 2218 | for (AccessUnit::iterator it_nalu = it_au->begin(); it_nalu != it_au->end(); it_nalu++) |
---|
| 2219 | { |
---|
| 2220 | if( (*it_nalu)->m_nalUnitType == NAL_UNIT_SPS ) |
---|
| 2221 | { |
---|
| 2222 | first_au->insert(++it_sps, *it_nalu); |
---|
| 2223 | it_nalu = it_au->erase(it_nalu); |
---|
| 2224 | } |
---|
| 2225 | } |
---|
| 2226 | } |
---|
| 2227 | } |
---|
| 2228 | |
---|
| 2229 | #endif |
---|
| 2230 | |
---|
[313] | 2231 | #if RC_SHVC_HARMONIZATION |
---|
| 2232 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 2233 | { |
---|
| 2234 | if ( m_acTEncTop[layer].getUseRateCtrl() ) |
---|
| 2235 | { |
---|
| 2236 | (m_acTEncTop[layer].getRateCtrl())->destroyRCGOP(); |
---|
| 2237 | } |
---|
| 2238 | } |
---|
| 2239 | #endif |
---|
| 2240 | |
---|
| 2241 | iTotalNumEncoded = 0; |
---|
| 2242 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 2243 | { |
---|
[494] | 2244 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 2245 | //8 |
---|
| 2246 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 2247 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 2248 | |
---|
| 2249 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 2250 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 2251 | #endif |
---|
[313] | 2252 | // write bistream to file if necessary |
---|
| 2253 | iNumEncoded = m_acTEncTop[layer].getNumPicRcvd(); |
---|
| 2254 | if ( iNumEncoded > 0 ) |
---|
| 2255 | { |
---|
| 2256 | xWriteRecon(layer, iNumEncoded); |
---|
| 2257 | iTotalNumEncoded += iNumEncoded; |
---|
| 2258 | } |
---|
| 2259 | m_acTEncTop[layer].setNumPicRcvd( 0 ); |
---|
| 2260 | } |
---|
| 2261 | |
---|
| 2262 | // write bitstream out |
---|
| 2263 | if(iTotalNumEncoded) |
---|
| 2264 | { |
---|
[588] | 2265 | #if P0130_EOB |
---|
| 2266 | if( bEos ) |
---|
| 2267 | { |
---|
| 2268 | OutputNALUnit nalu(NAL_UNIT_EOB); |
---|
| 2269 | nalu.m_layerId = 0; |
---|
| 2270 | |
---|
| 2271 | AccessUnit& accessUnit = outputAccessUnits.back(); |
---|
[835] | 2272 | #if T_ID_EOB_BUG_FIX |
---|
| 2273 | nalu.m_temporalId = 0; |
---|
| 2274 | #else |
---|
[588] | 2275 | nalu.m_temporalId = accessUnit.front()->m_temporalId; |
---|
[835] | 2276 | #endif |
---|
[588] | 2277 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
| 2278 | } |
---|
| 2279 | #endif |
---|
[313] | 2280 | xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits); |
---|
| 2281 | outputAccessUnits.clear(); |
---|
| 2282 | } |
---|
| 2283 | |
---|
| 2284 | // print out summary |
---|
| 2285 | if (bEos) |
---|
| 2286 | { |
---|
[442] | 2287 | printOutSummary(m_isTopFieldFirst); |
---|
[313] | 2288 | } |
---|
| 2289 | |
---|
| 2290 | bFirstFrame = false; |
---|
| 2291 | } |
---|
| 2292 | // delete original YUV buffer |
---|
| 2293 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 2294 | { |
---|
| 2295 | pcPicYuvOrg[layer]->destroy(); |
---|
| 2296 | delete pcPicYuvOrg[layer]; |
---|
| 2297 | pcPicYuvOrg[layer] = NULL; |
---|
| 2298 | |
---|
| 2299 | // delete used buffers in encoder class |
---|
| 2300 | m_acTEncTop[layer].deletePicBuffer(); |
---|
| 2301 | } |
---|
| 2302 | |
---|
| 2303 | // delete buffers & classes |
---|
| 2304 | xDeleteBuffer(); |
---|
| 2305 | xDestroyLib(); |
---|
| 2306 | |
---|
| 2307 | printRateSummary(); |
---|
| 2308 | |
---|
| 2309 | return; |
---|
| 2310 | } |
---|
| 2311 | |
---|
[442] | 2312 | Void TAppEncTop::printOutSummary(Bool isField) |
---|
[313] | 2313 | { |
---|
| 2314 | UInt layer; |
---|
| 2315 | |
---|
| 2316 | // set frame rate |
---|
| 2317 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 2318 | { |
---|
[442] | 2319 | if(isField) |
---|
| 2320 | { |
---|
| 2321 | m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2); |
---|
| 2322 | m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
| 2323 | m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
| 2324 | m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
| 2325 | } |
---|
| 2326 | else |
---|
| 2327 | { |
---|
| 2328 | m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate()); |
---|
| 2329 | m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
| 2330 | m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
| 2331 | m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
| 2332 | } |
---|
[313] | 2333 | } |
---|
| 2334 | |
---|
| 2335 | //-- all |
---|
| 2336 | printf( "\n\nSUMMARY --------------------------------------------------------\n" ); |
---|
| 2337 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
| 2338 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 2339 | { |
---|
| 2340 | m_gcAnalyzeAll[layer].printOut('a', layer); |
---|
| 2341 | } |
---|
| 2342 | |
---|
| 2343 | printf( "\n\nI Slices--------------------------------------------------------\n" ); |
---|
| 2344 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
| 2345 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 2346 | { |
---|
| 2347 | m_gcAnalyzeI[layer].printOut('i', layer); |
---|
| 2348 | } |
---|
| 2349 | |
---|
| 2350 | printf( "\n\nP Slices--------------------------------------------------------\n" ); |
---|
| 2351 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
| 2352 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 2353 | { |
---|
| 2354 | m_gcAnalyzeP[layer].printOut('p', layer); |
---|
| 2355 | } |
---|
| 2356 | |
---|
| 2357 | printf( "\n\nB Slices--------------------------------------------------------\n" ); |
---|
| 2358 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
| 2359 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 2360 | { |
---|
| 2361 | m_gcAnalyzeB[layer].printOut('b', layer); |
---|
| 2362 | } |
---|
[442] | 2363 | |
---|
| 2364 | if(isField) |
---|
| 2365 | { |
---|
| 2366 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 2367 | { |
---|
| 2368 | //-- interlaced summary |
---|
| 2369 | m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate()); |
---|
| 2370 | printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); |
---|
| 2371 | m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll[layer].getBits()); |
---|
| 2372 | |
---|
| 2373 | #if _SUMMARY_OUT_ |
---|
| 2374 | m_gcAnalyzeAll_in.printSummaryOutInterlaced(); |
---|
| 2375 | #endif |
---|
| 2376 | } |
---|
| 2377 | } |
---|
[313] | 2378 | } |
---|
| 2379 | |
---|
| 2380 | #else |
---|
| 2381 | Void TAppEncTop::encode() |
---|
| 2382 | { |
---|
| 2383 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
| 2384 | if (!bitstreamFile) |
---|
| 2385 | { |
---|
| 2386 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
| 2387 | exit(EXIT_FAILURE); |
---|
| 2388 | } |
---|
| 2389 | |
---|
| 2390 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
| 2391 | TComPicYuv* pcPicYuvRec = NULL; |
---|
| 2392 | |
---|
| 2393 | // initialize internal class & member variables |
---|
| 2394 | xInitLibCfg(); |
---|
| 2395 | xCreateLib(); |
---|
[442] | 2396 | xInitLib(m_isField); |
---|
[313] | 2397 | |
---|
| 2398 | // main encoder loop |
---|
| 2399 | Int iNumEncoded = 0; |
---|
| 2400 | Bool bEos = false; |
---|
| 2401 | |
---|
| 2402 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
| 2403 | |
---|
| 2404 | // allocate original YUV buffer |
---|
[442] | 2405 | if( m_isField ) |
---|
| 2406 | { |
---|
| 2407 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 2408 | } |
---|
| 2409 | else |
---|
| 2410 | { |
---|
| 2411 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 2412 | } |
---|
[313] | 2413 | |
---|
| 2414 | while ( !bEos ) |
---|
| 2415 | { |
---|
| 2416 | // get buffers |
---|
| 2417 | xGetBuffer(pcPicYuvRec); |
---|
| 2418 | |
---|
| 2419 | // read input YUV file |
---|
| 2420 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad ); |
---|
| 2421 | |
---|
| 2422 | // increase number of received frames |
---|
| 2423 | m_iFrameRcvd++; |
---|
| 2424 | |
---|
[442] | 2425 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
[313] | 2426 | Bool flush = 0; |
---|
| 2427 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
| 2428 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
| 2429 | { |
---|
| 2430 | flush = true; |
---|
| 2431 | bEos = true; |
---|
| 2432 | m_iFrameRcvd--; |
---|
| 2433 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
| 2434 | } |
---|
| 2435 | |
---|
| 2436 | // call encoding function for one frame |
---|
[442] | 2437 | if ( m_isField ) |
---|
| 2438 | { |
---|
| 2439 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst); |
---|
| 2440 | } |
---|
| 2441 | else |
---|
| 2442 | { |
---|
[313] | 2443 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
[442] | 2444 | } |
---|
[313] | 2445 | |
---|
| 2446 | // write bistream to file if necessary |
---|
| 2447 | if ( iNumEncoded > 0 ) |
---|
| 2448 | { |
---|
| 2449 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
| 2450 | outputAccessUnits.clear(); |
---|
| 2451 | } |
---|
| 2452 | } |
---|
| 2453 | |
---|
[442] | 2454 | m_cTEncTop.printSummary(m_isField); |
---|
[313] | 2455 | |
---|
| 2456 | // delete original YUV buffer |
---|
| 2457 | pcPicYuvOrg->destroy(); |
---|
| 2458 | delete pcPicYuvOrg; |
---|
| 2459 | pcPicYuvOrg = NULL; |
---|
| 2460 | |
---|
| 2461 | // delete used buffers in encoder class |
---|
| 2462 | m_cTEncTop.deletePicBuffer(); |
---|
| 2463 | |
---|
| 2464 | // delete buffers & classes |
---|
| 2465 | xDeleteBuffer(); |
---|
| 2466 | xDestroyLib(); |
---|
| 2467 | |
---|
| 2468 | printRateSummary(); |
---|
| 2469 | |
---|
| 2470 | return; |
---|
| 2471 | } |
---|
| 2472 | #endif |
---|
| 2473 | |
---|
| 2474 | // ==================================================================================================================== |
---|
| 2475 | // Protected member functions |
---|
| 2476 | // ==================================================================================================================== |
---|
| 2477 | |
---|
| 2478 | /** |
---|
| 2479 | - application has picture buffer list with size of GOP |
---|
| 2480 | - picture buffer list acts as ring buffer |
---|
| 2481 | - end of the list has the latest picture |
---|
| 2482 | . |
---|
| 2483 | */ |
---|
| 2484 | #if SVC_EXTENSION |
---|
| 2485 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
| 2486 | { |
---|
| 2487 | assert( m_iGOPSize > 0 ); |
---|
| 2488 | |
---|
| 2489 | // org. buffer |
---|
| 2490 | if ( m_acListPicYuvRec[layer].size() == (UInt)m_iGOPSize ) |
---|
| 2491 | { |
---|
| 2492 | rpcPicYuvRec = m_acListPicYuvRec[layer].popFront(); |
---|
| 2493 | |
---|
| 2494 | } |
---|
| 2495 | else |
---|
| 2496 | { |
---|
| 2497 | rpcPicYuvRec = new TComPicYuv; |
---|
| 2498 | |
---|
[494] | 2499 | #if LAYER_CTB |
---|
| 2500 | #if AUXILIARY_PICTURES |
---|
| 2501 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
| 2502 | #else |
---|
| 2503 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
| 2504 | #endif |
---|
| 2505 | #else |
---|
| 2506 | #if AUXILIARY_PICTURES |
---|
| 2507 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
| 2508 | #else |
---|
[313] | 2509 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
[494] | 2510 | #endif |
---|
| 2511 | #endif |
---|
[313] | 2512 | |
---|
| 2513 | } |
---|
| 2514 | m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec ); |
---|
| 2515 | } |
---|
| 2516 | |
---|
| 2517 | Void TAppEncTop::xDeleteBuffer( ) |
---|
| 2518 | { |
---|
| 2519 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 2520 | { |
---|
| 2521 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].begin(); |
---|
| 2522 | |
---|
| 2523 | Int iSize = Int( m_acListPicYuvRec[layer].size() ); |
---|
| 2524 | |
---|
| 2525 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 2526 | { |
---|
| 2527 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 2528 | pcPicYuvRec->destroy(); |
---|
| 2529 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
| 2530 | } |
---|
[494] | 2531 | } |
---|
[313] | 2532 | } |
---|
| 2533 | |
---|
| 2534 | Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded) |
---|
| 2535 | { |
---|
[815] | 2536 | #if REPN_FORMAT_IN_VPS |
---|
| 2537 | ChromaFormat chromaFormatIdc = m_acLayerCfg[layer].getChromaFormatIDC(); |
---|
| 2538 | Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ); |
---|
| 2539 | Int yScal = TComSPS::getWinUnitY( chromaFormatIdc ); |
---|
| 2540 | #endif |
---|
| 2541 | |
---|
[442] | 2542 | if (m_isField) |
---|
| 2543 | { |
---|
| 2544 | //Reinterlace fields |
---|
| 2545 | Int i; |
---|
| 2546 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
[313] | 2547 | |
---|
[442] | 2548 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 2549 | { |
---|
| 2550 | --iterPicYuvRec; |
---|
| 2551 | } |
---|
[313] | 2552 | |
---|
[442] | 2553 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
| 2554 | { |
---|
| 2555 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
| 2556 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
[313] | 2557 | |
---|
| 2558 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
[442] | 2559 | if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed()) |
---|
[313] | 2560 | #else |
---|
[442] | 2561 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
[313] | 2562 | #endif |
---|
[442] | 2563 | { |
---|
[815] | 2564 | #if REPN_FORMAT_IN_VPS |
---|
[823] | 2565 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfWinLeft() * xScal, m_acLayerCfg[layer].getConfWinRight() * xScal, |
---|
| 2566 | m_acLayerCfg[layer].getConfWinTop() * yScal, m_acLayerCfg[layer].getConfWinBottom() * yScal, m_isTopFieldFirst ); |
---|
[815] | 2567 | #else |
---|
[823] | 2568 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfWinLeft(), m_acLayerCfg[layer].getConfWinRight(), m_acLayerCfg[layer].getConfWinTop(), m_acLayerCfg[layer].getConfWinBottom(), m_isTopFieldFirst ); |
---|
[815] | 2569 | #endif |
---|
[442] | 2570 | } |
---|
| 2571 | } |
---|
| 2572 | } |
---|
| 2573 | else |
---|
| 2574 | { |
---|
| 2575 | Int i; |
---|
| 2576 | |
---|
| 2577 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
| 2578 | |
---|
| 2579 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
[313] | 2580 | { |
---|
[442] | 2581 | --iterPicYuvRec; |
---|
[313] | 2582 | } |
---|
[442] | 2583 | |
---|
| 2584 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 2585 | { |
---|
| 2586 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 2587 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 2588 | if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed()) |
---|
| 2589 | #else |
---|
| 2590 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
| 2591 | #endif |
---|
| 2592 | { |
---|
[815] | 2593 | #if REPN_FORMAT_IN_VPS |
---|
[823] | 2594 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfWinLeft() * xScal, m_acLayerCfg[layer].getConfWinRight() * xScal, |
---|
| 2595 | m_acLayerCfg[layer].getConfWinTop() * yScal, m_acLayerCfg[layer].getConfWinBottom() * yScal ); |
---|
[815] | 2596 | #else |
---|
[823] | 2597 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfWinLeft(), m_acLayerCfg[layer].getConfWinRight(), |
---|
| 2598 | m_acLayerCfg[layer].getConfWinTop(), m_acLayerCfg[layer].getConfWinBottom() ); |
---|
[815] | 2599 | #endif |
---|
[442] | 2600 | } |
---|
| 2601 | } |
---|
[313] | 2602 | } |
---|
| 2603 | } |
---|
| 2604 | |
---|
| 2605 | Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
| 2606 | { |
---|
[442] | 2607 | if (m_isField) |
---|
| 2608 | { |
---|
| 2609 | //Reinterlace fields |
---|
| 2610 | Int i; |
---|
| 2611 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
[313] | 2612 | |
---|
[442] | 2613 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 2614 | for ( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ ) |
---|
| 2615 | #else |
---|
| 2616 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
| 2617 | #endif |
---|
[494] | 2618 | { |
---|
[442] | 2619 | const AccessUnit& auTop = *(iterBitstream++); |
---|
| 2620 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
| 2621 | rateStatsAccum(auTop, statsTop); |
---|
[313] | 2622 | |
---|
[442] | 2623 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
| 2624 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
| 2625 | rateStatsAccum(auBottom, statsBottom); |
---|
| 2626 | } |
---|
| 2627 | } |
---|
| 2628 | else |
---|
| 2629 | { |
---|
| 2630 | Int i; |
---|
| 2631 | |
---|
| 2632 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
| 2633 | |
---|
[313] | 2634 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
[442] | 2635 | for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ ) |
---|
[313] | 2636 | #else |
---|
[442] | 2637 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
[313] | 2638 | #endif |
---|
[442] | 2639 | { |
---|
| 2640 | const AccessUnit& au = *(iterBitstream++); |
---|
| 2641 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
| 2642 | rateStatsAccum(au, stats); |
---|
| 2643 | } |
---|
[313] | 2644 | } |
---|
| 2645 | } |
---|
| 2646 | |
---|
| 2647 | #else // SVC_EXTENSION |
---|
| 2648 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
| 2649 | { |
---|
| 2650 | assert( m_iGOPSize > 0 ); |
---|
| 2651 | |
---|
| 2652 | // org. buffer |
---|
| 2653 | if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize ) |
---|
| 2654 | { |
---|
| 2655 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
| 2656 | |
---|
| 2657 | } |
---|
| 2658 | else |
---|
| 2659 | { |
---|
| 2660 | rpcPicYuvRec = new TComPicYuv; |
---|
| 2661 | |
---|
| 2662 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 2663 | |
---|
| 2664 | } |
---|
| 2665 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
| 2666 | } |
---|
| 2667 | |
---|
| 2668 | Void TAppEncTop::xDeleteBuffer( ) |
---|
| 2669 | { |
---|
| 2670 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
| 2671 | |
---|
| 2672 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
| 2673 | |
---|
| 2674 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 2675 | { |
---|
| 2676 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 2677 | pcPicYuvRec->destroy(); |
---|
| 2678 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
| 2679 | } |
---|
| 2680 | |
---|
| 2681 | } |
---|
| 2682 | |
---|
| 2683 | /** \param iNumEncoded number of encoded frames |
---|
| 2684 | */ |
---|
| 2685 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
| 2686 | { |
---|
[442] | 2687 | if (m_isField) |
---|
| 2688 | { |
---|
| 2689 | //Reinterlace fields |
---|
| 2690 | Int i; |
---|
| 2691 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
| 2692 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
[313] | 2693 | |
---|
[442] | 2694 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 2695 | { |
---|
| 2696 | --iterPicYuvRec; |
---|
| 2697 | } |
---|
[313] | 2698 | |
---|
[442] | 2699 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
| 2700 | { |
---|
| 2701 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
| 2702 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
| 2703 | |
---|
| 2704 | if (m_pchReconFile) |
---|
| 2705 | { |
---|
[823] | 2706 | m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst ); |
---|
[442] | 2707 | } |
---|
| 2708 | |
---|
| 2709 | const AccessUnit& auTop = *(iterBitstream++); |
---|
| 2710 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
| 2711 | rateStatsAccum(auTop, statsTop); |
---|
| 2712 | |
---|
| 2713 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
| 2714 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
| 2715 | rateStatsAccum(auBottom, statsBottom); |
---|
| 2716 | } |
---|
| 2717 | } |
---|
| 2718 | else |
---|
[313] | 2719 | { |
---|
[442] | 2720 | Int i; |
---|
| 2721 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
| 2722 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
| 2723 | |
---|
| 2724 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
[313] | 2725 | { |
---|
[442] | 2726 | --iterPicYuvRec; |
---|
| 2727 | } |
---|
| 2728 | |
---|
| 2729 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 2730 | { |
---|
| 2731 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 2732 | if (m_pchReconFile) |
---|
| 2733 | { |
---|
[823] | 2734 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
[442] | 2735 | } |
---|
| 2736 | |
---|
| 2737 | const AccessUnit& au = *(iterBitstream++); |
---|
| 2738 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
| 2739 | rateStatsAccum(au, stats); |
---|
[313] | 2740 | } |
---|
| 2741 | } |
---|
| 2742 | } |
---|
| 2743 | #endif |
---|
| 2744 | |
---|
| 2745 | /** |
---|
| 2746 | * |
---|
| 2747 | */ |
---|
| 2748 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
| 2749 | { |
---|
| 2750 | AccessUnit::const_iterator it_au = au.begin(); |
---|
| 2751 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
| 2752 | |
---|
| 2753 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
| 2754 | { |
---|
| 2755 | switch ((*it_au)->m_nalUnitType) |
---|
| 2756 | { |
---|
| 2757 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
| 2758 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
[540] | 2759 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
[313] | 2760 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
| 2761 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
| 2762 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
| 2763 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
| 2764 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
| 2765 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
| 2766 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
| 2767 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
| 2768 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
| 2769 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
| 2770 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
| 2771 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
| 2772 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
| 2773 | case NAL_UNIT_VPS: |
---|
| 2774 | case NAL_UNIT_SPS: |
---|
| 2775 | case NAL_UNIT_PPS: |
---|
| 2776 | m_essentialBytes += *it_stats; |
---|
| 2777 | break; |
---|
| 2778 | default: |
---|
| 2779 | break; |
---|
| 2780 | } |
---|
| 2781 | |
---|
| 2782 | m_totalBytes += *it_stats; |
---|
| 2783 | } |
---|
| 2784 | } |
---|
| 2785 | |
---|
| 2786 | void TAppEncTop::printRateSummary() |
---|
| 2787 | { |
---|
| 2788 | #if SVC_EXTENSION |
---|
| 2789 | Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate(); |
---|
| 2790 | #else |
---|
| 2791 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
| 2792 | #endif |
---|
| 2793 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
| 2794 | #if VERBOSE_RATE |
---|
| 2795 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
| 2796 | #endif |
---|
| 2797 | } |
---|
| 2798 | |
---|
| 2799 | //! \} |
---|