Skip to content

Commit

Permalink
Prepare v1.9.1-rc1 (#318)
Browse files Browse the repository at this point in the history
* Preparing v1.9.1 with fixes to RC, IF and 8-bit encoding

* Set version to 1.9.1-rc1
  • Loading branch information
adamjw24 authored Sep 11, 2023
1 parent 19efe30 commit e37b855
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 22 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ if( NOT CMAKE_VERSION VERSION_LESS 3.13.0 )
endif()

# project name
project( vvenc VERSION 1.9.0 )
project( vvenc VERSION 1.9.1 )

# set alternative version numbering for release candidates
#set( PROJECT_VERSION_RC rc1 )
set( PROJECT_VERSION_RC rc1 )
if( PROJECT_VERSION_RC )
set( PROJECT_VERSION "${PROJECT_VERSION}-${PROJECT_VERSION_RC}" )
endif()
Expand Down
18 changes: 18 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/////////////////////////////////////////
tag 1.9.1-rc1
* libvvenc:
- added library parameters:
- vvenc_config::m_maxPicWidth, vvenc_config::m_maxPicHeight to signal maximal possible picture size when
encoding for resolution change (e.g. using CRA_CRE decoder refresh)
- added medium_lowDecEnergy as a built-in preset (in C-API: VVENC_MEDIUM_LOWDECNRG)
- refactoring and improvements of affine search and interpolation filtering
- fixed 8-bit encoding from 10-bit input and proper handling of 8-bit video in BIM
- added proper setting of conformance window
- refactoring and improvements to rate control (RC)
- fixed potential integer overflow
- finalized spatial subsampling implementation for 2-pass RC

* vvencFFapp:
- added parameter: MaxPicSize/MaxPicWidth/MaxPicHeight to control the signaled maximal picture size during
resolution change

/////////////////////////////////////////
tag 1.9.0

Expand Down
3 changes: 2 additions & 1 deletion include/vvenc/vvencCfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ typedef enum
VVENC_MEDIUM = 2,
VVENC_SLOW = 3,
VVENC_SLOWER = 4,
VVENC_MEDIUM_LOWDECNRG = 130, // medium based low decoding energy
VVENC_FIRSTPASS = 254,
VVENC_TOOLTEST = 255,
}vvencPresetMode;
Expand Down Expand Up @@ -848,7 +849,7 @@ VVENC_DECL bool vvenc_init_config_parameter( vvenc_config *cfg );
#define VVENC_OPT_TICKSPERSEC "tickspersec" // m_TicksPerSecond
#define VVENC_OPT_INPUTBITDEPTH "inputbitdepth" // m_inputBitDepth
#define VVENC_OPT_FRAMES "framestobeencoded" // m_framesToBeEncoded
#define VVENC_OPT_PRESET "preset" // set preset like "faster,fast,medium,slow,slower
#define VVENC_OPT_PRESET "preset" // set preset like "faster,fast,medium,slow,slower,medium_lowDecEnergy
#define VVENC_OPT_THREADS "threads" // m_numThreads
#define VVENC_OPT_BITRATE "bitrate" // m_RCTargetBitrate
#define VVENC_OPT_QP "qp" // m_QP
Expand Down
4 changes: 2 additions & 2 deletions source/Lib/EncoderLib/BitAllocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ double filterAndCalculateAverageActivity (const Pel* pSrc, const int iSrcStride,
}
if (spVisAct)
{
*spVisAct = unsigned (0.5 + spatAct * double(bitDepth < 12 ? 1 << (12 - bitDepth) : 1));
*spVisAct = unsigned (0.5 + spatAct * double (bitDepth < 12 ? 1 << (12 - bitDepth) : 1));
}

// skip first row as there may be a black border frame
Expand Down Expand Up @@ -474,7 +474,7 @@ int BitAllocation::applyQPAdaptationSlice (const Slice* slice, const VVEncCfg* e
{
const uint32_t nCtu = ctuBoundingAddr - ctuStartAddr;

pic->picSpVisAct = ClipBD (uint16_t ((picSpVisAct + (nCtu >> 1)) / nCtu), bitDepth);
pic->picSpVisAct = ClipBD (uint16_t ((picSpVisAct + (nCtu >> 1)) / nCtu), 12);
}
if (encCfg->m_usePerceptQPATempFiltISlice && slice->isIntra() && pic->getOrigBuf (compID).buf != pic->getOrigBufPrev (compID, PREV_FRAME_1).buf && zeroMinActCTUs * 2 > ctuBoundingAddr - ctuStartAddr)
{
Expand Down
2 changes: 1 addition & 1 deletion source/Lib/EncoderLib/PreProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ uint16_t PreProcess::xGetPicVisualActivity(Picture* curPic, const Picture* refPi
&picSpVisAct);

uint16_t ret = ClipBD( (uint16_t)( 0.5 + visActY ), bitDepth );
curPic->picSpVisAct = ClipBD( (uint16_t) picSpVisAct, bitDepth );
curPic->picSpVisAct = ClipBD( (uint16_t) picSpVisAct, 12 );

return ret;
}
Expand Down
10 changes: 5 additions & 5 deletions source/Lib/EncoderLib/RateCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ void RateCtrl::readStatsFile()

void RateCtrl::adjustStatsDownsample()
{
int meanValue = 0; //MCTF or Activity
int64_t meanValue = 0; //MCTF or Activity
int amount = 0;
auto itr = m_listRCFirstPassStats.begin();
for (; itr != m_listRCFirstPassStats.end(); itr++)
Expand All @@ -652,7 +652,7 @@ void RateCtrl::adjustStatsDownsample()
if (meanValue != 0)
{
meanValue = meanValue / amount;
int sumVar = 0;
int64_t sumVar = 0;
int numVar = 0;
auto itrv = m_listRCFirstPassStats.begin();
for (; itrv != m_listRCFirstPassStats.end(); itrv++)
Expand All @@ -666,8 +666,8 @@ void RateCtrl::adjustStatsDownsample()
}
if (numVar)
{
sumVar = sumVar / (numVar - 1);
sumVar = (int) sqrt((double) sumVar);
sumVar = sumVar / std::max(1, numVar - 1);
sumVar = int64_t (0.5 + sqrt((double) sumVar));
}
int value_gopbefore = 0;
int value_gopcur = 0;
Expand Down Expand Up @@ -701,7 +701,7 @@ void RateCtrl::adjustStatsDownsample()
doChangeBits = false;
if (stat.gopNum != 0)
{
int var_cur = abs(statValue - meanValue);
const int64_t var_cur = abs(statValue - meanValue);
if (var_cur > (sumVar << 1))
{
doChangeBits = true;
Expand Down
12 changes: 7 additions & 5 deletions source/Lib/apputils/VVEncAppCfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ const std::vector<SVPair<vvencPresetMode>> PresetToEnumMap =
{ "medium", vvencPresetMode::VVENC_MEDIUM },
{ "slow", vvencPresetMode::VVENC_SLOW },
{ "slower", vvencPresetMode::VVENC_SLOWER },
{ "medium_lowDecEnergy", vvencPresetMode::VVENC_MEDIUM_LOWDECNRG },
{ "medium_lowdecenergy", vvencPresetMode::VVENC_MEDIUM_LOWDECNRG },
{ "firstpass", vvencPresetMode::VVENC_FIRSTPASS },
{ "tooltest", vvencPresetMode::VVENC_TOOLTEST },
};
Expand Down Expand Up @@ -612,7 +614,7 @@ int parse( int argc, char* argv[], vvenc_config* c, std::ostream& rcOstr )
{
opts.setSubSection("Encoder Options");
opts.addOptions()
("preset", toPreset, "preset for detailed parameter configuration (faster, fast, medium, slow, slower)")
("preset", toPreset, "preset for detailed parameter configuration (faster, fast, medium, slow, slower, medium_lowDecEnergy)")
("bitrate,b", toBitrate, "bitrate for rate control (0: constant-QP encoding without rate control; otherwise\n"
"bits/second; use e.g. 1.5M, 1.5Mbps, 1500k, 1500kbps, 1500000bps, 1500000)")
("maxrate,m", toMaxRate, "approximate maximum instantaneous bitrate for constrained VBR in rate control (0:\n"
Expand All @@ -634,7 +636,7 @@ int parse( int argc, char* argv[], vvenc_config* c, std::ostream& rcOstr )
opts.setSubSection("Threading, performance");
opts.addOptions()
("Threads,t", c->m_numThreads, "Number of threads")
("preset", toPreset, "select preset for specific encoding setting (faster, fast, medium, slow, slower)")
("preset", toPreset, "select preset for specific encoding setting (faster, fast, medium, slow, slower, medium_lowDecEnergy)")
("Tiles", toNumTiles, "Set number of tile columns and rows")
;

Expand Down Expand Up @@ -1081,8 +1083,8 @@ int parse( int argc, char* argv[], vvenc_config* c, std::ostream& rcOstr )
("ReduceIntraChromaModesFullRD", c->m_reduceIntraChromaModesFullRD, "Reduce modes for chroma full RD intra search")
("FirstPassMode", c->m_FirstPassMode, "Mode for first encoding pass when using rate control "
"(0: default, 1: faster, 2: faster with temporal downsampling, "
"3: (experimental) faster with resolution downsampling, "
"4: (experimental) faster with temporal and resolution downsampling)" )
"3: faster with resolution downsampling, "
"4: faster with temporal and resolution downsampling)" )
;

opts.setSubSection("Input Options");
Expand Down Expand Up @@ -1370,7 +1372,7 @@ virtual std::string getAppConfigAsString( vvenc_config* c, vvencMsgLevel eMsgLev
if( eMsgLevel >= VVENC_INFO )
{
if( format != ext )
css << loglvl << "Input File : " << m_inputFileName << " (" << format << ")\n";
css << loglvl << "Input File : " << m_inputFileName << " (" << format << ")\n";
else
css << loglvl << "Input File : " << m_inputFileName << "\n";
css << loglvl << "Bitstream File : " << m_bitstreamFileName << "\n";
Expand Down
45 changes: 39 additions & 6 deletions source/Lib/vvenc/vvencCfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ VVENC_DECL bool vvenc_init_config_parameter( vvenc_config *c )
{
css << "TicksPerSecond must be a multiple of FrameRate/Framescale (" << c->m_FrameRate << "/" << c->m_FrameScale << "). Use 27000000 for NTSC content" << std::endl;
}
vvenc_confirmParameter( c, ( c->m_TicksPerSecond > 0 ) && ((int64_t)c->m_TicksPerSecond*(int64_t)c->m_FrameScale)%c->m_FrameRate, css.str().c_str() );
vvenc_confirmParameter( c, ( c->m_TicksPerSecond > 0 && c->m_FrameRate > 0) && ((int64_t)c->m_TicksPerSecond*(int64_t)c->m_FrameScale)%c->m_FrameRate, css.str().c_str() );


vvenc_confirmParameter( c, c->m_numThreads < -1 || c->m_numThreads > 256, "Number of threads out of range (-1 <= t <= 256)");
Expand Down Expand Up @@ -788,6 +788,16 @@ VVENC_DECL bool vvenc_init_config_parameter( vvenc_config *c )

vvenc::MsgLog msg(c->m_msgCtx, c->m_msgFnc);

if( c->m_FirstPassMode > 2 && c->m_RCTargetBitrate != 0 )
{
// lookahead will only be set to 0 later
if( c->m_LookAhead > 0 || c->m_RCNumPasses == 1 || std::min( c->m_SourceWidth, c->m_SourceHeight ) < 720 )
{
c->m_FirstPassMode -= 2;
msg.log( VVENC_NOTICE, "First pass spatial downsampling (FirstPassMode=3/4) cannot be used for single pass encoding and videos with resolution lower than 720p, changing FirstPassMode to %d!\n", c->m_FirstPassMode );
}
}

const double d = (3840.0 * 2160.0) / double (c->m_SourceWidth * c->m_SourceHeight);
const int rcQP = (c->m_RCInitialQP > 0 ? std::min (vvenc::MAX_QP, c->m_RCInitialQP) : std::max (0, vvenc::MAX_QP_PERCEPT_QPA - (c->m_FirstPassMode > 2 ? 4 : 2) - int (0.5 + sqrt ((d * std::max (0, c->m_RCTargetBitrate)) / 500000.0))));

Expand All @@ -808,7 +818,6 @@ VVENC_DECL bool vvenc_init_config_parameter( vvenc_config *c )
vvenc_confirmParameter( c, c->m_RCTargetBitrate != VVENC_RC_OFF && ( c->m_RCTargetBitrate < 0 || c->m_RCTargetBitrate > 800000000 ), "TargetBitrate must be between 0 and 800000000" );
vvenc_confirmParameter( c, c->m_RCTargetBitrate != VVENC_RC_OFF && (int64_t) c->m_RCMaxBitrate * 2 < (int64_t) c->m_RCTargetBitrate * 3, "MaxBitrate must be at least 1.5*TargetBitrate" );
vvenc_confirmParameter( c, c->m_RCTargetBitrate != VVENC_RC_OFF && ( c->m_FirstPassMode < 0 || c->m_FirstPassMode > 4 ), "FirstPassMode must be 0, 1, 2, 3, or 4" );
vvenc_confirmParameter( c, std::min( c->m_SourceWidth, c->m_SourceHeight ) < 720 && ( c->m_FirstPassMode == 3 || c->m_FirstPassMode == 4 ), "Spatial downsampling cannot be applied to small-resolution videos (i.e. below 720p), use FirstPassMode values up to '2'");

if ( c->m_internChromaFormat < 0 || c->m_internChromaFormat >= VVENC_NUM_CHROMA_FORMAT )
{
Expand Down Expand Up @@ -1215,7 +1224,7 @@ VVENC_DECL bool vvenc_init_config_parameter( vvenc_config *c )

if( c->m_maxPicWidth > 0 && c->m_maxPicHeight > 0 )
{
vvenc_confirmParameter( c, !c->m_rprEnabledFlag || !c->m_resChangeInClvsEnabled, "if a maxSize is set, both RPR and resChangeInClvsEnabled have to enabled" );
vvenc_confirmParameter( c, !c->m_rprEnabledFlag || !c->m_resChangeInClvsEnabled, "if max picture size is set, both RPR and resChangeInClvsEnabled have to be enabled" );
}

if( c->m_IntraPeriod == 0 && c->m_IntraPeriodSec > 0 )
Expand Down Expand Up @@ -1895,8 +1904,6 @@ static bool checkCfgParameter( vvenc_config *c )
vvenc_confirmParameter( c, c->m_LookAhead && c->m_RCNumPasses != 1, "Look-ahead encoding is not supported for two-pass rate control" );
vvenc_confirmParameter( c, !c->m_LookAhead && c->m_RCNumPasses == 1 && c->m_RCTargetBitrate > 0, "Look-ahead encoding must be used with one-pass rate control" );
vvenc_confirmParameter( c, c->m_LookAhead && c->m_RCTargetBitrate == 0, "Look-ahead encoding is not supported when rate control is disabled" );
vvenc_confirmParameter( c, (c->m_LookAhead || c->m_RCNumPasses == 1) && c->m_FirstPassMode > 2, "Look-ahead or one pass RC can not be used with resolution downsampling" );


vvenc_confirmParameter(c, !((c->m_level==VVENC_LEVEL1)
|| (c->m_level==VVENC_LEVEL2) || (c->m_level==VVENC_LEVEL2_1)
Expand Down Expand Up @@ -2588,6 +2595,7 @@ VVENC_DECL int vvenc_init_preset( vvenc_config *c, vvencPresetMode preset )
break;

case vvencPresetMode::VVENC_MEDIUM:
case vvencPresetMode::VVENC_MEDIUM_LOWDECNRG:

// motion estimation
c->m_SearchRange = 384;
Expand Down Expand Up @@ -2658,6 +2666,28 @@ VVENC_DECL int vvenc_init_preset( vvenc_config *c, vvencPresetMode preset )
c->m_IBCFastMethod = 3;
c->m_TSsize = 4;

if( preset == vvencPresetMode::VVENC_MEDIUM_LOWDECNRG )
{
c->m_numRefPics = 2;
c->m_deblockLastTLayers = 1;
c->m_maxMTTDepth = 332222;
c->m_maxMTTDepthI = 3;
c->m_Affine = 3;
c->m_alfSpeed = 1;
c->m_BCW = 2;
c->m_BDOF = 0;
c->m_DMVR = 0;
c->m_ISP = 0;
c->m_LFNST = 0;
c->m_lumaReshapeEnable = 0;
c->m_MIP = 0;
c->m_useFastMIP = 0;
c->m_bUseSAO = true;
c->m_saoScc = true;
c->m_SbTMVP = 0;
c->m_useFastMrg = 2;
}

break;

case vvencPresetMode::VVENC_SLOW:
Expand Down Expand Up @@ -2918,7 +2948,9 @@ VVENC_DECL const char* vvenc_get_config_as_string( vvenc_config *c, vvencMsgLeve

if( eMsgLevel >= VVENC_INFO )
{
css << loglvl << "Internal format : " << c->m_PadSourceWidth << "x" << c->m_PadSourceHeight << " " << (double)c->m_FrameRate/c->m_FrameScale << "Hz " << getDynamicRangeStr(c->m_HdrMode) << "\n";
css << loglvl << "Internal format : " << c->m_PadSourceWidth << "x" << c->m_PadSourceHeight << " " << (double)c->m_FrameRate/c->m_FrameScale << " Hz " << getDynamicRangeStr(c->m_HdrMode) << "\n";
css << loglvl << "Threads : " << c->m_numThreads << " (parallel frames: " << c->m_maxParallelFrames <<")\n";

css << loglvl << "Rate control : ";

if ( c->m_RCTargetBitrate > 0 )
Expand Down Expand Up @@ -3157,6 +3189,7 @@ VVENC_DECL const char* vvenc_get_config_as_string( vvenc_config *c, vvencMsgLeve
}

css << "LookAhead:" << c->m_LookAhead << " ";
css << "FirstPassMode:" << c->m_FirstPassMode << " ";

css << "\n" << loglvl << "PARALLEL PROCESSING CFG: ";
css << "NumThreads:" << c->m_numThreads << " ";
Expand Down

0 comments on commit e37b855

Please sign in to comment.