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