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