Newer
Older

Karsten Suehring
committed
/* The copyright in this software is being made available under the BSD
* License, included below. This software may be subject to other third party
* and contributor rights, including patent rights, and no such rights are
* granted under this license.
*
* Copyright (c) 2010-2019, ITU/ISO/IEC

Karsten Suehring
committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/** \file EncApp.cpp
\brief Encoder application class
*/
#include <list>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <iomanip>
#include "EncApp.h"
#include "EncoderLib/AnnexBwrite.h"
#if EXTENSION_360_VIDEO
#include "AppEncHelper360/TExt360AppEncTop.h"
#endif
Rickard Sjöberg
committed
#if JVET_O0549_ENCODER_ONLY_FILTER
#include "EncoderLib/EncTemporalFilter.h"
#endif

Karsten Suehring
committed
using namespace std;
//! \ingroup EncoderApp
//! \{
// ====================================================================================================================
// Constructor / destructor / initialization / destroy
// ====================================================================================================================
EncApp::EncApp()
{
m_iFrameRcvd = 0;
m_totalBytes = 0;
m_essentialBytes = 0;
#if JVET_O0756_CALCULATE_HDRMETRICS
m_metricTime = std::chrono::milliseconds(0);
#endif

Karsten Suehring
committed
}
EncApp::~EncApp()
{
}
void EncApp::xInitLibCfg()
{
VPS vps;
vps.setMaxLayers ( 1 );
for(int i = 0; i < MAX_TLAYER; i++)
{
vps.setVPSIncludedLayerId ( 0, i );
}
vps.setVPSExtensionFlag ( false );
m_cEncLib.setVPS(&vps);

Karsten Suehring
committed
m_cEncLib.setProfile ( m_profile);
m_cEncLib.setLevel ( m_levelTier, m_level);
m_cEncLib.setNumSubProfile ( m_numSubProfile );
for (int i = 0; i < m_numSubProfile; i++)
{
m_cEncLib.setSubProfile(i, m_subProfile[i]);
}

Karsten Suehring
committed
m_cEncLib.setProgressiveSourceFlag ( m_progressiveSourceFlag);
m_cEncLib.setInterlacedSourceFlag ( m_interlacedSourceFlag);
m_cEncLib.setNonPackedConstraintFlag ( m_nonPackedConstraintFlag);
m_cEncLib.setFrameOnlyConstraintFlag ( m_frameOnlyConstraintFlag);
m_cEncLib.setBitDepthConstraintValue ( m_bitDepthConstraint );
m_cEncLib.setChromaFormatConstraintValue ( m_chromaFormatConstraint );
m_cEncLib.setIntraConstraintFlag ( m_intraConstraintFlag );
m_cEncLib.setOnePictureOnlyConstraintFlag ( m_onePictureOnlyConstraintFlag );
m_cEncLib.setLowerBitRateConstraintFlag ( m_lowerBitRateConstraintFlag );
m_cEncLib.setPrintMSEBasedSequencePSNR ( m_printMSEBasedSequencePSNR);
m_cEncLib.setPrintFrameMSE ( m_printFrameMSE);
m_cEncLib.setPrintHexPsnr(m_printHexPsnr);
m_cEncLib.setPrintSequenceMSE ( m_printSequenceMSE);
m_cEncLib.setCabacZeroWordPaddingEnabled ( m_cabacZeroWordPaddingEnabled );
m_cEncLib.setFrameRate ( m_iFrameRate );
m_cEncLib.setFrameSkip ( m_FrameSkip );
m_cEncLib.setTemporalSubsampleRatio ( m_temporalSubsampleRatio );
m_cEncLib.setSourceWidth ( m_iSourceWidth );
m_cEncLib.setSourceHeight ( m_iSourceHeight );
m_cEncLib.setConformanceWindow ( m_confWinLeft / SPS::getWinUnitX( m_InputChromaFormatIDC ), m_confWinRight / SPS::getWinUnitX( m_InputChromaFormatIDC ), m_confWinTop / SPS::getWinUnitY( m_InputChromaFormatIDC ), m_confWinBottom / SPS::getWinUnitY( m_InputChromaFormatIDC ) );
m_cEncLib.setScalingRatio ( m_scalingRatioHor, m_scalingRatioVer );
m_cEncLib.setRPREnabled ( m_rprEnabled );
m_cEncLib.setSwitchPocPeriod ( m_switchPocPeriod );
m_cEncLib.setUpscaledOutput ( m_upscaledOutput );

Karsten Suehring
committed
m_cEncLib.setFramesToBeEncoded ( m_framesToBeEncoded );
//====== SPS constraint flags =======
m_cEncLib.setIntraOnlyConstraintFlag ( m_intraConstraintFlag );
m_cEncLib.setMaxBitDepthConstraintIdc ( m_bitDepthConstraint - 8 );
m_cEncLib.setMaxChromaFormatConstraintIdc ( m_chromaFormatConstraint );
m_cEncLib.setFrameConstraintFlag ( m_bFrameConstraintFlag );
m_cEncLib.setNoQtbttDualTreeIntraConstraintFlag ( !m_dualTree );
m_cEncLib.setNoPartitionConstraintsOverrideConstraintFlag ( !m_SplitConsOverrideEnabledFlag );
m_cEncLib.setNoSaoConstraintFlag ( !m_bUseSAO );
m_cEncLib.setNoAlfConstraintFlag ( !m_alf );
m_cEncLib.setNoRefWraparoundConstraintFlag ( m_bNoRefWraparoundConstraintFlag );
m_cEncLib.setNoTemporalMvpConstraintFlag ( m_TMVPModeId ? false : true );
m_cEncLib.setNoSbtmvpConstraintFlag ( m_SubPuMvpMode ? false : true );
m_cEncLib.setNoAmvrConstraintFlag ( m_bNoAmvrConstraintFlag );
m_cEncLib.setNoBdofConstraintFlag ( !m_BIO );
m_cEncLib.setNoDmvrConstraintFlag ( !m_DMVR );
m_cEncLib.setNoCclmConstraintFlag ( m_LMChroma ? false : true );
m_cEncLib.setNoMtsConstraintFlag ( (m_MTS || m_MTSImplicit) ? false : true );
m_cEncLib.setNoSbtConstraintFlag ( !m_SBT );
m_cEncLib.setNoAffineMotionConstraintFlag ( !m_Affine );
m_cEncLib.setNoGbiConstraintFlag ( !m_GBi );
m_cEncLib.setNoIbcConstraintFlag ( m_IBCMode ? false : true );
m_cEncLib.setNoFPelMmvdConstraintFlag ( !(m_MMVD && m_allowDisFracMMVD) );
m_cEncLib.setNoTriangleConstraintFlag ( !m_Triangle );
m_cEncLib.setNoLadfConstraintFlag ( !m_LadfEnabed );
m_cEncLib.setNoTransformSkipConstraintFlag ( !m_useTransformSkip );
m_cEncLib.setNoBDPCMConstraintFlag ( !m_useBDPCM );
m_cEncLib.setNoJointCbCrConstraintFlag (!m_JointCbCrMode);
m_cEncLib.setNoQpDeltaConstraintFlag ( m_bNoQpDeltaConstraintFlag );
m_cEncLib.setNoDepQuantConstraintFlag ( !m_depQuantEnabledFlag);
m_cEncLib.setNoSignDataHidingConstraintFlag ( !m_signDataHidingEnabledFlag );

Karsten Suehring
committed
//====== Coding Structure ========
m_cEncLib.setIntraPeriod ( m_iIntraPeriod );
m_cEncLib.setDecodingRefreshType ( m_iDecodingRefreshType );
m_cEncLib.setGOPSize ( m_iGOPSize );
m_cEncLib.setDrapPeriod ( m_drapPeriod );
m_cEncLib.setReWriteParamSets ( m_rewriteParamSets );
m_cEncLib.setRPLList0 ( m_RPLList0);
m_cEncLib.setRPLList1 ( m_RPLList1);
m_cEncLib.setIDRRefParamListPresent ( m_idrRefParamList );
m_cEncLib.setGopList ( m_GOPList );

Karsten Suehring
committed
for(int i = 0; i < MAX_TLAYER; i++)
{
m_cEncLib.setNumReorderPics ( m_numReorderPics[i], i );
m_cEncLib.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i );
}
for( uint32_t uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
{
m_cEncLib.setLambdaModifier ( uiLoop, m_adLambdaModifier[ uiLoop ] );
}
m_cEncLib.setIntraLambdaModifier ( m_adIntraLambdaModifier );
m_cEncLib.setIntraQpFactor ( m_dIntraQpFactor );
m_cEncLib.setBaseQP ( m_iQP );
#if X0038_LAMBDA_FROM_QP_CAPABILITY
m_cEncLib.setIntraQPOffset ( m_intraQPOffset );
m_cEncLib.setLambdaFromQPEnable ( m_lambdaFromQPEnable );
Adarsh Krishnan Ramasubramonian
committed
#endif
m_cEncLib.setChromaQpMappingTableParams (m_chromaQpMappingTableParams);

Karsten Suehring
committed
m_cEncLib.setPad ( m_aiPad );
m_cEncLib.setAccessUnitDelimiter ( m_AccessUnitDelimiter );
m_cEncLib.setMaxTempLayer ( m_maxTempLayer );
//===== Slice ========
//====== Loop/Deblock Filter ========
m_cEncLib.setLoopFilterDisable ( m_bLoopFilterDisable );
m_cEncLib.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS );
m_cEncLib.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 );
m_cEncLib.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 );
#if W0038_DB_OPT
Loading
Loading full blame...