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