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