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