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