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