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