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