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