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