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