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