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