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