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