[324] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TAppEncTop.cpp |
---|
| 35 | \brief Encoder application class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include <list> |
---|
| 39 | #include <fstream> |
---|
| 40 | #include <stdlib.h> |
---|
| 41 | #include <stdio.h> |
---|
| 42 | #include <fcntl.h> |
---|
| 43 | #include <assert.h> |
---|
| 44 | |
---|
| 45 | #include "TAppEncTop.h" |
---|
| 46 | #include "TLibEncoder/AnnexBwrite.h" |
---|
| 47 | |
---|
| 48 | using namespace std; |
---|
| 49 | |
---|
| 50 | //! \ingroup TAppEncoder |
---|
| 51 | //! \{ |
---|
| 52 | |
---|
| 53 | // ==================================================================================================================== |
---|
| 54 | // Constructor / destructor / initialization / destroy |
---|
| 55 | // ==================================================================================================================== |
---|
| 56 | |
---|
| 57 | TAppEncTop::TAppEncTop() |
---|
| 58 | { |
---|
[368] | 59 | #if !H_MV |
---|
[324] | 60 | m_iFrameRcvd = 0; |
---|
[368] | 61 | #endif |
---|
[324] | 62 | m_totalBytes = 0; |
---|
| 63 | m_essentialBytes = 0; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | TAppEncTop::~TAppEncTop() |
---|
| 67 | { |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | Void TAppEncTop::xInitLibCfg() |
---|
| 71 | { |
---|
[446] | 72 | #if H_MV |
---|
| 73 | TComVPS& vps = m_vps; |
---|
| 74 | #else |
---|
[324] | 75 | TComVPS vps; |
---|
[446] | 76 | #endif |
---|
[324] | 77 | |
---|
[368] | 78 | #if H_MV |
---|
| 79 | Int maxTempLayer = -1; |
---|
| 80 | for (Int j = 0; j < m_numberOfLayers; j++) |
---|
| 81 | { |
---|
| 82 | maxTempLayer = max( m_maxTempLayerMvc[ j ], maxTempLayer ); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | vps.setMaxTLayers ( maxTempLayer ); |
---|
| 86 | if ( maxTempLayer ) |
---|
| 87 | { |
---|
| 88 | vps.setTemporalNestingFlag(true); |
---|
| 89 | } |
---|
| 90 | vps.setMaxLayers( m_numberOfLayers ); |
---|
| 91 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 92 | { |
---|
| 93 | Int maxNumReOrderPics = 0; |
---|
| 94 | Int maxDecPicBuffering = 0; |
---|
| 95 | for (Int j = 0; j < m_numberOfLayers; j++) |
---|
| 96 | { |
---|
| 97 | maxNumReOrderPics = max( maxNumReOrderPics, m_numReorderPicsMvc [ j ][ i ] ); |
---|
| 98 | maxDecPicBuffering = max( maxDecPicBuffering, m_maxDecPicBufferingMvc[ j ][ i ] ); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | vps.setNumReorderPics ( maxNumReOrderPics ,i ); |
---|
| 102 | vps.setMaxDecPicBuffering ( maxDecPicBuffering ,i ); |
---|
| 103 | } |
---|
| 104 | #else |
---|
[324] | 105 | vps.setMaxTLayers ( m_maxTempLayer ); |
---|
| 106 | if (m_maxTempLayer == 1) |
---|
| 107 | { |
---|
| 108 | vps.setTemporalNestingFlag(true); |
---|
| 109 | } |
---|
| 110 | vps.setMaxLayers ( 1 ); |
---|
| 111 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 112 | { |
---|
| 113 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 114 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 115 | } |
---|
[368] | 116 | #endif |
---|
| 117 | #if H_MV |
---|
| 118 | xSetLayerIds ( vps ); |
---|
| 119 | xSetDimensionIdAndLength ( vps ); |
---|
[493] | 120 | xSetDependencies( vps ); |
---|
[495] | 121 | xSetProfileTierLevel ( vps ); |
---|
[492] | 122 | xSetLayerSets ( vps ); |
---|
[446] | 123 | #if H_3D |
---|
| 124 | vps.initViewIndex(); |
---|
| 125 | m_ivPicLists.setVPS ( &vps ); |
---|
| 126 | #endif |
---|
[368] | 127 | |
---|
| 128 | for(Int layer = 0; layer < m_numberOfLayers; layer++) |
---|
| 129 | { |
---|
| 130 | m_frameRcvd .push_back(0); |
---|
| 131 | m_acTEncTopList .push_back(new TEncTop); |
---|
| 132 | m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv); |
---|
| 133 | m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv); |
---|
| 134 | m_picYuvRec .push_back(new TComList<TComPicYuv*>) ; |
---|
| 135 | |
---|
| 136 | m_ivPicLists.push_back( m_acTEncTopList[ layer ]->getListPic() ); |
---|
| 137 | TEncTop& m_cTEncTop = *m_acTEncTopList[ layer ]; // It is not a member, but this name helps avoiding code duplication !!! |
---|
| 138 | |
---|
[446] | 139 | m_cTEncTop.setLayerIdInVps ( layer ); |
---|
| 140 | m_cTEncTop.setLayerId ( vps.getLayerIdInNuh( layer ) ); |
---|
| 141 | m_cTEncTop.setViewId ( vps.getViewId ( layer ) ); |
---|
[368] | 142 | #if H_3D |
---|
[446] | 143 | Bool isDepth = ( vps.getDepthId ( layer ) != 0 ) ; |
---|
| 144 | m_cTEncTop.setViewIndex ( vps.getViewIndex ( layer ) ); |
---|
| 145 | m_cTEncTop.setIsDepth ( isDepth ); |
---|
| 146 | //====== Camera Parameters ========= |
---|
| 147 | m_cTEncTop.setCameraParameters ( &m_cCameraData ); |
---|
| 148 | m_cTEncTop.setCamParPrecision ( isDepth ? false : m_cCameraData.getCamParsCodedPrecision () ); |
---|
| 149 | m_cTEncTop.setCamParInSliceHeader ( isDepth ? 0 : m_cCameraData.getVaryingCameraParameters() ); |
---|
| 150 | m_cTEncTop.setCodedScale ( isDepth ? 0 : m_cCameraData.getCodedScale () ); |
---|
| 151 | m_cTEncTop.setCodedOffset ( isDepth ? 0 : m_cCameraData.getCodedOffset () ); |
---|
| 152 | #if H_3D_VSO |
---|
| 153 | //====== VSO ========= |
---|
| 154 | m_cTEncTop.setRenderModelParameters ( &m_cRenModStrParser ); |
---|
| 155 | m_cTEncTop.setForceLambdaScaleVSO ( isDepth ? m_bForceLambdaScaleVSO : false ); |
---|
| 156 | m_cTEncTop.setLambdaScaleVSO ( isDepth ? m_dLambdaScaleVSO : 1 ); |
---|
| 157 | m_cTEncTop.setVSOMode ( isDepth ? m_uiVSOMode : 0 ); |
---|
[438] | 158 | |
---|
[446] | 159 | m_cTEncTop.setAllowNegDist ( isDepth ? m_bAllowNegDist : false ); |
---|
| 160 | |
---|
| 161 | // SAIT_VSO_EST_A0033 |
---|
| 162 | m_cTEncTop.setUseEstimatedVSD ( isDepth ? m_bUseEstimatedVSD : false ); |
---|
| 163 | |
---|
| 164 | // LGE_WVSO_A0119 |
---|
| 165 | m_cTEncTop.setUseWVSO ( isDepth ? m_bUseWVSO : false ); |
---|
| 166 | m_cTEncTop.setVSOWeight ( isDepth ? m_iVSOWeight : 0 ); |
---|
| 167 | m_cTEncTop.setVSDWeight ( isDepth ? m_iVSDWeight : 0 ); |
---|
| 168 | m_cTEncTop.setDWeight ( isDepth ? m_iDWeight : 0 ); |
---|
| 169 | #endif // H_3D_VSO |
---|
| 170 | #endif // H_3D |
---|
| 171 | |
---|
| 172 | m_cTEncTop.setIvPicLists ( &m_ivPicLists ); |
---|
| 173 | #endif // H_MV |
---|
[324] | 174 | m_cTEncTop.setVPS(&vps); |
---|
| 175 | |
---|
| 176 | m_cTEncTop.setProfile(m_profile); |
---|
| 177 | m_cTEncTop.setLevel(m_levelTier, m_level); |
---|
| 178 | #if L0046_CONSTRAINT_FLAGS |
---|
| 179 | m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
| 180 | m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
| 181 | m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
| 182 | m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
| 183 | #endif |
---|
| 184 | |
---|
| 185 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
---|
| 186 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
---|
| 187 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
---|
| 188 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
---|
| 189 | m_cTEncTop.setConformanceWindow ( m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
| 190 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
| 191 | |
---|
| 192 | //====== Coding Structure ======== |
---|
| 193 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod ); |
---|
| 194 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
| 195 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
---|
[368] | 196 | #if H_MV |
---|
| 197 | m_cTEncTop.setGopList ( m_GOPListMvc[layer] ); |
---|
| 198 | m_cTEncTop.setExtraRPSs ( m_extraRPSsMvc[layer] ); |
---|
| 199 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 200 | { |
---|
| 201 | m_cTEncTop.setNumReorderPics ( m_numReorderPicsMvc[layer][i], i ); |
---|
| 202 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBufferingMvc[layer][i], i ); |
---|
| 203 | } |
---|
| 204 | #else |
---|
[324] | 205 | m_cTEncTop.setGopList ( m_GOPList ); |
---|
| 206 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
---|
| 207 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 208 | { |
---|
| 209 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 210 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 211 | } |
---|
[368] | 212 | #endif |
---|
[324] | 213 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
| 214 | { |
---|
| 215 | m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
| 216 | } |
---|
[368] | 217 | #if H_MV |
---|
| 218 | m_cTEncTop.setQP ( m_iQP[layer] ); |
---|
| 219 | #else |
---|
[324] | 220 | m_cTEncTop.setQP ( m_iQP ); |
---|
[368] | 221 | #endif |
---|
[446] | 222 | |
---|
[324] | 223 | m_cTEncTop.setPad ( m_aiPad ); |
---|
[446] | 224 | |
---|
[368] | 225 | #if H_MV |
---|
| 226 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayerMvc[layer] ); |
---|
| 227 | #else |
---|
[324] | 228 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
---|
[368] | 229 | #endif |
---|
[324] | 230 | m_cTEncTop.setUseAMP( m_enableAMP ); |
---|
| 231 | |
---|
| 232 | //===== Slice ======== |
---|
| 233 | |
---|
| 234 | //====== Loop/Deblock Filter ======== |
---|
[368] | 235 | #if H_MV |
---|
| 236 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable[layer]); |
---|
| 237 | #else |
---|
[324] | 238 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
[368] | 239 | #endif |
---|
[324] | 240 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
| 241 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
| 242 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
| 243 | m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
[446] | 244 | #if L0386_DB_METRIC |
---|
| 245 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
| 246 | #endif |
---|
[324] | 247 | |
---|
| 248 | //====== Motion search ======== |
---|
| 249 | m_cTEncTop.setFastSearch ( m_iFastSearch ); |
---|
| 250 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
---|
| 251 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
---|
| 252 | |
---|
| 253 | //====== Quality control ======== |
---|
| 254 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
| 255 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
| 256 | |
---|
| 257 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
---|
| 258 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
---|
| 259 | |
---|
| 260 | #if ADAPTIVE_QP_SELECTION |
---|
| 261 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
| 262 | #endif |
---|
| 263 | |
---|
| 264 | Int lowestQP; |
---|
| 265 | lowestQP = - 6*(g_bitDepthY - 8); // XXX: check |
---|
[446] | 266 | |
---|
[368] | 267 | #if H_MV |
---|
| 268 | if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layer] == lowestQP) && (m_useLossless == true)) |
---|
| 269 | #else |
---|
[324] | 270 | if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true)) |
---|
[368] | 271 | #endif |
---|
[324] | 272 | { |
---|
| 273 | m_bUseAdaptiveQP = false; |
---|
| 274 | } |
---|
| 275 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
| 276 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
| 277 | |
---|
| 278 | //====== Tool list ======== |
---|
| 279 | m_cTEncTop.setUseSBACRD ( m_bUseSBACRD ); |
---|
| 280 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
| 281 | m_cTEncTop.setUseASR ( m_bUseASR ); |
---|
| 282 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
---|
| 283 | m_cTEncTop.setUseLossless ( m_useLossless ); |
---|
[446] | 284 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
[324] | 285 | m_cTEncTop.setUseLComb ( m_bUseLComb ); |
---|
[446] | 286 | #endif |
---|
[368] | 287 | #if H_MV |
---|
| 288 | m_cTEncTop.setdQPs ( m_aidQP[layer] ); |
---|
| 289 | #else |
---|
[324] | 290 | m_cTEncTop.setdQPs ( m_aidQP ); |
---|
[368] | 291 | #endif |
---|
[324] | 292 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
---|
| 293 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
---|
| 294 | #if L0232_RD_PENALTY |
---|
| 295 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
---|
| 296 | #endif |
---|
| 297 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
| 298 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
| 299 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
| 300 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
| 301 | m_cTEncTop.setUseFastEnc ( m_bUseFastEnc ); |
---|
| 302 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
---|
| 303 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
| 304 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
| 305 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
| 306 | |
---|
| 307 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
---|
| 308 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
| 309 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
| 310 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
| 311 | m_cTEncTop.setUsePCM ( m_usePCM ); |
---|
| 312 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
| 313 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
| 314 | |
---|
| 315 | |
---|
| 316 | //====== Weighted Prediction ======== |
---|
| 317 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
---|
| 318 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
---|
| 319 | //====== Parallel Merge Estimation ======== |
---|
| 320 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
| 321 | |
---|
| 322 | //====== Slice ======== |
---|
| 323 | m_cTEncTop.setSliceMode ( m_sliceMode ); |
---|
| 324 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
| 325 | |
---|
| 326 | //====== Dependent Slice ======== |
---|
| 327 | m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
| 328 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
| 329 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
| 330 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
| 331 | { |
---|
| 332 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
| 333 | } |
---|
| 334 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
| 335 | { |
---|
| 336 | m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
| 337 | } |
---|
| 338 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
| 339 | { |
---|
| 340 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | if(m_sliceMode == 0 ) |
---|
| 344 | { |
---|
| 345 | m_bLFCrossSliceBoundaryFlag = true; |
---|
| 346 | } |
---|
| 347 | m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
[368] | 348 | #if H_MV |
---|
| 349 | m_cTEncTop.setUseSAO ( m_bUseSAO[layer] ); |
---|
| 350 | #else |
---|
[324] | 351 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
---|
[368] | 352 | #endif |
---|
[324] | 353 | m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
| 354 | |
---|
| 355 | m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary); |
---|
| 356 | m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization); |
---|
| 357 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
| 358 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
| 359 | |
---|
| 360 | m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
| 361 | m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
| 362 | m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
| 363 | m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
[446] | 364 | #if J0149_TONE_MAPPING_SEI |
---|
| 365 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
| 366 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
---|
| 367 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
| 368 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
| 369 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
| 370 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
| 371 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
---|
| 372 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
---|
| 373 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
| 374 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
| 375 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
| 376 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
| 377 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
---|
| 378 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
| 379 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
| 380 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
| 381 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
| 382 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
| 383 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
| 384 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
| 385 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
| 386 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
| 387 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
| 388 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
| 389 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
| 390 | #endif |
---|
[324] | 391 | m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
| 392 | m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
| 393 | m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
| 394 | m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
| 395 | m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
| 396 | m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
| 397 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
| 398 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
| 399 | m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
[446] | 400 | #if L0208_SOP_DESCRIPTION_SEI |
---|
| 401 | m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
| 402 | #endif |
---|
| 403 | #if K0180_SCALABLE_NESTING_SEI |
---|
| 404 | m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
| 405 | #endif |
---|
[324] | 406 | m_cTEncTop.setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
---|
| 407 | m_cTEncTop.setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
---|
| 408 | m_cTEncTop.setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
---|
| 409 | if(m_iUniformSpacingIdr==0) |
---|
| 410 | { |
---|
| 411 | m_cTEncTop.setColumnWidth ( m_pColumnWidth ); |
---|
| 412 | m_cTEncTop.setRowHeight ( m_pRowHeight ); |
---|
| 413 | } |
---|
| 414 | m_cTEncTop.xCheckGSParameters(); |
---|
| 415 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
---|
| 416 | if(uiTilesCount == 1) |
---|
| 417 | { |
---|
| 418 | m_bLFCrossTileBoundaryFlag = true; |
---|
| 419 | } |
---|
| 420 | m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
| 421 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
| 422 | m_cTEncTop.setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
| 423 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
---|
| 424 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
---|
| 425 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
---|
| 426 | m_cTEncTop.setSignHideFlag(m_signHideFlag); |
---|
| 427 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 428 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
| 429 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
| 430 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
| 431 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
---|
| 432 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
| 433 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
---|
| 434 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
---|
| 435 | #else |
---|
| 436 | m_cTEncTop.setUseRateCtrl ( m_enableRateCtrl); |
---|
| 437 | m_cTEncTop.setTargetBitrate ( m_targetBitrate); |
---|
| 438 | m_cTEncTop.setNumLCUInUnit ( m_numLCUInUnit); |
---|
| 439 | #endif |
---|
| 440 | m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
| 441 | m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue); |
---|
| 442 | m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
| 443 | m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
| 444 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
| 445 | m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
| 446 | m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc ); |
---|
| 447 | m_cTEncTop.setSarWidth( m_sarWidth ); |
---|
| 448 | m_cTEncTop.setSarHeight( m_sarHeight ); |
---|
| 449 | m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
| 450 | m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
| 451 | m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
| 452 | m_cTEncTop.setVideoFormat( m_videoFormat ); |
---|
| 453 | m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
| 454 | m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
| 455 | m_cTEncTop.setColourPrimaries( m_colourPrimaries ); |
---|
| 456 | m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics ); |
---|
| 457 | m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients ); |
---|
| 458 | m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
| 459 | m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
| 460 | m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
| 461 | m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
| 462 | m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
| 463 | m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
| 464 | m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
| 465 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
| 466 | m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
| 467 | m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
| 468 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
| 469 | m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
| 470 | m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
| 471 | m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
| 472 | m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
| 473 | m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
| 474 | #if SIGNAL_BITRATE_PICRATE_IN_VPS |
---|
| 475 | TComBitRatePicRateInfo *bitRatePicRateInfo = m_cTEncTop.getVPS()->getBitratePicrateInfo(); |
---|
| 476 | // The number of bit rate/pic rate have to equal to number of sub-layers. |
---|
| 477 | if(m_bitRatePicRateMaxTLayers) |
---|
| 478 | { |
---|
| 479 | assert(m_bitRatePicRateMaxTLayers == m_cTEncTop.getVPS()->getMaxTLayers()); |
---|
| 480 | } |
---|
| 481 | for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++) |
---|
| 482 | { |
---|
| 483 | bitRatePicRateInfo->setBitRateInfoPresentFlag( i, m_bitRateInfoPresentFlag[i] ); |
---|
| 484 | if( bitRatePicRateInfo->getBitRateInfoPresentFlag(i) ) |
---|
| 485 | { |
---|
| 486 | bitRatePicRateInfo->setAvgBitRate(i, m_avgBitRate[i]); |
---|
| 487 | bitRatePicRateInfo->setMaxBitRate(i, m_maxBitRate[i]); |
---|
| 488 | } |
---|
| 489 | } |
---|
| 490 | for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++) |
---|
| 491 | { |
---|
| 492 | bitRatePicRateInfo->setPicRateInfoPresentFlag( i, m_picRateInfoPresentFlag[i] ); |
---|
| 493 | if( bitRatePicRateInfo->getPicRateInfoPresentFlag(i) ) |
---|
| 494 | { |
---|
| 495 | bitRatePicRateInfo->setAvgPicRate (i, m_avgPicRate[i]); |
---|
| 496 | bitRatePicRateInfo->setConstantPicRateIdc(i, m_constantPicRateIdc[i]); |
---|
| 497 | } |
---|
| 498 | } |
---|
| 499 | #endif |
---|
[368] | 500 | #if H_MV |
---|
| 501 | } |
---|
| 502 | #endif |
---|
[446] | 503 | #if H_3D_VSO |
---|
| 504 | if ( m_bUseVSO ) |
---|
| 505 | { |
---|
| 506 | if ( m_uiVSOMode == 4 ) |
---|
| 507 | { |
---|
| 508 | #if H_3D_VSO_EARLY_SKIP |
---|
| 509 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip ); |
---|
| 510 | #else |
---|
| 511 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 ); |
---|
| 512 | #endif |
---|
| 513 | for ( Int layer = 0; layer < m_numberOfLayers ; layer++ ) |
---|
| 514 | { |
---|
| 515 | TEncTop* pcEncTop = m_acTEncTopList[ layer ]; |
---|
| 516 | Int iViewNum = pcEncTop->getViewIndex(); |
---|
| 517 | Int iContent = pcEncTop->getIsDepth() ? 1 : 0; |
---|
| 518 | Int iNumOfModels = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent); |
---|
[438] | 519 | |
---|
[446] | 520 | Bool bUseVSO = (iNumOfModels != 0); |
---|
| 521 | |
---|
| 522 | pcEncTop->setUseVSO( bUseVSO ); |
---|
| 523 | pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL ); |
---|
| 524 | |
---|
| 525 | for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ ) |
---|
| 526 | { |
---|
| 527 | Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode; |
---|
| 528 | |
---|
| 529 | m_cRenModStrParser.getSingleModelData ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ; |
---|
| 530 | m_cRendererModel .createSingleModel ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode ); |
---|
| 531 | } |
---|
| 532 | } |
---|
| 533 | } |
---|
| 534 | else |
---|
| 535 | { |
---|
| 536 | AOT(true); |
---|
| 537 | } |
---|
| 538 | } |
---|
| 539 | #endif |
---|
[324] | 540 | } |
---|
| 541 | |
---|
| 542 | Void TAppEncTop::xCreateLib() |
---|
| 543 | { |
---|
[368] | 544 | #if H_MV |
---|
| 545 | // initialize global variables |
---|
| 546 | initROM(); |
---|
| 547 | |
---|
| 548 | for( Int layer=0; layer < m_numberOfLayers; layer++) |
---|
| 549 | { |
---|
| 550 | m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
| 551 | m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
| 552 | |
---|
| 553 | if (m_pchReconFileList[layer]) |
---|
| 554 | { |
---|
| 555 | m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
| 556 | } |
---|
| 557 | m_acTEncTopList[layer]->create(); |
---|
| 558 | } |
---|
| 559 | #else |
---|
[324] | 560 | // Video I/O |
---|
| 561 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
| 562 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
| 563 | |
---|
| 564 | if (m_pchReconFile) |
---|
| 565 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
| 566 | |
---|
| 567 | // Neo Decoder |
---|
| 568 | m_cTEncTop.create(); |
---|
[368] | 569 | #endif |
---|
[324] | 570 | } |
---|
| 571 | |
---|
| 572 | Void TAppEncTop::xDestroyLib() |
---|
| 573 | { |
---|
[368] | 574 | #if H_MV |
---|
| 575 | // destroy ROM |
---|
| 576 | destroyROM(); |
---|
| 577 | |
---|
| 578 | for(Int layer=0; layer<m_numberOfLayers; layer++) |
---|
| 579 | { |
---|
| 580 | m_acTVideoIOYuvInputFileList[layer]->close(); |
---|
| 581 | m_acTVideoIOYuvReconFileList[layer]->close(); |
---|
| 582 | delete m_acTVideoIOYuvInputFileList[layer] ; |
---|
| 583 | m_acTVideoIOYuvInputFileList[layer] = NULL; |
---|
| 584 | delete m_acTVideoIOYuvReconFileList[layer] ; |
---|
| 585 | m_acTVideoIOYuvReconFileList[layer] = NULL; |
---|
| 586 | m_acTEncTopList[layer]->deletePicBuffer(); |
---|
| 587 | m_acTEncTopList[layer]->destroy(); |
---|
| 588 | delete m_acTEncTopList[layer] ; |
---|
| 589 | m_acTEncTopList[layer] = NULL; |
---|
| 590 | delete m_picYuvRec[layer] ; |
---|
| 591 | m_picYuvRec[layer] = NULL; |
---|
| 592 | } |
---|
| 593 | #else |
---|
[324] | 594 | // Video I/O |
---|
| 595 | m_cTVideoIOYuvInputFile.close(); |
---|
| 596 | m_cTVideoIOYuvReconFile.close(); |
---|
| 597 | |
---|
| 598 | // Neo Decoder |
---|
| 599 | m_cTEncTop.destroy(); |
---|
[368] | 600 | #endif |
---|
[324] | 601 | } |
---|
| 602 | |
---|
| 603 | Void TAppEncTop::xInitLib() |
---|
| 604 | { |
---|
[368] | 605 | #if H_MV |
---|
| 606 | for(Int layer=0; layer<m_numberOfLayers; layer++) |
---|
| 607 | { |
---|
| 608 | m_acTEncTopList[layer]->init( ); |
---|
| 609 | } |
---|
| 610 | #else |
---|
[324] | 611 | m_cTEncTop.init(); |
---|
[368] | 612 | #endif |
---|
[324] | 613 | } |
---|
| 614 | |
---|
| 615 | // ==================================================================================================================== |
---|
| 616 | // Public member functions |
---|
| 617 | // ==================================================================================================================== |
---|
| 618 | |
---|
| 619 | /** |
---|
| 620 | - create internal class |
---|
| 621 | - initialize internal variable |
---|
| 622 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
| 623 | - delete allocated buffers |
---|
| 624 | - destroy internal class |
---|
| 625 | . |
---|
| 626 | */ |
---|
| 627 | Void TAppEncTop::encode() |
---|
| 628 | { |
---|
| 629 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
| 630 | if (!bitstreamFile) |
---|
| 631 | { |
---|
| 632 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
| 633 | exit(EXIT_FAILURE); |
---|
| 634 | } |
---|
| 635 | |
---|
| 636 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
| 637 | TComPicYuv* pcPicYuvRec = NULL; |
---|
| 638 | |
---|
| 639 | // initialize internal class & member variables |
---|
| 640 | xInitLibCfg(); |
---|
| 641 | xCreateLib(); |
---|
| 642 | xInitLib(); |
---|
| 643 | |
---|
| 644 | // main encoder loop |
---|
[368] | 645 | #if H_MV |
---|
| 646 | Bool allEos = false; |
---|
| 647 | std::vector<Bool> eos ; |
---|
| 648 | std::vector<Bool> flush ; |
---|
| 649 | |
---|
| 650 | Int gopSize = 1; |
---|
| 651 | Int maxGopSize = 0; |
---|
| 652 | maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); |
---|
| 653 | |
---|
| 654 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
| 655 | { |
---|
| 656 | eos .push_back( false ); |
---|
| 657 | flush.push_back( false ); |
---|
| 658 | } |
---|
| 659 | #else |
---|
[324] | 660 | Int iNumEncoded = 0; |
---|
| 661 | Bool bEos = false; |
---|
[368] | 662 | #endif |
---|
[324] | 663 | |
---|
| 664 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
| 665 | |
---|
| 666 | // allocate original YUV buffer |
---|
| 667 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 668 | |
---|
[368] | 669 | #if H_MV |
---|
| 670 | while ( !allEos ) |
---|
| 671 | { |
---|
| 672 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
| 673 | { |
---|
| 674 | Int frmCnt = 0; |
---|
| 675 | while ( !eos[layer] && !(frmCnt == gopSize)) |
---|
| 676 | { |
---|
| 677 | // get buffers |
---|
| 678 | xGetBuffer(pcPicYuvRec, layer); |
---|
| 679 | |
---|
| 680 | // read input YUV file |
---|
| 681 | m_acTVideoIOYuvInputFileList[layer]->read ( pcPicYuvOrg, m_aiPad ); |
---|
| 682 | m_acTEncTopList [layer]->initNewPic( pcPicYuvOrg ); |
---|
| 683 | |
---|
| 684 | // increase number of received frames |
---|
| 685 | m_frameRcvd[layer]++; |
---|
| 686 | |
---|
| 687 | frmCnt++; |
---|
| 688 | |
---|
| 689 | eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded); |
---|
[446] | 690 | allEos = allEos||eos[layer]; |
---|
[368] | 691 | |
---|
| 692 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
| 693 | if (m_acTVideoIOYuvInputFileList[layer]->isEof()) |
---|
| 694 | { |
---|
| 695 | flush [layer] = true; |
---|
[446] | 696 | eos [layer] = true; |
---|
[368] | 697 | m_frameRcvd [layer]--; |
---|
| 698 | m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]); |
---|
| 699 | } |
---|
| 700 | } |
---|
| 701 | } |
---|
| 702 | for ( Int gopId=0; gopId < gopSize; gopId++ ) |
---|
| 703 | { |
---|
[446] | 704 | #if H_3D |
---|
| 705 | UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId ); |
---|
| 706 | if ( iNextPoc < m_framesToBeEncoded ) |
---|
| 707 | { |
---|
| 708 | m_cCameraData.update( iNextPoc ); |
---|
| 709 | } |
---|
| 710 | #endif |
---|
[368] | 711 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
| 712 | { |
---|
[446] | 713 | #if H_3D_VSO |
---|
| 714 | if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded ) |
---|
| 715 | { |
---|
| 716 | m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() ); |
---|
| 717 | m_acTEncTopList[layer] ->setDispCoeff( m_cCameraData.getDispCoeff() ); |
---|
| 718 | } |
---|
| 719 | #endif |
---|
[368] | 720 | Int iNumEncoded = 0; |
---|
| 721 | |
---|
| 722 | // call encoding function for one frame |
---|
| 723 | m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, *m_picYuvRec[layer], outputAccessUnits, iNumEncoded, gopId ); |
---|
| 724 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer); |
---|
| 725 | outputAccessUnits.clear(); |
---|
| 726 | } |
---|
| 727 | } |
---|
| 728 | gopSize = maxGopSize; |
---|
| 729 | } |
---|
| 730 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
| 731 | { |
---|
| 732 | m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded() ); |
---|
| 733 | } |
---|
| 734 | #else |
---|
[324] | 735 | while ( !bEos ) |
---|
| 736 | { |
---|
| 737 | // get buffers |
---|
| 738 | xGetBuffer(pcPicYuvRec); |
---|
| 739 | |
---|
| 740 | // read input YUV file |
---|
| 741 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad ); |
---|
| 742 | |
---|
| 743 | // increase number of received frames |
---|
| 744 | m_iFrameRcvd++; |
---|
| 745 | |
---|
| 746 | bEos = (m_iFrameRcvd == m_framesToBeEncoded); |
---|
| 747 | |
---|
| 748 | Bool flush = 0; |
---|
| 749 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
| 750 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
| 751 | { |
---|
| 752 | flush = true; |
---|
| 753 | bEos = true; |
---|
| 754 | m_iFrameRcvd--; |
---|
| 755 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
| 756 | } |
---|
| 757 | |
---|
| 758 | // call encoding function for one frame |
---|
| 759 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
| 760 | |
---|
| 761 | // write bistream to file if necessary |
---|
| 762 | if ( iNumEncoded > 0 ) |
---|
| 763 | { |
---|
| 764 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
| 765 | outputAccessUnits.clear(); |
---|
| 766 | } |
---|
| 767 | } |
---|
| 768 | |
---|
| 769 | m_cTEncTop.printSummary(); |
---|
[368] | 770 | #endif |
---|
[324] | 771 | |
---|
| 772 | // delete original YUV buffer |
---|
| 773 | pcPicYuvOrg->destroy(); |
---|
| 774 | delete pcPicYuvOrg; |
---|
| 775 | pcPicYuvOrg = NULL; |
---|
| 776 | |
---|
[368] | 777 | #if !H_MV |
---|
[324] | 778 | // delete used buffers in encoder class |
---|
| 779 | m_cTEncTop.deletePicBuffer(); |
---|
[368] | 780 | #endif |
---|
[324] | 781 | |
---|
| 782 | // delete buffers & classes |
---|
| 783 | xDeleteBuffer(); |
---|
| 784 | xDestroyLib(); |
---|
| 785 | |
---|
| 786 | printRateSummary(); |
---|
| 787 | |
---|
| 788 | return; |
---|
| 789 | } |
---|
| 790 | |
---|
| 791 | // ==================================================================================================================== |
---|
| 792 | // Protected member functions |
---|
| 793 | // ==================================================================================================================== |
---|
| 794 | |
---|
| 795 | /** |
---|
| 796 | - application has picture buffer list with size of GOP |
---|
| 797 | - picture buffer list acts as ring buffer |
---|
| 798 | - end of the list has the latest picture |
---|
| 799 | . |
---|
| 800 | */ |
---|
[368] | 801 | #if H_MV |
---|
| 802 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
| 803 | #else |
---|
[324] | 804 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
[368] | 805 | #endif |
---|
[324] | 806 | { |
---|
| 807 | assert( m_iGOPSize > 0 ); |
---|
| 808 | |
---|
| 809 | // org. buffer |
---|
[368] | 810 | #if H_MV |
---|
| 811 | if ( m_picYuvRec[layer]->size() == (UInt)m_iGOPSize ) |
---|
| 812 | { |
---|
| 813 | rpcPicYuvRec = m_picYuvRec[layer]->popFront(); |
---|
| 814 | #else |
---|
[324] | 815 | if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize ) |
---|
| 816 | { |
---|
| 817 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
[368] | 818 | #endif |
---|
[324] | 819 | |
---|
| 820 | } |
---|
| 821 | else |
---|
| 822 | { |
---|
| 823 | rpcPicYuvRec = new TComPicYuv; |
---|
| 824 | |
---|
| 825 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 826 | |
---|
| 827 | } |
---|
[368] | 828 | #if H_MV |
---|
| 829 | m_picYuvRec[layer]->pushBack( rpcPicYuvRec ); |
---|
| 830 | #else |
---|
[324] | 831 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
[368] | 832 | #endif |
---|
[324] | 833 | } |
---|
| 834 | |
---|
| 835 | Void TAppEncTop::xDeleteBuffer( ) |
---|
| 836 | { |
---|
[368] | 837 | #if H_MV |
---|
| 838 | for(Int layer=0; layer<m_picYuvRec.size(); layer++) |
---|
| 839 | { |
---|
| 840 | if(m_picYuvRec[layer]) |
---|
| 841 | { |
---|
| 842 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layer]->begin(); |
---|
| 843 | Int iSize = Int( m_picYuvRec[layer]->size() ); |
---|
| 844 | #else |
---|
[324] | 845 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
| 846 | |
---|
| 847 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
[368] | 848 | #endif |
---|
[324] | 849 | |
---|
| 850 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 851 | { |
---|
| 852 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 853 | pcPicYuvRec->destroy(); |
---|
| 854 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
| 855 | } |
---|
| 856 | |
---|
[368] | 857 | #if H_MV |
---|
| 858 | } |
---|
| 859 | } |
---|
| 860 | #endif |
---|
[324] | 861 | } |
---|
| 862 | |
---|
| 863 | /** \param iNumEncoded number of encoded frames |
---|
| 864 | */ |
---|
[368] | 865 | #if H_MV |
---|
| 866 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId) |
---|
| 867 | #else |
---|
[324] | 868 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
[368] | 869 | #endif |
---|
[324] | 870 | { |
---|
| 871 | Int i; |
---|
| 872 | |
---|
[368] | 873 | #if H_MV |
---|
| 874 | if( iNumEncoded > 0 ) |
---|
| 875 | { |
---|
| 876 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end(); |
---|
| 877 | #else |
---|
[324] | 878 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
| 879 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
[368] | 880 | #endif |
---|
[324] | 881 | |
---|
| 882 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 883 | { |
---|
| 884 | --iterPicYuvRec; |
---|
| 885 | } |
---|
| 886 | |
---|
| 887 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 888 | { |
---|
| 889 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
[368] | 890 | #if H_MV |
---|
| 891 | if (m_pchReconFileList[layerId]) |
---|
| 892 | { |
---|
| 893 | m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
| 894 | } |
---|
| 895 | } |
---|
| 896 | } |
---|
| 897 | if( ! accessUnits.empty() ) |
---|
| 898 | { |
---|
| 899 | list<AccessUnit>::iterator aUIter; |
---|
| 900 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
---|
| 901 | { |
---|
| 902 | const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter); |
---|
| 903 | rateStatsAccum(*aUIter, stats); |
---|
| 904 | } |
---|
| 905 | } |
---|
| 906 | #else |
---|
[324] | 907 | if (m_pchReconFile) |
---|
| 908 | { |
---|
| 909 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
| 910 | } |
---|
| 911 | |
---|
| 912 | const AccessUnit& au = *(iterBitstream++); |
---|
| 913 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
| 914 | rateStatsAccum(au, stats); |
---|
| 915 | } |
---|
[368] | 916 | #endif |
---|
[324] | 917 | } |
---|
| 918 | |
---|
| 919 | /** |
---|
| 920 | * |
---|
| 921 | */ |
---|
| 922 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
| 923 | { |
---|
| 924 | AccessUnit::const_iterator it_au = au.begin(); |
---|
| 925 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
| 926 | |
---|
| 927 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
| 928 | { |
---|
| 929 | switch ((*it_au)->m_nalUnitType) |
---|
| 930 | { |
---|
| 931 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
| 932 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
[446] | 933 | case NAL_UNIT_CODED_SLICE_TLA_R: |
---|
[324] | 934 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
| 935 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
| 936 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
[446] | 937 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
| 938 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
[324] | 939 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
[446] | 940 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
[324] | 941 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
| 942 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
| 943 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
[446] | 944 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
[324] | 945 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
[446] | 946 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
[324] | 947 | case NAL_UNIT_VPS: |
---|
| 948 | case NAL_UNIT_SPS: |
---|
| 949 | case NAL_UNIT_PPS: |
---|
| 950 | m_essentialBytes += *it_stats; |
---|
| 951 | break; |
---|
| 952 | default: |
---|
| 953 | break; |
---|
| 954 | } |
---|
| 955 | |
---|
| 956 | m_totalBytes += *it_stats; |
---|
| 957 | } |
---|
| 958 | } |
---|
| 959 | |
---|
| 960 | void TAppEncTop::printRateSummary() |
---|
| 961 | { |
---|
[368] | 962 | #if H_MV |
---|
| 963 | Double time = (Double) m_frameRcvd[0] / m_iFrameRate; |
---|
| 964 | printf("\n"); |
---|
| 965 | #else |
---|
[324] | 966 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
[368] | 967 | #endif |
---|
[324] | 968 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
| 969 | #if VERBOSE_RATE |
---|
| 970 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
| 971 | #endif |
---|
| 972 | } |
---|
| 973 | |
---|
[368] | 974 | #if H_MV |
---|
| 975 | Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps ) |
---|
| 976 | { |
---|
| 977 | vps.setScalabilityMask( m_scalabilityMask ); |
---|
| 978 | for( Int dim = 0; dim < m_dimIds.size(); dim++ ) |
---|
| 979 | { |
---|
[446] | 980 | vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] ); |
---|
| 981 | for( Int layer = 0; layer < vps.getMaxLayers(); layer++ ) |
---|
| 982 | { |
---|
| 983 | vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] ); |
---|
| 984 | } |
---|
[368] | 985 | } |
---|
| 986 | } |
---|
[324] | 987 | |
---|
[493] | 988 | Void TAppEncTop::xSetDependencies( TComVPS& vps ) |
---|
[368] | 989 | { |
---|
[493] | 990 | // Direct dependency flags + dependency types |
---|
| 991 | for( Int depLayer = 1; depLayer < MAX_NUM_LAYERS; depLayer++ ) |
---|
[368] | 992 | { |
---|
[493] | 993 | for( Int refLayer = 0; refLayer < MAX_NUM_LAYERS; refLayer++ ) |
---|
[368] | 994 | { |
---|
[493] | 995 | vps.setDirectDependencyFlag( depLayer, refLayer, false); |
---|
[495] | 996 | vps.setDirectDependencyType( depLayer, refLayer, -1 ); |
---|
[368] | 997 | } |
---|
[493] | 998 | } |
---|
| 999 | for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ ) |
---|
| 1000 | { |
---|
[495] | 1001 | Int numRefLayers = (Int) m_directRefLayers[depLayer].size(); |
---|
| 1002 | assert( numRefLayers == (Int) m_dependencyTypes[depLayer].size() ); |
---|
[493] | 1003 | for( Int i = 0; i < numRefLayers; i++ ) |
---|
[368] | 1004 | { |
---|
[493] | 1005 | Int refLayer = m_directRefLayers[depLayer][i]; |
---|
| 1006 | vps.setDirectDependencyFlag( depLayer, refLayer, true); |
---|
| 1007 | vps.setDirectDependencyType( depLayer, refLayer,m_dependencyTypes[depLayer][i]); |
---|
[368] | 1008 | } |
---|
| 1009 | } |
---|
| 1010 | |
---|
[493] | 1011 | // Max temporal id for inter layer reference pictures |
---|
| 1012 | for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++) |
---|
| 1013 | { |
---|
| 1014 | Int maxTid = -1; |
---|
[495] | 1015 | for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++) |
---|
[493] | 1016 | { |
---|
| 1017 | for( Int i = 0; i < getGOPSize(); i++ ) |
---|
| 1018 | { |
---|
[495] | 1019 | GOPEntry geCur = m_GOPListMvc[curLayerIdInVps][i]; |
---|
| 1020 | GOPEntry geRef = m_GOPListMvc[refLayerIdInVps][i]; |
---|
[493] | 1021 | |
---|
[495] | 1022 | for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++) |
---|
[493] | 1023 | { |
---|
[495] | 1024 | if ( m_directRefLayers[ curLayerIdInVps ][ geCur.m_interLayerPredLayerIdc[ j ]] == refLayerIdInVps ) |
---|
[493] | 1025 | { |
---|
[495] | 1026 | maxTid = std::max( maxTid, geRef.m_temporalId ); |
---|
[493] | 1027 | } |
---|
| 1028 | } |
---|
| 1029 | } |
---|
| 1030 | } |
---|
| 1031 | vps.setMaxTidIlRefPicPlus1( refLayerIdInVps, maxTid + 1 ); |
---|
| 1032 | } |
---|
[368] | 1033 | |
---|
[493] | 1034 | // Max one active ref layer flag |
---|
| 1035 | Bool maxOneActiveRefLayerFlag = true; |
---|
| 1036 | for ( Int currLayerIdInVps = 1; currLayerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; currLayerIdInVps++) |
---|
| 1037 | { |
---|
| 1038 | for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ ) |
---|
| 1039 | { |
---|
| 1040 | GOPEntry ge = m_GOPListMvc[currLayerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]; |
---|
[495] | 1041 | maxOneActiveRefLayerFlag = maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1); |
---|
[493] | 1042 | } |
---|
| 1043 | } |
---|
| 1044 | |
---|
| 1045 | vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag ); |
---|
| 1046 | vps.setRefLayers(); |
---|
| 1047 | }; |
---|
| 1048 | |
---|
[368] | 1049 | Void TAppEncTop::xSetLayerIds( TComVPS& vps ) |
---|
| 1050 | { |
---|
| 1051 | vps.setSplittingFlag ( m_splittingFlag ); |
---|
| 1052 | |
---|
| 1053 | Bool nuhLayerIdPresentFlag = !( m_layerIdInNuh.size() == 1 ); |
---|
| 1054 | Int maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ; |
---|
| 1055 | |
---|
[488] | 1056 | vps.setVpsMaxLayerId( maxNuhLayerId ); |
---|
[368] | 1057 | vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag ); |
---|
| 1058 | |
---|
| 1059 | for (Int layer = 0; layer < m_numberOfLayers; layer++ ) |
---|
| 1060 | { |
---|
| 1061 | vps.setLayerIdInNuh( layer, nuhLayerIdPresentFlag ? m_layerIdInNuh[ layer ] : layer ); |
---|
| 1062 | vps.setLayerIdInVps( vps.getLayerIdInNuh( layer ), layer ); |
---|
| 1063 | } |
---|
| 1064 | } |
---|
| 1065 | |
---|
| 1066 | Int TAppEncTop::xGetMax( std::vector<Int>& vec ) |
---|
| 1067 | { |
---|
| 1068 | Int maxVec = 0; |
---|
| 1069 | for ( Int i = 0; i < vec.size(); i++) |
---|
| 1070 | maxVec = max( vec[i], maxVec ); |
---|
| 1071 | return maxVec; |
---|
| 1072 | } |
---|
[492] | 1073 | |
---|
[495] | 1074 | Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps ) |
---|
| 1075 | { |
---|
| 1076 | const Int vpsNumProfileTierLevelMinus1 = 0; //TBD |
---|
| 1077 | vps.setVpsNumProfileTierLevelMinus1( vpsNumProfileTierLevelMinus1 ); |
---|
| 1078 | |
---|
| 1079 | for (Int i = 0; i <= vps.getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
| 1080 | { |
---|
| 1081 | vps.setVpsProfilePresentFlag( i, true ); |
---|
| 1082 | } |
---|
| 1083 | } |
---|
| 1084 | |
---|
| 1085 | |
---|
[492] | 1086 | Void TAppEncTop::xSetLayerSets( TComVPS& vps ) |
---|
| 1087 | { |
---|
| 1088 | // Layer sets |
---|
[498] | 1089 | vps.setVpsNumLayerSetsMinus1 ( m_vpsNumLayerSets - 1 ); |
---|
| 1090 | vps.setVpsNumberLayerSetsMinus1( vps.getVpsNumLayerSetsMinus1() ); |
---|
[492] | 1091 | |
---|
| 1092 | for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ ) |
---|
| 1093 | { |
---|
| 1094 | for( Int layerId = 0; layerId < MAX_NUM_LAYER_IDS; layerId++ ) |
---|
| 1095 | { |
---|
| 1096 | vps.setLayerIdIncludedFlag( false, lsIdx, layerId ); |
---|
| 1097 | } |
---|
| 1098 | for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++) |
---|
[493] | 1099 | { |
---|
| 1100 | vps.setLayerIdIncludedFlag( true, lsIdx, vps.getLayerIdInNuh( m_layerIdsInSets[lsIdx][i] ) ); |
---|
[492] | 1101 | } |
---|
| 1102 | } |
---|
| 1103 | |
---|
[495] | 1104 | Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); |
---|
[492] | 1105 | // Additional output layer sets + profileLevelTierIdx |
---|
| 1106 | vps.setDefaultOneTargetOutputLayerFlag ( m_defaultOneTargetOutputLayerFlag ); |
---|
| 1107 | vps.setMoreOutputLayerSetsThanDefaultFlag( numAddOuputLayerSets != 0 ); |
---|
| 1108 | vps.setNumAddOutputLayerSetsMinus1 ( numAddOuputLayerSets - 1 ); |
---|
| 1109 | |
---|
| 1110 | for (Int lsIdx = 1; lsIdx < m_vpsNumLayerSets; lsIdx++) |
---|
| 1111 | { |
---|
| 1112 | vps.setProfileLevelTierIdx( lsIdx, m_profileLevelTierIdx[ lsIdx ] ); |
---|
| 1113 | } |
---|
| 1114 | |
---|
| 1115 | for (Int addOutLs = 0; addOutLs < numAddOuputLayerSets; addOutLs++ ) |
---|
| 1116 | { |
---|
| 1117 | vps.setProfileLevelTierIdx( m_vpsNumLayerSets + addOutLs, m_profileLevelTierIdx[ addOutLs ] ); |
---|
| 1118 | |
---|
| 1119 | Int refLayerSetIdx = m_outputLayerSetIdx[ addOutLs ]; |
---|
| 1120 | vps.setOutputLayerSetIdxMinus1( m_vpsNumLayerSets + addOutLs, refLayerSetIdx - 1 ); |
---|
| 1121 | |
---|
| 1122 | for (Int i = 0; i < m_layerIdsInSets[ refLayerSetIdx].size(); i++ ) |
---|
| 1123 | { |
---|
| 1124 | Bool outputLayerFlag = false; |
---|
| 1125 | for (Int j = 0; j < m_layerIdsInAddOutputLayerSet[ addOutLs ].size(); j++ ) |
---|
| 1126 | { |
---|
| 1127 | if ( m_layerIdsInAddOutputLayerSet[addOutLs][ j ] == m_layerIdsInSets[ refLayerSetIdx][ i ] ) |
---|
| 1128 | { |
---|
| 1129 | outputLayerFlag = true; |
---|
| 1130 | break; |
---|
| 1131 | } |
---|
| 1132 | } |
---|
| 1133 | vps.setOutputLayerFlag( m_vpsNumLayerSets + addOutLs, i, outputLayerFlag ); |
---|
| 1134 | } |
---|
| 1135 | } |
---|
| 1136 | } |
---|
[368] | 1137 | #endif |
---|
[324] | 1138 | //! \} |
---|