[5] | 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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1179] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TAppEncTop.cpp |
---|
| 35 | \brief Encoder application class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include <list> |
---|
[56] | 39 | #include <fstream> |
---|
| 40 | #include <stdlib.h> |
---|
[2] | 41 | #include <stdio.h> |
---|
| 42 | #include <fcntl.h> |
---|
| 43 | #include <assert.h> |
---|
| 44 | |
---|
| 45 | #include "TAppEncTop.h" |
---|
[56] | 46 | #include "TLibEncoder/AnnexBwrite.h" |
---|
[2] | 47 | |
---|
[56] | 48 | using namespace std; |
---|
| 49 | |
---|
| 50 | //! \ingroup TAppEncoder |
---|
| 51 | //! \{ |
---|
| 52 | |
---|
[2] | 53 | // ==================================================================================================================== |
---|
| 54 | // Constructor / destructor / initialization / destroy |
---|
| 55 | // ==================================================================================================================== |
---|
| 56 | |
---|
| 57 | TAppEncTop::TAppEncTop() |
---|
| 58 | { |
---|
[964] | 59 | |
---|
[976] | 60 | #if H_MV |
---|
[964] | 61 | m_vps = new TComVPS; |
---|
[976] | 62 | #else |
---|
[608] | 63 | m_iFrameRcvd = 0; |
---|
| 64 | #endif |
---|
[56] | 65 | m_totalBytes = 0; |
---|
| 66 | m_essentialBytes = 0; |
---|
[2] | 67 | } |
---|
| 68 | |
---|
| 69 | TAppEncTop::~TAppEncTop() |
---|
| 70 | { |
---|
[976] | 71 | #if H_MV |
---|
[964] | 72 | if (m_vps) |
---|
| 73 | { |
---|
| 74 | delete m_vps; |
---|
| 75 | }; |
---|
| 76 | #endif |
---|
| 77 | |
---|
[2] | 78 | } |
---|
| 79 | |
---|
| 80 | Void TAppEncTop::xInitLibCfg() |
---|
| 81 | { |
---|
[608] | 82 | #if H_MV |
---|
[964] | 83 | TComVPS& vps = (*m_vps); |
---|
| 84 | #else |
---|
[608] | 85 | TComVPS vps; |
---|
[210] | 86 | #endif |
---|
[608] | 87 | |
---|
[773] | 88 | #if H_3D |
---|
[758] | 89 | vps.createCamPars(m_iNumberOfViews); |
---|
| 90 | TComDLT& dlt = m_dlt; |
---|
| 91 | #endif |
---|
| 92 | |
---|
[608] | 93 | #if H_MV |
---|
| 94 | Int maxTempLayer = -1; |
---|
| 95 | for (Int j = 0; j < m_numberOfLayers; j++) |
---|
[77] | 96 | { |
---|
[608] | 97 | maxTempLayer = max( m_maxTempLayerMvc[ j ], maxTempLayer ); |
---|
[77] | 98 | } |
---|
[608] | 99 | |
---|
| 100 | vps.setMaxTLayers ( maxTempLayer ); |
---|
| 101 | if ( maxTempLayer ) |
---|
[2] | 102 | { |
---|
[608] | 103 | vps.setTemporalNestingFlag(true); |
---|
| 104 | } |
---|
[622] | 105 | vps.setMaxLayersMinus1( m_numberOfLayers - 1); |
---|
[608] | 106 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 107 | { |
---|
| 108 | Int maxNumReOrderPics = 0; |
---|
| 109 | Int maxDecPicBuffering = 0; |
---|
| 110 | for (Int j = 0; j < m_numberOfLayers; j++) |
---|
[56] | 111 | { |
---|
[608] | 112 | maxNumReOrderPics = max( maxNumReOrderPics, m_numReorderPicsMvc [ j ][ i ] ); |
---|
| 113 | maxDecPicBuffering = max( maxDecPicBuffering, m_maxDecPicBufferingMvc[ j ][ i ] ); |
---|
[56] | 114 | } |
---|
[2] | 115 | |
---|
[608] | 116 | vps.setNumReorderPics ( maxNumReOrderPics ,i ); |
---|
| 117 | vps.setMaxDecPicBuffering ( maxDecPicBuffering ,i ); |
---|
| 118 | } |
---|
| 119 | #else |
---|
| 120 | vps.setMaxTLayers ( m_maxTempLayer ); |
---|
| 121 | if (m_maxTempLayer == 1) |
---|
| 122 | { |
---|
| 123 | vps.setTemporalNestingFlag(true); |
---|
| 124 | } |
---|
| 125 | vps.setMaxLayers ( 1 ); |
---|
| 126 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 127 | { |
---|
| 128 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 129 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 130 | } |
---|
[210] | 131 | #endif |
---|
[608] | 132 | #if H_MV |
---|
| 133 | xSetLayerIds ( vps ); |
---|
| 134 | xSetDimensionIdAndLength ( vps ); |
---|
[1066] | 135 | xSetDependencies ( vps ); |
---|
| 136 | xSetRepFormat ( vps ); |
---|
[608] | 137 | xSetProfileTierLevel ( vps ); |
---|
| 138 | xSetLayerSets ( vps ); |
---|
[872] | 139 | xSetDpbSize ( vps ); |
---|
[622] | 140 | xSetVPSVUI ( vps ); |
---|
[608] | 141 | #if H_3D |
---|
[1179] | 142 | xSetCamPara ( vps ); |
---|
[758] | 143 | m_ivPicLists.setVPS ( &vps ); |
---|
| 144 | xDeriveDltArray ( vps, dlt ); |
---|
[56] | 145 | #endif |
---|
[1066] | 146 | if ( m_targetEncLayerIdList.size() == 0 ) |
---|
| 147 | { |
---|
| 148 | for (Int i = 0; i < m_numberOfLayers; i++ ) |
---|
| 149 | { |
---|
| 150 | m_targetEncLayerIdList.push_back( vps.getLayerIdInNuh( i ) ); |
---|
| 151 | } |
---|
| 152 | } |
---|
| 153 | for( Int i = (Int) m_targetEncLayerIdList.size()-1 ; i >= 0 ; i--) |
---|
| 154 | { |
---|
| 155 | Int iNuhLayerId = m_targetEncLayerIdList[i]; |
---|
| 156 | Bool allRefLayersPresent = true; |
---|
| 157 | for( Int j = 0; j < vps.getNumRefLayers( iNuhLayerId ); j++) |
---|
| 158 | { |
---|
| 159 | allRefLayersPresent = allRefLayersPresent && xLayerIdInTargetEncLayerIdList( vps.getIdRefLayer( iNuhLayerId, j) ); |
---|
| 160 | } |
---|
| 161 | if ( !allRefLayersPresent ) |
---|
| 162 | { |
---|
| 163 | printf("\nCannot encode layer with nuh_layer_id equal to %d since not all reference layers are in TargetEncLayerIdList\n", iNuhLayerId); |
---|
| 164 | m_targetEncLayerIdList.erase( m_targetEncLayerIdList.begin() + i ); |
---|
| 165 | } |
---|
| 166 | } |
---|
[56] | 167 | |
---|
[1066] | 168 | if ( m_outputVpsInfo ) |
---|
| 169 | { |
---|
| 170 | vps.printScalabilityId(); |
---|
| 171 | vps.printLayerDependencies(); |
---|
| 172 | vps.printLayerSets(); |
---|
| 173 | vps.printPTL(); |
---|
| 174 | } |
---|
[622] | 175 | |
---|
[1124] | 176 | #if H_3D |
---|
| 177 | // Set 3d tool parameters |
---|
| 178 | |
---|
| 179 | for (Int d = 0; d < 2; d++) |
---|
| 180 | { |
---|
| 181 | m_sps3dExtension.setIvMvPredFlag ( d, m_ivMvPredFlag[d] ); |
---|
| 182 | m_sps3dExtension.setIvMvScalingFlag ( d, m_ivMvScalingFlag[d] ); |
---|
| 183 | if (d == 0 ) |
---|
| 184 | { |
---|
| 185 | m_sps3dExtension.setLog2SubPbSizeMinus3 ( d, m_log2SubPbSizeMinus3 ); |
---|
| 186 | m_sps3dExtension.setIvResPredFlag ( d, m_ivResPredFlag ); |
---|
| 187 | m_sps3dExtension.setDepthRefinementFlag ( d, m_depthRefinementFlag ); |
---|
| 188 | m_sps3dExtension.setViewSynthesisPredFlag ( d, m_viewSynthesisPredFlag ); |
---|
| 189 | m_sps3dExtension.setDepthBasedBlkPartFlag ( d, m_depthBasedBlkPartFlag ); |
---|
| 190 | } |
---|
| 191 | else |
---|
| 192 | { |
---|
| 193 | m_sps3dExtension.setMpiFlag ( d, m_mpiFlag ); |
---|
| 194 | m_sps3dExtension.setLog2MpiSubPbSizeMinus3( d, m_log2MpiSubPbSizeMinus3); |
---|
| 195 | m_sps3dExtension.setIntraContourFlag ( d, m_intraContourFlag ); |
---|
| 196 | m_sps3dExtension.setIntraSdcWedgeFlag ( d, m_intraSdcFlag || m_intraWedgeFlag ); |
---|
| 197 | m_sps3dExtension.setQtPredFlag ( d, m_qtPredFlag ); |
---|
| 198 | m_sps3dExtension.setInterSdcFlag ( d, m_interSdcFlag ); |
---|
[1179] | 199 | m_sps3dExtension.setDepthIntraSkipFlag ( d, m_depthIntraSkipFlag ); |
---|
[1124] | 200 | } |
---|
| 201 | } |
---|
| 202 | #endif |
---|
[622] | 203 | for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++) |
---|
[608] | 204 | { |
---|
| 205 | m_frameRcvd .push_back(0); |
---|
| 206 | m_acTEncTopList .push_back(new TEncTop); |
---|
| 207 | m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv); |
---|
| 208 | m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv); |
---|
| 209 | m_picYuvRec .push_back(new TComList<TComPicYuv*>) ; |
---|
[622] | 210 | m_ivPicLists.push_back( m_acTEncTopList[ layerIdInVps ]->getListPic() ); |
---|
| 211 | TEncTop& m_cTEncTop = *m_acTEncTopList[ layerIdInVps ]; // It is not a member, but this name helps avoiding code duplication !!! |
---|
[56] | 212 | |
---|
[622] | 213 | Int layerId = vps.getLayerIdInNuh( layerIdInVps ); |
---|
| 214 | m_cTEncTop.setLayerIdInVps ( layerIdInVps ); |
---|
| 215 | m_cTEncTop.setLayerId ( layerId ); |
---|
| 216 | m_cTEncTop.setViewId ( vps.getViewId ( layerId ) ); |
---|
| 217 | m_cTEncTop.setViewIndex ( vps.getViewIndex ( layerId ) ); |
---|
[608] | 218 | #if H_3D |
---|
[622] | 219 | Bool isDepth = ( vps.getDepthId ( layerId ) != 0 ) ; |
---|
[608] | 220 | m_cTEncTop.setIsDepth ( isDepth ); |
---|
| 221 | //====== Camera Parameters ========= |
---|
| 222 | m_cTEncTop.setCameraParameters ( &m_cCameraData ); |
---|
| 223 | #if H_3D_VSO |
---|
[2] | 224 | //====== VSO ========= |
---|
[608] | 225 | m_cTEncTop.setRenderModelParameters ( &m_cRenModStrParser ); |
---|
| 226 | m_cTEncTop.setForceLambdaScaleVSO ( isDepth ? m_bForceLambdaScaleVSO : false ); |
---|
| 227 | m_cTEncTop.setLambdaScaleVSO ( isDepth ? m_dLambdaScaleVSO : 1 ); |
---|
| 228 | m_cTEncTop.setVSOMode ( isDepth ? m_uiVSOMode : 0 ); |
---|
[2] | 229 | |
---|
[608] | 230 | m_cTEncTop.setAllowNegDist ( isDepth ? m_bAllowNegDist : false ); |
---|
[56] | 231 | |
---|
[608] | 232 | // SAIT_VSO_EST_A0033 |
---|
| 233 | m_cTEncTop.setUseEstimatedVSD ( isDepth ? m_bUseEstimatedVSD : false ); |
---|
[56] | 234 | |
---|
[608] | 235 | // LGE_WVSO_A0119 |
---|
| 236 | m_cTEncTop.setUseWVSO ( isDepth ? m_bUseWVSO : false ); |
---|
| 237 | m_cTEncTop.setVSOWeight ( isDepth ? m_iVSOWeight : 0 ); |
---|
| 238 | m_cTEncTop.setVSDWeight ( isDepth ? m_iVSDWeight : 0 ); |
---|
| 239 | m_cTEncTop.setDWeight ( isDepth ? m_iDWeight : 0 ); |
---|
| 240 | #endif // H_3D_VSO |
---|
[622] | 241 | #if H_3D_IC |
---|
[724] | 242 | m_cTEncTop.setUseIC ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC ); |
---|
[950] | 243 | m_cTEncTop.setUseICLowLatencyEnc ( m_bUseLowLatencyICEnc ); |
---|
[622] | 244 | #endif |
---|
[1124] | 245 | |
---|
| 246 | |
---|
| 247 | m_cTEncTop.setUseDMM ( isDepth ? m_intraWedgeFlag : false ); |
---|
| 248 | m_cTEncTop.setUseSDC ( isDepth ? m_intraSdcFlag : false ); |
---|
| 249 | m_cTEncTop.setUseDLT ( isDepth ? m_useDLT : false ); |
---|
| 250 | m_cTEncTop.setUseQTL ( isDepth ? m_bUseQTL : false ); |
---|
| 251 | |
---|
| 252 | |
---|
| 253 | m_cTEncTop.setSps3dExtension ( m_sps3dExtension ); |
---|
[608] | 254 | #endif // H_3D |
---|
[2] | 255 | |
---|
[608] | 256 | m_cTEncTop.setIvPicLists ( &m_ivPicLists ); |
---|
[773] | 257 | #endif // H_MV |
---|
[608] | 258 | m_cTEncTop.setVPS(&vps); |
---|
[2] | 259 | |
---|
[773] | 260 | #if H_3D |
---|
[758] | 261 | m_cTEncTop.setDLT(&dlt); |
---|
| 262 | #endif |
---|
| 263 | |
---|
[1066] | 264 | #if H_MV |
---|
| 265 | m_cTEncTop.setProfile(m_profile[0]); |
---|
| 266 | m_cTEncTop.setLevel (m_levelTier[0], m_level[0]); |
---|
| 267 | #else |
---|
[608] | 268 | m_cTEncTop.setProfile(m_profile); |
---|
| 269 | m_cTEncTop.setLevel(m_levelTier, m_level); |
---|
[1066] | 270 | #endif |
---|
[608] | 271 | m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
| 272 | m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
| 273 | m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
| 274 | m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
[56] | 275 | |
---|
[608] | 276 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
---|
| 277 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
---|
| 278 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
---|
| 279 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
---|
[1084] | 280 | m_cTEncTop.setConformanceWindow ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
[608] | 281 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
| 282 | |
---|
| 283 | //====== Coding Structure ======== |
---|
[773] | 284 | #if H_MV |
---|
[738] | 285 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod[ layerIdInVps ] ); |
---|
| 286 | #else |
---|
[608] | 287 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod ); |
---|
[738] | 288 | #endif |
---|
[608] | 289 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
| 290 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
---|
| 291 | #if H_MV |
---|
[622] | 292 | m_cTEncTop.setGopList ( m_GOPListMvc[layerIdInVps] ); |
---|
| 293 | m_cTEncTop.setExtraRPSs ( m_extraRPSsMvc[layerIdInVps] ); |
---|
| 294 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 295 | { |
---|
| 296 | m_cTEncTop.setNumReorderPics ( m_numReorderPicsMvc[layerIdInVps][i], i ); |
---|
| 297 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBufferingMvc[layerIdInVps][i], i ); |
---|
| 298 | } |
---|
| 299 | #else |
---|
[608] | 300 | m_cTEncTop.setGopList ( m_GOPList ); |
---|
| 301 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
---|
| 302 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
| 303 | { |
---|
| 304 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
| 305 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
| 306 | } |
---|
[189] | 307 | #endif |
---|
[608] | 308 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
| 309 | { |
---|
| 310 | m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
[2] | 311 | } |
---|
[608] | 312 | #if H_MV |
---|
[622] | 313 | m_cTEncTop.setQP ( m_iQP[layerIdInVps] ); |
---|
| 314 | #else |
---|
[608] | 315 | m_cTEncTop.setQP ( m_iQP ); |
---|
[210] | 316 | #endif |
---|
| 317 | |
---|
[608] | 318 | m_cTEncTop.setPad ( m_aiPad ); |
---|
[2] | 319 | |
---|
[608] | 320 | #if H_MV |
---|
[622] | 321 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayerMvc[layerIdInVps] ); |
---|
| 322 | #else |
---|
[608] | 323 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
---|
[210] | 324 | #endif |
---|
[608] | 325 | m_cTEncTop.setUseAMP( m_enableAMP ); |
---|
| 326 | |
---|
| 327 | //===== Slice ======== |
---|
| 328 | |
---|
| 329 | //====== Loop/Deblock Filter ======== |
---|
| 330 | #if H_MV |
---|
[622] | 331 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable[layerIdInVps]); |
---|
| 332 | #else |
---|
[608] | 333 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
[313] | 334 | #endif |
---|
[608] | 335 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
| 336 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
| 337 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
| 338 | m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
| 339 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
[2] | 340 | |
---|
[608] | 341 | //====== Motion search ======== |
---|
| 342 | m_cTEncTop.setFastSearch ( m_iFastSearch ); |
---|
| 343 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
---|
| 344 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
---|
[2] | 345 | |
---|
[1196] | 346 | #if H_MV |
---|
[1179] | 347 | m_cTEncTop.setUseDisparitySearchRangeRestriction ( m_bUseDisparitySearchRangeRestriction ); |
---|
| 348 | m_cTEncTop.setVerticalDisparitySearchRange ( m_iVerticalDisparitySearchRange ); |
---|
| 349 | #endif |
---|
[608] | 350 | //====== Quality control ======== |
---|
| 351 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
| 352 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
[2] | 353 | |
---|
[608] | 354 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
---|
| 355 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
---|
[56] | 356 | |
---|
| 357 | #if ADAPTIVE_QP_SELECTION |
---|
[608] | 358 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
[56] | 359 | #endif |
---|
| 360 | |
---|
[608] | 361 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
| 362 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
| 363 | |
---|
| 364 | //====== Tool list ======== |
---|
| 365 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
| 366 | m_cTEncTop.setUseASR ( m_bUseASR ); |
---|
| 367 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
---|
| 368 | #if H_MV |
---|
[622] | 369 | m_cTEncTop.setdQPs ( m_aidQP[layerIdInVps] ); |
---|
| 370 | #else |
---|
[608] | 371 | m_cTEncTop.setdQPs ( m_aidQP ); |
---|
[5] | 372 | #endif |
---|
[608] | 373 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
---|
| 374 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
---|
| 375 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
---|
| 376 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
| 377 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
| 378 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
| 379 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
| 380 | m_cTEncTop.setUseFastEnc ( m_bUseFastEnc ); |
---|
| 381 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
---|
| 382 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
| 383 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
| 384 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
[2] | 385 | |
---|
[608] | 386 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
---|
| 387 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
| 388 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
| 389 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
| 390 | m_cTEncTop.setUsePCM ( m_usePCM ); |
---|
| 391 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
| 392 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
| 393 | |
---|
[443] | 394 | |
---|
[608] | 395 | //====== Weighted Prediction ======== |
---|
| 396 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
---|
| 397 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
---|
| 398 | //====== Parallel Merge Estimation ======== |
---|
| 399 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
[443] | 400 | |
---|
[608] | 401 | //====== Slice ======== |
---|
| 402 | m_cTEncTop.setSliceMode ( m_sliceMode ); |
---|
| 403 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
[56] | 404 | |
---|
[608] | 405 | //====== Dependent Slice ======== |
---|
| 406 | m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
| 407 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
| 408 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
| 409 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
| 410 | { |
---|
| 411 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
| 412 | } |
---|
| 413 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
| 414 | { |
---|
| 415 | m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
| 416 | } |
---|
| 417 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
| 418 | { |
---|
| 419 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
| 420 | } |
---|
| 421 | |
---|
| 422 | if(m_sliceMode == 0 ) |
---|
| 423 | { |
---|
| 424 | m_bLFCrossSliceBoundaryFlag = true; |
---|
| 425 | } |
---|
| 426 | m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
| 427 | #if H_MV |
---|
[622] | 428 | m_cTEncTop.setUseSAO ( m_bUseSAO[layerIdInVps] ); |
---|
| 429 | #else |
---|
[608] | 430 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
---|
[189] | 431 | #endif |
---|
[608] | 432 | m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
[2] | 433 | |
---|
[608] | 434 | m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary); |
---|
| 435 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
| 436 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
[56] | 437 | |
---|
[608] | 438 | m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
| 439 | m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
| 440 | m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
| 441 | m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
| 442 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
| 443 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
---|
| 444 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
| 445 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
| 446 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
| 447 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
| 448 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
---|
| 449 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
---|
| 450 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
| 451 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
| 452 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
| 453 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
| 454 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
---|
| 455 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
| 456 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
| 457 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
| 458 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
[964] | 459 | m_cTEncTop.setTMISEIExposureIndexIdc ( m_exposureIndexIdc ); |
---|
| 460 | m_cTEncTop.setTMISEIExposureIndexValue ( m_exposureIndexValue ); |
---|
[608] | 461 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
| 462 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
| 463 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
| 464 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
| 465 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
| 466 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
| 467 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
| 468 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
| 469 | m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
| 470 | m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
| 471 | m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
| 472 | m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
| 473 | m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
| 474 | m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
| 475 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
| 476 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
| 477 | m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
| 478 | m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
| 479 | m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
[884] | 480 | #if H_MV |
---|
[872] | 481 | m_cTEncTop.setSubBitstreamPropSEIEnabled( m_subBistreamPropSEIEnabled ); |
---|
| 482 | if( m_subBistreamPropSEIEnabled ) |
---|
| 483 | { |
---|
| 484 | m_cTEncTop.setNumAdditionalSubStreams ( m_sbPropNumAdditionalSubStreams ); |
---|
| 485 | m_cTEncTop.setSubBitstreamMode ( m_sbPropSubBitstreamMode ); |
---|
| 486 | m_cTEncTop.setOutputLayerSetIdxToVps ( m_sbPropOutputLayerSetIdxToVps ); |
---|
| 487 | m_cTEncTop.setHighestSublayerId ( m_sbPropHighestSublayerId ); |
---|
| 488 | m_cTEncTop.setAvgBitRate ( m_sbPropAvgBitRate ); |
---|
| 489 | m_cTEncTop.setMaxBitRate ( m_sbPropMaxBitRate ); |
---|
| 490 | } |
---|
| 491 | #endif |
---|
[1084] | 492 | m_cTEncTop.setTileUniformSpacingFlag ( m_tileUniformSpacingFlag ); |
---|
| 493 | m_cTEncTop.setNumColumnsMinus1 ( m_numTileColumnsMinus1 ); |
---|
| 494 | m_cTEncTop.setNumRowsMinus1 ( m_numTileRowsMinus1 ); |
---|
| 495 | if(!m_tileUniformSpacingFlag) |
---|
[608] | 496 | { |
---|
[1084] | 497 | m_cTEncTop.setColumnWidth ( m_tileColumnWidth ); |
---|
| 498 | m_cTEncTop.setRowHeight ( m_tileRowHeight ); |
---|
[2] | 499 | } |
---|
[608] | 500 | m_cTEncTop.xCheckGSParameters(); |
---|
[1084] | 501 | Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1); |
---|
[608] | 502 | if(uiTilesCount == 1) |
---|
[2] | 503 | { |
---|
[608] | 504 | m_bLFCrossTileBoundaryFlag = true; |
---|
[2] | 505 | } |
---|
[608] | 506 | m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
| 507 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
| 508 | m_cTEncTop.setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
| 509 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
---|
| 510 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
---|
| 511 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
---|
| 512 | m_cTEncTop.setSignHideFlag(m_signHideFlag); |
---|
[655] | 513 | #if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227 |
---|
| 514 | if(!m_cTEncTop.getIsDepth()) //only for texture |
---|
| 515 | { |
---|
| 516 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
| 517 | } |
---|
| 518 | else |
---|
| 519 | { |
---|
| 520 | m_cTEncTop.setUseRateCtrl ( 0 ); |
---|
| 521 | } |
---|
| 522 | #else |
---|
| 523 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
| 524 | #endif |
---|
| 525 | #if !KWU_RC_VIEWRC_E0227 |
---|
[608] | 526 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
[655] | 527 | #endif |
---|
[608] | 528 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
| 529 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
---|
| 530 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
| 531 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
---|
| 532 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
---|
[655] | 533 | #if KWU_RC_MADPRED_E0227 |
---|
| 534 | if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth()) |
---|
| 535 | { |
---|
| 536 | m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred : 0); |
---|
| 537 | if(m_cTEncTop.getUseDepthMADPred()) |
---|
| 538 | { |
---|
| 539 | m_cTEncTop.setCamParam(&m_cCameraData); |
---|
| 540 | } |
---|
| 541 | } |
---|
| 542 | #endif |
---|
| 543 | #if KWU_RC_VIEWRC_E0227 |
---|
| 544 | if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth()) |
---|
| 545 | { |
---|
| 546 | m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl); |
---|
| 547 | if(m_iNumberOfViews == 1) |
---|
| 548 | { |
---|
| 549 | if(m_viewWiseRateCtrl) |
---|
| 550 | { |
---|
| 551 | m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]); |
---|
| 552 | } |
---|
| 553 | else |
---|
| 554 | { |
---|
| 555 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
| 556 | } |
---|
| 557 | } |
---|
| 558 | else |
---|
| 559 | { |
---|
| 560 | if(m_viewWiseRateCtrl) |
---|
| 561 | { |
---|
| 562 | m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]); |
---|
| 563 | } |
---|
| 564 | else |
---|
| 565 | { |
---|
| 566 | if(m_iNumberOfViews == 2) |
---|
| 567 | { |
---|
| 568 | if(m_cTEncTop.getViewId() == 0) |
---|
| 569 | { |
---|
| 570 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*80)/100 ); |
---|
| 571 | } |
---|
| 572 | else if(m_cTEncTop.getViewId() == 1) |
---|
| 573 | { |
---|
| 574 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*20)/100 ); |
---|
| 575 | } |
---|
| 576 | } |
---|
| 577 | else if(m_iNumberOfViews == 3) |
---|
| 578 | { |
---|
| 579 | if(m_cTEncTop.getViewId() == 0) |
---|
| 580 | { |
---|
| 581 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*66)/100 ); |
---|
| 582 | } |
---|
| 583 | else if(m_cTEncTop.getViewId() == 1) |
---|
| 584 | { |
---|
| 585 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*17)/100 ); |
---|
| 586 | } |
---|
| 587 | else if(m_cTEncTop.getViewId() == 2) |
---|
| 588 | { |
---|
| 589 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*17)/100 ); |
---|
| 590 | } |
---|
| 591 | } |
---|
| 592 | else |
---|
| 593 | { |
---|
| 594 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
| 595 | } |
---|
| 596 | } |
---|
| 597 | } |
---|
| 598 | } |
---|
| 599 | #endif |
---|
[608] | 600 | m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
[872] | 601 | m_cTEncTop.setCUTransquantBypassFlagForceValue(m_CUTransquantBypassFlagForce); |
---|
[608] | 602 | m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
| 603 | m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
| 604 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
| 605 | m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
[1084] | 606 | m_cTEncTop.setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag); |
---|
[608] | 607 | m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc ); |
---|
| 608 | m_cTEncTop.setSarWidth( m_sarWidth ); |
---|
| 609 | m_cTEncTop.setSarHeight( m_sarHeight ); |
---|
| 610 | m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
| 611 | m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
| 612 | m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
| 613 | m_cTEncTop.setVideoFormat( m_videoFormat ); |
---|
| 614 | m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
| 615 | m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
| 616 | m_cTEncTop.setColourPrimaries( m_colourPrimaries ); |
---|
| 617 | m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics ); |
---|
| 618 | m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients ); |
---|
| 619 | m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
| 620 | m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
| 621 | m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
| 622 | m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
| 623 | m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
| 624 | m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
| 625 | m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
| 626 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
| 627 | m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
| 628 | m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
| 629 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
| 630 | m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
| 631 | m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
| 632 | m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
| 633 | m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
| 634 | m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
| 635 | #if H_MV |
---|
| 636 | } |
---|
| 637 | #endif |
---|
[1179] | 638 | #if H_3D |
---|
| 639 | /// SET Profiles |
---|
| 640 | for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++) |
---|
| 641 | { |
---|
| 642 | Int profileIdc = -1; |
---|
| 643 | for (Int olsIdx = 0; olsIdx < vps.getNumOutputLayerSets(); olsIdx++ ) |
---|
| 644 | { |
---|
| 645 | Int lsIdx = vps.olsIdxToLsIdx( olsIdx ); |
---|
| 646 | for(Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++ ) |
---|
| 647 | { |
---|
| 648 | if( vps.getLayerIdInNuh( layerIdInVps) == vps.getLayerSetLayerIdList(lsIdx, i) ) |
---|
| 649 | { |
---|
| 650 | Int ptlIdx = vps.getProfileTierLevelIdx( olsIdx, i ); |
---|
| 651 | if ( ptlIdx != -1 ) |
---|
| 652 | { |
---|
| 653 | Int curProfileIdc = vps.getPTL(ptlIdx)->getGeneralPTL()->getProfileIdc(); |
---|
| 654 | if (profileIdc == -1) |
---|
| 655 | { |
---|
| 656 | profileIdc = curProfileIdc; |
---|
| 657 | } |
---|
| 658 | else |
---|
| 659 | { |
---|
| 660 | if ( profileIdc != curProfileIdc ) |
---|
| 661 | { |
---|
| 662 | fprintf(stderr, "Error: ProfileIdc for layer with index %d in VPS not equal in all OLSs. \n", layerIdInVps ); |
---|
| 663 | exit(EXIT_FAILURE); |
---|
| 664 | } |
---|
| 665 | } |
---|
| 666 | } |
---|
| 667 | } |
---|
| 668 | } |
---|
| 669 | } |
---|
| 670 | if (profileIdc == -1 ) |
---|
| 671 | { |
---|
| 672 | fprintf(stderr, "Error: No profile given for layer with index %d in VPS not equal in all OLS. \n", layerIdInVps ); |
---|
| 673 | exit(EXIT_FAILURE); |
---|
| 674 | } |
---|
| 675 | m_acTEncTopList[ layerIdInVps ]->setProfileIdc( profileIdc ); |
---|
| 676 | } |
---|
| 677 | #endif |
---|
[608] | 678 | #if H_3D_VSO |
---|
[2] | 679 | if ( m_bUseVSO ) |
---|
| 680 | { |
---|
| 681 | if ( m_uiVSOMode == 4 ) |
---|
[5] | 682 | { |
---|
[608] | 683 | #if H_3D_VSO_EARLY_SKIP |
---|
[100] | 684 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip ); |
---|
| 685 | #else |
---|
| 686 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 ); |
---|
| 687 | #endif |
---|
[608] | 688 | for ( Int layer = 0; layer < m_numberOfLayers ; layer++ ) |
---|
[2] | 689 | { |
---|
[608] | 690 | TEncTop* pcEncTop = m_acTEncTopList[ layer ]; |
---|
| 691 | Int iViewNum = pcEncTop->getViewIndex(); |
---|
| 692 | Int iContent = pcEncTop->getIsDepth() ? 1 : 0; |
---|
| 693 | Int iNumOfModels = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent); |
---|
[2] | 694 | |
---|
[608] | 695 | Bool bUseVSO = (iNumOfModels != 0); |
---|
[5] | 696 | |
---|
[608] | 697 | pcEncTop->setUseVSO( bUseVSO ); |
---|
| 698 | pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL ); |
---|
[2] | 699 | |
---|
[608] | 700 | for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ ) |
---|
| 701 | { |
---|
| 702 | Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode; |
---|
| 703 | |
---|
| 704 | m_cRenModStrParser.getSingleModelData ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ; |
---|
| 705 | m_cRendererModel .createSingleModel ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode ); |
---|
| 706 | } |
---|
[2] | 707 | } |
---|
| 708 | } |
---|
| 709 | else |
---|
| 710 | { |
---|
[56] | 711 | AOT(true); |
---|
[2] | 712 | } |
---|
[5] | 713 | } |
---|
| 714 | #endif |
---|
[2] | 715 | } |
---|
| 716 | |
---|
| 717 | Void TAppEncTop::xCreateLib() |
---|
| 718 | { |
---|
[608] | 719 | #if H_MV |
---|
| 720 | // initialize global variables |
---|
| 721 | initROM(); |
---|
| 722 | #if H_3D_DIM_DMM |
---|
| 723 | initWedgeLists( true ); |
---|
| 724 | #endif |
---|
| 725 | |
---|
| 726 | for( Int layer=0; layer < m_numberOfLayers; layer++) |
---|
[2] | 727 | { |
---|
[608] | 728 | m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
| 729 | m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
[2] | 730 | |
---|
[608] | 731 | if (m_pchReconFileList[layer]) |
---|
[2] | 732 | { |
---|
[608] | 733 | m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
| 734 | } |
---|
| 735 | m_acTEncTopList[layer]->create(); |
---|
| 736 | } |
---|
| 737 | #else |
---|
| 738 | // Video I/O |
---|
| 739 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
| 740 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
[2] | 741 | |
---|
[608] | 742 | if (m_pchReconFile) |
---|
| 743 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
| 744 | |
---|
| 745 | // Neo Decoder |
---|
| 746 | m_cTEncTop.create(); |
---|
[5] | 747 | #endif |
---|
[2] | 748 | } |
---|
| 749 | |
---|
| 750 | Void TAppEncTop::xDestroyLib() |
---|
| 751 | { |
---|
[608] | 752 | #if H_MV |
---|
| 753 | // destroy ROM |
---|
| 754 | destroyROM(); |
---|
| 755 | |
---|
| 756 | for(Int layer=0; layer<m_numberOfLayers; layer++) |
---|
[2] | 757 | { |
---|
[608] | 758 | m_acTVideoIOYuvInputFileList[layer]->close(); |
---|
| 759 | m_acTVideoIOYuvReconFileList[layer]->close(); |
---|
| 760 | delete m_acTVideoIOYuvInputFileList[layer] ; |
---|
| 761 | m_acTVideoIOYuvInputFileList[layer] = NULL; |
---|
| 762 | delete m_acTVideoIOYuvReconFileList[layer] ; |
---|
| 763 | m_acTVideoIOYuvReconFileList[layer] = NULL; |
---|
| 764 | m_acTEncTopList[layer]->deletePicBuffer(); |
---|
| 765 | m_acTEncTopList[layer]->destroy(); |
---|
| 766 | delete m_acTEncTopList[layer] ; |
---|
| 767 | m_acTEncTopList[layer] = NULL; |
---|
| 768 | delete m_picYuvRec[layer] ; |
---|
| 769 | m_picYuvRec[layer] = NULL; |
---|
[2] | 770 | } |
---|
[608] | 771 | #else |
---|
| 772 | // Video I/O |
---|
| 773 | m_cTVideoIOYuvInputFile.close(); |
---|
| 774 | m_cTVideoIOYuvReconFile.close(); |
---|
| 775 | |
---|
| 776 | // Neo Decoder |
---|
| 777 | m_cTEncTop.destroy(); |
---|
| 778 | #endif |
---|
[2] | 779 | } |
---|
| 780 | |
---|
[655] | 781 | Void TAppEncTop::xInitLib(Bool isFieldCoding) |
---|
[2] | 782 | { |
---|
[773] | 783 | #if H_3D |
---|
[758] | 784 | #endif |
---|
| 785 | |
---|
[608] | 786 | #if H_MV |
---|
| 787 | for(Int layer=0; layer<m_numberOfLayers; layer++) |
---|
[2] | 788 | { |
---|
[655] | 789 | #if KWU_RC_MADPRED_E0227 |
---|
| 790 | m_acTEncTopList[layer]->init( isFieldCoding, this ); |
---|
| 791 | #else |
---|
| 792 | m_acTEncTopList[layer]->init( isFieldCoding ); |
---|
| 793 | #endif |
---|
[2] | 794 | } |
---|
[608] | 795 | #else |
---|
[655] | 796 | m_cTEncTop.init( isFieldCoding ); |
---|
[210] | 797 | #endif |
---|
[2] | 798 | } |
---|
| 799 | |
---|
| 800 | // ==================================================================================================================== |
---|
| 801 | // Public member functions |
---|
| 802 | // ==================================================================================================================== |
---|
| 803 | |
---|
| 804 | /** |
---|
| 805 | - create internal class |
---|
| 806 | - initialize internal variable |
---|
| 807 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
| 808 | - delete allocated buffers |
---|
| 809 | - destroy internal class |
---|
| 810 | . |
---|
| 811 | */ |
---|
| 812 | Void TAppEncTop::encode() |
---|
| 813 | { |
---|
[56] | 814 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
| 815 | if (!bitstreamFile) |
---|
| 816 | { |
---|
| 817 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
| 818 | exit(EXIT_FAILURE); |
---|
| 819 | } |
---|
| 820 | |
---|
| 821 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
| 822 | TComPicYuv* pcPicYuvRec = NULL; |
---|
[608] | 823 | |
---|
[2] | 824 | // initialize internal class & member variables |
---|
| 825 | xInitLibCfg(); |
---|
| 826 | xCreateLib(); |
---|
[655] | 827 | xInitLib(m_isField); |
---|
[56] | 828 | |
---|
[2] | 829 | // main encoder loop |
---|
[608] | 830 | #if H_MV |
---|
[56] | 831 | Bool allEos = false; |
---|
| 832 | std::vector<Bool> eos ; |
---|
[608] | 833 | std::vector<Bool> flush ; |
---|
| 834 | |
---|
| 835 | Int gopSize = 1; |
---|
[56] | 836 | Int maxGopSize = 0; |
---|
[608] | 837 | maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); |
---|
[56] | 838 | |
---|
[608] | 839 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
[2] | 840 | { |
---|
[608] | 841 | eos .push_back( false ); |
---|
| 842 | flush.push_back( false ); |
---|
| 843 | } |
---|
| 844 | #else |
---|
| 845 | Int iNumEncoded = 0; |
---|
| 846 | Bool bEos = false; |
---|
[189] | 847 | #endif |
---|
[608] | 848 | |
---|
| 849 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
[56] | 850 | |
---|
[2] | 851 | // allocate original YUV buffer |
---|
[655] | 852 | if( m_isField ) |
---|
| 853 | { |
---|
| 854 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 855 | } |
---|
| 856 | else |
---|
| 857 | { |
---|
[2] | 858 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
[655] | 859 | } |
---|
[608] | 860 | |
---|
| 861 | #if H_MV |
---|
[1066] | 862 | while ( (m_targetEncLayerIdList.size() != 0 ) && !allEos ) |
---|
[2] | 863 | { |
---|
[608] | 864 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
[2] | 865 | { |
---|
[1066] | 866 | if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) )) |
---|
| 867 | { |
---|
| 868 | continue; |
---|
| 869 | } |
---|
| 870 | |
---|
[56] | 871 | Int frmCnt = 0; |
---|
[608] | 872 | while ( !eos[layer] && !(frmCnt == gopSize)) |
---|
[2] | 873 | { |
---|
| 874 | // get buffers |
---|
[608] | 875 | xGetBuffer(pcPicYuvRec, layer); |
---|
[56] | 876 | |
---|
[2] | 877 | // read input YUV file |
---|
[608] | 878 | m_acTVideoIOYuvInputFileList[layer]->read ( pcPicYuvOrg, m_aiPad ); |
---|
| 879 | m_acTEncTopList [layer]->initNewPic( pcPicYuvOrg ); |
---|
[2] | 880 | |
---|
[56] | 881 | // increase number of received frames |
---|
[608] | 882 | m_frameRcvd[layer]++; |
---|
| 883 | |
---|
[56] | 884 | frmCnt++; |
---|
| 885 | |
---|
[608] | 886 | eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded); |
---|
| 887 | allEos = allEos||eos[layer]; |
---|
[2] | 888 | |
---|
[608] | 889 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
| 890 | if (m_acTVideoIOYuvInputFileList[layer]->isEof()) |
---|
| 891 | { |
---|
| 892 | flush [layer] = true; |
---|
| 893 | eos [layer] = true; |
---|
| 894 | m_frameRcvd [layer]--; |
---|
| 895 | m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]); |
---|
[42] | 896 | } |
---|
| 897 | } |
---|
| 898 | } |
---|
[56] | 899 | for ( Int gopId=0; gopId < gopSize; gopId++ ) |
---|
[42] | 900 | { |
---|
[608] | 901 | #if H_3D |
---|
[56] | 902 | UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId ); |
---|
[608] | 903 | if ( iNextPoc < m_framesToBeEncoded ) |
---|
[2] | 904 | { |
---|
[296] | 905 | m_cCameraData.update( iNextPoc ); |
---|
[2] | 906 | } |
---|
[210] | 907 | #endif |
---|
[608] | 908 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
[210] | 909 | { |
---|
[1066] | 910 | if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) )) |
---|
| 911 | { |
---|
| 912 | continue; |
---|
| 913 | } |
---|
| 914 | |
---|
[608] | 915 | #if H_3D_VSO |
---|
| 916 | if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded ) |
---|
[210] | 917 | { |
---|
[608] | 918 | m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() ); |
---|
| 919 | m_acTEncTopList[layer] ->setDispCoeff( m_cCameraData.getDispCoeff() ); |
---|
| 920 | } |
---|
[313] | 921 | #endif |
---|
[833] | 922 | |
---|
[608] | 923 | Int iNumEncoded = 0; |
---|
[210] | 924 | |
---|
[608] | 925 | // call encoding function for one frame |
---|
| 926 | m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, *m_picYuvRec[layer], outputAccessUnits, iNumEncoded, gopId ); |
---|
| 927 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer); |
---|
| 928 | outputAccessUnits.clear(); |
---|
| 929 | } |
---|
| 930 | } |
---|
[655] | 931 | |
---|
[608] | 932 | gopSize = maxGopSize; |
---|
| 933 | } |
---|
| 934 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
| 935 | { |
---|
[1066] | 936 | if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) )) |
---|
| 937 | { |
---|
| 938 | continue; |
---|
| 939 | } |
---|
[655] | 940 | m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded(), m_isField ); |
---|
[608] | 941 | } |
---|
| 942 | #else |
---|
| 943 | while ( !bEos ) |
---|
| 944 | { |
---|
| 945 | // get buffers |
---|
| 946 | xGetBuffer(pcPicYuvRec); |
---|
[210] | 947 | |
---|
[608] | 948 | // read input YUV file |
---|
| 949 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad ); |
---|
[313] | 950 | |
---|
[608] | 951 | // increase number of received frames |
---|
| 952 | m_iFrameRcvd++; |
---|
[210] | 953 | |
---|
[655] | 954 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
[296] | 955 | |
---|
[608] | 956 | Bool flush = 0; |
---|
| 957 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
| 958 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
| 959 | { |
---|
| 960 | flush = true; |
---|
| 961 | bEos = true; |
---|
| 962 | m_iFrameRcvd--; |
---|
| 963 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
| 964 | } |
---|
[443] | 965 | |
---|
[608] | 966 | // call encoding function for one frame |
---|
[655] | 967 | if ( m_isField ) |
---|
| 968 | { |
---|
| 969 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst); |
---|
| 970 | } |
---|
| 971 | else |
---|
| 972 | { |
---|
[608] | 973 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
[655] | 974 | } |
---|
[608] | 975 | |
---|
| 976 | // write bistream to file if necessary |
---|
| 977 | if ( iNumEncoded > 0 ) |
---|
| 978 | { |
---|
| 979 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
| 980 | outputAccessUnits.clear(); |
---|
| 981 | } |
---|
| 982 | } |
---|
[313] | 983 | |
---|
[655] | 984 | m_cTEncTop.printSummary(m_isField); |
---|
[443] | 985 | #endif |
---|
[296] | 986 | |
---|
[56] | 987 | // delete original YUV buffer |
---|
| 988 | pcPicYuvOrg->destroy(); |
---|
| 989 | delete pcPicYuvOrg; |
---|
| 990 | pcPicYuvOrg = NULL; |
---|
| 991 | |
---|
[608] | 992 | #if !H_MV |
---|
| 993 | // delete used buffers in encoder class |
---|
| 994 | m_cTEncTop.deletePicBuffer(); |
---|
[210] | 995 | #endif |
---|
[2] | 996 | |
---|
[56] | 997 | // delete buffers & classes |
---|
| 998 | xDeleteBuffer(); |
---|
| 999 | xDestroyLib(); |
---|
[608] | 1000 | |
---|
| 1001 | printRateSummary(); |
---|
[2] | 1002 | |
---|
[608] | 1003 | #if H_3D_REN_MAX_DEV_OUT |
---|
| 1004 | Double dMaxDispDiff = m_cCameraData.getMaxShiftDeviation(); |
---|
| 1005 | |
---|
| 1006 | if ( !(dMaxDispDiff < 0) ) |
---|
| 1007 | { |
---|
| 1008 | printf("\n Max. possible shift error: %12.3f samples.\n", dMaxDispDiff ); |
---|
| 1009 | } |
---|
| 1010 | #endif |
---|
| 1011 | |
---|
[56] | 1012 | return; |
---|
| 1013 | } |
---|
[2] | 1014 | |
---|
| 1015 | // ==================================================================================================================== |
---|
| 1016 | // Protected member functions |
---|
| 1017 | // ==================================================================================================================== |
---|
| 1018 | |
---|
| 1019 | /** |
---|
| 1020 | - application has picture buffer list with size of GOP |
---|
| 1021 | - picture buffer list acts as ring buffer |
---|
| 1022 | - end of the list has the latest picture |
---|
| 1023 | . |
---|
| 1024 | */ |
---|
[608] | 1025 | #if H_MV |
---|
| 1026 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
| 1027 | #else |
---|
| 1028 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
| 1029 | #endif |
---|
[2] | 1030 | { |
---|
[56] | 1031 | assert( m_iGOPSize > 0 ); |
---|
| 1032 | |
---|
[608] | 1033 | // org. buffer |
---|
| 1034 | #if H_MV |
---|
| 1035 | if ( m_picYuvRec[layer]->size() == (UInt)m_iGOPSize ) |
---|
[56] | 1036 | { |
---|
[608] | 1037 | rpcPicYuvRec = m_picYuvRec[layer]->popFront(); |
---|
| 1038 | #else |
---|
| 1039 | if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize ) |
---|
| 1040 | { |
---|
| 1041 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
| 1042 | #endif |
---|
| 1043 | |
---|
[56] | 1044 | } |
---|
| 1045 | else |
---|
| 1046 | { |
---|
[608] | 1047 | rpcPicYuvRec = new TComPicYuv; |
---|
| 1048 | |
---|
| 1049 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 1050 | |
---|
[56] | 1051 | } |
---|
[608] | 1052 | #if H_MV |
---|
| 1053 | m_picYuvRec[layer]->pushBack( rpcPicYuvRec ); |
---|
| 1054 | #else |
---|
| 1055 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
| 1056 | #endif |
---|
[2] | 1057 | } |
---|
| 1058 | |
---|
| 1059 | Void TAppEncTop::xDeleteBuffer( ) |
---|
| 1060 | { |
---|
[608] | 1061 | #if H_MV |
---|
| 1062 | for(Int layer=0; layer<m_picYuvRec.size(); layer++) |
---|
[2] | 1063 | { |
---|
[608] | 1064 | if(m_picYuvRec[layer]) |
---|
[2] | 1065 | { |
---|
[608] | 1066 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layer]->begin(); |
---|
| 1067 | Int iSize = Int( m_picYuvRec[layer]->size() ); |
---|
| 1068 | #else |
---|
| 1069 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
| 1070 | |
---|
| 1071 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
| 1072 | #endif |
---|
| 1073 | |
---|
| 1074 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 1075 | { |
---|
| 1076 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 1077 | pcPicYuvRec->destroy(); |
---|
| 1078 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
[2] | 1079 | } |
---|
[608] | 1080 | |
---|
| 1081 | #if H_MV |
---|
[2] | 1082 | } |
---|
| 1083 | } |
---|
[608] | 1084 | #endif |
---|
[2] | 1085 | } |
---|
| 1086 | |
---|
| 1087 | /** \param iNumEncoded number of encoded frames |
---|
| 1088 | */ |
---|
[608] | 1089 | #if H_MV |
---|
| 1090 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId) |
---|
| 1091 | #else |
---|
| 1092 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
| 1093 | #endif |
---|
[2] | 1094 | { |
---|
[655] | 1095 | if (m_isField) |
---|
| 1096 | { |
---|
| 1097 | //Reinterlace fields |
---|
| 1098 | Int i; |
---|
[608] | 1099 | #if H_MV |
---|
[655] | 1100 | if( iNumEncoded > 0 ) |
---|
| 1101 | { |
---|
| 1102 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end(); |
---|
[608] | 1103 | #else |
---|
[655] | 1104 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
| 1105 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
[608] | 1106 | #endif |
---|
| 1107 | |
---|
[655] | 1108 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 1109 | { |
---|
| 1110 | --iterPicYuvRec; |
---|
| 1111 | } |
---|
| 1112 | |
---|
| 1113 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
| 1114 | { |
---|
| 1115 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
| 1116 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
| 1117 | |
---|
| 1118 | #if H_MV |
---|
| 1119 | if (m_pchReconFileList[layerId]) |
---|
| 1120 | { |
---|
[1084] | 1121 | m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst ); |
---|
[655] | 1122 | } |
---|
| 1123 | } |
---|
| 1124 | } |
---|
| 1125 | |
---|
| 1126 | if( ! accessUnits.empty() ) |
---|
[608] | 1127 | { |
---|
[655] | 1128 | list<AccessUnit>::iterator aUIter; |
---|
| 1129 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
---|
| 1130 | { |
---|
| 1131 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, *aUIter); |
---|
| 1132 | rateStatsAccum(*aUIter, stats); |
---|
| 1133 | } |
---|
[608] | 1134 | } |
---|
[655] | 1135 | #else |
---|
| 1136 | if (m_pchReconFile) |
---|
| 1137 | { |
---|
[1084] | 1138 | m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst ); |
---|
[655] | 1139 | } |
---|
| 1140 | |
---|
| 1141 | const AccessUnit& auTop = *(iterBitstream++); |
---|
| 1142 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
| 1143 | rateStatsAccum(auTop, statsTop); |
---|
| 1144 | |
---|
| 1145 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
| 1146 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
| 1147 | rateStatsAccum(auBottom, statsBottom); |
---|
| 1148 | } |
---|
| 1149 | #endif |
---|
| 1150 | } |
---|
| 1151 | else |
---|
[608] | 1152 | { |
---|
[655] | 1153 | Int i; |
---|
[608] | 1154 | #if H_MV |
---|
[655] | 1155 | if( iNumEncoded > 0 ) |
---|
| 1156 | { |
---|
| 1157 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end(); |
---|
| 1158 | #else |
---|
| 1159 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
| 1160 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
| 1161 | #endif |
---|
| 1162 | |
---|
| 1163 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 1164 | { |
---|
| 1165 | --iterPicYuvRec; |
---|
| 1166 | } |
---|
| 1167 | |
---|
| 1168 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
| 1169 | { |
---|
| 1170 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
| 1171 | #if H_MV |
---|
[608] | 1172 | if (m_pchReconFileList[layerId]) |
---|
[56] | 1173 | { |
---|
[1084] | 1174 | m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
[655] | 1175 | } |
---|
[56] | 1176 | } |
---|
[2] | 1177 | } |
---|
[56] | 1178 | if( ! accessUnits.empty() ) |
---|
[2] | 1179 | { |
---|
[56] | 1180 | list<AccessUnit>::iterator aUIter; |
---|
| 1181 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
---|
[2] | 1182 | { |
---|
[56] | 1183 | const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter); |
---|
| 1184 | rateStatsAccum(*aUIter, stats); |
---|
[2] | 1185 | } |
---|
| 1186 | } |
---|
[608] | 1187 | #else |
---|
[655] | 1188 | if (m_pchReconFile) |
---|
| 1189 | { |
---|
[1084] | 1190 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
[655] | 1191 | } |
---|
| 1192 | |
---|
| 1193 | const AccessUnit& au = *(iterBitstream++); |
---|
| 1194 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
| 1195 | rateStatsAccum(au, stats); |
---|
[2] | 1196 | } |
---|
[872] | 1197 | #endif |
---|
[608] | 1198 | } |
---|
| 1199 | } |
---|
[655] | 1200 | |
---|
[56] | 1201 | /** |
---|
| 1202 | * |
---|
| 1203 | */ |
---|
[608] | 1204 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
[2] | 1205 | { |
---|
[56] | 1206 | AccessUnit::const_iterator it_au = au.begin(); |
---|
[608] | 1207 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
[2] | 1208 | |
---|
[56] | 1209 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
[2] | 1210 | { |
---|
[56] | 1211 | switch ((*it_au)->m_nalUnitType) |
---|
[2] | 1212 | { |
---|
[608] | 1213 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
| 1214 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
[872] | 1215 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
[608] | 1216 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
| 1217 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
| 1218 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
| 1219 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
| 1220 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
| 1221 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
| 1222 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
| 1223 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
[56] | 1224 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
[608] | 1225 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
| 1226 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
| 1227 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
| 1228 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
| 1229 | case NAL_UNIT_VPS: |
---|
[56] | 1230 | case NAL_UNIT_SPS: |
---|
| 1231 | case NAL_UNIT_PPS: |
---|
| 1232 | m_essentialBytes += *it_stats; |
---|
| 1233 | break; |
---|
| 1234 | default: |
---|
| 1235 | break; |
---|
[2] | 1236 | } |
---|
| 1237 | |
---|
[56] | 1238 | m_totalBytes += *it_stats; |
---|
[2] | 1239 | } |
---|
| 1240 | } |
---|
| 1241 | |
---|
[608] | 1242 | void TAppEncTop::printRateSummary() |
---|
[2] | 1243 | { |
---|
[608] | 1244 | #if H_MV |
---|
| 1245 | Double time = (Double) m_frameRcvd[0] / m_iFrameRate; |
---|
| 1246 | printf("\n"); |
---|
| 1247 | #else |
---|
| 1248 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
[5] | 1249 | #endif |
---|
[56] | 1250 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
| 1251 | #if VERBOSE_RATE |
---|
| 1252 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
| 1253 | #endif |
---|
| 1254 | } |
---|
| 1255 | |
---|
[608] | 1256 | #if H_3D_DIM_DLT |
---|
[758] | 1257 | Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt) |
---|
[56] | 1258 | { |
---|
[189] | 1259 | TComPicYuv* pcDepthPicYuvOrg = new TComPicYuv; |
---|
| 1260 | // allocate original YUV buffer |
---|
| 1261 | pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
| 1262 | |
---|
| 1263 | TVideoIOYuv* depthVideoFile = new TVideoIOYuv; |
---|
| 1264 | |
---|
[608] | 1265 | UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1); |
---|
[189] | 1266 | |
---|
| 1267 | Bool abValidDepths[256]; |
---|
| 1268 | |
---|
[608] | 1269 | depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
[189] | 1270 | |
---|
| 1271 | // initialize boolean array |
---|
| 1272 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
| 1273 | abValidDepths[p] = false; |
---|
| 1274 | |
---|
| 1275 | Int iHeight = pcDepthPicYuvOrg->getHeight(); |
---|
| 1276 | Int iWidth = pcDepthPicYuvOrg->getWidth(); |
---|
| 1277 | Int iStride = pcDepthPicYuvOrg->getStride(); |
---|
| 1278 | |
---|
| 1279 | Pel* pInDM = pcDepthPicYuvOrg->getLumaAddr(); |
---|
| 1280 | |
---|
| 1281 | for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ ) |
---|
| 1282 | { |
---|
[608] | 1283 | depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad ); |
---|
[189] | 1284 | |
---|
| 1285 | // check all pixel values |
---|
| 1286 | for (Int i=0; i<iHeight; i++) |
---|
| 1287 | { |
---|
| 1288 | Int rowOffset = i*iStride; |
---|
| 1289 | |
---|
| 1290 | for (Int j=0; j<iWidth; j++) |
---|
| 1291 | { |
---|
| 1292 | Pel depthValue = pInDM[rowOffset+j]; |
---|
| 1293 | abValidDepths[depthValue] = true; |
---|
| 1294 | } |
---|
| 1295 | } |
---|
| 1296 | } |
---|
| 1297 | |
---|
| 1298 | depthVideoFile->close(); |
---|
[608] | 1299 | delete depthVideoFile; |
---|
[189] | 1300 | |
---|
| 1301 | pcDepthPicYuvOrg->destroy(); |
---|
| 1302 | delete pcDepthPicYuvOrg; |
---|
| 1303 | |
---|
| 1304 | // convert boolean array to idx2Depth LUT |
---|
[608] | 1305 | Int* aiIdx2DepthValue = (Int*) calloc(uiMaxDepthValue, sizeof(Int)); |
---|
| 1306 | Int iNumDepthValues = 0; |
---|
| 1307 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
[189] | 1308 | { |
---|
| 1309 | if( abValidDepths[p] == true) |
---|
| 1310 | { |
---|
[608] | 1311 | aiIdx2DepthValue[iNumDepthValues++] = p; |
---|
[189] | 1312 | } |
---|
| 1313 | } |
---|
| 1314 | |
---|
[608] | 1315 | if( uiNumFrames == 0 || numBitsForValue(iNumDepthValues) == g_bitDepthY ) |
---|
[189] | 1316 | { |
---|
[758] | 1317 | dlt->setUseDLTFlag(layer, false); |
---|
[189] | 1318 | } |
---|
| 1319 | |
---|
| 1320 | // assign LUT |
---|
[758] | 1321 | if( dlt->getUseDLTFlag(layer) ) |
---|
[773] | 1322 | { |
---|
[758] | 1323 | dlt->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues); |
---|
[773] | 1324 | } |
---|
[189] | 1325 | |
---|
| 1326 | // free temporary memory |
---|
[608] | 1327 | free(aiIdx2DepthValue); |
---|
[189] | 1328 | } |
---|
| 1329 | #endif |
---|
[56] | 1330 | |
---|
[608] | 1331 | #if H_MV |
---|
| 1332 | Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps ) |
---|
| 1333 | { |
---|
[622] | 1334 | vps.setScalabilityMaskFlag( m_scalabilityMask ); |
---|
[608] | 1335 | for( Int dim = 0; dim < m_dimIds.size(); dim++ ) |
---|
| 1336 | { |
---|
| 1337 | vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] ); |
---|
[622] | 1338 | for( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ ) |
---|
| 1339 | |
---|
[608] | 1340 | { |
---|
| 1341 | vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] ); |
---|
| 1342 | } |
---|
| 1343 | } |
---|
[622] | 1344 | |
---|
[1124] | 1345 | vps.initNumViews(); |
---|
[622] | 1346 | Int maxViewId = xGetMax( m_viewId ); |
---|
| 1347 | |
---|
[738] | 1348 | Int viewIdLen = gCeilLog2( maxViewId + 1 ); |
---|
| 1349 | const Int maxViewIdLen = ( 1 << 4 ) - 1; |
---|
| 1350 | assert( viewIdLen <= maxViewIdLen ); |
---|
| 1351 | vps.setViewIdLen( viewIdLen ); |
---|
[622] | 1352 | for (Int i = 0; i < m_iNumberOfViews; i++) |
---|
| 1353 | { |
---|
| 1354 | vps.setViewIdVal( i, m_viewId[ i] ); |
---|
| 1355 | } |
---|
| 1356 | |
---|
| 1357 | assert( m_iNumberOfViews == vps.getNumViews() ); |
---|
[1179] | 1358 | |
---|
| 1359 | |
---|
| 1360 | #if H_3D |
---|
| 1361 | vps.initViewCompLayer( ); |
---|
| 1362 | #endif |
---|
[608] | 1363 | } |
---|
[443] | 1364 | |
---|
[608] | 1365 | Void TAppEncTop::xSetDependencies( TComVPS& vps ) |
---|
[296] | 1366 | { |
---|
[608] | 1367 | // Direct dependency flags + dependency types |
---|
| 1368 | for( Int depLayer = 1; depLayer < MAX_NUM_LAYERS; depLayer++ ) |
---|
| 1369 | { |
---|
| 1370 | for( Int refLayer = 0; refLayer < MAX_NUM_LAYERS; refLayer++ ) |
---|
| 1371 | { |
---|
| 1372 | vps.setDirectDependencyFlag( depLayer, refLayer, false); |
---|
| 1373 | vps.setDirectDependencyType( depLayer, refLayer, -1 ); |
---|
| 1374 | } |
---|
[1124] | 1375 | } |
---|
[738] | 1376 | |
---|
| 1377 | Int defaultDirectDependencyType = -1; |
---|
[964] | 1378 | Bool defaultDirectDependencyFlag = false; |
---|
| 1379 | |
---|
[1179] | 1380 | Int directDepTypeLenMinus2 = 0; |
---|
[608] | 1381 | for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ ) |
---|
| 1382 | { |
---|
| 1383 | Int numRefLayers = (Int) m_directRefLayers[depLayer].size(); |
---|
| 1384 | assert( numRefLayers == (Int) m_dependencyTypes[depLayer].size() ); |
---|
| 1385 | for( Int i = 0; i < numRefLayers; i++ ) |
---|
| 1386 | { |
---|
| 1387 | Int refLayer = m_directRefLayers[depLayer][i]; |
---|
| 1388 | vps.setDirectDependencyFlag( depLayer, refLayer, true); |
---|
[738] | 1389 | Int curDirectDependencyType = m_dependencyTypes[depLayer][i]; |
---|
[1179] | 1390 | directDepTypeLenMinus2 = std::max( directDepTypeLenMinus2, gCeilLog2( curDirectDependencyType + 1 ) - 2 ); |
---|
[738] | 1391 | if ( defaultDirectDependencyType != -1 ) |
---|
| 1392 | { |
---|
| 1393 | defaultDirectDependencyFlag = defaultDirectDependencyFlag && (curDirectDependencyType == defaultDirectDependencyType ); |
---|
| 1394 | } |
---|
| 1395 | else |
---|
| 1396 | { |
---|
| 1397 | defaultDirectDependencyType = curDirectDependencyType; |
---|
[964] | 1398 | defaultDirectDependencyFlag = true; |
---|
[738] | 1399 | } |
---|
| 1400 | |
---|
| 1401 | vps.setDirectDependencyType( depLayer, refLayer, curDirectDependencyType); |
---|
[608] | 1402 | } |
---|
| 1403 | } |
---|
[296] | 1404 | |
---|
[738] | 1405 | vps.setDefaultDirectDependencyFlag( defaultDirectDependencyFlag ); |
---|
| 1406 | vps.setDefaultDirectDependencyType( defaultDirectDependencyFlag ? defaultDirectDependencyType : -1 ); |
---|
| 1407 | |
---|
[1179] | 1408 | assert( directDepTypeLenMinus2 <= 1 ); |
---|
| 1409 | vps.setDirectDepTypeLenMinus2( directDepTypeLenMinus2 ); |
---|
| 1410 | |
---|
| 1411 | |
---|
[1124] | 1412 | vps.setRefLayers(); |
---|
| 1413 | |
---|
[738] | 1414 | // Max sub layers, + presence flag |
---|
| 1415 | Bool subLayersMaxMinus1PresentFlag = false; |
---|
| 1416 | for (Int curLayerIdInVps = 0; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++ ) |
---|
[1066] | 1417 | { |
---|
| 1418 | Int curSubLayersMaxMinus1 = 0; |
---|
[738] | 1419 | for( Int i = 0; i < getGOPSize(); i++ ) |
---|
| 1420 | { |
---|
| 1421 | GOPEntry geCur = m_GOPListMvc[curLayerIdInVps][i]; |
---|
| 1422 | curSubLayersMaxMinus1 = std::max( curSubLayersMaxMinus1, geCur.m_temporalId ); |
---|
| 1423 | } |
---|
| 1424 | |
---|
| 1425 | vps.setSubLayersVpsMaxMinus1( curLayerIdInVps, curSubLayersMaxMinus1 ); |
---|
[1066] | 1426 | subLayersMaxMinus1PresentFlag = subLayersMaxMinus1PresentFlag || ( curSubLayersMaxMinus1 != vps.getMaxSubLayersMinus1() ); |
---|
[738] | 1427 | } |
---|
| 1428 | |
---|
| 1429 | vps.setVpsSubLayersMaxMinus1PresentFlag( subLayersMaxMinus1PresentFlag ); |
---|
| 1430 | |
---|
[1124] | 1431 | // Max temporal id for inter layer reference pictures |
---|
| 1432 | for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++) |
---|
| 1433 | { |
---|
| 1434 | Int refLayerIdInNuh = vps.getLayerIdInNuh( refLayerIdInVps ); |
---|
| 1435 | for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++) |
---|
| 1436 | { |
---|
| 1437 | Int curLayerIdInNuh = vps.getLayerIdInNuh( curLayerIdInVps ); |
---|
[1133] | 1438 | Int maxTid = -1; |
---|
[1124] | 1439 | #if H_3D |
---|
| 1440 | if ( vps.getDirectDependencyFlag( curLayerIdInVps, refLayerIdInVps ) ) |
---|
| 1441 | { |
---|
| 1442 | if ( m_depthFlag[ curLayerIdInVps] == m_depthFlag[ refLayerIdInVps ] ) |
---|
| 1443 | { |
---|
| 1444 | #endif |
---|
| 1445 | for( Int i = 0; i < ( getGOPSize() + 1); i++ ) |
---|
| 1446 | { |
---|
| 1447 | GOPEntry geCur = m_GOPListMvc[curLayerIdInVps][( i < getGOPSize() ? i : MAX_GOP )]; |
---|
| 1448 | GOPEntry geRef = m_GOPListMvc[refLayerIdInVps][( i < getGOPSize() ? i : MAX_GOP )]; |
---|
| 1449 | for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++) |
---|
| 1450 | { |
---|
| 1451 | #if H_3D |
---|
| 1452 | if ( vps.getIdRefListLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[ j ] ) == refLayerIdInNuh ) |
---|
| 1453 | #else |
---|
| 1454 | if ( vps.getIdDirectRefLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[ j ] ) == refLayerIdInNuh ) |
---|
| 1455 | #endif |
---|
| 1456 | { |
---|
| 1457 | Bool refLayerZero = ( i == getGOPSize() ) && ( refLayerIdInVps == 0 ); |
---|
[1179] | 1458 | maxTid = std::max( maxTid, refLayerZero ? 0 : geRef.m_temporalId ); |
---|
[1124] | 1459 | } |
---|
| 1460 | } |
---|
| 1461 | } |
---|
| 1462 | #if H_3D |
---|
| 1463 | } |
---|
| 1464 | else |
---|
| 1465 | { |
---|
| 1466 | if( m_depthFlag[ curLayerIdInVps ] && ( m_mpiFlag|| m_qtPredFlag || m_intraContourFlag ) ) |
---|
| 1467 | { |
---|
| 1468 | Int nuhLayerIdTex = vps.getLayerIdInNuh( vps.getViewIndex( curLayerIdInNuh ), false ); |
---|
| 1469 | if ( nuhLayerIdTex == refLayerIdInNuh ) |
---|
| 1470 | { |
---|
[1179] | 1471 | for( Int i = 0; i < ( getGOPSize() + 1); i++ ) |
---|
| 1472 | { |
---|
| 1473 | GOPEntry geCur = m_GOPListMvc[curLayerIdInVps][( i < getGOPSize() ? i : MAX_GOP )]; |
---|
| 1474 | GOPEntry geRef = m_GOPListMvc[refLayerIdInVps][( i < getGOPSize() ? i : MAX_GOP )]; |
---|
| 1475 | if ( geCur.m_interCompPredFlag ) |
---|
| 1476 | { |
---|
| 1477 | Bool refLayerZero = ( i == getGOPSize() ) && ( refLayerIdInVps == 0 ); |
---|
| 1478 | maxTid = std::max( maxTid, refLayerZero ? 0 : geRef.m_temporalId ); |
---|
| 1479 | } |
---|
| 1480 | } |
---|
| 1481 | } |
---|
| 1482 | } |
---|
| 1483 | if( !m_depthFlag[ curLayerIdInVps ] && vps.getNumRefListLayers( curLayerIdInNuh) > 0 && ( m_depthRefinementFlag || m_viewSynthesisPredFlag || m_depthBasedBlkPartFlag ) ) |
---|
| 1484 | { |
---|
| 1485 | for( Int i = 0; i < ( getGOPSize() + 1); i++ ) |
---|
| 1486 | { |
---|
| 1487 | GOPEntry geCur = m_GOPListMvc[curLayerIdInVps][( i < getGOPSize() ? i : MAX_GOP )]; |
---|
| 1488 | GOPEntry geRef = m_GOPListMvc[refLayerIdInVps][( i < getGOPSize() ? i : MAX_GOP )]; |
---|
| 1489 | |
---|
| 1490 | if ( geCur.m_interCompPredFlag ) |
---|
| 1491 | { |
---|
| 1492 | for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++ ) |
---|
| 1493 | { |
---|
| 1494 | Int nuhLayerIdDep = vps.getLayerIdInNuh( vps.getViewIndex( vps.getIdRefListLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[j] ) ), true ); |
---|
| 1495 | if ( nuhLayerIdDep == refLayerIdInNuh ) |
---|
| 1496 | { |
---|
| 1497 | Bool refLayerZero = ( i == getGOPSize() ) && ( refLayerIdInVps == 0 ); |
---|
| 1498 | maxTid = std::max( maxTid, refLayerZero ? 0 : geRef.m_temporalId ); |
---|
| 1499 | } |
---|
| 1500 | } |
---|
| 1501 | } |
---|
| 1502 | } |
---|
| 1503 | } |
---|
[1124] | 1504 | } |
---|
[1179] | 1505 | } // if ( vps.getDirectDependencyFlag( curLayerIdInVps, refLayerIdInVps ) ) |
---|
[1124] | 1506 | vps.setMaxTidIlRefPicsPlus1( refLayerIdInVps, curLayerIdInVps, maxTid + 1 ); |
---|
| 1507 | #endif |
---|
[1179] | 1508 | } // Loop curLayerIdInVps |
---|
| 1509 | } // Loop refLayerIdInVps |
---|
[1124] | 1510 | |
---|
| 1511 | // Max temporal id for inter layer reference pictures presence flag |
---|
| 1512 | Bool maxTidRefPresentFlag = false; |
---|
| 1513 | for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++) |
---|
| 1514 | { |
---|
| 1515 | for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++) |
---|
| 1516 | { |
---|
| 1517 | maxTidRefPresentFlag = maxTidRefPresentFlag || ( vps.getMaxTidIlRefPicsPlus1( refLayerIdInVps, curLayerIdInVps ) != 7 ); |
---|
| 1518 | } |
---|
| 1519 | } |
---|
| 1520 | vps.setMaxTidRefPresentFlag( maxTidRefPresentFlag ); |
---|
[296] | 1521 | |
---|
[1124] | 1522 | |
---|
[608] | 1523 | // Max one active ref layer flag |
---|
| 1524 | Bool maxOneActiveRefLayerFlag = true; |
---|
[622] | 1525 | for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; layerIdInVps++) |
---|
[296] | 1526 | { |
---|
[608] | 1527 | for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ ) |
---|
| 1528 | { |
---|
[622] | 1529 | GOPEntry ge = m_GOPListMvc[layerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]; |
---|
[608] | 1530 | maxOneActiveRefLayerFlag = maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1); |
---|
| 1531 | } |
---|
[1124] | 1532 | } |
---|
[608] | 1533 | |
---|
| 1534 | vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag ); |
---|
[622] | 1535 | |
---|
[738] | 1536 | // Poc Lsb Not Present Flag |
---|
| 1537 | for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers; layerIdInVps++) |
---|
| 1538 | { |
---|
| 1539 | if ( m_directRefLayers[ layerIdInVps ].size() == 0 ) |
---|
| 1540 | { |
---|
| 1541 | vps.setPocLsbNotPresentFlag( layerIdInVps, true ); |
---|
| 1542 | } |
---|
[1124] | 1543 | } |
---|
[622] | 1544 | |
---|
| 1545 | // All Ref layers active flag |
---|
| 1546 | Bool allRefLayersActiveFlag = true; |
---|
| 1547 | for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers && allRefLayersActiveFlag; layerIdInVps++) |
---|
| 1548 | { |
---|
[1124] | 1549 | Int layerIdInNuh = vps.getLayerIdInNuh( layerIdInVps ); |
---|
[622] | 1550 | for( Int i = 0; i < ( getGOPSize() + 1) && allRefLayersActiveFlag; i++ ) |
---|
| 1551 | { |
---|
| 1552 | GOPEntry ge = m_GOPListMvc[layerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]; |
---|
[738] | 1553 | Int tId = ge.m_temporalId; // Should be equal for all layers. |
---|
| 1554 | |
---|
| 1555 | // check if all reference layers when allRefLayerActiveFlag is equal to 1 are reference layer pictures specified in the gop entry |
---|
[1124] | 1556 | #if H_3D |
---|
| 1557 | for (Int k = 0; k < vps.getNumRefListLayers( layerIdInNuh ) && allRefLayersActiveFlag; k++ ) |
---|
| 1558 | { |
---|
| 1559 | Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdRefListLayer( layerIdInNuh , k ) ); |
---|
| 1560 | #else |
---|
| 1561 | for (Int k = 0; k < vps.getNumDirectRefLayers( layerIdInNuh ) && allRefLayersActiveFlag; k++ ) |
---|
| 1562 | { |
---|
| 1563 | Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdDirectRefLayer( layerIdInNuh , k ) ); |
---|
| 1564 | #endif |
---|
| 1565 | if ( vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId && ( tId == 0 || vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId ) ) |
---|
[738] | 1566 | { |
---|
| 1567 | Bool gopEntryFoundFlag = false; |
---|
| 1568 | for( Int l = 0; l < ge.m_numActiveRefLayerPics && !gopEntryFoundFlag; l++ ) |
---|
| 1569 | { |
---|
| 1570 | gopEntryFoundFlag = gopEntryFoundFlag || ( ge.m_interLayerPredLayerIdc[l] == k ); |
---|
| 1571 | } |
---|
| 1572 | allRefLayersActiveFlag = allRefLayersActiveFlag && gopEntryFoundFlag; |
---|
| 1573 | } |
---|
| 1574 | } |
---|
| 1575 | |
---|
| 1576 | // check if all inter layer reference pictures specified in the gop entry are valid reference layer pictures when allRefLayerActiveFlag is equal to 1 |
---|
| 1577 | // (Should actually always be true) |
---|
| 1578 | Bool maxTidIlRefAndSubLayerMaxVaildFlag = true; |
---|
| 1579 | for( Int l = 0; l < ge.m_numActiveRefLayerPics; l++ ) |
---|
| 1580 | { |
---|
| 1581 | Bool referenceLayerFoundFlag = false; |
---|
[1124] | 1582 | #if H_3D |
---|
| 1583 | for (Int k = 0; k < vps.getNumRefListLayers( layerIdInNuh ); k++ ) |
---|
| 1584 | { |
---|
| 1585 | Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdRefListLayer( layerIdInNuh, k) ); |
---|
| 1586 | #else |
---|
| 1587 | for (Int k = 0; k < vps.getNumDirectRefLayers( layerIdInNuh ); k++ ) |
---|
| 1588 | { |
---|
| 1589 | Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdDirectRefLayer( layerIdInNuh, k) ); |
---|
| 1590 | #endif |
---|
| 1591 | if ( vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId && ( tId == 0 || vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId ) ) |
---|
[738] | 1592 | { |
---|
| 1593 | referenceLayerFoundFlag = referenceLayerFoundFlag || ( ge.m_interLayerPredLayerIdc[l] == k ); |
---|
| 1594 | } |
---|
| 1595 | } |
---|
| 1596 | maxTidIlRefAndSubLayerMaxVaildFlag = maxTidIlRefAndSubLayerMaxVaildFlag && referenceLayerFoundFlag; |
---|
| 1597 | } |
---|
| 1598 | assert ( maxTidIlRefAndSubLayerMaxVaildFlag ); // Something wrong with MaxTidIlRefPicsPlus1 or SubLayersVpsMaxMinus1 |
---|
[622] | 1599 | } |
---|
| 1600 | } |
---|
| 1601 | |
---|
| 1602 | vps.setAllRefLayersActiveFlag( allRefLayersActiveFlag ); |
---|
[608] | 1603 | }; |
---|
| 1604 | |
---|
[1124] | 1605 | |
---|
[622] | 1606 | GOPEntry* TAppEncTop::xGetGopEntry( Int layerIdInVps, Int poc ) |
---|
| 1607 | { |
---|
| 1608 | GOPEntry* geFound = NULL; |
---|
| 1609 | for( Int i = 0; i < ( getGOPSize() + 1) && geFound == NULL ; i++ ) |
---|
| 1610 | { |
---|
| 1611 | GOPEntry* ge = &(m_GOPListMvc[layerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]); |
---|
| 1612 | if ( ge->m_POC == poc ) |
---|
| 1613 | { |
---|
| 1614 | geFound = ge; |
---|
| 1615 | } |
---|
| 1616 | } |
---|
| 1617 | assert( geFound != NULL ); |
---|
| 1618 | return geFound; |
---|
| 1619 | } |
---|
| 1620 | |
---|
[608] | 1621 | Void TAppEncTop::xSetLayerIds( TComVPS& vps ) |
---|
| 1622 | { |
---|
| 1623 | vps.setSplittingFlag ( m_splittingFlag ); |
---|
| 1624 | |
---|
| 1625 | Bool nuhLayerIdPresentFlag = !( m_layerIdInNuh.size() == 1 ); |
---|
| 1626 | Int maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ; |
---|
| 1627 | |
---|
| 1628 | vps.setVpsMaxLayerId( maxNuhLayerId ); |
---|
| 1629 | vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag ); |
---|
| 1630 | |
---|
| 1631 | for (Int layer = 0; layer < m_numberOfLayers; layer++ ) |
---|
| 1632 | { |
---|
| 1633 | vps.setLayerIdInNuh( layer, nuhLayerIdPresentFlag ? m_layerIdInNuh[ layer ] : layer ); |
---|
| 1634 | vps.setLayerIdInVps( vps.getLayerIdInNuh( layer ), layer ); |
---|
[296] | 1635 | } |
---|
[608] | 1636 | } |
---|
| 1637 | |
---|
| 1638 | Int TAppEncTop::xGetMax( std::vector<Int>& vec ) |
---|
| 1639 | { |
---|
| 1640 | Int maxVec = 0; |
---|
| 1641 | for ( Int i = 0; i < vec.size(); i++) |
---|
[622] | 1642 | { |
---|
[608] | 1643 | maxVec = max( vec[i], maxVec ); |
---|
[622] | 1644 | } |
---|
[608] | 1645 | return maxVec; |
---|
| 1646 | } |
---|
| 1647 | |
---|
| 1648 | Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps ) |
---|
| 1649 | { |
---|
[1066] | 1650 | |
---|
| 1651 | // SET PTL |
---|
| 1652 | assert( m_profile.size() == m_level.size() && m_profile.size() == m_levelTier.size() ); |
---|
| 1653 | vps.setVpsNumProfileTierLevelMinus1( (Int) m_profile.size() - 1 ); |
---|
| 1654 | for ( Int ptlIdx = 0; ptlIdx <= vps.getVpsNumProfileTierLevelMinus1(); ptlIdx++ ) |
---|
| 1655 | { |
---|
| 1656 | if ( ptlIdx > 1 ) |
---|
| 1657 | { |
---|
| 1658 | Bool vpsProfilePresentFlag = ( m_profile[ptlIdx] != m_profile[ptlIdx - 1] ) |
---|
| 1659 | || ( m_inblFlag[ptlIdx ] != m_inblFlag[ptlIdx - 1] ); |
---|
| 1660 | vps.setVpsProfilePresentFlag( ptlIdx, vpsProfilePresentFlag ); |
---|
| 1661 | } |
---|
| 1662 | |
---|
| 1663 | xSetProfileTierLevel( vps, ptlIdx, -1, m_profile[ptlIdx], m_level[ptlIdx], |
---|
| 1664 | m_levelTier[ ptlIdx ], m_progressiveSourceFlag, m_interlacedSourceFlag, |
---|
| 1665 | m_nonPackedConstraintFlag, m_frameOnlyConstraintFlag, m_inblFlag[ptlIdx] ); |
---|
| 1666 | } |
---|
[608] | 1667 | } |
---|
[296] | 1668 | |
---|
[1066] | 1669 | Void TAppEncTop::xSetProfileTierLevel(TComVPS& vps, Int profileTierLevelIdx, Int subLayer, Profile::Name profile, Level::Name level, Level::Tier tier, Bool progressiveSourceFlag, Bool interlacedSourceFlag, Bool nonPackedConstraintFlag, Bool frameOnlyConstraintFlag, Bool inbldFlag) |
---|
| 1670 | { |
---|
| 1671 | TComPTL* ptlStruct = vps.getPTL( profileTierLevelIdx ); |
---|
| 1672 | assert( ptlStruct != NULL ); |
---|
[608] | 1673 | |
---|
[1066] | 1674 | ProfileTierLevel* ptl; |
---|
| 1675 | if ( subLayer == -1 ) |
---|
| 1676 | { |
---|
| 1677 | ptl = ptlStruct->getGeneralPTL(); |
---|
| 1678 | } |
---|
| 1679 | else |
---|
| 1680 | { |
---|
| 1681 | ptl = ptlStruct->getSubLayerPTL( subLayer ); |
---|
| 1682 | } |
---|
| 1683 | |
---|
| 1684 | assert( ptl != NULL ); |
---|
| 1685 | |
---|
| 1686 | ptl->setProfileIdc( profile ); |
---|
| 1687 | ptl->setTierFlag ( tier ); |
---|
| 1688 | ptl->setLevelIdc ( level ); |
---|
| 1689 | ptl->setProfileCompatibilityFlag( profile, true ); |
---|
| 1690 | ptl->setInbldFlag( inbldFlag ); |
---|
| 1691 | |
---|
| 1692 | switch ( profile ) |
---|
| 1693 | { |
---|
| 1694 | case Profile::MAIN: |
---|
| 1695 | break; |
---|
| 1696 | case Profile::MULTIVIEWMAIN: |
---|
| 1697 | #if H_3D |
---|
| 1698 | case Profile::MAIN3D: |
---|
| 1699 | #endif |
---|
| 1700 | ptl->setMax12bitConstraintFlag ( true ); |
---|
| 1701 | ptl->setMax12bitConstraintFlag ( true ); |
---|
| 1702 | ptl->setMax10bitConstraintFlag ( true ); |
---|
| 1703 | ptl->setMax8bitConstraintFlag ( true ); |
---|
| 1704 | ptl->setMax422chromaConstraintFlag ( true ); |
---|
| 1705 | ptl->setMax420chromaConstraintFlag ( true ); |
---|
| 1706 | ptl->setMaxMonochromeConstraintFlag ( false ); |
---|
| 1707 | ptl->setIntraConstraintFlag ( false ); |
---|
| 1708 | ptl->setOnePictureOnlyConstraintFlag( false ); |
---|
| 1709 | ptl->setLowerBitRateConstraintFlag ( true ); |
---|
| 1710 | break; |
---|
| 1711 | default: |
---|
| 1712 | assert( 0 ); // other profiles currently not supported |
---|
| 1713 | break; |
---|
| 1714 | } |
---|
| 1715 | } |
---|
| 1716 | |
---|
[622] | 1717 | Void TAppEncTop::xSetRepFormat( TComVPS& vps ) |
---|
| 1718 | { |
---|
[1179] | 1719 | |
---|
| 1720 | #if H_3D_DISABLE_CHROMA |
---|
| 1721 | Bool anyDepth = false; |
---|
| 1722 | for ( Int i = 0; i < m_numberOfLayers; i++ ) |
---|
| 1723 | { |
---|
| 1724 | vps.setVpsRepFormatIdx( i, m_depthFlag[ i ] ? 1 : 0 ); |
---|
| 1725 | anyDepth = anyDepth || m_depthFlag[ i ]; |
---|
| 1726 | } |
---|
| 1727 | |
---|
| 1728 | vps.setRepFormatIdxPresentFlag( anyDepth ); |
---|
| 1729 | vps.setVpsNumRepFormatsMinus1 ( anyDepth ? 1 : 0 ); |
---|
| 1730 | |
---|
| 1731 | for ( Int j = 0; j <= vps.getVpsNumRepFormatsMinus1(); j++ ) |
---|
| 1732 | { |
---|
| 1733 | TComRepFormat* repFormat = new TComRepFormat; |
---|
| 1734 | |
---|
| 1735 | repFormat->setBitDepthVpsChromaMinus8 ( g_bitDepthC - 8 ); |
---|
| 1736 | repFormat->setBitDepthVpsLumaMinus8 ( g_bitDepthY - 8 ); |
---|
| 1737 | repFormat->setChromaFormatVpsIdc ( j == 1 ? CHROMA_400 : CHROMA_420 ); |
---|
| 1738 | repFormat->setPicHeightVpsInLumaSamples ( m_iSourceHeight ); |
---|
| 1739 | repFormat->setPicWidthVpsInLumaSamples ( m_iSourceWidth ); |
---|
| 1740 | repFormat->setChromaAndBitDepthVpsPresentFlag( true ); |
---|
| 1741 | // ToDo not supported yet. |
---|
| 1742 | //repFormat->setSeparateColourPlaneVpsFlag( ); |
---|
| 1743 | Bool conformanceWindowVpsFlag = ( m_confWinBottom != 0 ) || ( m_confWinRight != 0 ) || ( m_confWinTop != 0 ) || ( m_confWinBottom != 0 ); |
---|
| 1744 | repFormat->setConformanceWindowVpsFlag( conformanceWindowVpsFlag ); |
---|
| 1745 | if ( conformanceWindowVpsFlag ) |
---|
| 1746 | { |
---|
| 1747 | repFormat->setConfWinVpsLeftOffset ( m_confWinLeft / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) ); |
---|
| 1748 | repFormat->setConfWinVpsRightOffset ( m_confWinRight / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) ); |
---|
| 1749 | repFormat->setConfWinVpsTopOffset ( m_confWinTop / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) ); |
---|
| 1750 | repFormat->setConfWinVpsBottomOffset ( m_confWinBottom / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) ); |
---|
| 1751 | } |
---|
| 1752 | assert( vps.getRepFormat( j ) == NULL ); |
---|
| 1753 | vps.setRepFormat( j , repFormat ); |
---|
| 1754 | }; |
---|
| 1755 | |
---|
| 1756 | |
---|
| 1757 | #else |
---|
[964] | 1758 | vps.setRepFormatIdxPresentFlag( false ); |
---|
[622] | 1759 | vps.setVpsNumRepFormatsMinus1 ( 0 ); |
---|
| 1760 | |
---|
| 1761 | TComRepFormat* repFormat = new TComRepFormat; |
---|
| 1762 | |
---|
| 1763 | repFormat->setBitDepthVpsChromaMinus8 ( g_bitDepthC - 8 ); |
---|
| 1764 | repFormat->setBitDepthVpsLumaMinus8 ( g_bitDepthY - 8 ); |
---|
| 1765 | repFormat->setChromaFormatVpsIdc ( CHROMA_420 ); |
---|
| 1766 | repFormat->setPicHeightVpsInLumaSamples ( m_iSourceHeight ); |
---|
| 1767 | repFormat->setPicWidthVpsInLumaSamples ( m_iSourceWidth ); |
---|
[738] | 1768 | repFormat->setChromaAndBitDepthVpsPresentFlag( true ); |
---|
[622] | 1769 | // ToDo not supported yet. |
---|
| 1770 | //repFormat->setSeparateColourPlaneVpsFlag( ); |
---|
| 1771 | |
---|
[1066] | 1772 | repFormat->setConformanceWindowVpsFlag( true ); |
---|
[1084] | 1773 | repFormat->setConfWinVpsLeftOffset ( m_confWinLeft / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) ); |
---|
| 1774 | repFormat->setConfWinVpsRightOffset ( m_confWinRight / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) ); |
---|
| 1775 | repFormat->setConfWinVpsTopOffset ( m_confWinTop / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) ); |
---|
| 1776 | repFormat->setConfWinVpsBottomOffset ( m_confWinBottom / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) ); |
---|
[622] | 1777 | assert( vps.getRepFormat( 0 ) == NULL ); |
---|
| 1778 | vps.setRepFormat( 0 , repFormat ); |
---|
[1179] | 1779 | #endif |
---|
[622] | 1780 | } |
---|
| 1781 | |
---|
[738] | 1782 | Void TAppEncTop::xSetDpbSize ( TComVPS& vps ) |
---|
| 1783 | { |
---|
| 1784 | // These settings need to be verified |
---|
| 1785 | |
---|
| 1786 | TComDpbSize* dpbSize = vps.getDpbSize(); |
---|
| 1787 | |
---|
| 1788 | assert ( dpbSize != 0 ); |
---|
| 1789 | |
---|
[964] | 1790 | for( Int i = 0; i < vps.getNumOutputLayerSets(); i++ ) |
---|
[738] | 1791 | { |
---|
[964] | 1792 | Int currLsIdx = vps.olsIdxToLsIdx( i ); |
---|
[872] | 1793 | Bool subLayerFlagInfoPresentFlag = false; |
---|
| 1794 | |
---|
[964] | 1795 | for( Int j = 0; j <= vps.getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ ) |
---|
[872] | 1796 | { |
---|
| 1797 | Bool subLayerDpbInfoPresentFlag = false; |
---|
[964] | 1798 | for( Int k = 0; k < vps.getNumLayersInIdList( currLsIdx ); k++ ) |
---|
[872] | 1799 | { |
---|
[1066] | 1800 | Int layerIdInVps = vps.getLayerIdInVps( vps.getLayerSetLayerIdList( currLsIdx, k ) ); |
---|
| 1801 | if ( vps.getNecessaryLayerFlag( i,k ) && ( vps.getVpsBaseLayerInternalFlag() || vps.getLayerSetLayerIdList( currLsIdx, k ) != 0 ) ) |
---|
| 1802 | { |
---|
| 1803 | dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 ); |
---|
| 1804 | if ( j > 0 ) |
---|
| 1805 | { |
---|
| 1806 | subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) != dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) ); |
---|
| 1807 | } |
---|
| 1808 | } |
---|
| 1809 | else |
---|
| 1810 | { |
---|
| 1811 | if (vps.getNecessaryLayerFlag(i,k) && j == 0 && k == 0 ) |
---|
| 1812 | { |
---|
| 1813 | dpbSize->setMaxVpsDecPicBufferingMinus1(i, k ,j, 0 ); |
---|
| 1814 | } |
---|
| 1815 | } |
---|
[872] | 1816 | } |
---|
| 1817 | |
---|
| 1818 | Int maxNumReorderPics = MIN_INT; |
---|
[1066] | 1819 | for ( Int idx = 0; idx < vps.getNumLayersInIdList( currLsIdx ); idx++ ) |
---|
| 1820 | { |
---|
| 1821 | if (vps.getNecessaryLayerFlag(i, idx )) |
---|
| 1822 | { |
---|
| 1823 | Int layerIdInVps = vps.getLayerIdInVps( vps.getLayerSetLayerIdList(currLsIdx, idx) ); |
---|
| 1824 | maxNumReorderPics = std::max( maxNumReorderPics, m_numReorderPicsMvc[ layerIdInVps ][ j ] ); |
---|
| 1825 | } |
---|
| 1826 | } |
---|
[872] | 1827 | assert( maxNumReorderPics != MIN_INT ); |
---|
| 1828 | |
---|
| 1829 | dpbSize->setMaxVpsNumReorderPics( i, j, maxNumReorderPics ); |
---|
| 1830 | if ( j > 0 ) |
---|
| 1831 | { |
---|
| 1832 | subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsNumReorderPics( i, j ) != dpbSize->getMaxVpsNumReorderPics( i, j - 1 ) ); |
---|
| 1833 | } |
---|
| 1834 | |
---|
| 1835 | // To Be Done ! |
---|
| 1836 | // dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, xx ); |
---|
| 1837 | if ( j > 0 ) |
---|
| 1838 | { |
---|
| 1839 | subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ) != dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
| 1840 | } |
---|
| 1841 | |
---|
| 1842 | if( j > 0 ) |
---|
| 1843 | { |
---|
| 1844 | dpbSize->setSubLayerDpbInfoPresentFlag( i, j, subLayerDpbInfoPresentFlag ); |
---|
| 1845 | subLayerFlagInfoPresentFlag = subLayerFlagInfoPresentFlag || subLayerDpbInfoPresentFlag; |
---|
| 1846 | } |
---|
| 1847 | } |
---|
| 1848 | dpbSize->setSubLayerFlagInfoPresentFlag( i, subLayerFlagInfoPresentFlag ); |
---|
| 1849 | } |
---|
| 1850 | } |
---|
| 1851 | |
---|
[608] | 1852 | Void TAppEncTop::xSetLayerSets( TComVPS& vps ) |
---|
| 1853 | { |
---|
| 1854 | // Layer sets |
---|
| 1855 | vps.setVpsNumLayerSetsMinus1 ( m_vpsNumLayerSets - 1 ); |
---|
| 1856 | |
---|
| 1857 | for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ ) |
---|
| 1858 | { |
---|
| 1859 | for( Int layerId = 0; layerId < MAX_NUM_LAYER_IDS; layerId++ ) |
---|
| 1860 | { |
---|
| 1861 | vps.setLayerIdIncludedFlag( false, lsIdx, layerId ); |
---|
| 1862 | } |
---|
| 1863 | for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++) |
---|
| 1864 | { |
---|
| 1865 | vps.setLayerIdIncludedFlag( true, lsIdx, vps.getLayerIdInNuh( m_layerIdsInSets[lsIdx][i] ) ); |
---|
| 1866 | } |
---|
| 1867 | } |
---|
[738] | 1868 | vps.deriveLayerSetLayerIdList(); |
---|
[608] | 1869 | |
---|
| 1870 | Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); |
---|
| 1871 | // Additional output layer sets + profileLevelTierIdx |
---|
[964] | 1872 | vps.setDefaultOutputLayerIdc ( m_defaultOutputLayerIdc ); |
---|
[1066] | 1873 | if( vps.getNumIndependentLayers() == 0 && m_numAddLayerSets > 0 ) |
---|
| 1874 | { |
---|
| 1875 | fprintf( stderr, "\nWarning: Ignoring additional layer sets since NumIndependentLayers is equal to 0.\n"); |
---|
| 1876 | } |
---|
| 1877 | else |
---|
| 1878 | { |
---|
| 1879 | vps.setNumAddLayerSets( m_numAddLayerSets ); |
---|
| 1880 | if ( m_highestLayerIdxPlus1.size() < vps.getNumAddLayerSets() ) |
---|
| 1881 | { |
---|
| 1882 | fprintf(stderr, "\nError: Number of highestLayerIdxPlus1 parameters must be greater than or equal to NumAddLayerSets\n"); |
---|
| 1883 | exit(EXIT_FAILURE); |
---|
| 1884 | } |
---|
| 1885 | |
---|
| 1886 | for (Int i = 0; i < vps.getNumAddLayerSets(); i++) |
---|
| 1887 | { |
---|
| 1888 | if ( m_highestLayerIdxPlus1[ i ].size() < vps.getNumIndependentLayers() ) |
---|
| 1889 | { |
---|
| 1890 | fprintf(stderr, "Error: Number of elements in highestLayerIdxPlus1[ %d ] parameters must be greater than or equal to NumIndependentLayers(= %d)\n", i, vps.getNumIndependentLayers()); |
---|
| 1891 | exit(EXIT_FAILURE); |
---|
| 1892 | } |
---|
| 1893 | |
---|
| 1894 | for (Int j = 1; j < vps.getNumIndependentLayers(); j++) |
---|
| 1895 | { |
---|
| 1896 | if ( m_highestLayerIdxPlus1[ i ][ j ] < 0 || m_highestLayerIdxPlus1[ i ][ j ] > vps.getNumLayersInTreePartition( j ) ) |
---|
| 1897 | { |
---|
| 1898 | fprintf(stderr, "Error: highestLayerIdxPlus1[ %d ][ %d ] shall be in the range of 0 to NumLayersInTreePartition[ %d ] (= %d ), inclusive. \n", i, j, j, vps.getNumLayersInTreePartition( j ) ); |
---|
| 1899 | exit(EXIT_FAILURE); |
---|
| 1900 | } |
---|
| 1901 | vps.setHighestLayerIdxPlus1( i, j, m_highestLayerIdxPlus1[ i ][ j ] ); |
---|
| 1902 | } |
---|
| 1903 | vps.deriveAddLayerSetLayerIdList( i ); |
---|
| 1904 | } |
---|
| 1905 | } |
---|
[964] | 1906 | vps.setNumAddOlss ( numAddOuputLayerSets ); |
---|
[872] | 1907 | vps.initTargetLayerIdLists(); |
---|
[608] | 1908 | |
---|
[1066] | 1909 | for (Int olsIdx = 0; olsIdx < vps.getNumLayerSets() + numAddOuputLayerSets; olsIdx++) |
---|
| 1910 | { |
---|
| 1911 | Int addOutLsIdx = olsIdx - vps.getNumLayerSets(); |
---|
[964] | 1912 | vps.setLayerSetIdxForOlsMinus1( olsIdx, ( ( addOutLsIdx < 0 ) ? olsIdx : m_outputLayerSetIdx[ addOutLsIdx ] ) - 1 ); |
---|
[738] | 1913 | |
---|
[1066] | 1914 | Int lsIdx = vps.olsIdxToLsIdx( olsIdx ); |
---|
[964] | 1915 | if (vps.getDefaultOutputLayerIdc() == 2 || addOutLsIdx >= 0 ) |
---|
[872] | 1916 | { |
---|
[1066] | 1917 | for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++) |
---|
[872] | 1918 | { |
---|
| 1919 | vps.setOutputLayerFlag( olsIdx, i, ( olsIdx == 0 && i == 0 ) ? vps.inferOutputLayerFlag(olsIdx, i ) : false ); // This is a software only fix for a bug in the spec. In spec outputLayerFlag neither present nor inferred for this case ! |
---|
| 1920 | } |
---|
| 1921 | |
---|
| 1922 | std::vector<Int>& outLayerIdList = ( addOutLsIdx >= 0 ) ? m_layerIdsInAddOutputLayerSet[addOutLsIdx] : m_layerIdsInDefOutputLayerSet[olsIdx]; |
---|
| 1923 | |
---|
| 1924 | Bool outputLayerInLayerSetFlag = false; |
---|
| 1925 | for (Int j = 0; j < outLayerIdList.size(); j++) |
---|
| 1926 | { |
---|
[1066] | 1927 | for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++) |
---|
| 1928 | { |
---|
| 1929 | if ( vps.getLayerSetLayerIdList( lsIdx, i ) == outLayerIdList[ j ] ) |
---|
[872] | 1930 | { |
---|
| 1931 | vps.setOutputLayerFlag( olsIdx, i, true ); |
---|
| 1932 | outputLayerInLayerSetFlag = true; |
---|
| 1933 | break; |
---|
| 1934 | } |
---|
| 1935 | } |
---|
[1066] | 1936 | if ( !outputLayerInLayerSetFlag ) |
---|
| 1937 | { |
---|
| 1938 | fprintf(stderr, "Error: Output layer %d in output layer set %d not in corresponding layer set %d \n", outLayerIdList[ j ], olsIdx , lsIdx ); |
---|
| 1939 | exit(EXIT_FAILURE); |
---|
| 1940 | } |
---|
[872] | 1941 | } |
---|
| 1942 | } |
---|
| 1943 | else |
---|
| 1944 | { |
---|
[1066] | 1945 | for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++) |
---|
[872] | 1946 | { |
---|
| 1947 | vps.setOutputLayerFlag( olsIdx, i, vps.inferOutputLayerFlag( olsIdx, i ) ); |
---|
| 1948 | } |
---|
| 1949 | } |
---|
| 1950 | |
---|
[1066] | 1951 | vps.deriveNecessaryLayerFlags( olsIdx ); |
---|
[872] | 1952 | vps.deriveTargetLayerIdList( olsIdx ); |
---|
| 1953 | |
---|
[1066] | 1954 | // SET profile_tier_level_index. |
---|
| 1955 | if ( olsIdx == 0 ) |
---|
| 1956 | { |
---|
| 1957 | vps.setProfileTierLevelIdx( 0, 0 , vps.getMaxLayersMinus1() > 0 ? 1 : 0 ); |
---|
| 1958 | } |
---|
| 1959 | else |
---|
| 1960 | { |
---|
| 1961 | if( (Int) m_profileTierLevelIdx[ olsIdx ].size() < vps.getNumLayersInIdList( lsIdx ) ) |
---|
| 1962 | { |
---|
| 1963 | fprintf( stderr, "Warning: Not enough profileTierLevelIdx values given for the %d-th OLS. Inferring default values.\n", olsIdx ); |
---|
| 1964 | } |
---|
| 1965 | for (Int j = 0; j < vps.getNumLayersInIdList( lsIdx ); j++) |
---|
| 1966 | { |
---|
| 1967 | if( j < (Int) m_profileTierLevelIdx[ olsIdx ].size() ) |
---|
| 1968 | { |
---|
| 1969 | vps.setProfileTierLevelIdx(olsIdx, j, m_profileTierLevelIdx[olsIdx][j] ); |
---|
| 1970 | if( !vps.getNecessaryLayerFlag(olsIdx,j) && m_profileTierLevelIdx[ olsIdx ][ j ] != -1 ) |
---|
| 1971 | { |
---|
| 1972 | fprintf( stderr, "Warning: The %d-th layer in the %d-th OLS is not necessary such that profileTierLevelIdx[%d][%d] will be ignored. Set value to -1 to suppress warning.\n", j,olsIdx,olsIdx,j ); |
---|
| 1973 | } |
---|
| 1974 | } |
---|
| 1975 | else if ( vps.getNecessaryLayerFlag(olsIdx,j) ) |
---|
| 1976 | { |
---|
| 1977 | // setting default values |
---|
| 1978 | if ( j == 0 || vps.getVpsNumProfileTierLevelMinus1() < 1 ) |
---|
| 1979 | { |
---|
| 1980 | // set base layer as default |
---|
| 1981 | vps.setProfileTierLevelIdx(olsIdx, j, 1 ); |
---|
| 1982 | } |
---|
| 1983 | else |
---|
| 1984 | { |
---|
| 1985 | // set VpsProfileTierLevel[2] as default |
---|
| 1986 | vps.setProfileTierLevelIdx(olsIdx, j, 2 ); |
---|
| 1987 | } |
---|
| 1988 | } |
---|
| 1989 | } |
---|
| 1990 | } |
---|
[976] | 1991 | |
---|
[964] | 1992 | if ( vps.getNumOutputLayersInOutputLayerSet( olsIdx ) == 1 && |
---|
| 1993 | vps.getNumDirectRefLayers( vps.getOlsHighestOutputLayerId( olsIdx ) ) ) |
---|
| 1994 | { |
---|
| 1995 | vps.setAltOutputLayerFlag( olsIdx , m_altOutputLayerFlag[ olsIdx ]); |
---|
| 1996 | } |
---|
| 1997 | else |
---|
| 1998 | { |
---|
| 1999 | vps.setAltOutputLayerFlag( olsIdx , false ); |
---|
| 2000 | if ( m_altOutputLayerFlag[ olsIdx ] ) |
---|
| 2001 | { |
---|
| 2002 | printf( "\nWarning: Ignoring AltOutputLayerFlag for output layer set %d, since more than one output layer or no dependent layers.\n", olsIdx ); |
---|
| 2003 | } |
---|
| 2004 | } |
---|
[872] | 2005 | } |
---|
[296] | 2006 | } |
---|
[622] | 2007 | |
---|
| 2008 | Void TAppEncTop::xSetVPSVUI( TComVPS& vps ) |
---|
| 2009 | { |
---|
| 2010 | vps.setVpsVuiPresentFlag( m_vpsVuiPresentFlag ); |
---|
| 2011 | |
---|
[872] | 2012 | TComVPSVUI* pcVPSVUI = vps.getVPSVUI( ); |
---|
| 2013 | assert( pcVPSVUI ); |
---|
| 2014 | |
---|
[622] | 2015 | if ( m_vpsVuiPresentFlag ) |
---|
| 2016 | { |
---|
[738] | 2017 | // All this stuff could actually be derived by the encoder, |
---|
| 2018 | // however preliminary setting it from input parameters |
---|
| 2019 | |
---|
| 2020 | pcVPSVUI->setCrossLayerPicTypeAlignedFlag( m_crossLayerPicTypeAlignedFlag ); |
---|
| 2021 | pcVPSVUI->setCrossLayerIrapAlignedFlag ( m_crossLayerIrapAlignedFlag ); |
---|
[872] | 2022 | pcVPSVUI->setAllLayersIdrAlignedFlag ( m_allLayersIdrAlignedFlag ); |
---|
[622] | 2023 | pcVPSVUI->setBitRatePresentVpsFlag( m_bitRatePresentVpsFlag ); |
---|
| 2024 | pcVPSVUI->setPicRatePresentVpsFlag( m_picRatePresentVpsFlag ); |
---|
| 2025 | |
---|
| 2026 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) || pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
| 2027 | { |
---|
[1066] | 2028 | for( Int i = 0; i < vps.getNumLayerSets(); i++ ) |
---|
[622] | 2029 | { |
---|
| 2030 | for( Int j = 0; j <= vps.getMaxTLayers(); j++ ) |
---|
| 2031 | { |
---|
| 2032 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) && m_bitRatePresentFlag[i].size() > j ) |
---|
| 2033 | { |
---|
| 2034 | pcVPSVUI->setBitRatePresentFlag( i, j, m_bitRatePresentFlag[i][j] ); |
---|
| 2035 | } |
---|
| 2036 | if( pcVPSVUI->getPicRatePresentVpsFlag( ) && m_picRatePresentFlag[i].size() > j ) |
---|
| 2037 | { |
---|
| 2038 | pcVPSVUI->setPicRatePresentFlag( i, j, m_picRatePresentFlag[i][j] ); |
---|
| 2039 | } |
---|
| 2040 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) && m_avgBitRate[i].size() > j ) |
---|
| 2041 | { |
---|
| 2042 | pcVPSVUI->setAvgBitRate( i, j, m_avgBitRate[i][j] ); |
---|
| 2043 | } |
---|
| 2044 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) && m_maxBitRate[i].size() > j ) |
---|
| 2045 | { |
---|
| 2046 | pcVPSVUI->setMaxBitRate( i, j, m_maxBitRate[i][j] ); |
---|
| 2047 | } |
---|
| 2048 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) && m_constantPicRateIdc[i].size() > j ) |
---|
| 2049 | { |
---|
| 2050 | pcVPSVUI->setConstantPicRateIdc( i, j, m_constantPicRateIdc[i][j] ); |
---|
| 2051 | } |
---|
| 2052 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) && m_avgPicRate[i].size() > j ) |
---|
| 2053 | { |
---|
| 2054 | pcVPSVUI->setAvgPicRate( i, j, m_avgPicRate[i][j] ); |
---|
| 2055 | } |
---|
| 2056 | } |
---|
| 2057 | } |
---|
| 2058 | } |
---|
| 2059 | |
---|
[738] | 2060 | pcVPSVUI->setTilesNotInUseFlag( m_tilesNotInUseFlag ); |
---|
| 2061 | |
---|
| 2062 | if( !pcVPSVUI->getTilesNotInUseFlag() ) |
---|
| 2063 | { |
---|
| 2064 | for( Int i = 0; i <= vps.getMaxLayersMinus1(); i++ ) |
---|
| 2065 | { |
---|
| 2066 | pcVPSVUI->setTilesInUseFlag( i, m_tilesInUseFlag[ i ] ); |
---|
| 2067 | if( pcVPSVUI->getTilesInUseFlag( i ) ) |
---|
| 2068 | { |
---|
| 2069 | pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, m_loopFilterNotAcrossTilesFlag[ i ] ); |
---|
| 2070 | } |
---|
| 2071 | } |
---|
| 2072 | |
---|
| 2073 | for( Int i = 1; i <= vps.getMaxLayersMinus1(); i++ ) |
---|
| 2074 | { |
---|
| 2075 | for( Int j = 0; j < vps.getNumDirectRefLayers( vps.getLayerIdInNuh( i ) ) ; j++ ) |
---|
| 2076 | { |
---|
[1066] | 2077 | Int layerIdx = vps.getLayerIdInVps( vps.getIdDirectRefLayer(vps.getLayerIdInNuh( i ) , j )); |
---|
[738] | 2078 | if( pcVPSVUI->getTilesInUseFlag( i ) && pcVPSVUI->getTilesInUseFlag( layerIdx ) ) |
---|
| 2079 | { |
---|
| 2080 | pcVPSVUI->setTileBoundariesAlignedFlag( i, j, m_tileBoundariesAlignedFlag[i][j] ); |
---|
| 2081 | } |
---|
| 2082 | } |
---|
| 2083 | } |
---|
| 2084 | } |
---|
| 2085 | |
---|
| 2086 | pcVPSVUI->setWppNotInUseFlag( m_wppNotInUseFlag ); |
---|
| 2087 | |
---|
| 2088 | if( !pcVPSVUI->getWppNotInUseFlag( ) ) |
---|
| 2089 | { |
---|
| 2090 | for( Int i = 1; i <= vps.getMaxLayersMinus1(); i++ ) |
---|
| 2091 | { |
---|
| 2092 | pcVPSVUI->setWppInUseFlag( i, m_wppInUseFlag[ i ]); |
---|
| 2093 | } |
---|
| 2094 | } |
---|
[622] | 2095 | |
---|
[1066] | 2096 | pcVPSVUI->setSingleLayerForNonIrapFlag( m_singleLayerForNonIrapFlag ); |
---|
| 2097 | pcVPSVUI->setHigherLayerIrapSkipFlag( m_higherLayerIrapSkipFlag ); |
---|
| 2098 | |
---|
[622] | 2099 | pcVPSVUI->setIlpRestrictedRefLayersFlag( m_ilpRestrictedRefLayersFlag ); |
---|
| 2100 | |
---|
| 2101 | if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ) |
---|
| 2102 | { |
---|
| 2103 | for( Int i = 1; i <= vps.getMaxLayersMinus1(); i++ ) |
---|
| 2104 | { |
---|
| 2105 | for( Int j = 0; j < vps.getNumDirectRefLayers( vps.getLayerIdInNuh( i ) ); j++ ) |
---|
| 2106 | { |
---|
| 2107 | if ( m_minSpatialSegmentOffsetPlus1[i].size() > j ) |
---|
| 2108 | { |
---|
| 2109 | pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, m_minSpatialSegmentOffsetPlus1[i][j] ); |
---|
| 2110 | } |
---|
| 2111 | if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) |
---|
| 2112 | { |
---|
| 2113 | if ( m_ctuBasedOffsetEnabledFlag[i].size() > j ) |
---|
| 2114 | { |
---|
| 2115 | pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, m_ctuBasedOffsetEnabledFlag[i][j] ); |
---|
| 2116 | } |
---|
| 2117 | if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ) |
---|
| 2118 | { |
---|
| 2119 | if ( m_minHorizontalCtuOffsetPlus1[i].size() > j ) |
---|
| 2120 | { |
---|
| 2121 | pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, m_minHorizontalCtuOffsetPlus1[i][j] ); |
---|
| 2122 | } |
---|
| 2123 | } |
---|
| 2124 | } |
---|
| 2125 | } |
---|
| 2126 | } |
---|
| 2127 | } |
---|
[738] | 2128 | pcVPSVUI->setVideoSignalInfoIdxPresentFlag( true ); |
---|
| 2129 | pcVPSVUI->setVpsNumVideoSignalInfoMinus1 ( 0 ); |
---|
| 2130 | |
---|
| 2131 | assert ( pcVPSVUI->getVideoSignalInfo( 0 ) == NULL ); |
---|
| 2132 | |
---|
| 2133 | TComVideoSignalInfo* videoSignalInfo = new TComVideoSignalInfo; |
---|
| 2134 | |
---|
| 2135 | videoSignalInfo->setColourPrimariesVps ( m_colourPrimaries ); |
---|
| 2136 | videoSignalInfo->setMatrixCoeffsVps ( m_matrixCoefficients ); |
---|
| 2137 | videoSignalInfo->setTransferCharacteristicsVps( m_transferCharacteristics ); |
---|
| 2138 | videoSignalInfo->setVideoVpsFormat ( m_videoFormat ); |
---|
| 2139 | videoSignalInfo->setVideoFullRangeVpsFlag ( m_videoFullRangeFlag ); |
---|
| 2140 | |
---|
| 2141 | pcVPSVUI->setVideoSignalInfo( 0, videoSignalInfo ); |
---|
| 2142 | |
---|
| 2143 | for (Int i = 0; i < m_numberOfLayers; i++) |
---|
| 2144 | { |
---|
| 2145 | pcVPSVUI->setVpsVideoSignalInfoIdx( i, 0 ); |
---|
| 2146 | } |
---|
| 2147 | pcVPSVUI->setVpsVuiBspHrdPresentFlag( false ); // TBD |
---|
[622] | 2148 | } |
---|
[872] | 2149 | else |
---|
| 2150 | { |
---|
| 2151 | pcVPSVUI->setCrossLayerIrapAlignedFlag ( false ); |
---|
| 2152 | } |
---|
[622] | 2153 | } |
---|
[1179] | 2154 | |
---|
| 2155 | #if H_3D |
---|
| 2156 | Void TAppEncTop::xSetCamPara ( TComVPS& vps ) |
---|
| 2157 | { |
---|
| 2158 | vps.setCpPrecision( m_cCameraData.getCamParsCodedPrecision()); |
---|
| 2159 | |
---|
| 2160 | for ( Int n = 1; n < vps.getNumViews(); n++ ) |
---|
| 2161 | { |
---|
| 2162 | Int i = vps.getViewOIdxList( n ); |
---|
| 2163 | Int iInVps = vps.getVoiInVps ( i ); |
---|
| 2164 | vps.setNumCp( iInVps, n); |
---|
| 2165 | |
---|
| 2166 | if ( vps.getNumCp( iInVps ) > 0 ) |
---|
| 2167 | { |
---|
| 2168 | vps.setCpInSliceSegmentHeaderFlag( iInVps, m_cCameraData.getVaryingCameraParameters() ); |
---|
| 2169 | |
---|
| 2170 | for( Int m = 0; m < vps.getNumCp( iInVps ); m++ ) |
---|
| 2171 | { |
---|
| 2172 | vps.setCpRefVoi( iInVps, m, vps.getViewOIdxList( m ) ); |
---|
| 2173 | if( !vps.getCpInSliceSegmentHeaderFlag( iInVps ) ) |
---|
| 2174 | { |
---|
| 2175 | Int j = vps.getCpRefVoi( iInVps, m ); |
---|
| 2176 | Int jInVps = vps.getVoiInVps( j ); |
---|
| 2177 | |
---|
| 2178 | vps.setVpsCpScale ( iInVps, jInVps, m_cCameraData.getCodedScale() [ jInVps ][ iInVps ] ) ; |
---|
| 2179 | vps.setVpsCpInvScale( iInVps, jInVps, m_cCameraData.getCodedScale() [ iInVps ][ jInVps ] ) ; |
---|
| 2180 | vps.setVpsCpOff ( iInVps, jInVps, m_cCameraData.getCodedOffset()[ jInVps ][ iInVps ] ) ; |
---|
| 2181 | vps.setVpsCpInvOff ( iInVps, jInVps, m_cCameraData.getCodedOffset()[ iInVps ][ jInVps ] ) ; |
---|
| 2182 | } |
---|
| 2183 | } |
---|
| 2184 | } |
---|
| 2185 | } |
---|
| 2186 | vps.deriveCpPresentFlag(); |
---|
| 2187 | } |
---|
| 2188 | #endif |
---|
| 2189 | |
---|
| 2190 | |
---|
[1066] | 2191 | Bool TAppEncTop::xLayerIdInTargetEncLayerIdList(Int nuhLayerId) |
---|
| 2192 | { |
---|
| 2193 | return ( std::find(m_targetEncLayerIdList.begin(), m_targetEncLayerIdList.end(), nuhLayerId) != m_targetEncLayerIdList.end()) ; |
---|
| 2194 | } |
---|
| 2195 | |
---|
| 2196 | |
---|
| 2197 | #endif |
---|
| 2198 | |
---|
| 2199 | |
---|
[608] | 2200 | #if H_3D |
---|
[296] | 2201 | |
---|
[758] | 2202 | Void TAppEncTop::xDeriveDltArray( TComVPS& vps, TComDLT& dlt ) |
---|
| 2203 | { |
---|
| 2204 | Int iNumDepthViews = 0; |
---|
| 2205 | Bool bDltPresentFlag = false; |
---|
| 2206 | |
---|
| 2207 | for ( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ ) |
---|
| 2208 | { |
---|
| 2209 | Bool isDepth = ( vps.getDepthId( layer ) == 1 ); |
---|
| 2210 | |
---|
| 2211 | if ( isDepth ) |
---|
| 2212 | { |
---|
| 2213 | iNumDepthViews++; |
---|
| 2214 | } |
---|
| 2215 | |
---|
| 2216 | dlt.setUseDLTFlag( layer , isDepth && m_useDLT ); |
---|
| 2217 | if( dlt.getUseDLTFlag( layer ) ) |
---|
| 2218 | { |
---|
| 2219 | xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod[layer], 24), &vps, &dlt); |
---|
| 2220 | bDltPresentFlag = bDltPresentFlag || dlt.getUseDLTFlag(layer); |
---|
| 2221 | dlt.setInterViewDltPredEnableFlag(layer, (dlt.getUseDLTFlag(layer) && (layer>1))); |
---|
| 2222 | } |
---|
| 2223 | } |
---|
| 2224 | |
---|
| 2225 | dlt.setDltPresentFlag( bDltPresentFlag ); |
---|
| 2226 | dlt.setNumDepthViews ( iNumDepthViews ); |
---|
| 2227 | } |
---|
| 2228 | #endif |
---|
[56] | 2229 | //! \} |
---|