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