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