[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
[466] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
| 6 | * Copyright (c) 2010-2013, 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 | } |
---|
[442] | 92 | #if REPN_FORMAT_IN_VPS |
---|
| 93 | vps->setRepFormatIdxPresentFlag( true ); // Could be disabled to optimize in some cases. |
---|
| 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 | // Currently only picture width and height are considred. It has to be updated if different chroma format and bit-depth will are used. |
---|
| 102 | Bool found = false; |
---|
| 103 | for( UInt idx = 0; idx < layer; idx++ ) |
---|
| 104 | { |
---|
| 105 | if( m_acLayerCfg[layer].getSourceWidth() == m_acLayerCfg[idx].getSourceWidth() && m_acLayerCfg[layer].getSourceHeight() == m_acLayerCfg[idx].getSourceHeight() ) |
---|
| 106 | { |
---|
| 107 | found = true; |
---|
| 108 | break; |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | if( !found ) |
---|
| 112 | { |
---|
| 113 | formatIdx++; |
---|
| 114 | } |
---|
[313] | 115 | |
---|
[442] | 116 | m_acLayerCfg[layer].setRepFormatIdx( formatIdx ); |
---|
| 117 | } |
---|
| 118 | |
---|
[466] | 119 | assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" ); |
---|
[442] | 120 | vps->setVpsRepFormatIdx( layer, m_acLayerCfg[layer].getRepFormatIdx() ); |
---|
| 121 | maxRepFormatIdx = std::max( m_acLayerCfg[layer].getRepFormatIdx(), maxRepFormatIdx ); |
---|
| 122 | } |
---|
| 123 | assert( vps->getVpsRepFormatIdx( 0 ) == 0 ); // Base layer should point to the first one. |
---|
| 124 | Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1]; |
---|
| 125 | // Check that all the indices from 0 to maxRepFormatIdx are used in the VPS |
---|
| 126 | for(Int i = 0; i <= maxRepFormatIdx; i++) |
---|
| 127 | { |
---|
| 128 | mapIdxToLayer[i] = -1; |
---|
| 129 | UInt layer; |
---|
| 130 | for(layer=0; layer < m_numLayers; layer++) |
---|
| 131 | { |
---|
| 132 | if( vps->getVpsRepFormatIdx(layer) == i ) |
---|
| 133 | { |
---|
| 134 | mapIdxToLayer[i] = layer; |
---|
| 135 | break; |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | assert( layer != m_numLayers ); // One of the VPS Rep format indices not set |
---|
| 139 | } |
---|
| 140 | vps->setVpsNumRepFormats( maxRepFormatIdx + 1 ); |
---|
| 141 | for(UInt idx=0; idx < vps->getVpsNumRepFormats(); idx++) |
---|
| 142 | { |
---|
[466] | 143 | RepFormat *repFormat = vps->getVpsRepFormat( idx ); |
---|
[442] | 144 | repFormat->setPicWidthVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceWidth() ); |
---|
| 145 | repFormat->setPicHeightVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceHeight() ); |
---|
| 146 | repFormat->setChromaFormatVpsIdc ( 1 ); // Need modification to change for each layer - corresponds to 420 |
---|
| 147 | repFormat->setSeparateColourPlaneVpsFlag( 0 ); // Need modification to change for each layer |
---|
[466] | 148 | #if O0194_REPN_FORMAT_IN_VPS_BUGFIX |
---|
| 149 | repFormat->setBitDepthVpsLuma ( getInternalBitDepthY(mapIdxToLayer[idx]) ); // Need modification to change for each layer |
---|
| 150 | repFormat->setBitDepthVpsChroma ( getInternalBitDepthC(mapIdxToLayer[idx]) ); // Need modification to change for each layer |
---|
| 151 | #else |
---|
[442] | 152 | repFormat->setBitDepthVpsLuma ( getInternalBitDepthY() ); // Need modification to change for each layer |
---|
| 153 | repFormat->setBitDepthVpsChroma ( getInternalBitDepthC() ); // Need modification to change for each layer |
---|
[466] | 154 | #endif |
---|
[442] | 155 | } |
---|
| 156 | delete [] mapIdxToLayer; |
---|
| 157 | #endif |
---|
[313] | 158 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 159 | { |
---|
[466] | 160 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 161 | //1 |
---|
| 162 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 163 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 164 | |
---|
| 165 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 166 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 167 | |
---|
| 168 | // Set this to be used in Upsampling filter in function "TComUpsampleFilter::upsampleBasePic" |
---|
| 169 | g_bitDepthYLayer[layer] = g_bitDepthY; |
---|
| 170 | g_bitDepthCLayer[layer] = g_bitDepthC; |
---|
| 171 | #endif |
---|
[313] | 172 | //m_acTEncTop[layer].setVPS(&vps); |
---|
| 173 | m_acTEncTop[layer].setFrameRate ( m_acLayerCfg[layer].getFrameRate() ); |
---|
| 174 | m_acTEncTop[layer].setFrameSkip ( m_FrameSkip ); |
---|
| 175 | m_acTEncTop[layer].setSourceWidth ( m_acLayerCfg[layer].getSourceWidth() ); |
---|
| 176 | m_acTEncTop[layer].setSourceHeight ( m_acLayerCfg[layer].getSourceHeight() ); |
---|
| 177 | m_acTEncTop[layer].setConformanceMode ( m_acLayerCfg[layer].getConformanceMode() ); |
---|
| 178 | m_acTEncTop[layer].setConformanceWindow ( m_acLayerCfg[layer].m_confLeft, m_acLayerCfg[layer].m_confRight, m_acLayerCfg[layer].m_confTop, m_acLayerCfg[layer].m_confBottom ); |
---|
| 179 | m_acTEncTop[layer].setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
| 180 | |
---|
| 181 | m_acTEncTop[layer].setProfile(m_profile); |
---|
| 182 | m_acTEncTop[layer].setLevel(m_levelTier, m_level); |
---|
| 183 | m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
| 184 | m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
| 185 | m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
| 186 | m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
| 187 | |
---|
| 188 | #if REF_IDX_MFM |
---|
| 189 | #if AVC_BASE |
---|
| 190 | #if M0457_PREDICTION_INDICATIONS |
---|
| 191 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers()); |
---|
| 192 | #else |
---|
| 193 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true )); |
---|
| 194 | #endif |
---|
| 195 | #else |
---|
| 196 | #if M0457_PREDICTION_INDICATIONS |
---|
| 197 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_acLayerCfg[layer].getNumMotionPredRefLayers() > 0 ) ); |
---|
| 198 | #else |
---|
| 199 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : true); |
---|
| 200 | #endif |
---|
| 201 | #endif |
---|
| 202 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 203 | m_acTEncTop[layer].setIlSampleOnlyPred( layer == 0 ? 0 : m_ilSampleOnlyPred[layer] ); |
---|
| 204 | #endif |
---|
| 205 | #endif |
---|
[466] | 206 | // set layer ID |
---|
| 207 | m_acTEncTop[layer].setLayerId ( layer ); |
---|
[313] | 208 | m_acTEncTop[layer].setNumLayer ( m_numLayers ); |
---|
| 209 | m_acTEncTop[layer].setLayerEnc(m_apcTEncTop); |
---|
| 210 | |
---|
| 211 | //====== Coding Structure ======== |
---|
| 212 | m_acTEncTop[layer].setIntraPeriod ( m_acLayerCfg[layer].m_iIntraPeriod ); |
---|
| 213 | m_acTEncTop[layer].setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
| 214 | m_acTEncTop[layer].setGOPSize ( m_iGOPSize ); |
---|
[345] | 215 | #if FINAL_RPL_CHANGE_N0082 |
---|
| 216 | m_acTEncTop[layer].setGopList ( m_acLayerCfg[layer].m_GOPListLayer ); |
---|
| 217 | #else |
---|
[313] | 218 | m_acTEncTop[layer].setGopList ( m_GOPList ); |
---|
[345] | 219 | #endif |
---|
[313] | 220 | m_acTEncTop[layer].setExtraRPSs ( m_extraRPSs ); |
---|
| 221 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 222 | { |
---|
| 223 | m_acTEncTop[layer].setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 224 | m_acTEncTop[layer].setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 225 | } |
---|
| 226 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
| 227 | { |
---|
| 228 | m_acTEncTop[layer].setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
| 229 | } |
---|
| 230 | m_acTEncTop[layer].setQP ( m_acLayerCfg[layer].getIntQP() ); |
---|
| 231 | |
---|
| 232 | m_acTEncTop[layer].setPad ( m_acLayerCfg[layer].getPad() ); |
---|
| 233 | |
---|
| 234 | m_acTEncTop[layer].setMaxTempLayer ( m_maxTempLayer ); |
---|
| 235 | m_acTEncTop[layer].setUseAMP( m_enableAMP ); |
---|
[442] | 236 | #if N0120_MAX_TID_REF_CFG |
---|
| 237 | if (layer<m_numLayers-1) |
---|
| 238 | { |
---|
[466] | 239 | m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1()); |
---|
[442] | 240 | } |
---|
[466] | 241 | #endif |
---|
[313] | 242 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 243 | if(layer) |
---|
| 244 | { |
---|
| 245 | #if M0457_PREDICTION_INDICATIONS |
---|
| 246 | for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++) |
---|
| 247 | { |
---|
| 248 | m_acTEncTop[layer].setSamplePredEnabledFlag(i, false); |
---|
| 249 | m_acTEncTop[layer].setMotionPredEnabledFlag(i, false); |
---|
| 250 | } |
---|
| 251 | if(m_acLayerCfg[layer].getNumSamplePredRefLayers() == -1) |
---|
| 252 | { |
---|
| 253 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
| 254 | m_acTEncTop[layer].setNumSamplePredRefLayers (1); // One sample pred ref. layer |
---|
| 255 | m_acTEncTop[layer].setSamplePredRefLayerId (0, layer - 1); // Previous layer |
---|
| 256 | m_acTEncTop[layer].setSamplePredEnabledFlag (layer - 1, true); |
---|
| 257 | } |
---|
| 258 | else |
---|
| 259 | { |
---|
[466] | 260 | m_acTEncTop[layer].setNumSamplePredRefLayers ( m_acLayerCfg[layer].getNumSamplePredRefLayers() ); |
---|
[313] | 261 | for(Int i = 0; i < m_acTEncTop[layer].getNumSamplePredRefLayers(); i++) |
---|
| 262 | { |
---|
| 263 | m_acTEncTop[layer].setSamplePredRefLayerId ( i, m_acLayerCfg[layer].getSamplePredRefLayerId(i)); |
---|
| 264 | m_acTEncTop[layer].setSamplePredEnabledFlag (m_acLayerCfg[layer].getSamplePredRefLayerId(i), true); |
---|
[466] | 265 | } |
---|
[313] | 266 | } |
---|
| 267 | if(m_acLayerCfg[layer].getNumMotionPredRefLayers() == -1) |
---|
| 268 | { |
---|
| 269 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
| 270 | m_acTEncTop[layer].setNumMotionPredRefLayers (1); // One motion pred ref. layer |
---|
| 271 | m_acTEncTop[layer].setMotionPredRefLayerId (0, layer - 1); // Previous layer |
---|
| 272 | m_acTEncTop[layer].setMotionPredEnabledFlag (layer - 1, true); |
---|
| 273 | } |
---|
| 274 | else |
---|
| 275 | { |
---|
[466] | 276 | m_acTEncTop[layer].setNumMotionPredRefLayers ( m_acLayerCfg[layer].getNumMotionPredRefLayers() ); |
---|
[313] | 277 | for(Int i = 0; i < m_acTEncTop[layer].getNumMotionPredRefLayers(); i++) |
---|
| 278 | { |
---|
| 279 | m_acTEncTop[layer].setMotionPredRefLayerId ( i, m_acLayerCfg[layer].getMotionPredRefLayerId(i)); |
---|
[442] | 280 | m_acTEncTop[layer].setMotionPredEnabledFlag (m_acLayerCfg[layer].getMotionPredRefLayerId(i), true); |
---|
[466] | 281 | } |
---|
[313] | 282 | } |
---|
| 283 | Int numDirectRefLayers = 0; |
---|
| 284 | for (Int i = 0; i < layer; i++) |
---|
| 285 | { |
---|
| 286 | if (m_acTEncTop[layer].getSamplePredEnabledFlag(i) || m_acTEncTop[layer].getMotionPredEnabledFlag(i)) |
---|
| 287 | { |
---|
| 288 | m_acTEncTop[layer].setRefLayerId(numDirectRefLayers, i); |
---|
| 289 | numDirectRefLayers++; |
---|
| 290 | } |
---|
| 291 | } |
---|
| 292 | m_acTEncTop[layer].setNumDirectRefLayers(numDirectRefLayers); |
---|
| 293 | #else |
---|
| 294 | if(m_acLayerCfg[layer].getNumDirectRefLayers() == -1) |
---|
| 295 | { |
---|
| 296 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
| 297 | m_acTEncTop[layer].setNumDirectRefLayers (1); // One ref. layer |
---|
| 298 | m_acTEncTop[layer].setRefLayerId (0, layer - 1); // Previous layer |
---|
| 299 | } |
---|
| 300 | else |
---|
| 301 | { |
---|
[466] | 302 | m_acTEncTop[layer].setNumDirectRefLayers ( m_acLayerCfg[layer].getNumDirectRefLayers() ); |
---|
[313] | 303 | for(Int i = 0; i < m_acTEncTop[layer].getNumDirectRefLayers(); i++) |
---|
| 304 | { |
---|
| 305 | m_acTEncTop[layer].setRefLayerId ( i, m_acLayerCfg[layer].getRefLayerId(i)); |
---|
| 306 | } |
---|
| 307 | } |
---|
| 308 | #endif |
---|
| 309 | if(m_acLayerCfg[layer].getNumActiveRefLayers() == -1) |
---|
| 310 | { |
---|
| 311 | #if M0457_PREDICTION_INDICATIONS |
---|
| 312 | m_acTEncTop[layer].setNumActiveRefLayers( m_acTEncTop[layer].getNumDirectRefLayers() ); |
---|
| 313 | #else |
---|
| 314 | m_acTEncTop[layer].setNumActiveRefLayers( m_acLayerCfg[layer].getNumDirectRefLayers() ); |
---|
| 315 | #endif |
---|
| 316 | for( Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++ ) |
---|
| 317 | { |
---|
| 318 | m_acTEncTop[layer].setPredLayerId(i, i); |
---|
| 319 | } |
---|
| 320 | } |
---|
| 321 | else |
---|
| 322 | { |
---|
[466] | 323 | m_acTEncTop[layer].setNumActiveRefLayers ( m_acLayerCfg[layer].getNumActiveRefLayers() ); |
---|
[313] | 324 | for(Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++) |
---|
| 325 | { |
---|
| 326 | m_acTEncTop[layer].setPredLayerId ( i, m_acLayerCfg[layer].getPredLayerId(i)); |
---|
| 327 | } |
---|
| 328 | } |
---|
| 329 | } |
---|
| 330 | #endif |
---|
| 331 | //===== Slice ======== |
---|
| 332 | |
---|
| 333 | //====== Loop/Deblock Filter ======== |
---|
| 334 | m_acTEncTop[layer].setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
| 335 | m_acTEncTop[layer].setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
| 336 | m_acTEncTop[layer].setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
| 337 | m_acTEncTop[layer].setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
| 338 | m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
| 339 | m_acTEncTop[layer].setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
| 340 | |
---|
| 341 | //====== Motion search ======== |
---|
| 342 | m_acTEncTop[layer].setFastSearch ( m_iFastSearch ); |
---|
| 343 | m_acTEncTop[layer].setSearchRange ( m_iSearchRange ); |
---|
| 344 | m_acTEncTop[layer].setBipredSearchRange ( m_bipredSearchRange ); |
---|
| 345 | |
---|
| 346 | //====== Quality control ======== |
---|
| 347 | m_acTEncTop[layer].setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
| 348 | m_acTEncTop[layer].setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
| 349 | |
---|
| 350 | m_acTEncTop[layer].setChromaCbQpOffset ( m_cbQpOffset ); |
---|
| 351 | m_acTEncTop[layer].setChromaCrQpOffset ( m_crQpOffset ); |
---|
| 352 | |
---|
| 353 | #if ADAPTIVE_QP_SELECTION |
---|
| 354 | m_acTEncTop[layer].setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
| 355 | #endif |
---|
| 356 | |
---|
| 357 | Int lowestQP; |
---|
| 358 | lowestQP = - 6*(g_bitDepthY - 8); // XXX: check |
---|
| 359 | |
---|
| 360 | if ((m_iMaxDeltaQP == 0 ) && (m_acLayerCfg[layer].getIntQP() == lowestQP) && (m_useLossless == true)) |
---|
| 361 | { |
---|
| 362 | m_bUseAdaptiveQP = false; |
---|
| 363 | } |
---|
| 364 | m_acTEncTop[layer].setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
| 365 | m_acTEncTop[layer].setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
| 366 | |
---|
| 367 | //====== Tool list ======== |
---|
| 368 | m_acTEncTop[layer].setUseSBACRD ( m_bUseSBACRD ); |
---|
| 369 | m_acTEncTop[layer].setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
| 370 | m_acTEncTop[layer].setUseASR ( m_bUseASR ); |
---|
| 371 | m_acTEncTop[layer].setUseHADME ( m_bUseHADME ); |
---|
| 372 | m_acTEncTop[layer].setUseLossless ( m_useLossless ); |
---|
| 373 | m_acTEncTop[layer].setdQPs ( m_acLayerCfg[layer].getdQPs() ); |
---|
| 374 | m_acTEncTop[layer].setUseRDOQ ( m_useRDOQ ); |
---|
| 375 | m_acTEncTop[layer].setUseRDOQTS ( m_useRDOQTS ); |
---|
| 376 | m_acTEncTop[layer].setRDpenalty ( m_rdPenalty ); |
---|
| 377 | m_acTEncTop[layer].setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
| 378 | m_acTEncTop[layer].setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
| 379 | m_acTEncTop[layer].setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
| 380 | m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
| 381 | m_acTEncTop[layer].setUseFastEnc ( m_bUseFastEnc ); |
---|
[466] | 382 | m_acTEncTop[layer].setUseEarlyCU ( m_bUseEarlyCU ); |
---|
[313] | 383 | m_acTEncTop[layer].setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
| 384 | m_acTEncTop[layer].setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
| 385 | m_acTEncTop[layer].setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
| 386 | #if FAST_INTRA_SHVC |
---|
| 387 | m_acTEncTop[layer].setUseFastIntraScalable ( m_useFastIntraScalable ); |
---|
| 388 | #endif |
---|
| 389 | |
---|
| 390 | m_acTEncTop[layer].setUseTransformSkip ( m_useTransformSkip ); |
---|
| 391 | m_acTEncTop[layer].setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
| 392 | m_acTEncTop[layer].setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
| 393 | m_acTEncTop[layer].setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
| 394 | m_acTEncTop[layer].setUsePCM ( m_usePCM ); |
---|
| 395 | m_acTEncTop[layer].setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
| 396 | m_acTEncTop[layer].setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
| 397 | |
---|
| 398 | |
---|
| 399 | //====== Weighted Prediction ======== |
---|
| 400 | m_acTEncTop[layer].setUseWP ( m_useWeightedPred ); |
---|
| 401 | m_acTEncTop[layer].setWPBiPred ( m_useWeightedBiPred ); |
---|
[466] | 402 | #if O0194_WEIGHTED_PREDICTION_CGS |
---|
| 403 | if (layer!=0){ |
---|
| 404 | // Enable weighted prediction for enhancement layer |
---|
| 405 | m_acTEncTop[layer].setUseWP ( true ); |
---|
| 406 | m_acTEncTop[layer].setWPBiPred ( true ); |
---|
| 407 | } |
---|
| 408 | #endif |
---|
[313] | 409 | //====== Parallel Merge Estimation ======== |
---|
| 410 | m_acTEncTop[layer].setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
| 411 | |
---|
| 412 | //====== Slice ======== |
---|
| 413 | m_acTEncTop[layer].setSliceMode ( m_sliceMode ); |
---|
| 414 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument ); |
---|
| 415 | |
---|
| 416 | //====== Dependent Slice ======== |
---|
| 417 | m_acTEncTop[layer].setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
| 418 | m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
| 419 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
| 420 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
| 421 | { |
---|
| 422 | m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
| 423 | } |
---|
| 424 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
| 425 | { |
---|
| 426 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
| 427 | } |
---|
| 428 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
| 429 | { |
---|
| 430 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument ); |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | if(m_sliceMode == 0 ) |
---|
| 434 | { |
---|
| 435 | m_bLFCrossSliceBoundaryFlag = true; |
---|
| 436 | } |
---|
| 437 | m_acTEncTop[layer].setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
| 438 | m_acTEncTop[layer].setUseSAO ( m_bUseSAO ); |
---|
| 439 | m_acTEncTop[layer].setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
| 440 | |
---|
| 441 | m_acTEncTop[layer].setSaoLcuBoundary (m_saoLcuBoundary); |
---|
| 442 | m_acTEncTop[layer].setSaoLcuBasedOptimization (m_saoLcuBasedOptimization); |
---|
[466] | 443 | m_acTEncTop[layer].setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
| 444 | m_acTEncTop[layer].setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
[313] | 445 | |
---|
| 446 | m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
| 447 | m_acTEncTop[layer].setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
| 448 | m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
| 449 | m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
| 450 | m_acTEncTop[layer].setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
| 451 | m_acTEncTop[layer].setTMISEIToneMapId ( m_toneMapId ); |
---|
| 452 | m_acTEncTop[layer].setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
| 453 | m_acTEncTop[layer].setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
| 454 | m_acTEncTop[layer].setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
| 455 | m_acTEncTop[layer].setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
| 456 | m_acTEncTop[layer].setTMISEIModelID ( m_toneMapModelId ); |
---|
| 457 | m_acTEncTop[layer].setTMISEIMinValue ( m_toneMapMinValue ); |
---|
| 458 | m_acTEncTop[layer].setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
| 459 | m_acTEncTop[layer].setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
| 460 | m_acTEncTop[layer].setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
| 461 | m_acTEncTop[layer].setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
| 462 | m_acTEncTop[layer].setTMISEINumPivots ( m_numPivots ); |
---|
| 463 | m_acTEncTop[layer].setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
| 464 | m_acTEncTop[layer].setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
| 465 | m_acTEncTop[layer].setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
| 466 | m_acTEncTop[layer].setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
| 467 | m_acTEncTop[layer].setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
| 468 | m_acTEncTop[layer].setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
| 469 | m_acTEncTop[layer].setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
| 470 | m_acTEncTop[layer].setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
| 471 | m_acTEncTop[layer].setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
| 472 | m_acTEncTop[layer].setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
| 473 | m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
| 474 | m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
| 475 | m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
| 476 | m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
| 477 | m_acTEncTop[layer].setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
| 478 | m_acTEncTop[layer].setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
| 479 | m_acTEncTop[layer].setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
| 480 | m_acTEncTop[layer].setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
| 481 | m_acTEncTop[layer].setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
| 482 | m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
| 483 | m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
| 484 | #if M0043_LAYERS_PRESENT_SEI |
---|
| 485 | m_acTEncTop[layer].setLayersPresentSEIEnabled( m_layersPresentSEIEnabled ); |
---|
| 486 | #endif |
---|
| 487 | m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
| 488 | m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
[442] | 489 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 490 | m_acTEncTop[layer].setInterLayerConstrainedTileSetsSEIEnabled( m_interLayerConstrainedTileSetsSEIEnabled ); |
---|
| 491 | m_acTEncTop[layer].setIlNumSetsInMessage( m_ilNumSetsInMessage ); |
---|
| 492 | m_acTEncTop[layer].setSkippedTileSetPresentFlag( m_skippedTileSetPresentFlag ); |
---|
| 493 | m_acTEncTop[layer].setTopLeftTileIndex( m_topLeftTileIndex ); |
---|
| 494 | m_acTEncTop[layer].setBottomRightTileIndex( m_bottomRightTileIndex ); |
---|
| 495 | m_acTEncTop[layer].setIlcIdc( m_ilcIdc ); |
---|
| 496 | #endif |
---|
[313] | 497 | m_acTEncTop[layer].setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
---|
| 498 | m_acTEncTop[layer].setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
---|
| 499 | m_acTEncTop[layer].setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
---|
| 500 | if(m_iUniformSpacingIdr==0) |
---|
| 501 | { |
---|
| 502 | m_acTEncTop[layer].setColumnWidth ( m_pColumnWidth ); |
---|
| 503 | m_acTEncTop[layer].setRowHeight ( m_pRowHeight ); |
---|
| 504 | } |
---|
| 505 | m_acTEncTop[layer].xCheckGSParameters(); |
---|
| 506 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
---|
| 507 | if(uiTilesCount == 1) |
---|
| 508 | { |
---|
[466] | 509 | m_bLFCrossTileBoundaryFlag = true; |
---|
[313] | 510 | } |
---|
| 511 | m_acTEncTop[layer].setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
| 512 | m_acTEncTop[layer].setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
| 513 | m_acTEncTop[layer].setWaveFrontSubstreams ( m_acLayerCfg[layer].m_iWaveFrontSubstreams ); |
---|
| 514 | m_acTEncTop[layer].setTMVPModeId ( m_TMVPModeId ); |
---|
| 515 | m_acTEncTop[layer].setUseScalingListId ( m_useScalingListId ); |
---|
| 516 | m_acTEncTop[layer].setScalingListFile ( m_scalingListFile ); |
---|
| 517 | m_acTEncTop[layer].setSignHideFlag(m_signHideFlag); |
---|
| 518 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 519 | #if RC_SHVC_HARMONIZATION |
---|
| 520 | m_acTEncTop[layer].setUseRateCtrl (m_acLayerCfg[layer].getRCEnableRateControl()); |
---|
| 521 | m_acTEncTop[layer].setTargetBitrate (m_acLayerCfg[layer].getRCTargetBitrate()); |
---|
| 522 | m_acTEncTop[layer].setKeepHierBit (m_acLayerCfg[layer].getRCKeepHierarchicalBit()); |
---|
| 523 | m_acTEncTop[layer].setLCULevelRC (m_acLayerCfg[layer].getRCLCULevelRC()); |
---|
| 524 | m_acTEncTop[layer].setUseLCUSeparateModel (m_acLayerCfg[layer].getRCUseLCUSeparateModel()); |
---|
| 525 | m_acTEncTop[layer].setInitialQP (m_acLayerCfg[layer].getRCInitialQP()); |
---|
| 526 | m_acTEncTop[layer].setForceIntraQP (m_acLayerCfg[layer].getRCForceIntraQP()); |
---|
| 527 | #else |
---|
| 528 | m_acTEncTop[layer].setUseRateCtrl ( m_RCEnableRateControl ); |
---|
| 529 | m_acTEncTop[layer].setTargetBitrate ( m_RCTargetBitrate ); |
---|
| 530 | m_acTEncTop[layer].setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
| 531 | m_acTEncTop[layer].setLCULevelRC ( m_RCLCULevelRC ); |
---|
| 532 | m_acTEncTop[layer].setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
| 533 | m_acTEncTop[layer].setInitialQP ( m_RCInitialQP ); |
---|
| 534 | m_acTEncTop[layer].setForceIntraQP ( m_RCForceIntraQP ); |
---|
| 535 | #endif |
---|
| 536 | #else |
---|
| 537 | m_acTEncTop[layer].setUseRateCtrl ( m_enableRateCtrl); |
---|
| 538 | m_acTEncTop[layer].setTargetBitrate ( m_targetBitrate); |
---|
| 539 | m_acTEncTop[layer].setNumLCUInUnit ( m_numLCUInUnit); |
---|
| 540 | #endif |
---|
| 541 | m_acTEncTop[layer].setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
| 542 | m_acTEncTop[layer].setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue); |
---|
| 543 | m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
| 544 | m_acTEncTop[layer].setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
[466] | 545 | m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
[313] | 546 | m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
| 547 | m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc ); |
---|
| 548 | m_acTEncTop[layer].setSarWidth( m_sarWidth ); |
---|
| 549 | m_acTEncTop[layer].setSarHeight( m_sarHeight ); |
---|
| 550 | m_acTEncTop[layer].setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
| 551 | m_acTEncTop[layer].setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
| 552 | m_acTEncTop[layer].setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
| 553 | m_acTEncTop[layer].setVideoFormat( m_videoFormat ); |
---|
| 554 | m_acTEncTop[layer].setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
| 555 | m_acTEncTop[layer].setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
| 556 | m_acTEncTop[layer].setColourPrimaries( m_colourPrimaries ); |
---|
| 557 | m_acTEncTop[layer].setTransferCharacteristics( m_transferCharacteristics ); |
---|
| 558 | m_acTEncTop[layer].setMatrixCoefficients( m_matrixCoefficients ); |
---|
| 559 | m_acTEncTop[layer].setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
| 560 | m_acTEncTop[layer].setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
| 561 | m_acTEncTop[layer].setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
| 562 | m_acTEncTop[layer].setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
| 563 | m_acTEncTop[layer].setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
| 564 | m_acTEncTop[layer].setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
| 565 | m_acTEncTop[layer].setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
| 566 | m_acTEncTop[layer].setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
| 567 | m_acTEncTop[layer].setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
| 568 | m_acTEncTop[layer].setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
| 569 | m_acTEncTop[layer].setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
| 570 | m_acTEncTop[layer].setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
| 571 | m_acTEncTop[layer].setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
| 572 | m_acTEncTop[layer].setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
| 573 | m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
| 574 | m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
| 575 | m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled); |
---|
[466] | 576 | #if SCALED_REF_LAYER_OFFSETS |
---|
[313] | 577 | if( layer > 0 ) |
---|
| 578 | { |
---|
| 579 | m_acTEncTop[layer].setNumScaledRefLayerOffsets( m_acLayerCfg[layer].m_numScaledRefLayerOffsets ); |
---|
| 580 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
| 581 | { |
---|
| 582 | m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i], |
---|
[466] | 583 | 2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]); |
---|
[313] | 584 | } |
---|
| 585 | } |
---|
[466] | 586 | #endif |
---|
[313] | 587 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 588 | m_acTEncTop[layer].setAdaptiveResolutionChange( m_adaptiveResolutionChange ); |
---|
| 589 | #endif |
---|
| 590 | } |
---|
| 591 | } |
---|
[466] | 592 | #else |
---|
[313] | 593 | Void TAppEncTop::xInitLibCfg() |
---|
| 594 | { |
---|
| 595 | TComVPS vps; |
---|
| 596 | |
---|
| 597 | vps.setMaxTLayers ( m_maxTempLayer ); |
---|
| 598 | if (m_maxTempLayer == 1) |
---|
| 599 | { |
---|
| 600 | vps.setTemporalNestingFlag(true); |
---|
| 601 | } |
---|
| 602 | vps.setMaxLayers ( 1 ); |
---|
| 603 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 604 | { |
---|
| 605 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 606 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 607 | } |
---|
| 608 | m_cTEncTop.setVPS(&vps); |
---|
| 609 | |
---|
| 610 | m_cTEncTop.setProfile(m_profile); |
---|
| 611 | m_cTEncTop.setLevel(m_levelTier, m_level); |
---|
| 612 | m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
| 613 | m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
| 614 | m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
| 615 | m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
| 616 | |
---|
| 617 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
---|
| 618 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
---|
| 619 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
---|
| 620 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
---|
| 621 | m_cTEncTop.setConformanceWindow ( m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
| 622 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
| 623 | |
---|
| 624 | //====== Coding Structure ======== |
---|
| 625 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod ); |
---|
| 626 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
| 627 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
---|
| 628 | m_cTEncTop.setGopList ( m_GOPList ); |
---|
| 629 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
---|
| 630 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 631 | { |
---|
| 632 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 633 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 634 | } |
---|
| 635 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
| 636 | { |
---|
| 637 | m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
| 638 | } |
---|
| 639 | m_cTEncTop.setQP ( m_iQP ); |
---|
| 640 | |
---|
| 641 | m_cTEncTop.setPad ( m_aiPad ); |
---|
| 642 | |
---|
| 643 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
---|
| 644 | m_cTEncTop.setUseAMP( m_enableAMP ); |
---|
| 645 | |
---|
| 646 | //===== Slice ======== |
---|
| 647 | |
---|
| 648 | //====== Loop/Deblock Filter ======== |
---|
| 649 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
| 650 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
| 651 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
| 652 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
| 653 | m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
| 654 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
| 655 | |
---|
| 656 | //====== Motion search ======== |
---|
| 657 | m_cTEncTop.setFastSearch ( m_iFastSearch ); |
---|
| 658 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
---|
| 659 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
---|
| 660 | |
---|
| 661 | //====== Quality control ======== |
---|
| 662 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
| 663 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
| 664 | |
---|
| 665 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
---|
| 666 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
---|
| 667 | |
---|
| 668 | #if ADAPTIVE_QP_SELECTION |
---|
| 669 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
| 670 | #endif |
---|
| 671 | |
---|
| 672 | Int lowestQP; |
---|
| 673 | lowestQP = - 6*(g_bitDepthY - 8); // XXX: check |
---|
| 674 | |
---|
| 675 | if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true)) |
---|
| 676 | { |
---|
| 677 | m_bUseAdaptiveQP = false; |
---|
| 678 | } |
---|
| 679 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
| 680 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
| 681 | |
---|
| 682 | //====== Tool list ======== |
---|
| 683 | m_cTEncTop.setUseSBACRD ( m_bUseSBACRD ); |
---|
| 684 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
| 685 | m_cTEncTop.setUseASR ( m_bUseASR ); |
---|
| 686 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
---|
| 687 | m_cTEncTop.setUseLossless ( m_useLossless ); |
---|
| 688 | m_cTEncTop.setdQPs ( m_aidQP ); |
---|
| 689 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
---|
| 690 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
---|
| 691 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
---|
| 692 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
| 693 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
| 694 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
| 695 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
| 696 | m_cTEncTop.setUseFastEnc ( m_bUseFastEnc ); |
---|
[466] | 697 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
---|
[313] | 698 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
| 699 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
| 700 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
| 701 | #if FAST_INTRA_SHVC |
---|
| 702 | m_cTEncTop.setUseFastIntraScalable ( m_useFastIntraScalable ); |
---|
| 703 | #endif |
---|
| 704 | |
---|
| 705 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
---|
| 706 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
| 707 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
| 708 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
| 709 | m_cTEncTop.setUsePCM ( m_usePCM ); |
---|
| 710 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
| 711 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
| 712 | |
---|
| 713 | |
---|
| 714 | //====== Weighted Prediction ======== |
---|
| 715 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
---|
| 716 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
---|
| 717 | //====== Parallel Merge Estimation ======== |
---|
| 718 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
| 719 | |
---|
| 720 | //====== Slice ======== |
---|
| 721 | m_cTEncTop.setSliceMode ( m_sliceMode ); |
---|
| 722 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
| 723 | |
---|
| 724 | //====== Dependent Slice ======== |
---|
| 725 | m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
| 726 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
| 727 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
| 728 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
| 729 | { |
---|
| 730 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
| 731 | } |
---|
| 732 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
| 733 | { |
---|
| 734 | m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
| 735 | } |
---|
| 736 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
| 737 | { |
---|
| 738 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
| 739 | } |
---|
| 740 | |
---|
| 741 | if(m_sliceMode == 0 ) |
---|
| 742 | { |
---|
| 743 | m_bLFCrossSliceBoundaryFlag = true; |
---|
| 744 | } |
---|
| 745 | m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
| 746 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
---|
| 747 | m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
| 748 | |
---|
| 749 | m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary); |
---|
| 750 | m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization); |
---|
[466] | 751 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
| 752 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
[313] | 753 | |
---|
| 754 | m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
| 755 | m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
| 756 | m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
| 757 | m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
| 758 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
| 759 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
---|
| 760 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
| 761 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
| 762 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
| 763 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
| 764 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
---|
| 765 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
---|
| 766 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
| 767 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
| 768 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
| 769 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
| 770 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
---|
| 771 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
| 772 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
| 773 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
| 774 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
| 775 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
| 776 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
| 777 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
| 778 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
| 779 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
| 780 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
| 781 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
| 782 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
| 783 | m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
| 784 | m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
| 785 | m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
| 786 | m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
| 787 | m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
| 788 | m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
| 789 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
| 790 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
| 791 | m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
| 792 | #if M0043_LAYERS_PRESENT_SEI |
---|
| 793 | m_cTEncTop.setLayersPresentSEIEnabled( m_layersPresentSEIEnabled ); |
---|
| 794 | #endif |
---|
| 795 | m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
| 796 | m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
| 797 | m_cTEncTop.setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
---|
| 798 | m_cTEncTop.setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
---|
| 799 | m_cTEncTop.setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
---|
| 800 | if(m_iUniformSpacingIdr==0) |
---|
| 801 | { |
---|
| 802 | m_cTEncTop.setColumnWidth ( m_pColumnWidth ); |
---|
| 803 | m_cTEncTop.setRowHeight ( m_pRowHeight ); |
---|
| 804 | } |
---|
| 805 | m_cTEncTop.xCheckGSParameters(); |
---|
| 806 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
---|
| 807 | if(uiTilesCount == 1) |
---|
| 808 | { |
---|
[466] | 809 | m_bLFCrossTileBoundaryFlag = true; |
---|
[313] | 810 | } |
---|
| 811 | m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
| 812 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
| 813 | m_cTEncTop.setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
| 814 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
---|
| 815 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
---|
| 816 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
---|
| 817 | m_cTEncTop.setSignHideFlag(m_signHideFlag); |
---|
| 818 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 819 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
| 820 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
| 821 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
| 822 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
---|
| 823 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
| 824 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
---|
| 825 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
---|
| 826 | #else |
---|
| 827 | m_cTEncTop.setUseRateCtrl ( m_enableRateCtrl); |
---|
| 828 | m_cTEncTop.setTargetBitrate ( m_targetBitrate); |
---|
| 829 | m_cTEncTop.setNumLCUInUnit ( m_numLCUInUnit); |
---|
| 830 | #endif |
---|
| 831 | m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
| 832 | m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue); |
---|
| 833 | m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
| 834 | m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
[466] | 835 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
[313] | 836 | m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
| 837 | m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc ); |
---|
| 838 | m_cTEncTop.setSarWidth( m_sarWidth ); |
---|
| 839 | m_cTEncTop.setSarHeight( m_sarHeight ); |
---|
| 840 | m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
| 841 | m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
| 842 | m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
| 843 | m_cTEncTop.setVideoFormat( m_videoFormat ); |
---|
| 844 | m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
| 845 | m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
| 846 | m_cTEncTop.setColourPrimaries( m_colourPrimaries ); |
---|
| 847 | m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics ); |
---|
| 848 | m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients ); |
---|
| 849 | m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
| 850 | m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
| 851 | m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
| 852 | m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
| 853 | m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
| 854 | m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
| 855 | m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
| 856 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
| 857 | m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
| 858 | m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
| 859 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
| 860 | m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
| 861 | m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
| 862 | m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
| 863 | m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
| 864 | m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
| 865 | } |
---|
[466] | 866 | #endif |
---|
[313] | 867 | |
---|
| 868 | Void TAppEncTop::xCreateLib() |
---|
| 869 | { |
---|
| 870 | // Video I/O |
---|
| 871 | #if SVC_EXTENSION |
---|
| 872 | // initialize global variables |
---|
| 873 | initROM(); |
---|
| 874 | |
---|
| 875 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 876 | { |
---|
[466] | 877 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 878 | //2 |
---|
| 879 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 880 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 881 | |
---|
| 882 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 883 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
[445] | 884 | #endif |
---|
[466] | 885 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 886 | 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 |
---|
| 887 | #else |
---|
[313] | 888 | m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(), false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
[466] | 889 | #endif |
---|
[313] | 890 | m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1]); |
---|
| 891 | |
---|
| 892 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
| 893 | { |
---|
[466] | 894 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 895 | 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 |
---|
| 896 | #else |
---|
[313] | 897 | m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // write mode |
---|
[466] | 898 | #endif |
---|
[313] | 899 | } |
---|
| 900 | |
---|
| 901 | m_acTEncTop[layer].create(); |
---|
| 902 | } |
---|
[466] | 903 | #else |
---|
[313] | 904 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
| 905 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
| 906 | |
---|
| 907 | if (m_pchReconFile) |
---|
| 908 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
| 909 | |
---|
| 910 | // Neo Decoder |
---|
| 911 | m_cTEncTop.create(); |
---|
[466] | 912 | #endif |
---|
[313] | 913 | } |
---|
| 914 | |
---|
| 915 | Void TAppEncTop::xDestroyLib() |
---|
| 916 | { |
---|
| 917 | // Video I/O |
---|
| 918 | #if SVC_EXTENSION |
---|
| 919 | // destroy ROM |
---|
| 920 | destroyROM(); |
---|
| 921 | |
---|
| 922 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 923 | { |
---|
| 924 | m_acTVideoIOYuvInputFile[layer].close(); |
---|
| 925 | m_acTVideoIOYuvReconFile[layer].close(); |
---|
| 926 | |
---|
| 927 | m_acTEncTop[layer].destroy(); |
---|
| 928 | } |
---|
[466] | 929 | #else |
---|
[313] | 930 | m_cTVideoIOYuvInputFile.close(); |
---|
| 931 | m_cTVideoIOYuvReconFile.close(); |
---|
| 932 | |
---|
| 933 | // Neo Decoder |
---|
| 934 | m_cTEncTop.destroy(); |
---|
[466] | 935 | #endif |
---|
[313] | 936 | } |
---|
| 937 | |
---|
[442] | 938 | Void TAppEncTop::xInitLib(Bool isFieldCoding) |
---|
[313] | 939 | { |
---|
| 940 | #if SVC_EXTENSION |
---|
| 941 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 942 | { |
---|
[466] | 943 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 944 | //3 |
---|
| 945 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 946 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 947 | |
---|
| 948 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 949 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
[445] | 950 | #endif |
---|
[442] | 951 | m_acTEncTop[layer].init(isFieldCoding); |
---|
[313] | 952 | } |
---|
| 953 | #if VPS_RENAME |
---|
| 954 | m_acTEncTop[0].getVPS()->setMaxLayers( m_numLayers ); |
---|
| 955 | #endif |
---|
| 956 | #if VPS_EXTN_OP_LAYER_SETS |
---|
| 957 | TComVPS* vps = m_acTEncTop[0].getVPS(); |
---|
| 958 | vps->setMaxLayerId(m_numLayers - 1); // Set max-layer ID |
---|
| 959 | |
---|
| 960 | vps->setNumLayerSets(m_numLayers); |
---|
| 961 | for(Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
| 962 | { |
---|
| 963 | for(Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++) |
---|
| 964 | { |
---|
[466] | 965 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 966 | //4 |
---|
| 967 | g_bitDepthY = m_acLayerCfg[layerId].m_internalBitDepthY; |
---|
| 968 | g_bitDepthC = m_acLayerCfg[layerId].m_internalBitDepthC; |
---|
| 969 | |
---|
| 970 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthY : m_acLayerCfg[layerId].m_internalBitDepthY; |
---|
| 971 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC; |
---|
| 972 | #endif |
---|
[313] | 973 | vps->setLayerIdIncludedFlag(true, setId, layerId); |
---|
| 974 | } |
---|
| 975 | } |
---|
| 976 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
| 977 | UInt i = 0, dimIdLen = 0; |
---|
| 978 | #if AVC_BASE |
---|
| 979 | vps->setAvcBaseLayerFlag(m_avcBaseLayerFlag); |
---|
| 980 | #else |
---|
| 981 | vps->setAvcBaseLayerFlag(false); |
---|
| 982 | #endif |
---|
| 983 | vps->setSplittingFlag(false); |
---|
| 984 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
| 985 | { |
---|
| 986 | vps->setScalabilityMask(i, false); |
---|
| 987 | } |
---|
[466] | 988 | if(m_numLayers > 1) |
---|
[313] | 989 | { |
---|
| 990 | Int scalabilityTypes = 0; |
---|
| 991 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
| 992 | { |
---|
| 993 | vps->setScalabilityMask(i, m_scalabilityMask[i]); |
---|
| 994 | scalabilityTypes += m_scalabilityMask[i]; |
---|
| 995 | } |
---|
| 996 | assert( scalabilityTypes == 1 ); |
---|
| 997 | vps->setNumScalabilityTypes(scalabilityTypes); |
---|
| 998 | } |
---|
| 999 | else |
---|
| 1000 | { |
---|
| 1001 | vps->setNumScalabilityTypes(0); |
---|
| 1002 | } |
---|
| 1003 | while((1 << dimIdLen) < m_numLayers) |
---|
| 1004 | { |
---|
| 1005 | dimIdLen++; |
---|
| 1006 | } |
---|
| 1007 | vps->setDimensionIdLen(0, dimIdLen); |
---|
| 1008 | vps->setNuhLayerIdPresentFlag(false); |
---|
| 1009 | vps->setLayerIdInNuh(0, 0); |
---|
| 1010 | vps->setLayerIdInVps(0, 0); |
---|
| 1011 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1012 | { |
---|
| 1013 | vps->setLayerIdInNuh(i, i); |
---|
| 1014 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
| 1015 | vps->setDimensionId(i, 0, i); |
---|
| 1016 | } |
---|
| 1017 | #endif |
---|
[345] | 1018 | #if N0120_MAX_TID_REF_PRESENT_FLAG |
---|
[442] | 1019 | #if N0120_MAX_TID_REF_CFG |
---|
| 1020 | vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag); |
---|
[466] | 1021 | #else |
---|
[442] | 1022 | vps->setMaxTidRefPresentFlag(true); |
---|
[466] | 1023 | #endif |
---|
[442] | 1024 | if (vps->getMaxTidRefPresentFlag()) |
---|
[345] | 1025 | { |
---|
| 1026 | for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ ) |
---|
| 1027 | { |
---|
[442] | 1028 | #if N0120_MAX_TID_REF_CFG |
---|
[466] | 1029 | vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1()); |
---|
| 1030 | #else |
---|
[442] | 1031 | vps->setMaxTidIlRefPicsPlus1(i, vps->getMaxTLayers()+1); |
---|
[466] | 1032 | #endif |
---|
[345] | 1033 | } |
---|
| 1034 | } |
---|
| 1035 | else |
---|
| 1036 | { |
---|
| 1037 | for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ ) |
---|
| 1038 | { |
---|
[442] | 1039 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
[345] | 1040 | } |
---|
| 1041 | } |
---|
[466] | 1042 | #endif |
---|
[345] | 1043 | #if ILP_SSH_SIG |
---|
[458] | 1044 | #if ILP_SSH_SIG_FIX |
---|
| 1045 | vps->setIlpSshSignalingEnabledFlag(false); |
---|
| 1046 | #else |
---|
[345] | 1047 | vps->setIlpSshSignalingEnabledFlag(true); |
---|
| 1048 | #endif |
---|
[458] | 1049 | #endif |
---|
[313] | 1050 | #if VPS_EXTN_PROFILE_INFO |
---|
| 1051 | vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets()); |
---|
| 1052 | for(Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
| 1053 | { |
---|
| 1054 | vps->setProfilePresentFlag(setId, true); |
---|
| 1055 | // Note - may need to be changed for other layer structures. |
---|
| 1056 | *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL()); |
---|
| 1057 | } |
---|
| 1058 | #endif |
---|
| 1059 | // Target output layer |
---|
[466] | 1060 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
| 1061 | vps->setNumOutputLayerSets(vps->getNumLayerSets()); |
---|
| 1062 | vps->setNumProfileTierLevel(vps->getNumLayerSets()); |
---|
[313] | 1063 | vps->setDefaultOneTargetOutputLayerFlag(true); |
---|
| 1064 | for(i = 1; i < vps->getNumLayerSets(); i++) |
---|
| 1065 | { |
---|
| 1066 | vps->setProfileLevelTierIdx(i, i); |
---|
[466] | 1067 | vps->setOutputLayerSetIdx(i, i); |
---|
[313] | 1068 | } |
---|
[466] | 1069 | #else |
---|
| 1070 | vps->setNumOutputLayerSets(1); |
---|
| 1071 | Int lsIdx = 1; |
---|
| 1072 | vps->setOutputLayerSetIdx(0, lsIdx); // Because only one layer set |
---|
| 1073 | #endif |
---|
[313] | 1074 | for(Int lsIdx = 1; lsIdx < vps->getNumLayerSets(); lsIdx++) |
---|
| 1075 | { |
---|
[466] | 1076 | // Include the highest layer as output layer |
---|
[313] | 1077 | for(UInt layer=0; layer <= vps->getMaxLayerId() ; layer++) |
---|
| 1078 | { |
---|
| 1079 | if(vps->getLayerIdIncludedFlag(lsIdx, layer)) |
---|
| 1080 | { |
---|
| 1081 | vps->setOutputLayerFlag(lsIdx, layer, layer == (vps->getMaxLayerId())); |
---|
| 1082 | } |
---|
| 1083 | } |
---|
| 1084 | } |
---|
| 1085 | #endif |
---|
| 1086 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1087 | // Direct reference layers |
---|
| 1088 | UInt maxDirectRefLayers = 0; |
---|
| 1089 | for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 1090 | { |
---|
| 1091 | vps->setNumDirectRefLayers( layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers() ); |
---|
| 1092 | maxDirectRefLayers = max<UInt>( maxDirectRefLayers, vps->getNumDirectRefLayers( layerCtr ) ); |
---|
| 1093 | |
---|
| 1094 | for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++) |
---|
| 1095 | { |
---|
| 1096 | vps->setRefLayerId( layerCtr, i, m_acTEncTop[layerCtr].getRefLayerId(i) ); |
---|
| 1097 | } |
---|
| 1098 | // Set direct dependency flag |
---|
| 1099 | // Initialize flag to 0 |
---|
| 1100 | for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1101 | { |
---|
| 1102 | vps->setDirectDependencyFlag( layerCtr, refLayerCtr, false ); |
---|
| 1103 | } |
---|
| 1104 | for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++) |
---|
| 1105 | { |
---|
| 1106 | vps->setDirectDependencyFlag( layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true); |
---|
| 1107 | } |
---|
| 1108 | #if M0457_PREDICTION_INDICATIONS |
---|
| 1109 | vps->setDirectDepTypeLen(2); // sample and motion types are encoded |
---|
| 1110 | for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1111 | { |
---|
| 1112 | if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr)) |
---|
| 1113 | { |
---|
| 1114 | assert(m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) || m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr)); |
---|
| 1115 | vps->setDirectDependencyType( layerCtr, refLayerCtr, ((m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) ? 1 : 0) | |
---|
| 1116 | (m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr) ? 2 : 0)) - 1); |
---|
| 1117 | } |
---|
| 1118 | else |
---|
| 1119 | { |
---|
| 1120 | vps->setDirectDependencyType( layerCtr, refLayerCtr, 0 ); |
---|
| 1121 | } |
---|
| 1122 | } |
---|
| 1123 | #endif |
---|
| 1124 | } |
---|
[442] | 1125 | #if IL_SL_SIGNALLING_N0371 |
---|
| 1126 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1127 | { |
---|
| 1128 | for(Int j = 0; j < i; j++) |
---|
| 1129 | { |
---|
| 1130 | vps->setScalingListLayerDependency( i, j, vps->checkLayerDependency( i,j ) ); |
---|
| 1131 | } |
---|
| 1132 | } |
---|
[313] | 1133 | #endif |
---|
[442] | 1134 | #endif |
---|
[466] | 1135 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 1136 | vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true); |
---|
| 1137 | #endif |
---|
| 1138 | #if N0147_IRAP_ALIGN_FLAG |
---|
| 1139 | vps->setCrossLayerIrapAlignFlag(true); |
---|
[442] | 1140 | for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 1141 | { |
---|
| 1142 | for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1143 | { |
---|
| 1144 | if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr)) |
---|
[466] | 1145 | { |
---|
[442] | 1146 | if(m_acTEncTop[layerCtr].getIntraPeriod() != m_acTEncTop[refLayerCtr].getIntraPeriod()) |
---|
| 1147 | { |
---|
| 1148 | vps->setCrossLayerIrapAlignFlag(false); |
---|
| 1149 | break; |
---|
| 1150 | } |
---|
| 1151 | } |
---|
| 1152 | } |
---|
| 1153 | } |
---|
| 1154 | |
---|
| 1155 | if( vps->getAvcBaseLayerFlag() ) |
---|
| 1156 | { |
---|
| 1157 | vps->setCrossLayerIrapAlignFlag(false); |
---|
| 1158 | } |
---|
[466] | 1159 | #endif |
---|
[313] | 1160 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1161 | vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false); |
---|
| 1162 | #endif |
---|
[461] | 1163 | #if !VPS_EXTN_OFFSET_CALC |
---|
[442] | 1164 | #if VPS_EXTN_OFFSET |
---|
| 1165 | // to be updated according to the current semantics |
---|
| 1166 | vps->setExtensionOffset( 0xffff ); |
---|
[313] | 1167 | #endif |
---|
[461] | 1168 | #endif |
---|
[464] | 1169 | |
---|
| 1170 | #if O0215_PHASE_ALIGNMENT |
---|
| 1171 | vps->setPhaseAlignFlag( m_phaseAlignFlag ); |
---|
| 1172 | #endif |
---|
| 1173 | |
---|
[442] | 1174 | #else //SVC_EXTENSION |
---|
| 1175 | m_cTEncTop.init(isFieldCoding); |
---|
| 1176 | #endif //SVC_EXTENSION |
---|
[313] | 1177 | } |
---|
| 1178 | |
---|
| 1179 | // ==================================================================================================================== |
---|
| 1180 | // Public member functions |
---|
| 1181 | // ==================================================================================================================== |
---|
| 1182 | |
---|
| 1183 | /** |
---|
| 1184 | - create internal class |
---|
| 1185 | - initialize internal variable |
---|
| 1186 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
| 1187 | - delete allocated buffers |
---|
| 1188 | - destroy internal class |
---|
| 1189 | . |
---|
| 1190 | */ |
---|
| 1191 | #if SVC_EXTENSION |
---|
| 1192 | Void TAppEncTop::encode() |
---|
| 1193 | { |
---|
| 1194 | fstream bitstreamFile(m_pBitstreamFile, fstream::binary | fstream::out); |
---|
| 1195 | if (!bitstreamFile) |
---|
| 1196 | { |
---|
| 1197 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pBitstreamFile); |
---|
| 1198 | exit(EXIT_FAILURE); |
---|
| 1199 | } |
---|
| 1200 | |
---|
| 1201 | TComPicYuv* pcPicYuvOrg [MAX_LAYERS]; |
---|
| 1202 | TComPicYuv* pcPicYuvRec = NULL; |
---|
| 1203 | |
---|
| 1204 | // initialize internal class & member variables |
---|
| 1205 | xInitLibCfg(); |
---|
| 1206 | xCreateLib(); |
---|
[442] | 1207 | xInitLib(m_isField); |
---|
[313] | 1208 | |
---|
| 1209 | // main encoder loop |
---|
| 1210 | Int iNumEncoded = 0, iTotalNumEncoded = 0; |
---|
| 1211 | Bool bEos = false; |
---|
| 1212 | |
---|
| 1213 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
| 1214 | |
---|
| 1215 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1216 | { |
---|
[466] | 1217 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 1218 | //5 |
---|
| 1219 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1220 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 1221 | |
---|
| 1222 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1223 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 1224 | #endif |
---|
[313] | 1225 | // allocate original YUV buffer |
---|
| 1226 | pcPicYuvOrg[layer] = new TComPicYuv; |
---|
[442] | 1227 | if( m_isField ) |
---|
| 1228 | { |
---|
[313] | 1229 | #if SVC_UPSAMPLING |
---|
[442] | 1230 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
[313] | 1231 | #else |
---|
[442] | 1232 | pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
[313] | 1233 | #endif |
---|
[442] | 1234 | } |
---|
| 1235 | else |
---|
| 1236 | { |
---|
| 1237 | #if SVC_UPSAMPLING |
---|
| 1238 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
| 1239 | #else |
---|
| 1240 | pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 1241 | #endif |
---|
| 1242 | } |
---|
[313] | 1243 | } |
---|
| 1244 | |
---|
| 1245 | #if AVC_SYNTAX |
---|
| 1246 | fstream streamSyntaxFile; |
---|
| 1247 | if( m_acTEncTop[0].getVPS()->getAvcBaseLayerFlag() ) |
---|
| 1248 | { |
---|
| 1249 | if( !m_BLSyntaxFile ) |
---|
| 1250 | { |
---|
| 1251 | printf( "Wrong base layer syntax input file\n" ); |
---|
| 1252 | exit(EXIT_FAILURE); |
---|
| 1253 | } |
---|
| 1254 | streamSyntaxFile.open( m_BLSyntaxFile, fstream::in | fstream::binary ); |
---|
| 1255 | if( !streamSyntaxFile.good() ) |
---|
| 1256 | { |
---|
| 1257 | printf( "Base layer syntax input reading error\n" ); |
---|
| 1258 | exit(EXIT_FAILURE); |
---|
| 1259 | } |
---|
| 1260 | m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile ); |
---|
| 1261 | } |
---|
| 1262 | #endif |
---|
| 1263 | |
---|
| 1264 | Bool bFirstFrame = true; |
---|
| 1265 | while ( !bEos ) |
---|
| 1266 | { |
---|
[466] | 1267 | // Read enough frames |
---|
[313] | 1268 | Bool bFramesReadyToCode = false; |
---|
| 1269 | while(!bFramesReadyToCode) |
---|
| 1270 | { |
---|
| 1271 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1272 | { |
---|
[466] | 1273 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 1274 | //6 |
---|
| 1275 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1276 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 1277 | |
---|
| 1278 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1279 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
[445] | 1280 | #endif |
---|
[313] | 1281 | // get buffers |
---|
| 1282 | xGetBuffer(pcPicYuvRec, layer); |
---|
| 1283 | |
---|
| 1284 | // read input YUV file |
---|
| 1285 | m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() ); |
---|
| 1286 | |
---|
| 1287 | if(layer == m_numLayers-1) |
---|
| 1288 | { |
---|
| 1289 | // increase number of received frames |
---|
| 1290 | m_iFrameRcvd++; |
---|
| 1291 | // check end of file |
---|
[442] | 1292 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
[313] | 1293 | } |
---|
| 1294 | |
---|
[442] | 1295 | if ( m_isField ) |
---|
| 1296 | { |
---|
| 1297 | m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], m_isTopFieldFirst ); |
---|
| 1298 | } |
---|
| 1299 | else |
---|
| 1300 | { |
---|
| 1301 | m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] ); |
---|
| 1302 | } |
---|
[313] | 1303 | } |
---|
| 1304 | |
---|
| 1305 | bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos ); |
---|
| 1306 | } |
---|
| 1307 | Bool flush = 0; |
---|
| 1308 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
| 1309 | if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof()) |
---|
| 1310 | { |
---|
| 1311 | flush = true; |
---|
| 1312 | bEos = true; |
---|
| 1313 | m_iFrameRcvd--; |
---|
| 1314 | m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd); |
---|
| 1315 | } |
---|
| 1316 | |
---|
| 1317 | #if RC_SHVC_HARMONIZATION |
---|
| 1318 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1319 | { |
---|
| 1320 | if ( m_acTEncTop[layer].getUseRateCtrl() ) |
---|
| 1321 | { |
---|
| 1322 | (m_acTEncTop[layer].getRateCtrl())->initRCGOP(m_acTEncTop[layer].getNumPicRcvd()); |
---|
| 1323 | } |
---|
| 1324 | } |
---|
| 1325 | #endif |
---|
| 1326 | |
---|
| 1327 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1328 | if (m_adaptiveResolutionChange) |
---|
| 1329 | { |
---|
| 1330 | for(UInt layer = 0; layer < m_numLayers; layer++) |
---|
| 1331 | { |
---|
| 1332 | TComList<TComPicYuv*>::iterator iterPicYuvRec; |
---|
| 1333 | for (iterPicYuvRec = m_acListPicYuvRec[layer].begin(); iterPicYuvRec != m_acListPicYuvRec[layer].end(); iterPicYuvRec++) |
---|
| 1334 | { |
---|
| 1335 | TComPicYuv* recPic = *(iterPicYuvRec); |
---|
| 1336 | recPic->setReconstructed(false); |
---|
| 1337 | } |
---|
| 1338 | } |
---|
| 1339 | } |
---|
| 1340 | #endif |
---|
| 1341 | |
---|
[466] | 1342 | // loop through frames in one GOP |
---|
[313] | 1343 | for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ ) |
---|
| 1344 | { |
---|
| 1345 | // layer by layer for each frame |
---|
| 1346 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1347 | { |
---|
[466] | 1348 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 1349 | //7 |
---|
| 1350 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1351 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
[445] | 1352 | |
---|
[466] | 1353 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1354 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
[445] | 1355 | #endif |
---|
[313] | 1356 | // call encoding function for one frame |
---|
[442] | 1357 | if ( m_isField ) |
---|
| 1358 | { |
---|
| 1359 | m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst ); |
---|
| 1360 | } |
---|
| 1361 | else |
---|
| 1362 | { |
---|
| 1363 | m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP ); |
---|
| 1364 | } |
---|
[313] | 1365 | } |
---|
| 1366 | } |
---|
| 1367 | |
---|
| 1368 | #if RC_SHVC_HARMONIZATION |
---|
| 1369 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1370 | { |
---|
| 1371 | if ( m_acTEncTop[layer].getUseRateCtrl() ) |
---|
| 1372 | { |
---|
| 1373 | (m_acTEncTop[layer].getRateCtrl())->destroyRCGOP(); |
---|
| 1374 | } |
---|
| 1375 | } |
---|
| 1376 | #endif |
---|
| 1377 | |
---|
| 1378 | iTotalNumEncoded = 0; |
---|
| 1379 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1380 | { |
---|
[466] | 1381 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 1382 | //8 |
---|
| 1383 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1384 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 1385 | |
---|
| 1386 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
| 1387 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
| 1388 | #endif |
---|
[313] | 1389 | // write bistream to file if necessary |
---|
| 1390 | iNumEncoded = m_acTEncTop[layer].getNumPicRcvd(); |
---|
| 1391 | if ( iNumEncoded > 0 ) |
---|
| 1392 | { |
---|
| 1393 | xWriteRecon(layer, iNumEncoded); |
---|
| 1394 | iTotalNumEncoded += iNumEncoded; |
---|
| 1395 | } |
---|
| 1396 | m_acTEncTop[layer].setNumPicRcvd( 0 ); |
---|
| 1397 | } |
---|
| 1398 | |
---|
| 1399 | // write bitstream out |
---|
| 1400 | if(iTotalNumEncoded) |
---|
| 1401 | { |
---|
| 1402 | xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits); |
---|
| 1403 | outputAccessUnits.clear(); |
---|
| 1404 | } |
---|
| 1405 | |
---|
| 1406 | // print out summary |
---|
| 1407 | if (bEos) |
---|
| 1408 | { |
---|
[442] | 1409 | printOutSummary(m_isTopFieldFirst); |
---|
[313] | 1410 | } |
---|
| 1411 | |
---|
| 1412 | bFirstFrame = false; |
---|
| 1413 | } |
---|
| 1414 | // delete original YUV buffer |
---|
| 1415 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1416 | { |
---|
| 1417 | pcPicYuvOrg[layer]->destroy(); |
---|
| 1418 | delete pcPicYuvOrg[layer]; |
---|
| 1419 | pcPicYuvOrg[layer] = NULL; |
---|
| 1420 | |
---|
| 1421 | // delete used buffers in encoder class |
---|
| 1422 | m_acTEncTop[layer].deletePicBuffer(); |
---|
| 1423 | } |
---|
| 1424 | |
---|
| 1425 | #if AVC_SYNTAX |
---|
| 1426 | if( streamSyntaxFile.is_open() ) |
---|
| 1427 | { |
---|
| 1428 | streamSyntaxFile.close(); |
---|
| 1429 | } |
---|
| 1430 | #endif |
---|
| 1431 | |
---|
| 1432 | // delete buffers & classes |
---|
| 1433 | xDeleteBuffer(); |
---|
| 1434 | xDestroyLib(); |
---|
| 1435 | |
---|
| 1436 | printRateSummary(); |
---|
| 1437 | |
---|
| 1438 | return; |
---|
| 1439 | } |
---|
| 1440 | |
---|
[442] | 1441 | Void TAppEncTop::printOutSummary(Bool isField) |
---|
[313] | 1442 | { |
---|
| 1443 | UInt layer; |
---|
| 1444 | |
---|
| 1445 | // set frame rate |
---|
| 1446 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 1447 | { |
---|
[442] | 1448 | if(isField) |
---|
| 1449 | { |
---|
| 1450 | m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2); |
---|
| 1451 | m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
| 1452 | m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
| 1453 | m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
| 1454 | } |
---|
| 1455 | else |
---|
| 1456 | { |
---|
| 1457 | m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate()); |
---|
| 1458 | m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
| 1459 | m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
| 1460 | m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
| 1461 | } |
---|
[313] | 1462 | } |
---|
| 1463 | |
---|
| 1464 | //-- all |
---|
| 1465 | printf( "\n\nSUMMARY --------------------------------------------------------\n" ); |
---|
| 1466 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
| 1467 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 1468 | { |
---|
| 1469 | m_gcAnalyzeAll[layer].printOut('a', layer); |
---|
| 1470 | } |
---|
| 1471 | |
---|
| 1472 | printf( "\n\nI Slices--------------------------------------------------------\n" ); |
---|
| 1473 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
| 1474 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 1475 | { |
---|
| 1476 | m_gcAnalyzeI[layer].printOut('i', layer); |
---|
| 1477 | } |
---|
| 1478 | |
---|
| 1479 | printf( "\n\nP Slices--------------------------------------------------------\n" ); |
---|
| 1480 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
| 1481 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 1482 | { |
---|
| 1483 | m_gcAnalyzeP[layer].printOut('p', layer); |
---|
| 1484 | } |
---|
| 1485 | |
---|
| 1486 | printf( "\n\nB Slices--------------------------------------------------------\n" ); |
---|
| 1487 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
| 1488 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 1489 | { |
---|
| 1490 | m_gcAnalyzeB[layer].printOut('b', layer); |
---|
| 1491 | } |
---|
[442] | 1492 | |
---|
| 1493 | if(isField) |
---|
| 1494 | { |
---|
| 1495 | for(layer = 0; layer < m_numLayers; layer++) |
---|
| 1496 | { |
---|
| 1497 | //-- interlaced summary |
---|
| 1498 | m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate()); |
---|
| 1499 | printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); |
---|
| 1500 | m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll[layer].getBits()); |
---|
| 1501 | |
---|
| 1502 | #if _SUMMARY_OUT_ |
---|
| 1503 | m_gcAnalyzeAll_in.printSummaryOutInterlaced(); |
---|
| 1504 | #endif |
---|
| 1505 | } |
---|
| 1506 | } |
---|
[313] | 1507 | } |
---|
| 1508 | |
---|
| 1509 | #else |
---|
| 1510 | Void TAppEncTop::encode() |
---|
| 1511 | { |
---|
| 1512 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
| 1513 | if (!bitstreamFile) |
---|
| 1514 | { |
---|
| 1515 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
| 1516 | exit(EXIT_FAILURE); |
---|
| 1517 | } |
---|
| 1518 | |
---|
| 1519 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
| 1520 | TComPicYuv* pcPicYuvRec = NULL; |
---|
| 1521 | |
---|
| 1522 | // initialize internal class & member variables |
---|
| 1523 | xInitLibCfg(); |
---|
| 1524 | xCreateLib(); |
---|
[442] | 1525 | xInitLib(m_isField); |
---|
[313] | 1526 | |
---|
| 1527 | // main encoder loop |
---|
| 1528 | Int iNumEncoded = 0; |
---|
| 1529 | Bool bEos = false; |
---|
| 1530 | |
---|
| 1531 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
| 1532 | |
---|
| 1533 | // allocate original YUV buffer |
---|
[442] | 1534 | if( m_isField ) |
---|
| 1535 | { |
---|
| 1536 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 1537 | } |
---|
| 1538 | else |
---|
| 1539 | { |
---|
| 1540 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 1541 | } |
---|
[313] | 1542 | |
---|
| 1543 | while ( !bEos ) |
---|
| 1544 | { |
---|
| 1545 | // get buffers |
---|
| 1546 | xGetBuffer(pcPicYuvRec); |
---|
| 1547 | |
---|
| 1548 | // read input YUV file |
---|
| 1549 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad ); |
---|
| 1550 | |
---|
| 1551 | // increase number of received frames |
---|
| 1552 | m_iFrameRcvd++; |
---|
| 1553 | |
---|
[442] | 1554 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
[313] | 1555 | Bool flush = 0; |
---|
| 1556 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
| 1557 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
| 1558 | { |
---|
| 1559 | flush = true; |
---|
| 1560 | bEos = true; |
---|
| 1561 | m_iFrameRcvd--; |
---|
| 1562 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
| 1563 | } |
---|
| 1564 | |
---|
| 1565 | // call encoding function for one frame |
---|
[442] | 1566 | if ( m_isField ) |
---|
| 1567 | { |
---|
| 1568 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst); |
---|
| 1569 | } |
---|
| 1570 | else |
---|
| 1571 | { |
---|
[313] | 1572 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
[442] | 1573 | } |
---|
[313] | 1574 | |
---|
| 1575 | // write bistream to file if necessary |
---|
| 1576 | if ( iNumEncoded > 0 ) |
---|
| 1577 | { |
---|
| 1578 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
| 1579 | outputAccessUnits.clear(); |
---|
| 1580 | } |
---|
| 1581 | } |
---|
| 1582 | |
---|
[442] | 1583 | m_cTEncTop.printSummary(m_isField); |
---|
[313] | 1584 | |
---|
| 1585 | // delete original YUV buffer |
---|
| 1586 | pcPicYuvOrg->destroy(); |
---|
| 1587 | delete pcPicYuvOrg; |
---|
| 1588 | pcPicYuvOrg = NULL; |
---|
| 1589 | |
---|
| 1590 | // delete used buffers in encoder class |
---|
| 1591 | m_cTEncTop.deletePicBuffer(); |
---|
| 1592 | |
---|
| 1593 | // delete buffers & classes |
---|
| 1594 | xDeleteBuffer(); |
---|
| 1595 | xDestroyLib(); |
---|
| 1596 | |
---|
| 1597 | printRateSummary(); |
---|
| 1598 | |
---|
| 1599 | return; |
---|
| 1600 | } |
---|
| 1601 | #endif |
---|
| 1602 | |
---|
| 1603 | // ==================================================================================================================== |
---|
| 1604 | // Protected member functions |
---|
| 1605 | // ==================================================================================================================== |
---|
| 1606 | |
---|
| 1607 | /** |
---|
| 1608 | - application has picture buffer list with size of GOP |
---|
| 1609 | - picture buffer list acts as ring buffer |
---|
| 1610 | - end of the list has the latest picture |
---|
| 1611 | . |
---|
| 1612 | */ |
---|
| 1613 | #if SVC_EXTENSION |
---|
| 1614 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
| 1615 | { |
---|
| 1616 | assert( m_iGOPSize > 0 ); |
---|
| 1617 | |
---|
| 1618 | // org. buffer |
---|
| 1619 | if ( m_acListPicYuvRec[layer].size() == (UInt)m_iGOPSize ) |
---|
| 1620 | { |
---|
| 1621 | rpcPicYuvRec = m_acListPicYuvRec[layer].popFront(); |
---|
| 1622 | |
---|
| 1623 | } |
---|
| 1624 | else |
---|
| 1625 | { |
---|
| 1626 | rpcPicYuvRec = new TComPicYuv; |
---|
| 1627 | |
---|
| 1628 | #if SVC_UPSAMPLING |
---|
| 1629 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
| 1630 | #else |
---|
| 1631 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 1632 | #endif |
---|
| 1633 | |
---|
| 1634 | } |
---|
| 1635 | m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec ); |
---|
| 1636 | } |
---|
| 1637 | |
---|
| 1638 | Void TAppEncTop::xDeleteBuffer( ) |
---|
| 1639 | { |
---|
| 1640 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1641 | { |
---|
| 1642 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].begin(); |
---|
| 1643 | |
---|
| 1644 | Int iSize = Int( m_acListPicYuvRec[layer].size() ); |
---|
| 1645 | |
---|
| 1646 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 1647 | { |
---|
| 1648 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 1649 | pcPicYuvRec->destroy(); |
---|
| 1650 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
| 1651 | } |
---|
[466] | 1652 | } |
---|
[313] | 1653 | } |
---|
| 1654 | |
---|
| 1655 | Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded) |
---|
| 1656 | { |
---|
[442] | 1657 | if (m_isField) |
---|
| 1658 | { |
---|
| 1659 | //Reinterlace fields |
---|
| 1660 | Int i; |
---|
| 1661 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
[313] | 1662 | |
---|
[442] | 1663 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 1664 | { |
---|
| 1665 | --iterPicYuvRec; |
---|
| 1666 | } |
---|
[313] | 1667 | |
---|
[442] | 1668 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
| 1669 | { |
---|
| 1670 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
| 1671 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
[313] | 1672 | |
---|
| 1673 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
[442] | 1674 | if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed()) |
---|
[313] | 1675 | #else |
---|
[442] | 1676 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
[313] | 1677 | #endif |
---|
[442] | 1678 | { |
---|
| 1679 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom(), m_isTopFieldFirst ); |
---|
| 1680 | } |
---|
| 1681 | } |
---|
| 1682 | } |
---|
| 1683 | else |
---|
| 1684 | { |
---|
| 1685 | Int i; |
---|
| 1686 | |
---|
| 1687 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
| 1688 | |
---|
| 1689 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
[313] | 1690 | { |
---|
[442] | 1691 | --iterPicYuvRec; |
---|
[313] | 1692 | } |
---|
[442] | 1693 | |
---|
| 1694 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 1695 | { |
---|
| 1696 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 1697 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1698 | if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed()) |
---|
| 1699 | #else |
---|
| 1700 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
| 1701 | #endif |
---|
| 1702 | { |
---|
[466] | 1703 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), |
---|
[442] | 1704 | m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() ); |
---|
| 1705 | } |
---|
| 1706 | } |
---|
[313] | 1707 | } |
---|
| 1708 | } |
---|
| 1709 | |
---|
| 1710 | Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
| 1711 | { |
---|
[442] | 1712 | if (m_isField) |
---|
| 1713 | { |
---|
| 1714 | //Reinterlace fields |
---|
| 1715 | Int i; |
---|
| 1716 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
[313] | 1717 | |
---|
[442] | 1718 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1719 | for ( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ ) |
---|
| 1720 | #else |
---|
| 1721 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
| 1722 | #endif |
---|
[466] | 1723 | { |
---|
[442] | 1724 | const AccessUnit& auTop = *(iterBitstream++); |
---|
| 1725 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
| 1726 | rateStatsAccum(auTop, statsTop); |
---|
[313] | 1727 | |
---|
[442] | 1728 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
| 1729 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
| 1730 | rateStatsAccum(auBottom, statsBottom); |
---|
| 1731 | } |
---|
| 1732 | } |
---|
| 1733 | else |
---|
| 1734 | { |
---|
| 1735 | Int i; |
---|
| 1736 | |
---|
| 1737 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
| 1738 | |
---|
[313] | 1739 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
[442] | 1740 | for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ ) |
---|
[313] | 1741 | #else |
---|
[442] | 1742 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
[313] | 1743 | #endif |
---|
[442] | 1744 | { |
---|
| 1745 | const AccessUnit& au = *(iterBitstream++); |
---|
| 1746 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
| 1747 | rateStatsAccum(au, stats); |
---|
| 1748 | } |
---|
[313] | 1749 | } |
---|
| 1750 | } |
---|
| 1751 | |
---|
| 1752 | #else // SVC_EXTENSION |
---|
| 1753 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
| 1754 | { |
---|
| 1755 | assert( m_iGOPSize > 0 ); |
---|
| 1756 | |
---|
| 1757 | // org. buffer |
---|
| 1758 | if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize ) |
---|
| 1759 | { |
---|
| 1760 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
| 1761 | |
---|
| 1762 | } |
---|
| 1763 | else |
---|
| 1764 | { |
---|
| 1765 | rpcPicYuvRec = new TComPicYuv; |
---|
| 1766 | |
---|
| 1767 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 1768 | |
---|
| 1769 | } |
---|
| 1770 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
| 1771 | } |
---|
| 1772 | |
---|
| 1773 | Void TAppEncTop::xDeleteBuffer( ) |
---|
| 1774 | { |
---|
| 1775 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
| 1776 | |
---|
| 1777 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
| 1778 | |
---|
| 1779 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 1780 | { |
---|
| 1781 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 1782 | pcPicYuvRec->destroy(); |
---|
| 1783 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
| 1784 | } |
---|
| 1785 | |
---|
| 1786 | } |
---|
| 1787 | |
---|
| 1788 | /** \param iNumEncoded number of encoded frames |
---|
| 1789 | */ |
---|
| 1790 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
| 1791 | { |
---|
[442] | 1792 | if (m_isField) |
---|
| 1793 | { |
---|
| 1794 | //Reinterlace fields |
---|
| 1795 | Int i; |
---|
| 1796 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
| 1797 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
[313] | 1798 | |
---|
[442] | 1799 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 1800 | { |
---|
| 1801 | --iterPicYuvRec; |
---|
| 1802 | } |
---|
[313] | 1803 | |
---|
[442] | 1804 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
| 1805 | { |
---|
| 1806 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
| 1807 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
| 1808 | |
---|
| 1809 | if (m_pchReconFile) |
---|
| 1810 | { |
---|
| 1811 | m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst ); |
---|
| 1812 | } |
---|
| 1813 | |
---|
| 1814 | const AccessUnit& auTop = *(iterBitstream++); |
---|
| 1815 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
| 1816 | rateStatsAccum(auTop, statsTop); |
---|
| 1817 | |
---|
| 1818 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
| 1819 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
| 1820 | rateStatsAccum(auBottom, statsBottom); |
---|
| 1821 | } |
---|
| 1822 | } |
---|
| 1823 | else |
---|
[313] | 1824 | { |
---|
[442] | 1825 | Int i; |
---|
[313] | 1826 | |
---|
[442] | 1827 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
| 1828 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
| 1829 | |
---|
| 1830 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
[313] | 1831 | { |
---|
[442] | 1832 | --iterPicYuvRec; |
---|
| 1833 | } |
---|
| 1834 | |
---|
| 1835 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 1836 | { |
---|
| 1837 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 1838 | if (m_pchReconFile) |
---|
| 1839 | { |
---|
| 1840 | #if SYNTAX_OUTPUT |
---|
| 1841 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
[313] | 1842 | #endif |
---|
[442] | 1843 | } |
---|
| 1844 | |
---|
| 1845 | const AccessUnit& au = *(iterBitstream++); |
---|
| 1846 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
| 1847 | rateStatsAccum(au, stats); |
---|
[313] | 1848 | } |
---|
| 1849 | } |
---|
| 1850 | } |
---|
| 1851 | #endif |
---|
| 1852 | |
---|
| 1853 | /** |
---|
| 1854 | * |
---|
| 1855 | */ |
---|
| 1856 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
| 1857 | { |
---|
| 1858 | AccessUnit::const_iterator it_au = au.begin(); |
---|
| 1859 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
| 1860 | |
---|
| 1861 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
| 1862 | { |
---|
| 1863 | switch ((*it_au)->m_nalUnitType) |
---|
| 1864 | { |
---|
| 1865 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
| 1866 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
| 1867 | case NAL_UNIT_CODED_SLICE_TLA_R: |
---|
| 1868 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
| 1869 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
| 1870 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
| 1871 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
| 1872 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
| 1873 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
| 1874 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
| 1875 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
| 1876 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
| 1877 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
| 1878 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
| 1879 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
| 1880 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
| 1881 | case NAL_UNIT_VPS: |
---|
| 1882 | case NAL_UNIT_SPS: |
---|
| 1883 | case NAL_UNIT_PPS: |
---|
| 1884 | m_essentialBytes += *it_stats; |
---|
| 1885 | break; |
---|
| 1886 | default: |
---|
| 1887 | break; |
---|
| 1888 | } |
---|
| 1889 | |
---|
| 1890 | m_totalBytes += *it_stats; |
---|
| 1891 | } |
---|
| 1892 | } |
---|
| 1893 | |
---|
| 1894 | void TAppEncTop::printRateSummary() |
---|
| 1895 | { |
---|
| 1896 | #if SVC_EXTENSION |
---|
| 1897 | Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate(); |
---|
| 1898 | #else |
---|
| 1899 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
| 1900 | #endif |
---|
| 1901 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
| 1902 | #if VERBOSE_RATE |
---|
| 1903 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
| 1904 | #endif |
---|
| 1905 | } |
---|
| 1906 | |
---|
| 1907 | //! \} |
---|