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