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