| 1 | /* The copyright in this software is being made available under the BSD |
|---|
| 2 | * License, included below. This software may be subject to other third party |
|---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
|---|
| 4 | * granted under this license. |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) 2010-2015, 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 | #if !SVC_EXTENSION |
|---|
| 45 | #include <iomanip> |
|---|
| 46 | #endif |
|---|
| 47 | |
|---|
| 48 | #include "TAppEncTop.h" |
|---|
| 49 | #include "TLibEncoder/AnnexBwrite.h" |
|---|
| 50 | |
|---|
| 51 | using namespace std; |
|---|
| 52 | |
|---|
| 53 | //! \ingroup TAppEncoder |
|---|
| 54 | //! \{ |
|---|
| 55 | |
|---|
| 56 | // ==================================================================================================================== |
|---|
| 57 | // Constructor / destructor / initialization / destroy |
|---|
| 58 | // ==================================================================================================================== |
|---|
| 59 | |
|---|
| 60 | TAppEncTop::TAppEncTop() |
|---|
| 61 | { |
|---|
| 62 | m_iFrameRcvd = 0; |
|---|
| 63 | m_totalBytes = 0; |
|---|
| 64 | m_essentialBytes = 0; |
|---|
| 65 | #if SVC_EXTENSION |
|---|
| 66 | memset( m_apcTVideoIOYuvInputFile, 0, sizeof(m_apcTVideoIOYuvInputFile) ); |
|---|
| 67 | memset( m_apcTVideoIOYuvReconFile, 0, sizeof(m_apcTVideoIOYuvReconFile) ); |
|---|
| 68 | memset( m_apcTEncTop, 0, sizeof(m_apcTEncTop) ); |
|---|
| 69 | #endif |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | TAppEncTop::~TAppEncTop() |
|---|
| 73 | { |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | Void TAppEncTop::xInitLibCfg() |
|---|
| 77 | { |
|---|
| 78 | #if SVC_EXTENSION |
|---|
| 79 | TComVPS& vps = *m_apcTEncTop[0]->getVPS(); |
|---|
| 80 | |
|---|
| 81 | vps.setMaxTLayers ( m_apcLayerCfg[0]->m_maxTempLayer ); |
|---|
| 82 | if (m_apcLayerCfg[0]->m_maxTempLayer == 1) |
|---|
| 83 | #else |
|---|
| 84 | TComVPS vps; |
|---|
| 85 | |
|---|
| 86 | vps.setMaxTLayers ( m_maxTempLayer ); |
|---|
| 87 | if (m_maxTempLayer == 1) |
|---|
| 88 | #endif |
|---|
| 89 | { |
|---|
| 90 | vps.setTemporalNestingFlag(true); |
|---|
| 91 | } |
|---|
| 92 | vps.setMaxLayers ( 1 ); |
|---|
| 93 | for(Int i = 0; i < MAX_TLAYER; i++) |
|---|
| 94 | { |
|---|
| 95 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
|---|
| 96 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | #if !SVC_EXTENSION |
|---|
| 100 | m_cTEncTop.setVPS(&vps); |
|---|
| 101 | #endif |
|---|
| 102 | |
|---|
| 103 | #if SVC_EXTENSION |
|---|
| 104 | vps.setVpsPocLsbAlignedFlag(false); |
|---|
| 105 | |
|---|
| 106 | Int maxRepFormatIdx = -1; |
|---|
| 107 | Int formatIdx = -1; |
|---|
| 108 | for(UInt layer=0; layer < m_numLayers; layer++) |
|---|
| 109 | { |
|---|
| 110 | // Auto generation of the format index |
|---|
| 111 | if( m_apcLayerCfg[layer]->getRepFormatIdx() == -1 ) |
|---|
| 112 | { |
|---|
| 113 | Bool found = false; |
|---|
| 114 | for( UInt idx = 0; idx < layer; idx++ ) |
|---|
| 115 | { |
|---|
| 116 | if( m_apcLayerCfg[layer]->m_iSourceWidth == m_apcLayerCfg[idx]->m_iSourceWidth && m_apcLayerCfg[layer]->m_iSourceHeight == m_apcLayerCfg[idx]->m_iSourceHeight |
|---|
| 117 | #if AUXILIARY_PICTURES |
|---|
| 118 | && m_apcLayerCfg[layer]->m_chromaFormatIDC == m_apcLayerCfg[idx]->m_chromaFormatIDC |
|---|
| 119 | #endif |
|---|
| 120 | && m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA] == m_apcLayerCfg[idx]->m_internalBitDepth[CHANNEL_TYPE_LUMA] && m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA] == m_apcLayerCfg[idx]->m_internalBitDepth[CHANNEL_TYPE_CHROMA] |
|---|
| 121 | ) |
|---|
| 122 | { |
|---|
| 123 | found = true; |
|---|
| 124 | break; |
|---|
| 125 | } |
|---|
| 126 | } |
|---|
| 127 | if( !found ) |
|---|
| 128 | { |
|---|
| 129 | formatIdx++; |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | m_apcLayerCfg[layer]->setRepFormatIdx( formatIdx ); |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | assert( m_apcLayerCfg[layer]->getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" ); |
|---|
| 136 | |
|---|
| 137 | vps.setVpsRepFormatIdx( layer, m_apcLayerCfg[layer]->getRepFormatIdx() ); |
|---|
| 138 | |
|---|
| 139 | maxRepFormatIdx = std::max( m_apcLayerCfg[layer]->getRepFormatIdx(), maxRepFormatIdx ); |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | assert( vps.getVpsRepFormatIdx( 0 ) == 0 ); // Base layer should point to the first one. |
|---|
| 143 | |
|---|
| 144 | Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1]; |
|---|
| 145 | |
|---|
| 146 | // Check that all the indices from 0 to maxRepFormatIdx are used in the VPS |
|---|
| 147 | for(Int i = 0; i <= maxRepFormatIdx; i++) |
|---|
| 148 | { |
|---|
| 149 | mapIdxToLayer[i] = -1; |
|---|
| 150 | UInt layer; |
|---|
| 151 | for(layer=0; layer < m_numLayers; layer++) |
|---|
| 152 | { |
|---|
| 153 | if( vps.getVpsRepFormatIdx(layer) == i ) |
|---|
| 154 | { |
|---|
| 155 | mapIdxToLayer[i] = layer; |
|---|
| 156 | break; |
|---|
| 157 | } |
|---|
| 158 | } |
|---|
| 159 | assert( layer != m_numLayers ); // One of the VPS Rep format indices not set |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | vps.setVpsNumRepFormats ( maxRepFormatIdx + 1 ); |
|---|
| 163 | |
|---|
| 164 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
|---|
| 165 | vps.setRepFormatIdxPresentFlag ( vps.getVpsNumRepFormats() > 1 ? true : false ); |
|---|
| 166 | |
|---|
| 167 | for(UInt idx=0; idx < vps.getVpsNumRepFormats(); idx++) |
|---|
| 168 | { |
|---|
| 169 | RepFormat *repFormat = vps.getVpsRepFormat( idx ); |
|---|
| 170 | repFormat->setChromaAndBitDepthVpsPresentFlag ( true ); |
|---|
| 171 | if (idx==0) |
|---|
| 172 | { |
|---|
| 173 | assert(repFormat->getChromaAndBitDepthVpsPresentFlag() == true); |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | repFormat->setPicWidthVpsInLumaSamples ( m_apcLayerCfg[mapIdxToLayer[idx]]->m_iSourceWidth ); |
|---|
| 177 | repFormat->setPicHeightVpsInLumaSamples ( m_apcLayerCfg[mapIdxToLayer[idx]]->m_iSourceHeight ); |
|---|
| 178 | #if AUXILIARY_PICTURES |
|---|
| 179 | repFormat->setChromaFormatVpsIdc ( m_apcLayerCfg[mapIdxToLayer[idx]]->m_chromaFormatIDC ); |
|---|
| 180 | #else |
|---|
| 181 | repFormat->setChromaFormatVpsIdc ( 1 ); // Need modification to change for each layer - corresponds to 420 |
|---|
| 182 | #endif |
|---|
| 183 | repFormat->setSeparateColourPlaneVpsFlag ( 0 ); // Need modification to change for each layer |
|---|
| 184 | |
|---|
| 185 | repFormat->setBitDepthVpsLuma ( getInternalBitDepth(mapIdxToLayer[idx], CHANNEL_TYPE_LUMA) ); // Need modification to change for each layer |
|---|
| 186 | repFormat->setBitDepthVpsChroma ( getInternalBitDepth(mapIdxToLayer[idx], CHANNEL_TYPE_CHROMA) ); // Need modification to change for each layer |
|---|
| 187 | |
|---|
| 188 | repFormat->getConformanceWindowVps().setWindow ( m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinLeft, |
|---|
| 189 | m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinRight, |
|---|
| 190 | m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinTop, |
|---|
| 191 | m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinBottom ); |
|---|
| 192 | |
|---|
| 193 | m_apcTEncTop[mapIdxToLayer[idx]]->setSkipPictureAtArcSwitch ( m_skipPictureAtArcSwitch ); |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | delete [] mapIdxToLayer; |
|---|
| 197 | |
|---|
| 198 | //Populate PTL in VPS |
|---|
| 199 | for( Int ii = 0; ii < m_numPTLInfo; ii++ ) |
|---|
| 200 | { |
|---|
| 201 | vps.getPTL(ii)->getGeneralPTL()->setLevelIdc(m_levelList[ii]); |
|---|
| 202 | vps.getPTL(ii)->getGeneralPTL()->setTierFlag(m_levelTierList[ii]); |
|---|
| 203 | vps.getPTL(ii)->getGeneralPTL()->setProfileIdc(m_profileList[ii]); |
|---|
| 204 | vps.getPTL(ii)->getGeneralPTL()->setProfileCompatibilityFlag(m_profileCompatibility[ii], 1); |
|---|
| 205 | vps.getPTL(ii)->getGeneralPTL()->setProgressiveSourceFlag(m_progressiveSourceFlagList[ii]); |
|---|
| 206 | vps.getPTL(ii)->getGeneralPTL()->setInterlacedSourceFlag(m_interlacedSourceFlagList[ii]); |
|---|
| 207 | vps.getPTL(ii)->getGeneralPTL()->setNonPackedConstraintFlag(m_nonPackedConstraintFlagList[ii]); |
|---|
| 208 | vps.getPTL(ii)->getGeneralPTL()->setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlagList[ii]); |
|---|
| 209 | } |
|---|
| 210 | vps.setNumProfileTierLevel(m_numPTLInfo); |
|---|
| 211 | |
|---|
| 212 | std::vector<Int> myvector; |
|---|
| 213 | vps.getProfileLevelTierIdx()->resize(m_numOutputLayerSets); |
|---|
| 214 | for( Int ii = 0; ii < m_numOutputLayerSets; ii++ ) |
|---|
| 215 | { |
|---|
| 216 | myvector = m_listOfLayerPTLofOlss[ii]; |
|---|
| 217 | |
|---|
| 218 | for( std::vector<Int>::iterator it = myvector.begin() ; it != myvector.end(); ++it ) |
|---|
| 219 | { |
|---|
| 220 | vps.addProfileLevelTierIdx(ii, it[0]); |
|---|
| 221 | } |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | assert( m_numLayers <= MAX_LAYERS ); |
|---|
| 225 | |
|---|
| 226 | for( UInt layer=0; layer < m_numLayers; layer++ ) |
|---|
| 227 | { |
|---|
| 228 | TEncTop& m_cTEncTop = *m_apcTEncTop[layer]; |
|---|
| 229 | //1 |
|---|
| 230 | m_cTEncTop.setInterLayerWeightedPredFlag ( m_useInterLayerWeightedPred ); |
|---|
| 231 | m_cTEncTop.setMFMEnabledFlag ( layer == 0 ? false : ( m_nonHEVCBaseLayerFlag ? false : true ) && m_apcLayerCfg[layer]->getNumMotionPredRefLayers()); |
|---|
| 232 | |
|---|
| 233 | // set layer ID |
|---|
| 234 | m_cTEncTop.setLayerId ( m_apcLayerCfg[layer]->m_layerId ); |
|---|
| 235 | m_cTEncTop.setNumLayer ( m_numLayers ); |
|---|
| 236 | m_cTEncTop.setLayerEnc ( m_apcTEncTop ); |
|---|
| 237 | |
|---|
| 238 | if( layer < m_numLayers - 1 ) |
|---|
| 239 | { |
|---|
| 240 | m_cTEncTop.setMaxTidIlRefPicsPlus1 ( m_apcLayerCfg[layer]->getMaxTidIlRefPicsPlus1()); |
|---|
| 241 | } |
|---|
| 242 | |
|---|
| 243 | if( layer ) |
|---|
| 244 | { |
|---|
| 245 | UInt prevLayerIdx = 0; |
|---|
| 246 | UInt prevLayerId = 0; |
|---|
| 247 | if (m_apcLayerCfg[layer]->getNumActiveRefLayers() > 0) |
|---|
| 248 | { |
|---|
| 249 | prevLayerIdx = m_apcLayerCfg[layer]->getPredLayerIdx(m_apcLayerCfg[layer]->getNumActiveRefLayers() - 1); |
|---|
| 250 | prevLayerId = m_cTEncTop.getRefLayerId(prevLayerIdx); |
|---|
| 251 | } |
|---|
| 252 | for(Int i = 0; i < MAX_VPS_LAYER_IDX_PLUS1; i++) |
|---|
| 253 | { |
|---|
| 254 | m_cTEncTop.setSamplePredEnabledFlag (i, false); |
|---|
| 255 | m_cTEncTop.setMotionPredEnabledFlag (i, false); |
|---|
| 256 | } |
|---|
| 257 | if(m_apcLayerCfg[layer]->getNumSamplePredRefLayers() == -1) |
|---|
| 258 | { |
|---|
| 259 | // Not included in the configuration file; assume that each layer depends on previous layer |
|---|
| 260 | m_cTEncTop.setNumSamplePredRefLayers (1); // One sample pred ref. layer |
|---|
| 261 | m_cTEncTop.setSamplePredRefLayerId (prevLayerIdx, prevLayerId); // Previous layer |
|---|
| 262 | m_cTEncTop.setSamplePredEnabledFlag (prevLayerIdx, true); |
|---|
| 263 | } |
|---|
| 264 | else |
|---|
| 265 | { |
|---|
| 266 | m_cTEncTop.setNumSamplePredRefLayers ( m_apcLayerCfg[layer]->getNumSamplePredRefLayers() ); |
|---|
| 267 | for( Int i = 0; i < m_cTEncTop.getNumSamplePredRefLayers(); i++ ) |
|---|
| 268 | { |
|---|
| 269 | m_cTEncTop.setSamplePredRefLayerId ( i, m_apcLayerCfg[layer]->getSamplePredRefLayerId(i)); |
|---|
| 270 | } |
|---|
| 271 | } |
|---|
| 272 | if( m_apcLayerCfg[layer]->getNumMotionPredRefLayers() == -1) |
|---|
| 273 | { |
|---|
| 274 | // Not included in the configuration file; assume that each layer depends on previous layer |
|---|
| 275 | m_cTEncTop.setNumMotionPredRefLayers (1); // One motion pred ref. layer |
|---|
| 276 | m_cTEncTop.setMotionPredRefLayerId (prevLayerIdx, prevLayerId); // Previous layer |
|---|
| 277 | m_cTEncTop.setMotionPredEnabledFlag (prevLayerIdx, true); |
|---|
| 278 | } |
|---|
| 279 | else |
|---|
| 280 | { |
|---|
| 281 | m_cTEncTop.setNumMotionPredRefLayers ( m_apcLayerCfg[layer]->getNumMotionPredRefLayers() ); |
|---|
| 282 | for( Int i = 0; i < m_cTEncTop.getNumMotionPredRefLayers(); i++ ) |
|---|
| 283 | { |
|---|
| 284 | m_cTEncTop.setMotionPredRefLayerId ( i, m_apcLayerCfg[layer]->getMotionPredRefLayerId(i)); |
|---|
| 285 | } |
|---|
| 286 | } |
|---|
| 287 | Int numDirectRefLayers = 0; |
|---|
| 288 | |
|---|
| 289 | assert( layer < MAX_LAYERS ); |
|---|
| 290 | |
|---|
| 291 | for (Int i = 0; i < m_apcLayerCfg[layer]->m_layerId; i++) |
|---|
| 292 | { |
|---|
| 293 | Int refLayerId = -1; |
|---|
| 294 | |
|---|
| 295 | for( Int layerIdc = 0; layerIdc < m_cTEncTop.getNumSamplePredRefLayers(); layerIdc++ ) |
|---|
| 296 | { |
|---|
| 297 | if( m_apcLayerCfg[layer]->getSamplePredRefLayerId(layerIdc) == i ) |
|---|
| 298 | { |
|---|
| 299 | refLayerId = i; |
|---|
| 300 | m_cTEncTop.setSamplePredEnabledFlag( numDirectRefLayers, true ); |
|---|
| 301 | break; |
|---|
| 302 | } |
|---|
| 303 | } |
|---|
| 304 | |
|---|
| 305 | for( Int layerIdc = 0; layerIdc < m_cTEncTop.getNumMotionPredRefLayers(); layerIdc++ ) |
|---|
| 306 | { |
|---|
| 307 | if( m_apcLayerCfg[layer]->getMotionPredRefLayerId(layerIdc) == i ) |
|---|
| 308 | { |
|---|
| 309 | refLayerId = i; |
|---|
| 310 | m_cTEncTop.setMotionPredEnabledFlag( numDirectRefLayers, true ); |
|---|
| 311 | break; |
|---|
| 312 | } |
|---|
| 313 | } |
|---|
| 314 | |
|---|
| 315 | if( refLayerId >= 0 ) |
|---|
| 316 | { |
|---|
| 317 | m_cTEncTop.setRefLayerId ( numDirectRefLayers, refLayerId ); |
|---|
| 318 | numDirectRefLayers++; |
|---|
| 319 | } |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | m_cTEncTop.setNumDirectRefLayers ( numDirectRefLayers ); |
|---|
| 323 | |
|---|
| 324 | if(m_apcLayerCfg[layer]->getNumActiveRefLayers() == -1) |
|---|
| 325 | { |
|---|
| 326 | m_cTEncTop.setNumActiveRefLayers ( m_cTEncTop.getNumDirectRefLayers() ); |
|---|
| 327 | for( Int i = 0; i < m_cTEncTop.getNumActiveRefLayers(); i++ ) |
|---|
| 328 | { |
|---|
| 329 | m_cTEncTop.setPredLayerIdx(i, i); |
|---|
| 330 | } |
|---|
| 331 | } |
|---|
| 332 | else |
|---|
| 333 | { |
|---|
| 334 | m_cTEncTop.setNumActiveRefLayers ( m_apcLayerCfg[layer]->getNumActiveRefLayers() ); |
|---|
| 335 | for(Int i = 0; i < m_cTEncTop.getNumActiveRefLayers(); i++) |
|---|
| 336 | { |
|---|
| 337 | m_cTEncTop.setPredLayerIdx ( i, m_apcLayerCfg[layer]->getPredLayerIdx(i)); |
|---|
| 338 | } |
|---|
| 339 | } |
|---|
| 340 | } |
|---|
| 341 | else |
|---|
| 342 | { |
|---|
| 343 | assert( layer == 0 ); |
|---|
| 344 | m_cTEncTop.setNumDirectRefLayers(0); |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | if( layer > 0 ) |
|---|
| 348 | { |
|---|
| 349 | #if AUXILIARY_PICTURES |
|---|
| 350 | Int subWidthC = ( m_apcLayerCfg[layer]->m_chromaFormatIDC == CHROMA_420 || m_apcLayerCfg[layer]->m_chromaFormatIDC == CHROMA_422 ) ? 2 : 1; |
|---|
| 351 | Int subHeightC = ( m_apcLayerCfg[layer]->m_chromaFormatIDC == CHROMA_420 ) ? 2 : 1; |
|---|
| 352 | #else |
|---|
| 353 | Int subWidthC = 2; |
|---|
| 354 | Int subHeightC = 2; |
|---|
| 355 | #endif |
|---|
| 356 | m_cTEncTop.setNumRefLayerLocationOffsets ( m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets ); |
|---|
| 357 | for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++) |
|---|
| 358 | { |
|---|
| 359 | m_cTEncTop.setRefLocationOffsetLayerId ( i, m_apcLayerCfg[layer]->m_refLocationOffsetLayerId[i]); |
|---|
| 360 | m_cTEncTop.setScaledRefLayerOffsetPresentFlag ( i, m_apcLayerCfg[layer]->m_scaledRefLayerOffsetPresentFlag[i] ); |
|---|
| 361 | m_cTEncTop.getScaledRefLayerWindow(i).setWindow ( subWidthC * m_apcLayerCfg[layer]->m_scaledRefLayerLeftOffset[i], subWidthC * m_apcLayerCfg[layer]->m_scaledRefLayerRightOffset[i], |
|---|
| 362 | subHeightC * m_apcLayerCfg[layer]->m_scaledRefLayerTopOffset[i], subHeightC * m_apcLayerCfg[layer]->m_scaledRefLayerBottomOffset[i]); |
|---|
| 363 | |
|---|
| 364 | Int rlSubWidthC = ( m_apcLayerCfg[i]->m_chromaFormatIDC == CHROMA_420 || m_apcLayerCfg[i]->m_chromaFormatIDC == CHROMA_422 ) ? 2 : 1; |
|---|
| 365 | Int rlSubHeightC = ( m_apcLayerCfg[i]->m_chromaFormatIDC == CHROMA_420 ) ? 2 : 1; |
|---|
| 366 | |
|---|
| 367 | m_cTEncTop.setRefRegionOffsetPresentFlag ( i, m_apcLayerCfg[layer]->m_refRegionOffsetPresentFlag[i] ); |
|---|
| 368 | m_cTEncTop.getRefLayerWindow(i).setWindow ( rlSubWidthC * m_apcLayerCfg[layer]->m_refRegionLeftOffset[i], rlSubWidthC * m_apcLayerCfg[layer]->m_refRegionRightOffset[i], |
|---|
| 369 | rlSubHeightC * m_apcLayerCfg[layer]->m_refRegionTopOffset[i], rlSubHeightC * m_apcLayerCfg[layer]->m_refRegionBottomOffset[i]); |
|---|
| 370 | m_cTEncTop.setResamplePhaseSetPresentFlag ( i, m_apcLayerCfg[layer]->m_resamplePhaseSetPresentFlag[i] ); |
|---|
| 371 | m_cTEncTop.setPhaseHorLuma ( i, m_apcLayerCfg[layer]->m_phaseHorLuma[i] ); |
|---|
| 372 | m_cTEncTop.setPhaseVerLuma ( i, m_apcLayerCfg[layer]->m_phaseVerLuma[i] ); |
|---|
| 373 | m_cTEncTop.setPhaseHorChroma ( i, m_apcLayerCfg[layer]->m_phaseHorChroma[i] ); |
|---|
| 374 | m_cTEncTop.setPhaseVerChroma ( i, m_apcLayerCfg[layer]->m_phaseVerChroma[i] ); |
|---|
| 375 | } |
|---|
| 376 | } |
|---|
| 377 | |
|---|
| 378 | m_cTEncTop.setElRapSliceTypeB ( m_elRapSliceBEnabled ); |
|---|
| 379 | |
|---|
| 380 | m_cTEncTop.setAdaptiveResolutionChange ( m_adaptiveResolutionChange ); |
|---|
| 381 | m_cTEncTop.setLayerSwitchOffBegin ( m_apcLayerCfg[layer]->m_layerSwitchOffBegin ); |
|---|
| 382 | m_cTEncTop.setLayerSwitchOffEnd ( m_apcLayerCfg[layer]->m_layerSwitchOffEnd ); |
|---|
| 383 | m_cTEncTop.setChromaFormatIDC ( m_apcLayerCfg[layer]->m_chromaFormatIDC ); |
|---|
| 384 | m_cTEncTop.setAltOuputLayerFlag ( m_altOutputLayerFlag ); |
|---|
| 385 | m_cTEncTop.setCrossLayerBLAFlag ( m_crossLayerBLAFlag ); |
|---|
| 386 | #if CGS_3D_ASYMLUT |
|---|
| 387 | m_cTEncTop.setCGSFlag ( layer == 0 ? 0 : m_nCGSFlag ); |
|---|
| 388 | m_cTEncTop.setCGSMaxOctantDepth ( m_nCGSMaxOctantDepth ); |
|---|
| 389 | m_cTEncTop.setCGSMaxYPartNumLog2 ( m_nCGSMaxYPartNumLog2 ); |
|---|
| 390 | m_cTEncTop.setCGSLUTBit ( m_nCGSLUTBit ); |
|---|
| 391 | m_cTEncTop.setCGSAdaptChroma ( m_nCGSAdaptiveChroma ); |
|---|
| 392 | #if R0179_ENC_OPT_3DLUT_SIZE |
|---|
| 393 | m_cTEncTop.setCGSLutSizeRDO ( m_nCGSLutSizeRDO ); |
|---|
| 394 | #endif |
|---|
| 395 | #endif |
|---|
| 396 | m_cTEncTop.setNumAddLayerSets ( m_numAddLayerSets ); |
|---|
| 397 | |
|---|
| 398 | #if FAST_INTRA_SHVC |
|---|
| 399 | m_cTEncTop.setUseFastIntraScalable ( m_useFastIntraScalable ); |
|---|
| 400 | #endif |
|---|
| 401 | |
|---|
| 402 | #if P0123_ALPHA_CHANNEL_SEI |
|---|
| 403 | m_cTEncTop.setAlphaSEIEnabled ( m_alphaSEIEnabled ); |
|---|
| 404 | m_cTEncTop.setAlphaCancelFlag ( m_alphaCancelFlag ); |
|---|
| 405 | m_cTEncTop.setAlphaUseIdc ( m_alphaUseIdc ); |
|---|
| 406 | m_cTEncTop.setAlphaBitDepthMinus8 ( m_alphaBitDepthMinus8 ); |
|---|
| 407 | m_cTEncTop.setAlphaTransparentValue ( m_alphaTransparentValue ); |
|---|
| 408 | m_cTEncTop.setAlphaOpaqueValue ( m_alphaOpaqueValue ); |
|---|
| 409 | m_cTEncTop.setAlphaIncrementFlag ( m_alphaIncrementFlag ); |
|---|
| 410 | m_cTEncTop.setAlphaClipFlag ( m_alphaClipFlag ); |
|---|
| 411 | m_cTEncTop.setAlphaClipTypeFlag ( m_alphaClipTypeFlag ); |
|---|
| 412 | #endif |
|---|
| 413 | #if Q0096_OVERLAY_SEI |
|---|
| 414 | m_cTEncTop.setOverlaySEIEnabled ( m_overlaySEIEnabled ); |
|---|
| 415 | m_cTEncTop.setOverlaySEICancelFlag ( m_overlayInfoCancelFlag ); |
|---|
| 416 | m_cTEncTop.setOverlaySEIContentAuxIdMinus128 ( m_overlayContentAuxIdMinus128 ); |
|---|
| 417 | m_cTEncTop.setOverlaySEILabelAuxIdMinus128 ( m_overlayLabelAuxIdMinus128 ); |
|---|
| 418 | m_cTEncTop.setOverlaySEIAlphaAuxIdMinus128 ( m_overlayAlphaAuxIdMinus128 ); |
|---|
| 419 | m_cTEncTop.setOverlaySEIElementLabelValueLengthMinus8 ( m_overlayElementLabelValueLengthMinus8 ); |
|---|
| 420 | m_cTEncTop.setOverlaySEINumOverlaysMinus1 ( m_numOverlaysMinus1 ); |
|---|
| 421 | m_cTEncTop.setOverlaySEIIdx ( m_overlayIdx ); |
|---|
| 422 | m_cTEncTop.setOverlaySEILanguagePresentFlag ( m_overlayLanguagePresentFlag ); |
|---|
| 423 | m_cTEncTop.setOverlaySEIContentLayerId ( m_overlayContentLayerId ); |
|---|
| 424 | m_cTEncTop.setOverlaySEILabelPresentFlag ( m_overlayLabelPresentFlag ); |
|---|
| 425 | m_cTEncTop.setOverlaySEILabelLayerId ( m_overlayLabelLayerId ); |
|---|
| 426 | m_cTEncTop.setOverlaySEIAlphaPresentFlag ( m_overlayAlphaPresentFlag ); |
|---|
| 427 | m_cTEncTop.setOverlaySEIAlphaLayerId ( m_overlayAlphaLayerId ); |
|---|
| 428 | m_cTEncTop.setOverlaySEINumElementsMinus1 ( m_numOverlayElementsMinus1 ); |
|---|
| 429 | m_cTEncTop.setOverlaySEIElementLabelMin ( m_overlayElementLabelMin ); |
|---|
| 430 | m_cTEncTop.setOverlaySEIElementLabelMax ( m_overlayElementLabelMax ); |
|---|
| 431 | m_cTEncTop.setOverlaySEILanguage ( m_overlayLanguage ); |
|---|
| 432 | m_cTEncTop.setOverlaySEIName ( m_overlayName ); |
|---|
| 433 | m_cTEncTop.setOverlaySEIElementName ( m_overlayElementName ); |
|---|
| 434 | m_cTEncTop.setOverlaySEIPersistenceFlag ( m_overlayInfoPersistenceFlag ); |
|---|
| 435 | #endif |
|---|
| 436 | #if Q0189_TMVP_CONSTRAINTS |
|---|
| 437 | m_cTEncTop.setTMVPConstraintsSEIEnabled ( m_TMVPConstraintsSEIEnabled); |
|---|
| 438 | #endif |
|---|
| 439 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
|---|
| 440 | m_cTEncTop.setInterLayerConstrainedTileSetsSEIEnabled ( m_interLayerConstrainedTileSetsSEIEnabled ); |
|---|
| 441 | m_cTEncTop.setIlNumSetsInMessage ( m_ilNumSetsInMessage ); |
|---|
| 442 | m_cTEncTop.setSkippedTileSetPresentFlag ( m_skippedTileSetPresentFlag ); |
|---|
| 443 | m_cTEncTop.setTopLeftTileIndex ( m_topLeftTileIndex ); |
|---|
| 444 | m_cTEncTop.setBottomRightTileIndex ( m_bottomRightTileIndex ); |
|---|
| 445 | m_cTEncTop.setIlcIdc ( m_ilcIdc ); |
|---|
| 446 | #endif |
|---|
| 447 | |
|---|
| 448 | Int& layerPTLIdx = m_apcLayerCfg[layer]->m_layerPTLIdx; |
|---|
| 449 | |
|---|
| 450 | Profile::Name& m_profile = m_profileList[layerPTLIdx]; |
|---|
| 451 | Level::Tier& m_levelTier = m_levelTierList[layerPTLIdx]; |
|---|
| 452 | Level::Name& m_level = m_levelList[layerPTLIdx]; |
|---|
| 453 | UInt& m_bitDepthConstraint = m_apcLayerCfg[layer]->m_bitDepthConstraint; |
|---|
| 454 | ChromaFormat& m_chromaFormatConstraint = m_apcLayerCfg[layer]->m_chromaFormatConstraint; |
|---|
| 455 | Bool& m_intraConstraintFlag = m_apcLayerCfg[layer]->m_intraConstraintFlag; |
|---|
| 456 | Bool& m_onePictureOnlyConstraintFlag = m_apcLayerCfg[layer]->m_onePictureOnlyConstraintFlag; |
|---|
| 457 | Bool& m_lowerBitRateConstraintFlag = m_apcLayerCfg[layer]->m_lowerBitRateConstraintFlag; |
|---|
| 458 | Bool& m_progressiveSourceFlag = m_progressiveSourceFlagList[layerPTLIdx]; |
|---|
| 459 | Bool& m_interlacedSourceFlag = m_interlacedSourceFlagList[layerPTLIdx]; |
|---|
| 460 | Bool& m_nonPackedConstraintFlag = m_nonPackedConstraintFlagList[layerPTLIdx]; |
|---|
| 461 | Bool& m_frameOnlyConstraintFlag = m_frameOnlyConstraintFlagList[layerPTLIdx]; |
|---|
| 462 | |
|---|
| 463 | Int& m_iFrameRate = m_apcLayerCfg[layer]->m_iFrameRate; |
|---|
| 464 | Int& m_iSourceWidth = m_apcLayerCfg[layer]->m_iSourceWidth; |
|---|
| 465 | Int& m_iSourceHeight = m_apcLayerCfg[layer]->m_iSourceHeight; |
|---|
| 466 | Int& m_confWinLeft = m_apcLayerCfg[layer]->m_confWinLeft; |
|---|
| 467 | Int& m_confWinRight = m_apcLayerCfg[layer]->m_confWinRight; |
|---|
| 468 | Int& m_confWinTop = m_apcLayerCfg[layer]->m_confWinTop; |
|---|
| 469 | Int& m_confWinBottom = m_apcLayerCfg[layer]->m_confWinBottom; |
|---|
| 470 | |
|---|
| 471 | Int& m_iIntraPeriod = m_apcLayerCfg[layer]->m_iIntraPeriod; |
|---|
| 472 | Int& m_iQP = m_apcLayerCfg[layer]->m_iQP; |
|---|
| 473 | Int *m_aiPad = m_apcLayerCfg[layer]->m_aiPad; |
|---|
| 474 | |
|---|
| 475 | Int& m_iMaxCuDQPDepth = m_apcLayerCfg[layer]->m_iMaxCuDQPDepth; |
|---|
| 476 | ChromaFormat& m_chromaFormatIDC = m_apcLayerCfg[layer]->m_chromaFormatIDC; |
|---|
| 477 | Int *m_aidQP = m_apcLayerCfg[layer]->m_aidQP; |
|---|
| 478 | |
|---|
| 479 | UInt& m_uiMaxCUWidth = m_apcLayerCfg[layer]->m_uiMaxCUWidth; |
|---|
| 480 | UInt& m_uiMaxCUHeight = m_apcLayerCfg[layer]->m_uiMaxCUHeight; |
|---|
| 481 | UInt& m_uiMaxTotalCUDepth = m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth; |
|---|
| 482 | UInt& m_uiLog2DiffMaxMinCodingBlockSize = m_apcLayerCfg[layer]->m_uiLog2DiffMaxMinCodingBlockSize; |
|---|
| 483 | UInt& m_uiQuadtreeTULog2MaxSize = m_apcLayerCfg[layer]->m_uiQuadtreeTULog2MaxSize; |
|---|
| 484 | UInt& m_uiQuadtreeTULog2MinSize = m_apcLayerCfg[layer]->m_uiQuadtreeTULog2MinSize; |
|---|
| 485 | UInt& m_uiQuadtreeTUMaxDepthInter = m_apcLayerCfg[layer]->m_uiQuadtreeTUMaxDepthInter; |
|---|
| 486 | UInt& m_uiQuadtreeTUMaxDepthIntra = m_apcLayerCfg[layer]->m_uiQuadtreeTUMaxDepthIntra; |
|---|
| 487 | |
|---|
| 488 | Bool& m_entropyCodingSyncEnabledFlag = m_apcLayerCfg[layer]->m_entropyCodingSyncEnabledFlag; |
|---|
| 489 | Bool& m_RCEnableRateControl = m_apcLayerCfg[layer]->m_RCEnableRateControl; |
|---|
| 490 | Int& m_RCTargetBitrate = m_apcLayerCfg[layer]->m_RCTargetBitrate; |
|---|
| 491 | Bool& m_RCKeepHierarchicalBit = m_apcLayerCfg[layer]->m_RCKeepHierarchicalBit; |
|---|
| 492 | Bool& m_RCLCULevelRC = m_apcLayerCfg[layer]->m_RCLCULevelRC; |
|---|
| 493 | Bool& m_RCUseLCUSeparateModel = m_apcLayerCfg[layer]->m_RCUseLCUSeparateModel; |
|---|
| 494 | Int& m_RCInitialQP = m_apcLayerCfg[layer]->m_RCInitialQP; |
|---|
| 495 | Bool& m_RCForceIntraQP = m_apcLayerCfg[layer]->m_RCForceIntraQP; |
|---|
| 496 | |
|---|
| 497 | #if U0132_TARGET_BITS_SATURATION |
|---|
| 498 | Bool& m_RCCpbSaturationEnabled = m_apcLayerCfg[layer]->m_RCCpbSaturationEnabled; |
|---|
| 499 | UInt& m_RCCpbSize = m_apcLayerCfg[layer]->m_RCCpbSize; |
|---|
| 500 | Double& m_RCInitialCpbFullness = m_apcLayerCfg[layer]->m_RCInitialCpbFullness; |
|---|
| 501 | #endif |
|---|
| 502 | |
|---|
| 503 | ScalingListMode& m_useScalingListId = m_apcLayerCfg[layer]->m_useScalingListId; |
|---|
| 504 | string& m_scalingListFileName = m_apcLayerCfg[layer]->m_scalingListFileName; |
|---|
| 505 | Bool& m_bUseSAO = m_apcLayerCfg[layer]->m_bUseSAO; |
|---|
| 506 | |
|---|
| 507 | GOPEntry* m_GOPList = m_apcLayerCfg[layer]->m_GOPList; |
|---|
| 508 | Int& m_extraRPSs = m_apcLayerCfg[layer]->m_extraRPSs; |
|---|
| 509 | Int& m_maxTempLayer = m_apcLayerCfg[layer]->m_maxTempLayer; |
|---|
| 510 | |
|---|
| 511 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 512 | string& m_colourRemapSEIFileRoot = m_apcLayerCfg[layer]->m_colourRemapSEIFileRoot; |
|---|
| 513 | #endif |
|---|
| 514 | #endif |
|---|
| 515 | |
|---|
| 516 | m_cTEncTop.setProfile ( m_profile); |
|---|
| 517 | m_cTEncTop.setLevel ( m_levelTier, m_level); |
|---|
| 518 | m_cTEncTop.setProgressiveSourceFlag ( m_progressiveSourceFlag); |
|---|
| 519 | m_cTEncTop.setInterlacedSourceFlag ( m_interlacedSourceFlag); |
|---|
| 520 | m_cTEncTop.setNonPackedConstraintFlag ( m_nonPackedConstraintFlag); |
|---|
| 521 | m_cTEncTop.setFrameOnlyConstraintFlag ( m_frameOnlyConstraintFlag); |
|---|
| 522 | m_cTEncTop.setBitDepthConstraintValue ( m_bitDepthConstraint ); |
|---|
| 523 | m_cTEncTop.setChromaFormatConstraintValue ( m_chromaFormatConstraint ); |
|---|
| 524 | m_cTEncTop.setIntraConstraintFlag ( m_intraConstraintFlag ); |
|---|
| 525 | m_cTEncTop.setOnePictureOnlyConstraintFlag ( m_onePictureOnlyConstraintFlag ); |
|---|
| 526 | m_cTEncTop.setLowerBitRateConstraintFlag ( m_lowerBitRateConstraintFlag ); |
|---|
| 527 | |
|---|
| 528 | m_cTEncTop.setPrintMSEBasedSequencePSNR ( m_printMSEBasedSequencePSNR); |
|---|
| 529 | m_cTEncTop.setPrintFrameMSE ( m_printFrameMSE); |
|---|
| 530 | m_cTEncTop.setPrintSequenceMSE ( m_printSequenceMSE); |
|---|
| 531 | m_cTEncTop.setCabacZeroWordPaddingEnabled ( m_cabacZeroWordPaddingEnabled ); |
|---|
| 532 | |
|---|
| 533 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
|---|
| 534 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
|---|
| 535 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
|---|
| 536 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
|---|
| 537 | m_cTEncTop.setConformanceWindow ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
|---|
| 538 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
|---|
| 539 | |
|---|
| 540 | //====== Coding Structure ======== |
|---|
| 541 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod ); |
|---|
| 542 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
|---|
| 543 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
|---|
| 544 | m_cTEncTop.setGopList ( m_GOPList ); |
|---|
| 545 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
|---|
| 546 | for(Int i = 0; i < MAX_TLAYER; i++) |
|---|
| 547 | { |
|---|
| 548 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
|---|
| 549 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
|---|
| 550 | } |
|---|
| 551 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
|---|
| 552 | { |
|---|
| 553 | m_cTEncTop.setLambdaModifier ( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
|---|
| 554 | } |
|---|
| 555 | m_cTEncTop.setIntraLambdaModifier ( m_adIntraLambdaModifier ); |
|---|
| 556 | m_cTEncTop.setIntraQpFactor ( m_dIntraQpFactor ); |
|---|
| 557 | |
|---|
| 558 | m_cTEncTop.setQP ( m_iQP ); |
|---|
| 559 | |
|---|
| 560 | m_cTEncTop.setPad ( m_aiPad ); |
|---|
| 561 | |
|---|
| 562 | m_cTEncTop.setAccessUnitDelimiter ( m_AccessUnitDelimiter ); |
|---|
| 563 | |
|---|
| 564 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
|---|
| 565 | m_cTEncTop.setUseAMP( m_enableAMP ); |
|---|
| 566 | |
|---|
| 567 | //===== Slice ======== |
|---|
| 568 | |
|---|
| 569 | //====== Loop/Deblock Filter ======== |
|---|
| 570 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
|---|
| 571 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
|---|
| 572 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
|---|
| 573 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
|---|
| 574 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
|---|
| 575 | |
|---|
| 576 | //====== Motion search ======== |
|---|
| 577 | m_cTEncTop.setDisableIntraPUsInInterSlices ( m_bDisableIntraPUsInInterSlices ); |
|---|
| 578 | m_cTEncTop.setMotionEstimationSearchMethod ( m_motionEstimationSearchMethod ); |
|---|
| 579 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
|---|
| 580 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
|---|
| 581 | m_cTEncTop.setClipForBiPredMeEnabled ( m_bClipForBiPredMeEnabled ); |
|---|
| 582 | m_cTEncTop.setFastMEAssumingSmootherMVEnabled ( m_bFastMEAssumingSmootherMVEnabled ); |
|---|
| 583 | m_cTEncTop.setMinSearchWindow ( m_minSearchWindow ); |
|---|
| 584 | m_cTEncTop.setRestrictMESampling ( m_bRestrictMESampling ); |
|---|
| 585 | |
|---|
| 586 | //====== Quality control ======== |
|---|
| 587 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
|---|
| 588 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
|---|
| 589 | m_cTEncTop.setDiffCuChromaQpOffsetDepth ( m_diffCuChromaQpOffsetDepth ); |
|---|
| 590 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
|---|
| 591 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
|---|
| 592 | |
|---|
| 593 | m_cTEncTop.setChromaFormatIdc ( m_chromaFormatIDC ); |
|---|
| 594 | |
|---|
| 595 | #if ADAPTIVE_QP_SELECTION |
|---|
| 596 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
|---|
| 597 | #endif |
|---|
| 598 | |
|---|
| 599 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
|---|
| 600 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
|---|
| 601 | m_cTEncTop.setExtendedPrecisionProcessingFlag ( m_extendedPrecisionProcessingFlag ); |
|---|
| 602 | m_cTEncTop.setHighPrecisionOffsetsEnabledFlag ( m_highPrecisionOffsetsEnabledFlag ); |
|---|
| 603 | |
|---|
| 604 | m_cTEncTop.setWeightedPredictionMethod( m_weightedPredictionMethod ); |
|---|
| 605 | |
|---|
| 606 | //====== Tool list ======== |
|---|
| 607 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
|---|
| 608 | m_cTEncTop.setFastDeltaQp ( m_bFastDeltaQP ); |
|---|
| 609 | m_cTEncTop.setUseASR ( m_bUseASR ); |
|---|
| 610 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
|---|
| 611 | m_cTEncTop.setdQPs ( m_aidQP ); |
|---|
| 612 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
|---|
| 613 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
|---|
| 614 | #if T0196_SELECTIVE_RDOQ |
|---|
| 615 | m_cTEncTop.setUseSelectiveRDOQ ( m_useSelectiveRDOQ ); |
|---|
| 616 | #endif |
|---|
| 617 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
|---|
| 618 | m_cTEncTop.setMaxCUWidth ( m_uiMaxCUWidth ); |
|---|
| 619 | m_cTEncTop.setMaxCUHeight ( m_uiMaxCUHeight ); |
|---|
| 620 | m_cTEncTop.setMaxTotalCUDepth ( m_uiMaxTotalCUDepth ); |
|---|
| 621 | m_cTEncTop.setLog2DiffMaxMinCodingBlockSize ( m_uiLog2DiffMaxMinCodingBlockSize ); |
|---|
| 622 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
|---|
| 623 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
|---|
| 624 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
|---|
| 625 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
|---|
| 626 | m_cTEncTop.setFastInterSearchMode ( m_fastInterSearchMode ); |
|---|
| 627 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
|---|
| 628 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
|---|
| 629 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
|---|
| 630 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
|---|
| 631 | m_cTEncTop.setCrossComponentPredictionEnabledFlag ( m_crossComponentPredictionEnabledFlag ); |
|---|
| 632 | m_cTEncTop.setUseReconBasedCrossCPredictionEstimate ( m_reconBasedCrossCPredictionEstimate ); |
|---|
| 633 | m_cTEncTop.setLog2SaoOffsetScale ( CHANNEL_TYPE_LUMA , m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA] ); |
|---|
| 634 | m_cTEncTop.setLog2SaoOffsetScale ( CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] ); |
|---|
| 635 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
|---|
| 636 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
|---|
| 637 | m_cTEncTop.setTransformSkipRotationEnabledFlag ( m_transformSkipRotationEnabledFlag ); |
|---|
| 638 | m_cTEncTop.setTransformSkipContextEnabledFlag ( m_transformSkipContextEnabledFlag ); |
|---|
| 639 | m_cTEncTop.setPersistentRiceAdaptationEnabledFlag ( m_persistentRiceAdaptationEnabledFlag ); |
|---|
| 640 | m_cTEncTop.setCabacBypassAlignmentEnabledFlag ( m_cabacBypassAlignmentEnabledFlag ); |
|---|
| 641 | m_cTEncTop.setLog2MaxTransformSkipBlockSize ( m_log2MaxTransformSkipBlockSize ); |
|---|
| 642 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
|---|
| 643 | { |
|---|
| 644 | m_cTEncTop.setRdpcmEnabledFlag ( RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]); |
|---|
| 645 | } |
|---|
| 646 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
|---|
| 647 | m_cTEncTop.setFastUDIUseMPMEnabled ( m_bFastUDIUseMPMEnabled ); |
|---|
| 648 | m_cTEncTop.setFastMEForGenBLowDelayEnabled ( m_bFastMEForGenBLowDelayEnabled ); |
|---|
| 649 | m_cTEncTop.setUseBLambdaForNonKeyLowDelayPictures ( m_bUseBLambdaForNonKeyLowDelayPictures ); |
|---|
| 650 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
|---|
| 651 | m_cTEncTop.setUsePCM ( m_usePCM ); |
|---|
| 652 | |
|---|
| 653 | // set internal bit-depth and constants |
|---|
| 654 | for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++) |
|---|
| 655 | { |
|---|
| 656 | #if SVC_EXTENSION |
|---|
| 657 | m_cTEncTop.setBitDepth((ChannelType)channelType, m_apcLayerCfg[layer]->m_internalBitDepth[channelType]); |
|---|
| 658 | m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_apcLayerCfg[layer]->m_MSBExtendedBitDepth[channelType] : m_apcLayerCfg[layer]->m_internalBitDepth[channelType]); |
|---|
| 659 | #else |
|---|
| 660 | m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]); |
|---|
| 661 | m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]); |
|---|
| 662 | #endif |
|---|
| 663 | } |
|---|
| 664 | |
|---|
| 665 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
|---|
| 666 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
|---|
| 667 | |
|---|
| 668 | |
|---|
| 669 | //====== Weighted Prediction ======== |
|---|
| 670 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
|---|
| 671 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
|---|
| 672 | |
|---|
| 673 | //====== Parallel Merge Estimation ======== |
|---|
| 674 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
|---|
| 675 | |
|---|
| 676 | //====== Slice ======== |
|---|
| 677 | m_cTEncTop.setSliceMode ( m_sliceMode ); |
|---|
| 678 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
|---|
| 679 | |
|---|
| 680 | //====== Dependent Slice ======== |
|---|
| 681 | m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode ); |
|---|
| 682 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
|---|
| 683 | |
|---|
| 684 | if(m_sliceMode == NO_SLICES ) |
|---|
| 685 | { |
|---|
| 686 | m_bLFCrossSliceBoundaryFlag = true; |
|---|
| 687 | } |
|---|
| 688 | m_cTEncTop.setLFCrossSliceBoundaryFlag ( m_bLFCrossSliceBoundaryFlag ); |
|---|
| 689 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
|---|
| 690 | m_cTEncTop.setTestSAODisableAtPictureLevel ( m_bTestSAODisableAtPictureLevel ); |
|---|
| 691 | m_cTEncTop.setSaoEncodingRate ( m_saoEncodingRate ); |
|---|
| 692 | m_cTEncTop.setSaoEncodingRateChroma ( m_saoEncodingRateChroma ); |
|---|
| 693 | m_cTEncTop.setMaxNumOffsetsPerPic ( m_maxNumOffsetsPerPic); |
|---|
| 694 | |
|---|
| 695 | m_cTEncTop.setSaoCtuBoundary ( m_saoCtuBoundary); |
|---|
| 696 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
|---|
| 697 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
|---|
| 698 | |
|---|
| 699 | m_cTEncTop.setIntraSmoothingDisabledFlag (!m_enableIntraReferenceSmoothing ); |
|---|
| 700 | m_cTEncTop.setDecodedPictureHashSEIType ( m_decodedPictureHashSEIType ); |
|---|
| 701 | m_cTEncTop.setRecoveryPointSEIEnabled ( m_recoveryPointSEIEnabled ); |
|---|
| 702 | m_cTEncTop.setBufferingPeriodSEIEnabled ( m_bufferingPeriodSEIEnabled ); |
|---|
| 703 | m_cTEncTop.setPictureTimingSEIEnabled ( m_pictureTimingSEIEnabled ); |
|---|
| 704 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
|---|
| 705 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
|---|
| 706 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
|---|
| 707 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
|---|
| 708 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
|---|
| 709 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
|---|
| 710 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
|---|
| 711 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
|---|
| 712 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
|---|
| 713 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
|---|
| 714 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
|---|
| 715 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
|---|
| 716 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
|---|
| 717 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
|---|
| 718 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
|---|
| 719 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
|---|
| 720 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
|---|
| 721 | m_cTEncTop.setTMISEIExposureIndexIdc ( m_exposureIndexIdc ); |
|---|
| 722 | m_cTEncTop.setTMISEIExposureIndexValue ( m_exposureIndexValue ); |
|---|
| 723 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
|---|
| 724 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
|---|
| 725 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
|---|
| 726 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
|---|
| 727 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
|---|
| 728 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
|---|
| 729 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
|---|
| 730 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
|---|
| 731 | m_cTEncTop.setChromaResamplingFilterHintEnabled ( m_chromaResamplingFilterSEIenabled ); |
|---|
| 732 | m_cTEncTop.setChromaResamplingHorFilterIdc ( m_chromaResamplingHorFilterIdc ); |
|---|
| 733 | m_cTEncTop.setChromaResamplingVerFilterIdc ( m_chromaResamplingVerFilterIdc ); |
|---|
| 734 | m_cTEncTop.setFramePackingArrangementSEIEnabled ( m_framePackingSEIEnabled ); |
|---|
| 735 | m_cTEncTop.setFramePackingArrangementSEIType ( m_framePackingSEIType ); |
|---|
| 736 | m_cTEncTop.setFramePackingArrangementSEIId ( m_framePackingSEIId ); |
|---|
| 737 | m_cTEncTop.setFramePackingArrangementSEIQuincunx ( m_framePackingSEIQuincunx ); |
|---|
| 738 | m_cTEncTop.setFramePackingArrangementSEIInterpretation ( m_framePackingSEIInterpretation ); |
|---|
| 739 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEIEnabled ( m_segmentedRectFramePackingSEIEnabled ); |
|---|
| 740 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEICancel ( m_segmentedRectFramePackingSEICancel ); |
|---|
| 741 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEIType ( m_segmentedRectFramePackingSEIType ); |
|---|
| 742 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEIPersistence( m_segmentedRectFramePackingSEIPersistence ); |
|---|
| 743 | m_cTEncTop.setDisplayOrientationSEIAngle ( m_displayOrientationSEIAngle ); |
|---|
| 744 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled ( m_temporalLevel0IndexSEIEnabled ); |
|---|
| 745 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled ( m_gradualDecodingRefreshInfoEnabled ); |
|---|
| 746 | m_cTEncTop.setNoDisplaySEITLayer ( m_noDisplaySEITLayer ); |
|---|
| 747 | m_cTEncTop.setDecodingUnitInfoSEIEnabled ( m_decodingUnitInfoSEIEnabled ); |
|---|
| 748 | m_cTEncTop.setSOPDescriptionSEIEnabled ( m_SOPDescriptionSEIEnabled ); |
|---|
| 749 | m_cTEncTop.setScalableNestingSEIEnabled ( m_scalableNestingSEIEnabled ); |
|---|
| 750 | m_cTEncTop.setTMCTSSEIEnabled ( m_tmctsSEIEnabled ); |
|---|
| 751 | m_cTEncTop.setTimeCodeSEIEnabled ( m_timeCodeSEIEnabled ); |
|---|
| 752 | m_cTEncTop.setNumberOfTimeSets ( m_timeCodeSEINumTs ); |
|---|
| 753 | for(Int i = 0; i < m_timeCodeSEINumTs; i++) |
|---|
| 754 | { |
|---|
| 755 | m_cTEncTop.setTimeSet(m_timeSetArray[i], i); |
|---|
| 756 | } |
|---|
| 757 | m_cTEncTop.setKneeSEIEnabled ( m_kneeSEIEnabled ); |
|---|
| 758 | m_cTEncTop.setKneeSEIId ( m_kneeSEIId ); |
|---|
| 759 | m_cTEncTop.setKneeSEICancelFlag ( m_kneeSEICancelFlag ); |
|---|
| 760 | m_cTEncTop.setKneeSEIPersistenceFlag ( m_kneeSEIPersistenceFlag ); |
|---|
| 761 | m_cTEncTop.setKneeSEIInputDrange ( m_kneeSEIInputDrange ); |
|---|
| 762 | m_cTEncTop.setKneeSEIInputDispLuminance ( m_kneeSEIInputDispLuminance ); |
|---|
| 763 | m_cTEncTop.setKneeSEIOutputDrange ( m_kneeSEIOutputDrange ); |
|---|
| 764 | m_cTEncTop.setKneeSEIOutputDispLuminance ( m_kneeSEIOutputDispLuminance ); |
|---|
| 765 | m_cTEncTop.setKneeSEINumKneePointsMinus1 ( m_kneeSEINumKneePointsMinus1 ); |
|---|
| 766 | m_cTEncTop.setKneeSEIInputKneePoint ( m_kneeSEIInputKneePoint ); |
|---|
| 767 | m_cTEncTop.setKneeSEIOutputKneePoint ( m_kneeSEIOutputKneePoint ); |
|---|
| 768 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 769 | m_cTEncTop.setColourRemapInfoSEIFileRoot ( m_colourRemapSEIFileRoot ); |
|---|
| 770 | #endif |
|---|
| 771 | m_cTEncTop.setMasteringDisplaySEI ( m_masteringDisplay ); |
|---|
| 772 | |
|---|
| 773 | m_cTEncTop.setTileUniformSpacingFlag ( m_tileUniformSpacingFlag ); |
|---|
| 774 | m_cTEncTop.setNumColumnsMinus1 ( m_numTileColumnsMinus1 ); |
|---|
| 775 | m_cTEncTop.setNumRowsMinus1 ( m_numTileRowsMinus1 ); |
|---|
| 776 | if(!m_tileUniformSpacingFlag) |
|---|
| 777 | { |
|---|
| 778 | m_cTEncTop.setColumnWidth ( m_tileColumnWidth ); |
|---|
| 779 | m_cTEncTop.setRowHeight ( m_tileRowHeight ); |
|---|
| 780 | } |
|---|
| 781 | m_cTEncTop.xCheckGSParameters(); |
|---|
| 782 | Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1); |
|---|
| 783 | if(uiTilesCount == 1) |
|---|
| 784 | { |
|---|
| 785 | m_bLFCrossTileBoundaryFlag = true; |
|---|
| 786 | } |
|---|
| 787 | m_cTEncTop.setLFCrossTileBoundaryFlag ( m_bLFCrossTileBoundaryFlag ); |
|---|
| 788 | m_cTEncTop.setEntropyCodingSyncEnabledFlag ( m_entropyCodingSyncEnabledFlag ); |
|---|
| 789 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
|---|
| 790 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
|---|
| 791 | m_cTEncTop.setScalingListFileName ( m_scalingListFileName ); |
|---|
| 792 | m_cTEncTop.setSignHideFlag ( m_signHideFlag); |
|---|
| 793 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
|---|
| 794 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
|---|
| 795 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
|---|
| 796 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
|---|
| 797 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
|---|
| 798 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
|---|
| 799 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
|---|
| 800 | #if U0132_TARGET_BITS_SATURATION |
|---|
| 801 | m_cTEncTop.setCpbSaturationEnabled ( m_RCCpbSaturationEnabled ); |
|---|
| 802 | m_cTEncTop.setCpbSize ( m_RCCpbSize ); |
|---|
| 803 | m_cTEncTop.setInitialCpbFullness ( m_RCInitialCpbFullness ); |
|---|
| 804 | #endif |
|---|
| 805 | m_cTEncTop.setTransquantBypassEnableFlag ( m_TransquantBypassEnableFlag ); |
|---|
| 806 | m_cTEncTop.setCUTransquantBypassFlagForceValue ( m_CUTransquantBypassFlagForce ); |
|---|
| 807 | m_cTEncTop.setCostMode ( m_costMode ); |
|---|
| 808 | m_cTEncTop.setUseRecalculateQPAccordingToLambda ( m_recalculateQPAccordingToLambda ); |
|---|
| 809 | m_cTEncTop.setUseStrongIntraSmoothing ( m_useStrongIntraSmoothing ); |
|---|
| 810 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
|---|
| 811 | m_cTEncTop.setVuiParametersPresentFlag ( m_vuiParametersPresentFlag ); |
|---|
| 812 | m_cTEncTop.setAspectRatioInfoPresentFlag ( m_aspectRatioInfoPresentFlag); |
|---|
| 813 | m_cTEncTop.setAspectRatioIdc ( m_aspectRatioIdc ); |
|---|
| 814 | m_cTEncTop.setSarWidth ( m_sarWidth ); |
|---|
| 815 | m_cTEncTop.setSarHeight ( m_sarHeight ); |
|---|
| 816 | m_cTEncTop.setOverscanInfoPresentFlag ( m_overscanInfoPresentFlag ); |
|---|
| 817 | m_cTEncTop.setOverscanAppropriateFlag ( m_overscanAppropriateFlag ); |
|---|
| 818 | m_cTEncTop.setVideoSignalTypePresentFlag ( m_videoSignalTypePresentFlag ); |
|---|
| 819 | m_cTEncTop.setVideoFormat ( m_videoFormat ); |
|---|
| 820 | m_cTEncTop.setVideoFullRangeFlag ( m_videoFullRangeFlag ); |
|---|
| 821 | m_cTEncTop.setColourDescriptionPresentFlag ( m_colourDescriptionPresentFlag ); |
|---|
| 822 | m_cTEncTop.setColourPrimaries ( m_colourPrimaries ); |
|---|
| 823 | m_cTEncTop.setTransferCharacteristics ( m_transferCharacteristics ); |
|---|
| 824 | m_cTEncTop.setMatrixCoefficients ( m_matrixCoefficients ); |
|---|
| 825 | m_cTEncTop.setChromaLocInfoPresentFlag ( m_chromaLocInfoPresentFlag ); |
|---|
| 826 | m_cTEncTop.setChromaSampleLocTypeTopField ( m_chromaSampleLocTypeTopField ); |
|---|
| 827 | m_cTEncTop.setChromaSampleLocTypeBottomField ( m_chromaSampleLocTypeBottomField ); |
|---|
| 828 | m_cTEncTop.setNeutralChromaIndicationFlag ( m_neutralChromaIndicationFlag ); |
|---|
| 829 | m_cTEncTop.setDefaultDisplayWindow ( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
|---|
| 830 | m_cTEncTop.setFrameFieldInfoPresentFlag ( m_frameFieldInfoPresentFlag ); |
|---|
| 831 | m_cTEncTop.setPocProportionalToTimingFlag ( m_pocProportionalToTimingFlag ); |
|---|
| 832 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
|---|
| 833 | m_cTEncTop.setBitstreamRestrictionFlag ( m_bitstreamRestrictionFlag ); |
|---|
| 834 | m_cTEncTop.setTilesFixedStructureFlag ( m_tilesFixedStructureFlag ); |
|---|
| 835 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag ( m_motionVectorsOverPicBoundariesFlag ); |
|---|
| 836 | m_cTEncTop.setMinSpatialSegmentationIdc ( m_minSpatialSegmentationIdc ); |
|---|
| 837 | m_cTEncTop.setMaxBytesPerPicDenom ( m_maxBytesPerPicDenom ); |
|---|
| 838 | m_cTEncTop.setMaxBitsPerMinCuDenom ( m_maxBitsPerMinCuDenom ); |
|---|
| 839 | m_cTEncTop.setLog2MaxMvLengthHorizontal ( m_log2MaxMvLengthHorizontal ); |
|---|
| 840 | m_cTEncTop.setLog2MaxMvLengthVertical ( m_log2MaxMvLengthVertical ); |
|---|
| 841 | m_cTEncTop.setEfficientFieldIRAPEnabled ( m_bEfficientFieldIRAPEnabled ); |
|---|
| 842 | m_cTEncTop.setHarmonizeGopFirstFieldCoupleEnabled ( m_bHarmonizeGopFirstFieldCoupleEnabled ); |
|---|
| 843 | |
|---|
| 844 | m_cTEncTop.setSummaryOutFilename ( m_summaryOutFilename ); |
|---|
| 845 | m_cTEncTop.setSummaryPicFilenameBase ( m_summaryPicFilenameBase ); |
|---|
| 846 | m_cTEncTop.setSummaryVerboseness ( m_summaryVerboseness ); |
|---|
| 847 | |
|---|
| 848 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 849 | m_cTEncTop.setLayersNotPresentSEIEnabled ( m_layersNotPresentSEIEnabled ); |
|---|
| 850 | #endif |
|---|
| 851 | |
|---|
| 852 | |
|---|
| 853 | #if SVC_EXTENSION |
|---|
| 854 | if( layer != 0 && m_useInterLayerWeightedPred ) |
|---|
| 855 | { |
|---|
| 856 | // Enable weighted prediction for enhancement layer |
|---|
| 857 | m_cTEncTop.setUseWP ( true ); |
|---|
| 858 | m_cTEncTop.setWPBiPred ( true ); |
|---|
| 859 | } |
|---|
| 860 | |
|---|
| 861 | } |
|---|
| 862 | #endif |
|---|
| 863 | } |
|---|
| 864 | |
|---|
| 865 | Void TAppEncTop::xCreateLib() |
|---|
| 866 | { |
|---|
| 867 | // Video I/O |
|---|
| 868 | #if SVC_EXTENSION |
|---|
| 869 | // initialize global variables |
|---|
| 870 | initROM(); |
|---|
| 871 | |
|---|
| 872 | for(UInt layer=0; layer<m_numLayers; layer++) |
|---|
| 873 | { |
|---|
| 874 | //2 |
|---|
| 875 | // Video I/O |
|---|
| 876 | m_apcTVideoIOYuvInputFile[layer]->open( m_apcLayerCfg[layer]->getInputFileName(), false, m_apcLayerCfg[layer]->m_inputBitDepth, m_apcLayerCfg[layer]->m_MSBExtendedBitDepth, m_apcLayerCfg[layer]->m_internalBitDepth ); // read mode |
|---|
| 877 | m_apcTVideoIOYuvInputFile[layer]->skipFrames(m_FrameSkip, m_apcLayerCfg[layer]->m_iSourceWidth - m_apcLayerCfg[layer]->m_aiPad[0], m_apcLayerCfg[layer]->m_iSourceHeight - m_apcLayerCfg[layer]->m_aiPad[1], m_apcLayerCfg[layer]->m_InputChromaFormatIDC); |
|---|
| 878 | |
|---|
| 879 | if( !m_apcLayerCfg[layer]->getReconFileName().empty() ) |
|---|
| 880 | { |
|---|
| 881 | m_apcTVideoIOYuvReconFile[layer]->open( m_apcLayerCfg[layer]->getReconFileName(), true, m_apcLayerCfg[layer]->m_outputBitDepth, m_apcLayerCfg[layer]->m_MSBExtendedBitDepth, m_apcLayerCfg[layer]->m_internalBitDepth ); // write mode |
|---|
| 882 | } |
|---|
| 883 | |
|---|
| 884 | // Neo Decoder |
|---|
| 885 | m_apcTEncTop[layer]->create(); |
|---|
| 886 | } |
|---|
| 887 | #else //SVC_EXTENSION |
|---|
| 888 | // Video I/O |
|---|
| 889 | m_cTVideoIOYuvInputFile.open( m_inputFileName, false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth ); // read mode |
|---|
| 890 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC); |
|---|
| 891 | |
|---|
| 892 | if (!m_reconFileName.empty()) |
|---|
| 893 | { |
|---|
| 894 | m_cTVideoIOYuvReconFile.open(m_reconFileName, true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth); // write mode |
|---|
| 895 | } |
|---|
| 896 | |
|---|
| 897 | // Neo Decoder |
|---|
| 898 | m_cTEncTop.create(); |
|---|
| 899 | #endif //SVC_EXTENSION |
|---|
| 900 | } |
|---|
| 901 | |
|---|
| 902 | Void TAppEncTop::xDestroyLib() |
|---|
| 903 | { |
|---|
| 904 | // Video I/O |
|---|
| 905 | #if SVC_EXTENSION |
|---|
| 906 | // destroy ROM |
|---|
| 907 | destroyROM(); |
|---|
| 908 | |
|---|
| 909 | for( UInt layer=0; layer < m_numLayers; layer++ ) |
|---|
| 910 | { |
|---|
| 911 | if( m_apcTVideoIOYuvInputFile[layer] ) |
|---|
| 912 | { |
|---|
| 913 | m_apcTVideoIOYuvInputFile[layer]->close(); |
|---|
| 914 | delete m_apcTVideoIOYuvInputFile[layer]; |
|---|
| 915 | m_apcTVideoIOYuvInputFile[layer] = NULL; |
|---|
| 916 | } |
|---|
| 917 | |
|---|
| 918 | if( m_apcTVideoIOYuvReconFile[layer] ) |
|---|
| 919 | { |
|---|
| 920 | m_apcTVideoIOYuvReconFile[layer]->close(); |
|---|
| 921 | delete m_apcTVideoIOYuvReconFile[layer]; |
|---|
| 922 | m_apcTVideoIOYuvReconFile[layer] = NULL; |
|---|
| 923 | } |
|---|
| 924 | |
|---|
| 925 | if( m_apcTEncTop[layer] ) |
|---|
| 926 | { |
|---|
| 927 | m_apcTEncTop[layer]->destroy(); |
|---|
| 928 | delete m_apcTEncTop[layer]; |
|---|
| 929 | m_apcTEncTop[layer] = NULL; |
|---|
| 930 | } |
|---|
| 931 | } |
|---|
| 932 | #else //SVC_EXTENSION |
|---|
| 933 | m_cTVideoIOYuvInputFile.close(); |
|---|
| 934 | m_cTVideoIOYuvReconFile.close(); |
|---|
| 935 | |
|---|
| 936 | // Neo Decoder |
|---|
| 937 | m_cTEncTop.destroy(); |
|---|
| 938 | #endif //SVC_EXTENSION |
|---|
| 939 | } |
|---|
| 940 | |
|---|
| 941 | Void TAppEncTop::xInitLib(Bool isFieldCoding) |
|---|
| 942 | { |
|---|
| 943 | #if SVC_EXTENSION |
|---|
| 944 | TComVPS* vps = m_apcTEncTop[0]->getVPS(); |
|---|
| 945 | m_apcTEncTop[0]->getVPS()->setMaxLayers( m_numLayers ); |
|---|
| 946 | |
|---|
| 947 | UInt i = 0, dimIdLen = 0; |
|---|
| 948 | |
|---|
| 949 | while((1 << dimIdLen) < m_numLayers) |
|---|
| 950 | { |
|---|
| 951 | dimIdLen++; |
|---|
| 952 | } |
|---|
| 953 | vps->setDimensionIdLen(0, dimIdLen); |
|---|
| 954 | vps->setNuhLayerIdPresentFlag(false); |
|---|
| 955 | vps->setLayerIdInNuh(0, 0); |
|---|
| 956 | vps->setLayerIdxInVps(0, 0); |
|---|
| 957 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 958 | { |
|---|
| 959 | vps->setLayerIdInNuh(i, m_apcLayerCfg[i]->m_layerId); |
|---|
| 960 | vps->setLayerIdxInVps(vps->getLayerIdInNuh(i), i); |
|---|
| 961 | vps->setDimensionId(i, 0, i); |
|---|
| 962 | |
|---|
| 963 | if( m_apcLayerCfg[i]->m_layerId != i ) |
|---|
| 964 | { |
|---|
| 965 | vps->setNuhLayerIdPresentFlag(true); |
|---|
| 966 | } |
|---|
| 967 | } |
|---|
| 968 | |
|---|
| 969 | for(UInt layer=0; layer<m_numLayers; layer++) |
|---|
| 970 | { |
|---|
| 971 | //3 |
|---|
| 972 | #if LAYER_CTB |
|---|
| 973 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
|---|
| 974 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
|---|
| 975 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
|---|
| 976 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
|---|
| 977 | #endif |
|---|
| 978 | m_apcTEncTop[layer]->init(isFieldCoding); |
|---|
| 979 | } |
|---|
| 980 | |
|---|
| 981 | // Set max-layer ID |
|---|
| 982 | vps->setMaxLayerId( m_apcLayerCfg[m_numLayers - 1]->m_layerId ); |
|---|
| 983 | vps->setVpsExtensionFlag( m_numLayers > 1 ? true : false ); |
|---|
| 984 | |
|---|
| 985 | if( m_numLayerSets > 1 ) |
|---|
| 986 | { |
|---|
| 987 | vps->setNumLayerSets(m_numLayerSets); |
|---|
| 988 | |
|---|
| 989 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
|---|
| 990 | { |
|---|
| 991 | for (Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++) |
|---|
| 992 | { |
|---|
| 993 | vps->setLayerIdIncludedFlag(false, setId, layerId); |
|---|
| 994 | } |
|---|
| 995 | } |
|---|
| 996 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
|---|
| 997 | { |
|---|
| 998 | for( i = 0; i < m_numLayerInIdList[setId]; i++ ) |
|---|
| 999 | { |
|---|
| 1000 | //4 |
|---|
| 1001 | vps->setLayerIdIncludedFlag(true, setId, m_layerSetLayerIdList[setId][i]); |
|---|
| 1002 | } |
|---|
| 1003 | } |
|---|
| 1004 | } |
|---|
| 1005 | else |
|---|
| 1006 | { |
|---|
| 1007 | // Default layer sets |
|---|
| 1008 | vps->setNumLayerSets(m_numLayers); |
|---|
| 1009 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
|---|
| 1010 | { |
|---|
| 1011 | for (Int layerIdx = 0; layerIdx <= vps->getMaxLayers(); layerIdx++) |
|---|
| 1012 | { |
|---|
| 1013 | //4 |
|---|
| 1014 | UInt layerId = vps->getLayerIdInNuh(layerIdx); |
|---|
| 1015 | |
|---|
| 1016 | if (layerId <= setId) |
|---|
| 1017 | { |
|---|
| 1018 | vps->setLayerIdIncludedFlag(true, setId, layerId); |
|---|
| 1019 | } |
|---|
| 1020 | else |
|---|
| 1021 | { |
|---|
| 1022 | vps->setLayerIdIncludedFlag(false, setId, layerId); |
|---|
| 1023 | } |
|---|
| 1024 | } |
|---|
| 1025 | } |
|---|
| 1026 | } |
|---|
| 1027 | |
|---|
| 1028 | vps->setVpsNumLayerSetsMinus1(vps->getNumLayerSets() - 1); |
|---|
| 1029 | vps->setNumAddLayerSets(m_numAddLayerSets); |
|---|
| 1030 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
|---|
| 1031 | |
|---|
| 1032 | if( m_numAddLayerSets > 0 ) |
|---|
| 1033 | { |
|---|
| 1034 | for (Int setId = 0; setId < m_numAddLayerSets; setId++) |
|---|
| 1035 | { |
|---|
| 1036 | for (Int j = 0; j < m_numHighestLayerIdx[setId]; j++) |
|---|
| 1037 | { |
|---|
| 1038 | vps->setHighestLayerIdxPlus1(setId, j + 1, m_highestLayerIdx[setId][j] + 1); |
|---|
| 1039 | } |
|---|
| 1040 | } |
|---|
| 1041 | } |
|---|
| 1042 | |
|---|
| 1043 | #if AVC_BASE |
|---|
| 1044 | vps->setNonHEVCBaseLayerFlag( m_nonHEVCBaseLayerFlag ); |
|---|
| 1045 | if ( m_nonHEVCBaseLayerFlag ) |
|---|
| 1046 | { |
|---|
| 1047 | vps->setBaseLayerInternalFlag (false); |
|---|
| 1048 | } |
|---|
| 1049 | #else |
|---|
| 1050 | vps->setAvcBaseLayerFlag(false); |
|---|
| 1051 | #endif |
|---|
| 1052 | |
|---|
| 1053 | for( Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx < vps->getNumProfileTierLevel(); idx++ ) |
|---|
| 1054 | { |
|---|
| 1055 | vps->setProfilePresentFlag(idx, true); |
|---|
| 1056 | } |
|---|
| 1057 | |
|---|
| 1058 | vps->setSplittingFlag(false); |
|---|
| 1059 | |
|---|
| 1060 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
|---|
| 1061 | { |
|---|
| 1062 | vps->setScalabilityMask(i, false); |
|---|
| 1063 | } |
|---|
| 1064 | if(m_numLayers > 1) |
|---|
| 1065 | { |
|---|
| 1066 | Int scalabilityTypes = 0; |
|---|
| 1067 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
|---|
| 1068 | { |
|---|
| 1069 | vps->setScalabilityMask(i, m_scalabilityMask[i]); |
|---|
| 1070 | scalabilityTypes += m_scalabilityMask[i]; |
|---|
| 1071 | } |
|---|
| 1072 | #if AUXILIARY_PICTURES |
|---|
| 1073 | assert( scalabilityTypes <= 2 ); |
|---|
| 1074 | #else |
|---|
| 1075 | assert( scalabilityTypes == 1 ); |
|---|
| 1076 | #endif |
|---|
| 1077 | vps->setNumScalabilityTypes(scalabilityTypes); |
|---|
| 1078 | } |
|---|
| 1079 | else |
|---|
| 1080 | { |
|---|
| 1081 | vps->setNumScalabilityTypes(0); |
|---|
| 1082 | } |
|---|
| 1083 | |
|---|
| 1084 | #if AUXILIARY_PICTURES |
|---|
| 1085 | if (m_scalabilityMask[AUX_ID]) |
|---|
| 1086 | { |
|---|
| 1087 | UInt maxAuxId = 0; |
|---|
| 1088 | UInt auxDimIdLen = 1; |
|---|
| 1089 | Int auxId = vps->getNumScalabilityTypes() - 1; |
|---|
| 1090 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 1091 | { |
|---|
| 1092 | if (m_apcLayerCfg[i]->m_auxId > maxAuxId) |
|---|
| 1093 | { |
|---|
| 1094 | maxAuxId = m_apcLayerCfg[i]->m_auxId; |
|---|
| 1095 | } |
|---|
| 1096 | } |
|---|
| 1097 | while((1 << auxDimIdLen) < (maxAuxId + 1)) |
|---|
| 1098 | { |
|---|
| 1099 | auxDimIdLen++; |
|---|
| 1100 | } |
|---|
| 1101 | vps->setDimensionIdLen(auxId, auxDimIdLen); |
|---|
| 1102 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 1103 | { |
|---|
| 1104 | vps->setDimensionId(i, auxId, m_apcLayerCfg[i]->m_auxId); |
|---|
| 1105 | } |
|---|
| 1106 | } |
|---|
| 1107 | #endif |
|---|
| 1108 | |
|---|
| 1109 | vps->setMaxTSLayersPresentFlag(true); |
|---|
| 1110 | |
|---|
| 1111 | for( i = 0; i < vps->getMaxLayers(); i++ ) |
|---|
| 1112 | { |
|---|
| 1113 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
|---|
| 1114 | } |
|---|
| 1115 | |
|---|
| 1116 | vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag); |
|---|
| 1117 | if (vps->getMaxTidRefPresentFlag()) |
|---|
| 1118 | { |
|---|
| 1119 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
|---|
| 1120 | { |
|---|
| 1121 | for( Int j = i+1; j < vps->getMaxLayers(); j++) |
|---|
| 1122 | { |
|---|
| 1123 | vps->setMaxTidIlRefPicsPlus1(i, j, m_apcTEncTop[i]->getMaxTidIlRefPicsPlus1()); |
|---|
| 1124 | } |
|---|
| 1125 | } |
|---|
| 1126 | } |
|---|
| 1127 | else |
|---|
| 1128 | { |
|---|
| 1129 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
|---|
| 1130 | { |
|---|
| 1131 | for( Int j = i+1; j < vps->getMaxLayers(); j++) |
|---|
| 1132 | { |
|---|
| 1133 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
|---|
| 1134 | } |
|---|
| 1135 | } |
|---|
| 1136 | } |
|---|
| 1137 | |
|---|
| 1138 | vps->setIlpSshSignalingEnabledFlag(false); |
|---|
| 1139 | |
|---|
| 1140 | // Direct reference layers |
|---|
| 1141 | UInt maxDirectRefLayers = 0; |
|---|
| 1142 | Bool isDefaultDirectDependencyTypeSet = false; |
|---|
| 1143 | for (UInt layerCtr = 1; layerCtr < vps->getMaxLayers(); layerCtr++) |
|---|
| 1144 | { |
|---|
| 1145 | UInt layerId = vps->getLayerIdInNuh(layerCtr); |
|---|
| 1146 | Int numDirectRefLayers = 0; |
|---|
| 1147 | |
|---|
| 1148 | vps->setNumDirectRefLayers(layerId, m_apcTEncTop[layerCtr]->getNumDirectRefLayers()); |
|---|
| 1149 | maxDirectRefLayers = max<UInt>(maxDirectRefLayers, vps->getNumDirectRefLayers(layerId)); |
|---|
| 1150 | |
|---|
| 1151 | for (i = 0; i < vps->getNumDirectRefLayers(layerId); i++) |
|---|
| 1152 | { |
|---|
| 1153 | vps->setRefLayerId(layerId, i, m_apcTEncTop[layerCtr]->getRefLayerId(i)); |
|---|
| 1154 | } |
|---|
| 1155 | // Set direct dependency flag |
|---|
| 1156 | // Initialize flag to 0 |
|---|
| 1157 | for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
|---|
| 1158 | { |
|---|
| 1159 | vps->setDirectDependencyFlag(layerCtr, refLayerCtr, false); |
|---|
| 1160 | } |
|---|
| 1161 | for (i = 0; i < vps->getNumDirectRefLayers(layerId); i++) |
|---|
| 1162 | { |
|---|
| 1163 | vps->setDirectDependencyFlag(layerCtr, vps->getLayerIdxInVps(m_apcTEncTop[layerCtr]->getRefLayerId(i)), true); |
|---|
| 1164 | } |
|---|
| 1165 | // prediction indications |
|---|
| 1166 | vps->setDirectDepTypeLen(2); // sample and motion types are encoded |
|---|
| 1167 | for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
|---|
| 1168 | { |
|---|
| 1169 | if (vps->getDirectDependencyFlag(layerCtr, refLayerCtr)) |
|---|
| 1170 | { |
|---|
| 1171 | assert(m_apcTEncTop[layerCtr]->getSamplePredEnabledFlag(numDirectRefLayers) || m_apcTEncTop[layerCtr]->getMotionPredEnabledFlag(numDirectRefLayers)); |
|---|
| 1172 | vps->setDirectDependencyType(layerCtr, refLayerCtr, ((m_apcTEncTop[layerCtr]->getSamplePredEnabledFlag(numDirectRefLayers) ? 1 : 0) | |
|---|
| 1173 | (m_apcTEncTop[layerCtr]->getMotionPredEnabledFlag(numDirectRefLayers) ? 2 : 0)) - 1); |
|---|
| 1174 | |
|---|
| 1175 | if (!isDefaultDirectDependencyTypeSet) |
|---|
| 1176 | { |
|---|
| 1177 | vps->setDefaultDirectDependecyTypeFlag(1); |
|---|
| 1178 | vps->setDefaultDirectDependecyType(vps->getDirectDependencyType(layerCtr, refLayerCtr)); |
|---|
| 1179 | isDefaultDirectDependencyTypeSet = true; |
|---|
| 1180 | } |
|---|
| 1181 | else if (vps->getDirectDependencyType(layerCtr, refLayerCtr) != vps->getDefaultDirectDependencyType()) |
|---|
| 1182 | { |
|---|
| 1183 | vps->setDefaultDirectDependecyTypeFlag(0); |
|---|
| 1184 | } |
|---|
| 1185 | |
|---|
| 1186 | numDirectRefLayers ++; |
|---|
| 1187 | } |
|---|
| 1188 | else |
|---|
| 1189 | { |
|---|
| 1190 | vps->setDirectDependencyType(layerCtr, refLayerCtr, 0); |
|---|
| 1191 | } |
|---|
| 1192 | } |
|---|
| 1193 | } |
|---|
| 1194 | |
|---|
| 1195 | // dependency constraint |
|---|
| 1196 | vps->setNumRefLayers(); |
|---|
| 1197 | |
|---|
| 1198 | if( vps->getMaxLayers() > MAX_REF_LAYERS ) |
|---|
| 1199 | { |
|---|
| 1200 | for( UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++ ) |
|---|
| 1201 | { |
|---|
| 1202 | assert(vps->getNumRefLayers(vps->getLayerIdInNuh(layerCtr)) <= MAX_REF_LAYERS); |
|---|
| 1203 | } |
|---|
| 1204 | } |
|---|
| 1205 | |
|---|
| 1206 | // The Layer ID List variables should be derived here. |
|---|
| 1207 | vps->deriveLayerIdListVariables(); |
|---|
| 1208 | vps->setPredictedLayerIds(); |
|---|
| 1209 | vps->setTreePartitionLayerIdList(); |
|---|
| 1210 | vps->deriveLayerIdListVariablesForAddLayerSets(); |
|---|
| 1211 | |
|---|
| 1212 | vps->setDefaultTargetOutputLayerIdc( m_defaultTargetOutputLayerIdc ); // As per configuration file |
|---|
| 1213 | |
|---|
| 1214 | if( m_numOutputLayerSets == -1 ) // # of output layer sets not specified in the configuration file |
|---|
| 1215 | { |
|---|
| 1216 | vps->setNumOutputLayerSets(vps->getNumLayerSets()); |
|---|
| 1217 | |
|---|
| 1218 | for(i = 1; i < vps->getNumLayerSets(); i++) |
|---|
| 1219 | { |
|---|
| 1220 | vps->setOutputLayerSetIdx(i, i); |
|---|
| 1221 | } |
|---|
| 1222 | } |
|---|
| 1223 | else |
|---|
| 1224 | { |
|---|
| 1225 | vps->setNumOutputLayerSets( m_numOutputLayerSets ); |
|---|
| 1226 | for( Int olsCtr = 0; olsCtr < vps->getNumLayerSets(); olsCtr ++ ) // Default output layer sets |
|---|
| 1227 | { |
|---|
| 1228 | vps->setOutputLayerSetIdx(olsCtr, olsCtr); |
|---|
| 1229 | } |
|---|
| 1230 | for( Int olsCtr = vps->getNumLayerSets(); olsCtr < vps->getNumOutputLayerSets(); olsCtr ++ ) // Non-default output layer sets |
|---|
| 1231 | { |
|---|
| 1232 | vps->setOutputLayerSetIdx(olsCtr, m_outputLayerSetIdx[olsCtr - vps->getNumLayerSets()]); |
|---|
| 1233 | } |
|---|
| 1234 | } |
|---|
| 1235 | |
|---|
| 1236 | // Target output layer |
|---|
| 1237 | vps->deriveNumberOfSubDpbs(); |
|---|
| 1238 | vps->setOutputLayerFlag( 0, 0, 1 ); |
|---|
| 1239 | |
|---|
| 1240 | // derive OutputLayerFlag[i][j] |
|---|
| 1241 | // default_output_layer_idc equal to 1 specifies that only the layer with the highest value of nuh_layer_id such that nuh_layer_id equal to nuhLayerIdA and |
|---|
| 1242 | // AuxId[ nuhLayerIdA ] equal to 0 in each of the output layer sets with index in the range of 1 to vps_num_layer_sets_minus1, inclusive, is an output layer of its output layer set. |
|---|
| 1243 | |
|---|
| 1244 | // Include the highest layer as output layer for each layer set |
|---|
| 1245 | for(Int lsIdx = 1; lsIdx <= vps->getVpsNumLayerSetsMinus1(); lsIdx++) |
|---|
| 1246 | { |
|---|
| 1247 | for( UInt layer = 0; layer < vps->getNumLayersInIdList(lsIdx); layer++ ) |
|---|
| 1248 | { |
|---|
| 1249 | switch( vps->getDefaultTargetOutputLayerIdc() ) |
|---|
| 1250 | { |
|---|
| 1251 | case 0: vps->setOutputLayerFlag( lsIdx, layer, 1 ); |
|---|
| 1252 | break; |
|---|
| 1253 | case 1: vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 ); |
|---|
| 1254 | break; |
|---|
| 1255 | case 2: |
|---|
| 1256 | case 3: vps->setOutputLayerFlag( lsIdx, layer, (layer != vps->getNumLayersInIdList(lsIdx) - 1) ? std::find( m_listOfOutputLayers[lsIdx].begin(), m_listOfOutputLayers[lsIdx].end(), m_layerSetLayerIdList[lsIdx][layer]) != m_listOfOutputLayers[lsIdx].end() |
|---|
| 1257 | : m_listOfOutputLayers[lsIdx][m_listOfOutputLayers[lsIdx].size()-1] == m_layerSetLayerIdList[lsIdx][layer] ); |
|---|
| 1258 | break; |
|---|
| 1259 | } |
|---|
| 1260 | } |
|---|
| 1261 | } |
|---|
| 1262 | |
|---|
| 1263 | for( Int olsIdx = vps->getVpsNumLayerSetsMinus1() + 1; olsIdx < vps->getNumOutputLayerSets(); olsIdx++ ) |
|---|
| 1264 | { |
|---|
| 1265 | for( UInt layer = 0; layer < vps->getNumLayersInIdList(vps->getOutputLayerSetIdx(olsIdx)); layer++ ) |
|---|
| 1266 | { |
|---|
| 1267 | vps->setOutputLayerFlag( olsIdx, layer, (layer != vps->getNumLayersInIdList(vps->getOutputLayerSetIdx(olsIdx)) - 1) ? std::find( m_listOfOutputLayers[olsIdx].begin(), m_listOfOutputLayers[olsIdx].end(), vps->getLayerSetLayerIdList(vps->getOutputLayerSetIdx(olsIdx), layer)) != m_listOfOutputLayers[olsIdx].end() |
|---|
| 1268 | : m_listOfOutputLayers[olsIdx][m_listOfOutputLayers[olsIdx].size()-1] == vps->getLayerSetLayerIdList(vps->getOutputLayerSetIdx(olsIdx), layer) ); |
|---|
| 1269 | } |
|---|
| 1270 | } |
|---|
| 1271 | |
|---|
| 1272 | vps->deriveNecessaryLayerFlag(); |
|---|
| 1273 | vps->checkNecessaryLayerFlagCondition(); |
|---|
| 1274 | vps->calculateMaxSLInLayerSets(); |
|---|
| 1275 | |
|---|
| 1276 | // Initialize dpb_size_table() for all ouput layer sets in the VPS extension |
|---|
| 1277 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
|---|
| 1278 | { |
|---|
| 1279 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
|---|
| 1280 | Int layerSetId = vps->getOutputLayerSetIdx(i); |
|---|
| 1281 | |
|---|
| 1282 | for(Int j = 0; j < vps->getMaxTLayers(); j++) |
|---|
| 1283 | { |
|---|
| 1284 | |
|---|
| 1285 | Int maxNumReorderPics = -1; |
|---|
| 1286 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
|---|
| 1287 | { |
|---|
| 1288 | Int layerId = vps->getLayerSetLayerIdList(layerSetId, k); // k-th layer in the output layer set |
|---|
| 1289 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, m_apcTEncTop[vps->getLayerIdxInVps(layerId)]->getMaxDecPicBuffering(j) - 1 ); |
|---|
| 1290 | maxNumReorderPics = std::max( maxNumReorderPics, m_apcTEncTop[vps->getLayerIdxInVps(layerId)]->getNumReorderPics(j)); |
|---|
| 1291 | } |
|---|
| 1292 | vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics); |
|---|
| 1293 | vps->determineSubDpbInfoFlags(); |
|---|
| 1294 | } |
|---|
| 1295 | } |
|---|
| 1296 | |
|---|
| 1297 | vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true); |
|---|
| 1298 | |
|---|
| 1299 | // POC LSB not present flag |
|---|
| 1300 | for( i = 1; i< vps->getMaxLayers(); i++ ) |
|---|
| 1301 | { |
|---|
| 1302 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
|---|
| 1303 | { |
|---|
| 1304 | // make independedent layers base-layer compliant |
|---|
| 1305 | vps->setPocLsbNotPresentFlag(i, true); |
|---|
| 1306 | } |
|---|
| 1307 | } |
|---|
| 1308 | |
|---|
| 1309 | vps->setCrossLayerPictureTypeAlignFlag( m_crossLayerPictureTypeAlignFlag ); |
|---|
| 1310 | vps->setCrossLayerAlignedIdrOnlyFlag( m_crossLayerAlignedIdrOnlyFlag ); |
|---|
| 1311 | vps->setCrossLayerIrapAlignFlag( m_crossLayerIrapAlignFlag ); |
|---|
| 1312 | |
|---|
| 1313 | if( vps->getCrossLayerPictureTypeAlignFlag() ) |
|---|
| 1314 | { |
|---|
| 1315 | // When not present, the value of cross_layer_irap_aligned_flag is inferred to be equal to vps_vui_present_flag, |
|---|
| 1316 | assert( m_crossLayerIrapAlignFlag == true ); |
|---|
| 1317 | vps->setCrossLayerIrapAlignFlag( true ); |
|---|
| 1318 | } |
|---|
| 1319 | |
|---|
| 1320 | for(UInt layerCtr = 1;layerCtr < vps->getMaxLayers(); layerCtr++) |
|---|
| 1321 | { |
|---|
| 1322 | for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
|---|
| 1323 | { |
|---|
| 1324 | if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr)) |
|---|
| 1325 | { |
|---|
| 1326 | assert( layerCtr < MAX_LAYERS ); |
|---|
| 1327 | |
|---|
| 1328 | if(m_apcTEncTop[layerCtr]->getIntraPeriod() != m_apcTEncTop[refLayerCtr]->getIntraPeriod()) |
|---|
| 1329 | { |
|---|
| 1330 | vps->setCrossLayerIrapAlignFlag(false); |
|---|
| 1331 | break; |
|---|
| 1332 | } |
|---|
| 1333 | } |
|---|
| 1334 | } |
|---|
| 1335 | } |
|---|
| 1336 | vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false); |
|---|
| 1337 | vps->setHigherLayerIrapSkipFlag(m_skipPictureAtArcSwitch); |
|---|
| 1338 | |
|---|
| 1339 | for( Int k = 0; k < MAX_VPS_LAYER_SETS_PLUS1; k++ ) |
|---|
| 1340 | { |
|---|
| 1341 | vps->setAltOuputLayerFlag( k, m_altOutputLayerFlag ); |
|---|
| 1342 | } |
|---|
| 1343 | |
|---|
| 1344 | // VPS VUI BSP HRD parameters |
|---|
| 1345 | vps->setVpsVuiBspHrdPresentFlag(false); |
|---|
| 1346 | TEncTop *pcCfg = m_apcTEncTop[0]; |
|---|
| 1347 | if( pcCfg->getBufferingPeriodSEIEnabled() ) |
|---|
| 1348 | { |
|---|
| 1349 | Int j; |
|---|
| 1350 | vps->setVpsVuiBspHrdPresentFlag(true); |
|---|
| 1351 | vps->setVpsNumAddHrdParams( vps->getMaxLayers() ); |
|---|
| 1352 | vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams() + 1); |
|---|
| 1353 | for( i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) |
|---|
| 1354 | { |
|---|
| 1355 | vps->setCprmsAddPresentFlag( j, true ); |
|---|
| 1356 | vps->setNumSubLayerHrdMinus1( j, vps->getMaxTLayers() - 1 ); |
|---|
| 1357 | |
|---|
| 1358 | UInt layerIdx = j; |
|---|
| 1359 | TEncTop *pcCfgLayer = m_apcTEncTop[layerIdx]; |
|---|
| 1360 | |
|---|
| 1361 | Int iPicWidth = pcCfgLayer->getSourceWidth(); |
|---|
| 1362 | Int iPicHeight = pcCfgLayer->getSourceHeight(); |
|---|
| 1363 | |
|---|
| 1364 | UInt uiWidthInCU = ( iPicWidth % m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth ) ? iPicWidth / m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth + 1 : iPicWidth / m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth; |
|---|
| 1365 | UInt uiHeightInCU = ( iPicHeight % m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight ) ? iPicHeight / m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight + 1 : iPicHeight / m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight; |
|---|
| 1366 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_apcLayerCfg[layerIdx]->m_uiMaxCUDepth << 1); |
|---|
| 1367 | |
|---|
| 1368 | UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; |
|---|
| 1369 | |
|---|
| 1370 | UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 ); |
|---|
| 1371 | if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 ) |
|---|
| 1372 | { |
|---|
| 1373 | numDU ++; |
|---|
| 1374 | } |
|---|
| 1375 | //vps->getBspHrd(i)->setNumDU( numDU ); |
|---|
| 1376 | vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) ); |
|---|
| 1377 | } |
|---|
| 1378 | |
|---|
| 1379 | // Signalling of additional partitioning schemes |
|---|
| 1380 | for( Int h = 1; h < vps->getNumOutputLayerSets(); h++ ) |
|---|
| 1381 | { |
|---|
| 1382 | Int lsIdx = vps->getOutputLayerSetIdx( h ); |
|---|
| 1383 | vps->setNumSignalledPartitioningSchemes(h, 1); // Only the default per-layer partitioning scheme |
|---|
| 1384 | for( j = 1; j < vps->getNumSignalledPartitioningSchemes(h); j++ ) |
|---|
| 1385 | { |
|---|
| 1386 | // ToDo: Add code for additional partitioning schemes here |
|---|
| 1387 | // ToDo: Initialize num_partitions_in_scheme_minus1 and layer_included_in_partition_flag |
|---|
| 1388 | } |
|---|
| 1389 | |
|---|
| 1390 | for( i = 0; i < vps->getNumSignalledPartitioningSchemes(h); i++ ) |
|---|
| 1391 | { |
|---|
| 1392 | if( i == 0 ) |
|---|
| 1393 | { |
|---|
| 1394 | for(Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1( lsIdx ); t++) |
|---|
| 1395 | { |
|---|
| 1396 | vps->setNumBspSchedulesMinus1( h, i, t, 0 ); |
|---|
| 1397 | for( j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ ) |
|---|
| 1398 | { |
|---|
| 1399 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) |
|---|
| 1400 | { |
|---|
| 1401 | // Only for the default partition |
|---|
| 1402 | Int nuhlayerId = vps->getLayerSetLayerIdList( lsIdx, k); |
|---|
| 1403 | Int layerIdxInVps = vps->getLayerIdxInVps( nuhlayerId ); |
|---|
| 1404 | vps->setBspHrdIdx(h, i, t, j, k, layerIdxInVps + vps->getNumHrdParameters()); |
|---|
| 1405 | |
|---|
| 1406 | vps->setBspSchedIdx(h, i, t, j, k, 0); |
|---|
| 1407 | } |
|---|
| 1408 | } |
|---|
| 1409 | } |
|---|
| 1410 | } |
|---|
| 1411 | else |
|---|
| 1412 | { |
|---|
| 1413 | assert(0); // Need to add support for additional partitioning schemes. |
|---|
| 1414 | } |
|---|
| 1415 | } |
|---|
| 1416 | } |
|---|
| 1417 | } |
|---|
| 1418 | #else //SVC_EXTENSION |
|---|
| 1419 | m_cTEncTop.init(isFieldCoding); |
|---|
| 1420 | #endif //SVC_EXTENSION |
|---|
| 1421 | } |
|---|
| 1422 | |
|---|
| 1423 | // ==================================================================================================================== |
|---|
| 1424 | // Public member functions |
|---|
| 1425 | // ==================================================================================================================== |
|---|
| 1426 | |
|---|
| 1427 | /** |
|---|
| 1428 | - create internal class |
|---|
| 1429 | - initialize internal variable |
|---|
| 1430 | - until the end of input YUV file, call encoding function in TEncTop class |
|---|
| 1431 | - delete allocated buffers |
|---|
| 1432 | - destroy internal class |
|---|
| 1433 | . |
|---|
| 1434 | */ |
|---|
| 1435 | #if SVC_EXTENSION |
|---|
| 1436 | Void TAppEncTop::encode() |
|---|
| 1437 | { |
|---|
| 1438 | fstream bitstreamFile(m_bitstreamFileName.c_str(), fstream::binary | fstream::out); |
|---|
| 1439 | if (!bitstreamFile) |
|---|
| 1440 | { |
|---|
| 1441 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_bitstreamFileName.c_str()); |
|---|
| 1442 | exit(EXIT_FAILURE); |
|---|
| 1443 | } |
|---|
| 1444 | |
|---|
| 1445 | // allocated memory |
|---|
| 1446 | for( Int layer = 0; layer < m_numLayers; layer++ ) |
|---|
| 1447 | { |
|---|
| 1448 | m_apcTVideoIOYuvInputFile[layer] = new TVideoIOYuv; |
|---|
| 1449 | m_apcTVideoIOYuvReconFile[layer] = new TVideoIOYuv; |
|---|
| 1450 | m_apcTEncTop[layer] = new TEncTop; |
|---|
| 1451 | } |
|---|
| 1452 | |
|---|
| 1453 | TComPicYuv* pcPicYuvOrg [MAX_LAYERS]; |
|---|
| 1454 | TComPicYuv* pcPicYuvRec = NULL; |
|---|
| 1455 | |
|---|
| 1456 | // initialize internal class & member variables |
|---|
| 1457 | xInitLibCfg(); |
|---|
| 1458 | xCreateLib(); |
|---|
| 1459 | xInitLib(m_isField); |
|---|
| 1460 | |
|---|
| 1461 | // main encoder loop |
|---|
| 1462 | Int iNumEncoded = 0, iTotalNumEncoded = 0; |
|---|
| 1463 | Bool bEos = false; |
|---|
| 1464 | |
|---|
| 1465 | const InputColourSpaceConversion ipCSC = m_inputColourSpaceConvert; |
|---|
| 1466 | const InputColourSpaceConversion snrCSC = (!m_snrInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
|---|
| 1467 | |
|---|
| 1468 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
|---|
| 1469 | |
|---|
| 1470 | TComPicYuv acPicYuvTrueOrg[MAX_LAYERS]; |
|---|
| 1471 | |
|---|
| 1472 | for(UInt layer=0; layer<m_numLayers; layer++) |
|---|
| 1473 | { |
|---|
| 1474 | //5 |
|---|
| 1475 | // allocate original YUV buffer |
|---|
| 1476 | pcPicYuvOrg[layer] = new TComPicYuv; |
|---|
| 1477 | if( m_isField ) |
|---|
| 1478 | { |
|---|
| 1479 | pcPicYuvOrg[layer]->create( m_apcLayerCfg[layer]->m_iSourceWidth, m_apcLayerCfg[layer]->m_iSourceHeightOrg, m_apcLayerCfg[layer]->m_chromaFormatIDC, m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL ); |
|---|
| 1480 | acPicYuvTrueOrg[layer].create( m_apcLayerCfg[layer]->m_iSourceWidth, m_apcLayerCfg[layer]->m_iSourceHeightOrg, m_apcLayerCfg[layer]->m_chromaFormatIDC, m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL ); |
|---|
| 1481 | } |
|---|
| 1482 | else |
|---|
| 1483 | { |
|---|
| 1484 | pcPicYuvOrg[layer]->create( m_apcLayerCfg[layer]->m_iSourceWidth, m_apcLayerCfg[layer]->m_iSourceHeight, m_apcLayerCfg[layer]->m_chromaFormatIDC, m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL ); |
|---|
| 1485 | acPicYuvTrueOrg[layer].create( m_apcLayerCfg[layer]->m_iSourceWidth, m_apcLayerCfg[layer]->m_iSourceHeight, m_apcLayerCfg[layer]->m_chromaFormatIDC, m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL ); |
|---|
| 1486 | } |
|---|
| 1487 | } |
|---|
| 1488 | |
|---|
| 1489 | Bool bFirstFrame = true; |
|---|
| 1490 | while ( !bEos ) |
|---|
| 1491 | { |
|---|
| 1492 | // Read enough frames |
|---|
| 1493 | Bool bFramesReadyToCode = false; |
|---|
| 1494 | while(!bFramesReadyToCode) |
|---|
| 1495 | { |
|---|
| 1496 | for(UInt layer=0; layer<m_numLayers; layer++) |
|---|
| 1497 | { |
|---|
| 1498 | //6 |
|---|
| 1499 | // get buffers |
|---|
| 1500 | xGetBuffer(pcPicYuvRec, layer); |
|---|
| 1501 | |
|---|
| 1502 | // read input YUV file |
|---|
| 1503 | m_apcTVideoIOYuvInputFile[layer]->read( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer], ipCSC, m_apcLayerCfg[layer]->m_aiPad, m_apcLayerCfg[layer]->m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range ); |
|---|
| 1504 | |
|---|
| 1505 | #if AUXILIARY_PICTURES |
|---|
| 1506 | if( m_apcLayerCfg[layer]->m_chromaFormatIDC == CHROMA_400 || (m_apcTEncTop[0]->getVPS()->getScalabilityMask(AUX_ID) && (m_apcLayerCfg[layer]->m_auxId == AUX_ALPHA || m_apcLayerCfg[layer]->m_auxId == AUX_DEPTH)) ) |
|---|
| 1507 | { |
|---|
| 1508 | pcPicYuvOrg[layer]->convertToMonochrome(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
|---|
| 1509 | } |
|---|
| 1510 | #endif |
|---|
| 1511 | |
|---|
| 1512 | if(layer == m_numLayers-1) |
|---|
| 1513 | { |
|---|
| 1514 | // increase number of received frames |
|---|
| 1515 | m_iFrameRcvd++; |
|---|
| 1516 | // check end of file |
|---|
| 1517 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
|---|
| 1518 | } |
|---|
| 1519 | |
|---|
| 1520 | if ( m_isField ) |
|---|
| 1521 | { |
|---|
| 1522 | m_apcTEncTop[layer]->encodePrep( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer], m_isTopFieldFirst ); |
|---|
| 1523 | } |
|---|
| 1524 | else |
|---|
| 1525 | { |
|---|
| 1526 | m_apcTEncTop[layer]->encodePrep( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer] ); |
|---|
| 1527 | } |
|---|
| 1528 | } |
|---|
| 1529 | |
|---|
| 1530 | bFramesReadyToCode = !(!bFirstFrame && ( m_apcTEncTop[m_numLayers-1]->getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos ); |
|---|
| 1531 | } |
|---|
| 1532 | Bool flush = 0; |
|---|
| 1533 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
|---|
| 1534 | if (m_apcTVideoIOYuvInputFile[m_numLayers-1]->isEof()) |
|---|
| 1535 | { |
|---|
| 1536 | flush = true; |
|---|
| 1537 | bEos = true; |
|---|
| 1538 | m_iFrameRcvd--; |
|---|
| 1539 | m_apcTEncTop[m_numLayers-1]->setFramesToBeEncoded(m_iFrameRcvd); |
|---|
| 1540 | } |
|---|
| 1541 | |
|---|
| 1542 | #if RC_SHVC_HARMONIZATION |
|---|
| 1543 | for( UInt layer=0; layer<m_numLayers; layer++ ) |
|---|
| 1544 | { |
|---|
| 1545 | if( m_apcTEncTop[layer]->getUseRateCtrl() ) |
|---|
| 1546 | { |
|---|
| 1547 | m_apcTEncTop[layer]->getRateCtrl()->initRCGOP(m_apcTEncTop[layer]->getNumPicRcvd()); |
|---|
| 1548 | } |
|---|
| 1549 | } |
|---|
| 1550 | #endif |
|---|
| 1551 | |
|---|
| 1552 | if( m_adaptiveResolutionChange ) |
|---|
| 1553 | { |
|---|
| 1554 | for(UInt layer = 0; layer < m_numLayers; layer++) |
|---|
| 1555 | { |
|---|
| 1556 | TComList<TComPicYuv*>::iterator iterPicYuvRec; |
|---|
| 1557 | for (iterPicYuvRec = m_acListPicYuvRec[layer].begin(); iterPicYuvRec != m_acListPicYuvRec[layer].end(); iterPicYuvRec++) |
|---|
| 1558 | { |
|---|
| 1559 | TComPicYuv* recPic = *(iterPicYuvRec); |
|---|
| 1560 | recPic->setReconstructed(false); |
|---|
| 1561 | } |
|---|
| 1562 | } |
|---|
| 1563 | } |
|---|
| 1564 | |
|---|
| 1565 | // loop through frames in one GOP |
|---|
| 1566 | for( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ ) |
|---|
| 1567 | { |
|---|
| 1568 | // layer by layer for each frame |
|---|
| 1569 | for( UInt layer=0; layer<m_numLayers; layer++ ) |
|---|
| 1570 | { |
|---|
| 1571 | //7 |
|---|
| 1572 | #if LAYER_CTB |
|---|
| 1573 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
|---|
| 1574 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
|---|
| 1575 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
|---|
| 1576 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
|---|
| 1577 | #endif |
|---|
| 1578 | // call encoding function for one frame |
|---|
| 1579 | if ( m_isField ) |
|---|
| 1580 | { |
|---|
| 1581 | m_apcTEncTop[layer]->encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst ); |
|---|
| 1582 | } |
|---|
| 1583 | else |
|---|
| 1584 | { |
|---|
| 1585 | m_apcTEncTop[layer]->encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP ); |
|---|
| 1586 | } |
|---|
| 1587 | } |
|---|
| 1588 | } |
|---|
| 1589 | #if R0247_SEI_ACTIVE |
|---|
| 1590 | if(bFirstFrame) |
|---|
| 1591 | { |
|---|
| 1592 | list<AccessUnit>::iterator first_au = outputAccessUnits.begin(); |
|---|
| 1593 | if( m_nonHEVCBaseLayerFlag ) |
|---|
| 1594 | { |
|---|
| 1595 | first_au++; |
|---|
| 1596 | } |
|---|
| 1597 | AccessUnit::iterator it_sps; |
|---|
| 1598 | for (it_sps = first_au->begin(); it_sps != first_au->end(); it_sps++) |
|---|
| 1599 | { |
|---|
| 1600 | if( (*it_sps)->m_nalUnitType == NAL_UNIT_SPS ) |
|---|
| 1601 | { |
|---|
| 1602 | break; |
|---|
| 1603 | } |
|---|
| 1604 | } |
|---|
| 1605 | |
|---|
| 1606 | for (list<AccessUnit>::iterator it_au = ++outputAccessUnits.begin(); it_au != outputAccessUnits.end(); it_au++) |
|---|
| 1607 | { |
|---|
| 1608 | for (AccessUnit::iterator it_nalu = it_au->begin(); it_nalu != it_au->end(); it_nalu++) |
|---|
| 1609 | { |
|---|
| 1610 | if( (*it_nalu)->m_nalUnitType == NAL_UNIT_SPS ) |
|---|
| 1611 | { |
|---|
| 1612 | it_sps = first_au->insert(++it_sps, *it_nalu); |
|---|
| 1613 | it_nalu = it_au->erase(it_nalu); |
|---|
| 1614 | } |
|---|
| 1615 | } |
|---|
| 1616 | } |
|---|
| 1617 | } |
|---|
| 1618 | #endif |
|---|
| 1619 | |
|---|
| 1620 | #if RC_SHVC_HARMONIZATION |
|---|
| 1621 | for( UInt layer = 0; layer < m_numLayers; layer++ ) |
|---|
| 1622 | { |
|---|
| 1623 | if( m_apcTEncTop[layer]->getUseRateCtrl() ) |
|---|
| 1624 | { |
|---|
| 1625 | m_apcTEncTop[layer]->getRateCtrl()->destroyRCGOP(); |
|---|
| 1626 | } |
|---|
| 1627 | } |
|---|
| 1628 | #endif |
|---|
| 1629 | |
|---|
| 1630 | iTotalNumEncoded = 0; |
|---|
| 1631 | for( UInt layer=0; layer<m_numLayers; layer++ ) |
|---|
| 1632 | { |
|---|
| 1633 | //8 |
|---|
| 1634 | // write bistream to file if necessary |
|---|
| 1635 | iNumEncoded = m_apcTEncTop[layer]->getNumPicRcvd(); |
|---|
| 1636 | if ( iNumEncoded > 0 ) |
|---|
| 1637 | { |
|---|
| 1638 | xWriteRecon(layer, iNumEncoded); |
|---|
| 1639 | iTotalNumEncoded += iNumEncoded; |
|---|
| 1640 | } |
|---|
| 1641 | m_apcTEncTop[layer]->setNumPicRcvd( 0 ); |
|---|
| 1642 | } |
|---|
| 1643 | |
|---|
| 1644 | // write bitstream out |
|---|
| 1645 | if( iTotalNumEncoded ) |
|---|
| 1646 | { |
|---|
| 1647 | if( bEos ) |
|---|
| 1648 | { |
|---|
| 1649 | OutputNALUnit nalu(NAL_UNIT_EOB); |
|---|
| 1650 | nalu.m_nuhLayerId = 0; |
|---|
| 1651 | |
|---|
| 1652 | AccessUnit& accessUnit = outputAccessUnits.back(); |
|---|
| 1653 | nalu.m_temporalId = 0; |
|---|
| 1654 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
|---|
| 1655 | } |
|---|
| 1656 | |
|---|
| 1657 | xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits); |
|---|
| 1658 | outputAccessUnits.clear(); |
|---|
| 1659 | } |
|---|
| 1660 | |
|---|
| 1661 | // print out summary |
|---|
| 1662 | if (bEos) |
|---|
| 1663 | { |
|---|
| 1664 | printOutSummary(m_isTopFieldFirst, m_printMSEBasedSequencePSNR, m_printSequenceMSE); |
|---|
| 1665 | } |
|---|
| 1666 | |
|---|
| 1667 | bFirstFrame = false; |
|---|
| 1668 | } |
|---|
| 1669 | // delete original YUV buffer |
|---|
| 1670 | for(UInt layer=0; layer<m_numLayers; layer++) |
|---|
| 1671 | { |
|---|
| 1672 | pcPicYuvOrg[layer]->destroy(); |
|---|
| 1673 | delete pcPicYuvOrg[layer]; |
|---|
| 1674 | pcPicYuvOrg[layer] = NULL; |
|---|
| 1675 | |
|---|
| 1676 | // delete used buffers in encoder class |
|---|
| 1677 | m_apcTEncTop[layer]->deletePicBuffer(); |
|---|
| 1678 | acPicYuvTrueOrg[layer].destroy(); |
|---|
| 1679 | } |
|---|
| 1680 | |
|---|
| 1681 | // delete buffers & classes |
|---|
| 1682 | xDeleteBuffer(); |
|---|
| 1683 | xDestroyLib(); |
|---|
| 1684 | |
|---|
| 1685 | printRateSummary(); |
|---|
| 1686 | |
|---|
| 1687 | return; |
|---|
| 1688 | } |
|---|
| 1689 | |
|---|
| 1690 | Void TAppEncTop::printOutSummary(Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE) |
|---|
| 1691 | { |
|---|
| 1692 | UInt layer; |
|---|
| 1693 | const Int rateMultiplier = isField ? 2 : 1; |
|---|
| 1694 | |
|---|
| 1695 | // set frame rate |
|---|
| 1696 | for(layer = 0; layer < m_numLayers; layer++) |
|---|
| 1697 | { |
|---|
| 1698 | m_apcTEncTop[layer]->getAnalyzeAll()->setFrmRate( m_apcLayerCfg[layer]->m_iFrameRate * rateMultiplier ); |
|---|
| 1699 | m_apcTEncTop[layer]->getAnalyzeI()->setFrmRate( m_apcLayerCfg[layer]->m_iFrameRate * rateMultiplier ); |
|---|
| 1700 | m_apcTEncTop[layer]->getAnalyzeP()->setFrmRate( m_apcLayerCfg[layer]->m_iFrameRate * rateMultiplier ); |
|---|
| 1701 | m_apcTEncTop[layer]->getAnalyzeB()->setFrmRate( m_apcLayerCfg[layer]->m_iFrameRate * rateMultiplier ); |
|---|
| 1702 | } |
|---|
| 1703 | |
|---|
| 1704 | //-- all |
|---|
| 1705 | printf( "\n\nSUMMARY --------------------------------------------------------\n" ); |
|---|
| 1706 | for(layer = 0; layer < m_numLayers; layer++) |
|---|
| 1707 | { |
|---|
| 1708 | const UInt layerId = m_apcTEncTop[layer]->getVPS()->getLayerIdInNuh(layer); |
|---|
| 1709 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
|---|
| 1710 | m_apcTEncTop[layer]->getAnalyzeAll()->printOut('a', m_apcLayerCfg[layer]->m_chromaFormatIDC, printMSEBasedSNR, printSequenceMSE, bitDepths, layerId); |
|---|
| 1711 | } |
|---|
| 1712 | |
|---|
| 1713 | printf( "\n\nI Slices--------------------------------------------------------\n" ); |
|---|
| 1714 | for(layer = 0; layer < m_numLayers; layer++) |
|---|
| 1715 | { |
|---|
| 1716 | const UInt layerId = m_apcTEncTop[layer]->getVPS()->getLayerIdInNuh(layer); |
|---|
| 1717 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
|---|
| 1718 | m_apcTEncTop[layer]->getAnalyzeI()->printOut('i', m_apcLayerCfg[layer]->m_chromaFormatIDC, printMSEBasedSNR, printSequenceMSE, bitDepths, layerId); |
|---|
| 1719 | } |
|---|
| 1720 | |
|---|
| 1721 | printf( "\n\nP Slices--------------------------------------------------------\n" ); |
|---|
| 1722 | for(layer = 0; layer < m_numLayers; layer++) |
|---|
| 1723 | { |
|---|
| 1724 | const UInt layerId = m_apcTEncTop[layer]->getVPS()->getLayerIdInNuh(layer); |
|---|
| 1725 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
|---|
| 1726 | m_apcTEncTop[layer]->getAnalyzeP()->printOut('p', m_apcLayerCfg[layer]->m_chromaFormatIDC, printMSEBasedSNR, printSequenceMSE, bitDepths, layerId); |
|---|
| 1727 | } |
|---|
| 1728 | |
|---|
| 1729 | printf( "\n\nB Slices--------------------------------------------------------\n" ); |
|---|
| 1730 | for(layer = 0; layer < m_numLayers; layer++) |
|---|
| 1731 | { |
|---|
| 1732 | const UInt layerId = m_apcTEncTop[layer]->getVPS()->getLayerIdInNuh(layer); |
|---|
| 1733 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
|---|
| 1734 | m_apcTEncTop[layer]->getAnalyzeB()->printOut('b', m_apcLayerCfg[layer]->m_chromaFormatIDC, printMSEBasedSNR, printSequenceMSE, bitDepths, layerId); |
|---|
| 1735 | } |
|---|
| 1736 | |
|---|
| 1737 | for( layer = 0; layer < m_numLayers; layer++ ) |
|---|
| 1738 | { |
|---|
| 1739 | if (!m_apcTEncTop[layer]->getSummaryOutFilename().empty()) |
|---|
| 1740 | { |
|---|
| 1741 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
|---|
| 1742 | |
|---|
| 1743 | m_apcTEncTop[layer]->getAnalyzeAll()->printSummary(m_apcLayerCfg[layer]->m_chromaFormatIDC, printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryOutFilename()); |
|---|
| 1744 | } |
|---|
| 1745 | } |
|---|
| 1746 | |
|---|
| 1747 | for( layer = 0; layer < m_numLayers; layer++ ) |
|---|
| 1748 | { |
|---|
| 1749 | if (!m_apcTEncTop[layer]->getSummaryPicFilenameBase().empty()) |
|---|
| 1750 | { |
|---|
| 1751 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
|---|
| 1752 | |
|---|
| 1753 | m_apcTEncTop[layer]->getAnalyzeI()->printSummary(m_apcLayerCfg[layer]->m_chromaFormatIDC, printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"I.txt"); |
|---|
| 1754 | m_apcTEncTop[layer]->getAnalyzeP()->printSummary(m_apcLayerCfg[layer]->m_chromaFormatIDC, printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"P.txt"); |
|---|
| 1755 | m_apcTEncTop[layer]->getAnalyzeB()->printSummary(m_apcLayerCfg[layer]->m_chromaFormatIDC, printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"B.txt"); |
|---|
| 1756 | } |
|---|
| 1757 | } |
|---|
| 1758 | |
|---|
| 1759 | if(isField) |
|---|
| 1760 | { |
|---|
| 1761 | for(layer = 0; layer < m_numLayers; layer++) |
|---|
| 1762 | { |
|---|
| 1763 | const UInt layerId = m_apcTEncTop[layer]->getVPS()->getLayerIdInNuh(layer); |
|---|
| 1764 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
|---|
| 1765 | TEncAnalyze *analyze = m_apcTEncTop[layer]->getAnalyzeAllin(); |
|---|
| 1766 | |
|---|
| 1767 | //-- interlaced summary |
|---|
| 1768 | analyze->setFrmRate( m_apcLayerCfg[layer]->m_iFrameRate); |
|---|
| 1769 | analyze->setBits(m_apcTEncTop[layer]->getAnalyzeB()->getBits()); |
|---|
| 1770 | // prior to the above statement, the interlace analyser does not contain the correct total number of bits. |
|---|
| 1771 | |
|---|
| 1772 | printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); |
|---|
| 1773 | analyze->printOut('a', m_apcLayerCfg[layer]->m_chromaFormatIDC, printMSEBasedSNR, printSequenceMSE, bitDepths, layerId); |
|---|
| 1774 | |
|---|
| 1775 | if (!m_apcTEncTop[layer]->getSummaryOutFilename().empty()) |
|---|
| 1776 | { |
|---|
| 1777 | analyze->printSummary(m_apcLayerCfg[layer]->m_chromaFormatIDC, printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryOutFilename()); |
|---|
| 1778 | } |
|---|
| 1779 | } |
|---|
| 1780 | } |
|---|
| 1781 | |
|---|
| 1782 | printf("\n"); |
|---|
| 1783 | for( layer = 0; layer < m_numLayers; layer++ ) |
|---|
| 1784 | { |
|---|
| 1785 | const UInt layerId = m_apcTEncTop[layer]->getVPS()->getLayerIdInNuh(layer); |
|---|
| 1786 | printf("RVM[L%d]: %.3lf\n", layerId, m_apcTEncTop[layer]->calculateRVM()); |
|---|
| 1787 | } |
|---|
| 1788 | printf("\n"); |
|---|
| 1789 | } |
|---|
| 1790 | #else |
|---|
| 1791 | // ==================================================================================================================== |
|---|
| 1792 | // Public member functions |
|---|
| 1793 | // ==================================================================================================================== |
|---|
| 1794 | |
|---|
| 1795 | /** |
|---|
| 1796 | - create internal class |
|---|
| 1797 | - initialize internal variable |
|---|
| 1798 | - until the end of input YUV file, call encoding function in TEncTop class |
|---|
| 1799 | - delete allocated buffers |
|---|
| 1800 | - destroy internal class |
|---|
| 1801 | . |
|---|
| 1802 | */ |
|---|
| 1803 | Void TAppEncTop::encode() |
|---|
| 1804 | { |
|---|
| 1805 | fstream bitstreamFile(m_bitstreamFileName.c_str(), fstream::binary | fstream::out); |
|---|
| 1806 | if (!bitstreamFile) |
|---|
| 1807 | { |
|---|
| 1808 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_bitstreamFileName.c_str()); |
|---|
| 1809 | exit(EXIT_FAILURE); |
|---|
| 1810 | } |
|---|
| 1811 | |
|---|
| 1812 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
|---|
| 1813 | TComPicYuv* pcPicYuvRec = NULL; |
|---|
| 1814 | |
|---|
| 1815 | // initialize internal class & member variables |
|---|
| 1816 | xInitLibCfg(); |
|---|
| 1817 | xCreateLib(); |
|---|
| 1818 | xInitLib(m_isField); |
|---|
| 1819 | |
|---|
| 1820 | printChromaFormat(); |
|---|
| 1821 | |
|---|
| 1822 | // main encoder loop |
|---|
| 1823 | Int iNumEncoded = 0; |
|---|
| 1824 | Bool bEos = false; |
|---|
| 1825 | |
|---|
| 1826 | const InputColourSpaceConversion ipCSC = m_inputColourSpaceConvert; |
|---|
| 1827 | const InputColourSpaceConversion snrCSC = (!m_snrInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
|---|
| 1828 | |
|---|
| 1829 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
|---|
| 1830 | |
|---|
| 1831 | TComPicYuv cPicYuvTrueOrg; |
|---|
| 1832 | |
|---|
| 1833 | // allocate original YUV buffer |
|---|
| 1834 | if( m_isField ) |
|---|
| 1835 | { |
|---|
| 1836 | pcPicYuvOrg->create ( m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
|---|
| 1837 | cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true); |
|---|
| 1838 | } |
|---|
| 1839 | else |
|---|
| 1840 | { |
|---|
| 1841 | pcPicYuvOrg->create ( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
|---|
| 1842 | cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
|---|
| 1843 | } |
|---|
| 1844 | |
|---|
| 1845 | while ( !bEos ) |
|---|
| 1846 | { |
|---|
| 1847 | // get buffers |
|---|
| 1848 | xGetBuffer(pcPicYuvRec); |
|---|
| 1849 | |
|---|
| 1850 | // read input YUV file |
|---|
| 1851 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range ); |
|---|
| 1852 | |
|---|
| 1853 | // increase number of received frames |
|---|
| 1854 | m_iFrameRcvd++; |
|---|
| 1855 | |
|---|
| 1856 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
|---|
| 1857 | |
|---|
| 1858 | Bool flush = 0; |
|---|
| 1859 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
|---|
| 1860 | if (m_cTVideoIOYuvInputFile.isEof()) |
|---|
| 1861 | { |
|---|
| 1862 | flush = true; |
|---|
| 1863 | bEos = true; |
|---|
| 1864 | m_iFrameRcvd--; |
|---|
| 1865 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
|---|
| 1866 | } |
|---|
| 1867 | |
|---|
| 1868 | // call encoding function for one frame |
|---|
| 1869 | if ( m_isField ) |
|---|
| 1870 | { |
|---|
| 1871 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst ); |
|---|
| 1872 | } |
|---|
| 1873 | else |
|---|
| 1874 | { |
|---|
| 1875 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
|---|
| 1876 | } |
|---|
| 1877 | |
|---|
| 1878 | // write bistream to file if necessary |
|---|
| 1879 | if ( iNumEncoded > 0 ) |
|---|
| 1880 | { |
|---|
| 1881 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
|---|
| 1882 | outputAccessUnits.clear(); |
|---|
| 1883 | } |
|---|
| 1884 | } |
|---|
| 1885 | |
|---|
| 1886 | m_cTEncTop.printSummary(m_isField); |
|---|
| 1887 | |
|---|
| 1888 | // delete original YUV buffer |
|---|
| 1889 | pcPicYuvOrg->destroy(); |
|---|
| 1890 | delete pcPicYuvOrg; |
|---|
| 1891 | pcPicYuvOrg = NULL; |
|---|
| 1892 | |
|---|
| 1893 | // delete used buffers in encoder class |
|---|
| 1894 | m_cTEncTop.deletePicBuffer(); |
|---|
| 1895 | cPicYuvTrueOrg.destroy(); |
|---|
| 1896 | |
|---|
| 1897 | // delete buffers & classes |
|---|
| 1898 | xDeleteBuffer(); |
|---|
| 1899 | xDestroyLib(); |
|---|
| 1900 | |
|---|
| 1901 | printRateSummary(); |
|---|
| 1902 | |
|---|
| 1903 | return; |
|---|
| 1904 | } |
|---|
| 1905 | #endif //SVC_EXTENSION |
|---|
| 1906 | |
|---|
| 1907 | // ==================================================================================================================== |
|---|
| 1908 | // Protected member functions |
|---|
| 1909 | // ==================================================================================================================== |
|---|
| 1910 | |
|---|
| 1911 | /** |
|---|
| 1912 | - application has picture buffer list with size of GOP |
|---|
| 1913 | - picture buffer list acts as ring buffer |
|---|
| 1914 | - end of the list has the latest picture |
|---|
| 1915 | . |
|---|
| 1916 | */ |
|---|
| 1917 | #if SVC_EXTENSION |
|---|
| 1918 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
|---|
| 1919 | { |
|---|
| 1920 | assert( m_iGOPSize > 0 ); |
|---|
| 1921 | |
|---|
| 1922 | // org. buffer |
|---|
| 1923 | if ( m_acListPicYuvRec[layer].size() >= (UInt)m_iGOPSize ) // buffer will be 1 element longer when using field coding, to maintain first field whilst processing second. |
|---|
| 1924 | { |
|---|
| 1925 | rpcPicYuvRec = m_acListPicYuvRec[layer].popFront(); |
|---|
| 1926 | } |
|---|
| 1927 | else |
|---|
| 1928 | { |
|---|
| 1929 | rpcPicYuvRec = new TComPicYuv; |
|---|
| 1930 | |
|---|
| 1931 | rpcPicYuvRec->create( m_apcLayerCfg[layer]->m_iSourceWidth, m_apcLayerCfg[layer]->m_iSourceHeight, m_apcLayerCfg[layer]->m_chromaFormatIDC, m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL ); |
|---|
| 1932 | } |
|---|
| 1933 | m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec ); |
|---|
| 1934 | } |
|---|
| 1935 | |
|---|
| 1936 | Void TAppEncTop::xDeleteBuffer( ) |
|---|
| 1937 | { |
|---|
| 1938 | for(UInt layer=0; layer<m_numLayers; layer++) |
|---|
| 1939 | { |
|---|
| 1940 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].begin(); |
|---|
| 1941 | |
|---|
| 1942 | Int iSize = Int( m_acListPicYuvRec[layer].size() ); |
|---|
| 1943 | |
|---|
| 1944 | for ( Int i = 0; i < iSize; i++ ) |
|---|
| 1945 | { |
|---|
| 1946 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
|---|
| 1947 | pcPicYuvRec->destroy(); |
|---|
| 1948 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
|---|
| 1949 | } |
|---|
| 1950 | } |
|---|
| 1951 | } |
|---|
| 1952 | |
|---|
| 1953 | Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded) |
|---|
| 1954 | { |
|---|
| 1955 | ChromaFormat& chromaFormatIdc = m_apcLayerCfg[layer]->m_chromaFormatIDC; |
|---|
| 1956 | Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ); |
|---|
| 1957 | Int yScal = TComSPS::getWinUnitY( chromaFormatIdc ); |
|---|
| 1958 | |
|---|
| 1959 | const InputColourSpaceConversion ipCSC = (!m_outputInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
|---|
| 1960 | |
|---|
| 1961 | if (m_isField) |
|---|
| 1962 | { |
|---|
| 1963 | //Reinterlace fields |
|---|
| 1964 | Int i; |
|---|
| 1965 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
|---|
| 1966 | |
|---|
| 1967 | for ( i = 0; i < iNumEncoded; i++ ) |
|---|
| 1968 | { |
|---|
| 1969 | --iterPicYuvRec; |
|---|
| 1970 | } |
|---|
| 1971 | |
|---|
| 1972 | for ( i = 0; i < iNumEncoded/2; i++ ) |
|---|
| 1973 | { |
|---|
| 1974 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
|---|
| 1975 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
|---|
| 1976 | |
|---|
| 1977 | if( !m_apcLayerCfg[layer]->getReconFileName().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed() ) |
|---|
| 1978 | { |
|---|
| 1979 | m_apcTVideoIOYuvReconFile[layer]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_apcLayerCfg[layer]->getConfWinLeft() * xScal, m_apcLayerCfg[layer]->getConfWinRight() * xScal, |
|---|
| 1980 | m_apcLayerCfg[layer]->getConfWinTop() * yScal, m_apcLayerCfg[layer]->getConfWinBottom() * yScal, NUM_CHROMA_FORMAT, m_isTopFieldFirst ); |
|---|
| 1981 | } |
|---|
| 1982 | } |
|---|
| 1983 | } |
|---|
| 1984 | else |
|---|
| 1985 | { |
|---|
| 1986 | Int i; |
|---|
| 1987 | |
|---|
| 1988 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
|---|
| 1989 | |
|---|
| 1990 | for ( i = 0; i < iNumEncoded; i++ ) |
|---|
| 1991 | { |
|---|
| 1992 | --iterPicYuvRec; |
|---|
| 1993 | } |
|---|
| 1994 | |
|---|
| 1995 | for ( i = 0; i < iNumEncoded; i++ ) |
|---|
| 1996 | { |
|---|
| 1997 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
|---|
| 1998 | if( !m_apcLayerCfg[layer]->getReconFileName().empty() && pcPicYuvRec->isReconstructed() ) |
|---|
| 1999 | { |
|---|
| 2000 | m_apcTVideoIOYuvReconFile[layer]->write( pcPicYuvRec, ipCSC, m_apcLayerCfg[layer]->getConfWinLeft() * xScal, m_apcLayerCfg[layer]->getConfWinRight() * xScal, |
|---|
| 2001 | m_apcLayerCfg[layer]->getConfWinTop() * yScal, m_apcLayerCfg[layer]->getConfWinBottom() * yScal, |
|---|
| 2002 | NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range ); |
|---|
| 2003 | } |
|---|
| 2004 | } |
|---|
| 2005 | } |
|---|
| 2006 | } |
|---|
| 2007 | |
|---|
| 2008 | Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
|---|
| 2009 | { |
|---|
| 2010 | if (m_isField) |
|---|
| 2011 | { |
|---|
| 2012 | //Reinterlace fields |
|---|
| 2013 | Int i; |
|---|
| 2014 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
|---|
| 2015 | |
|---|
| 2016 | for( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ ) |
|---|
| 2017 | { |
|---|
| 2018 | const AccessUnit& auTop = *(iterBitstream++); |
|---|
| 2019 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
|---|
| 2020 | rateStatsAccum(auTop, statsTop); |
|---|
| 2021 | |
|---|
| 2022 | const AccessUnit& auBottom = *(iterBitstream++); |
|---|
| 2023 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
|---|
| 2024 | rateStatsAccum(auBottom, statsBottom); |
|---|
| 2025 | } |
|---|
| 2026 | } |
|---|
| 2027 | else |
|---|
| 2028 | { |
|---|
| 2029 | Int i; |
|---|
| 2030 | |
|---|
| 2031 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
|---|
| 2032 | |
|---|
| 2033 | for( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ ) |
|---|
| 2034 | { |
|---|
| 2035 | const AccessUnit& au = *(iterBitstream++); |
|---|
| 2036 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
|---|
| 2037 | rateStatsAccum(au, stats); |
|---|
| 2038 | } |
|---|
| 2039 | } |
|---|
| 2040 | } |
|---|
| 2041 | |
|---|
| 2042 | #else // SVC_EXTENSION |
|---|
| 2043 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
|---|
| 2044 | { |
|---|
| 2045 | assert( m_iGOPSize > 0 ); |
|---|
| 2046 | |
|---|
| 2047 | // org. buffer |
|---|
| 2048 | if ( m_cListPicYuvRec.size() >= (UInt)m_iGOPSize ) // buffer will be 1 element longer when using field coding, to maintain first field whilst processing second. |
|---|
| 2049 | { |
|---|
| 2050 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
|---|
| 2051 | |
|---|
| 2052 | } |
|---|
| 2053 | else |
|---|
| 2054 | { |
|---|
| 2055 | rpcPicYuvRec = new TComPicYuv; |
|---|
| 2056 | |
|---|
| 2057 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
|---|
| 2058 | |
|---|
| 2059 | } |
|---|
| 2060 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
|---|
| 2061 | } |
|---|
| 2062 | |
|---|
| 2063 | Void TAppEncTop::xDeleteBuffer( ) |
|---|
| 2064 | { |
|---|
| 2065 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
|---|
| 2066 | |
|---|
| 2067 | Int iSize = Int( m_cListPicYuvRec.size() ); |
|---|
| 2068 | |
|---|
| 2069 | for ( Int i = 0; i < iSize; i++ ) |
|---|
| 2070 | { |
|---|
| 2071 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
|---|
| 2072 | pcPicYuvRec->destroy(); |
|---|
| 2073 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
|---|
| 2074 | } |
|---|
| 2075 | |
|---|
| 2076 | } |
|---|
| 2077 | |
|---|
| 2078 | /** |
|---|
| 2079 | Write access units to output file. |
|---|
| 2080 | \param bitstreamFile target bitstream file |
|---|
| 2081 | \param iNumEncoded number of encoded frames |
|---|
| 2082 | \param accessUnits list of access units to be written |
|---|
| 2083 | */ |
|---|
| 2084 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
|---|
| 2085 | { |
|---|
| 2086 | const InputColourSpaceConversion ipCSC = (!m_outputInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
|---|
| 2087 | |
|---|
| 2088 | if (m_isField) |
|---|
| 2089 | { |
|---|
| 2090 | //Reinterlace fields |
|---|
| 2091 | Int i; |
|---|
| 2092 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
|---|
| 2093 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
|---|
| 2094 | |
|---|
| 2095 | for ( i = 0; i < iNumEncoded; i++ ) |
|---|
| 2096 | { |
|---|
| 2097 | --iterPicYuvRec; |
|---|
| 2098 | } |
|---|
| 2099 | |
|---|
| 2100 | for ( i = 0; i < iNumEncoded/2; i++ ) |
|---|
| 2101 | { |
|---|
| 2102 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
|---|
| 2103 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
|---|
| 2104 | |
|---|
| 2105 | if (!m_reconFileName.empty()) |
|---|
| 2106 | { |
|---|
| 2107 | m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst ); |
|---|
| 2108 | } |
|---|
| 2109 | |
|---|
| 2110 | const AccessUnit& auTop = *(iterBitstream++); |
|---|
| 2111 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
|---|
| 2112 | rateStatsAccum(auTop, statsTop); |
|---|
| 2113 | |
|---|
| 2114 | const AccessUnit& auBottom = *(iterBitstream++); |
|---|
| 2115 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
|---|
| 2116 | rateStatsAccum(auBottom, statsBottom); |
|---|
| 2117 | } |
|---|
| 2118 | } |
|---|
| 2119 | else |
|---|
| 2120 | { |
|---|
| 2121 | Int i; |
|---|
| 2122 | |
|---|
| 2123 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
|---|
| 2124 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
|---|
| 2125 | |
|---|
| 2126 | for ( i = 0; i < iNumEncoded; i++ ) |
|---|
| 2127 | { |
|---|
| 2128 | --iterPicYuvRec; |
|---|
| 2129 | } |
|---|
| 2130 | |
|---|
| 2131 | for ( i = 0; i < iNumEncoded; i++ ) |
|---|
| 2132 | { |
|---|
| 2133 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
|---|
| 2134 | if (!m_reconFileName.empty()) |
|---|
| 2135 | { |
|---|
| 2136 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, |
|---|
| 2137 | NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range ); |
|---|
| 2138 | } |
|---|
| 2139 | |
|---|
| 2140 | const AccessUnit& au = *(iterBitstream++); |
|---|
| 2141 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
|---|
| 2142 | rateStatsAccum(au, stats); |
|---|
| 2143 | } |
|---|
| 2144 | } |
|---|
| 2145 | } |
|---|
| 2146 | #endif |
|---|
| 2147 | |
|---|
| 2148 | /** |
|---|
| 2149 | * |
|---|
| 2150 | */ |
|---|
| 2151 | Void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
|---|
| 2152 | { |
|---|
| 2153 | AccessUnit::const_iterator it_au = au.begin(); |
|---|
| 2154 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
|---|
| 2155 | |
|---|
| 2156 | for (; it_au != au.end(); it_au++, it_stats++) |
|---|
| 2157 | { |
|---|
| 2158 | switch ((*it_au)->m_nalUnitType) |
|---|
| 2159 | { |
|---|
| 2160 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
|---|
| 2161 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
|---|
| 2162 | case NAL_UNIT_CODED_SLICE_TSA_R: |
|---|
| 2163 | case NAL_UNIT_CODED_SLICE_TSA_N: |
|---|
| 2164 | case NAL_UNIT_CODED_SLICE_STSA_R: |
|---|
| 2165 | case NAL_UNIT_CODED_SLICE_STSA_N: |
|---|
| 2166 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
|---|
| 2167 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
|---|
| 2168 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
|---|
| 2169 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
|---|
| 2170 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
|---|
| 2171 | case NAL_UNIT_CODED_SLICE_CRA: |
|---|
| 2172 | case NAL_UNIT_CODED_SLICE_RADL_N: |
|---|
| 2173 | case NAL_UNIT_CODED_SLICE_RADL_R: |
|---|
| 2174 | case NAL_UNIT_CODED_SLICE_RASL_N: |
|---|
| 2175 | case NAL_UNIT_CODED_SLICE_RASL_R: |
|---|
| 2176 | case NAL_UNIT_VPS: |
|---|
| 2177 | case NAL_UNIT_SPS: |
|---|
| 2178 | case NAL_UNIT_PPS: |
|---|
| 2179 | m_essentialBytes += *it_stats; |
|---|
| 2180 | break; |
|---|
| 2181 | default: |
|---|
| 2182 | break; |
|---|
| 2183 | } |
|---|
| 2184 | |
|---|
| 2185 | m_totalBytes += *it_stats; |
|---|
| 2186 | } |
|---|
| 2187 | } |
|---|
| 2188 | |
|---|
| 2189 | Void TAppEncTop::printRateSummary() |
|---|
| 2190 | { |
|---|
| 2191 | #if SVC_EXTENSION |
|---|
| 2192 | Double time = (Double) m_iFrameRcvd / m_apcLayerCfg[m_numLayers-1]->m_iFrameRate; |
|---|
| 2193 | #else |
|---|
| 2194 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
|---|
| 2195 | #endif |
|---|
| 2196 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
|---|
| 2197 | if (m_summaryVerboseness > 0) |
|---|
| 2198 | { |
|---|
| 2199 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
|---|
| 2200 | } |
|---|
| 2201 | } |
|---|
| 2202 | |
|---|
| 2203 | #if !SVC_EXTENSION |
|---|
| 2204 | Void TAppEncTop::printChromaFormat() |
|---|
| 2205 | { |
|---|
| 2206 | std::cout << std::setw(43) << "Input ChromaFormatIDC = "; |
|---|
| 2207 | switch (m_InputChromaFormatIDC) |
|---|
| 2208 | { |
|---|
| 2209 | case CHROMA_400: std::cout << " 4:0:0"; break; |
|---|
| 2210 | case CHROMA_420: std::cout << " 4:2:0"; break; |
|---|
| 2211 | case CHROMA_422: std::cout << " 4:2:2"; break; |
|---|
| 2212 | case CHROMA_444: std::cout << " 4:4:4"; break; |
|---|
| 2213 | default: |
|---|
| 2214 | std::cerr << "Invalid"; |
|---|
| 2215 | exit(1); |
|---|
| 2216 | } |
|---|
| 2217 | std::cout << std::endl; |
|---|
| 2218 | |
|---|
| 2219 | std::cout << std::setw(43) << "Output (internal) ChromaFormatIDC = "; |
|---|
| 2220 | switch (m_cTEncTop.getChromaFormatIdc()) |
|---|
| 2221 | { |
|---|
| 2222 | case CHROMA_400: std::cout << " 4:0:0"; break; |
|---|
| 2223 | case CHROMA_420: std::cout << " 4:2:0"; break; |
|---|
| 2224 | case CHROMA_422: std::cout << " 4:2:2"; break; |
|---|
| 2225 | case CHROMA_444: std::cout << " 4:4:4"; break; |
|---|
| 2226 | default: |
|---|
| 2227 | std::cerr << "Invalid"; |
|---|
| 2228 | exit(1); |
|---|
| 2229 | } |
|---|
| 2230 | std::cout << "\n" << std::endl; |
|---|
| 2231 | } |
|---|
| 2232 | #endif |
|---|
| 2233 | |
|---|
| 2234 | //! \} |
|---|