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