Commit 8266a885 authored by Frank Bossen's avatar Frank Bossen

Merge branch 'JVET-M0470' into 'master'

JVET-M0470: Fixed transition point between GR and TU + EG(k) escape codes for coefficient...

See merge request !202
parents c7b58ece 9fb008cd
Pipeline #663 passed with stage
......@@ -162,9 +162,11 @@ static const int MAXIMUM_INTRA_FILTERED_HEIGHT = 16;
static const int MAX_CPB_CNT = 32; ///< Upper bound of (cpb_cnt_minus1 + 1)
static const int MAX_NUM_LAYER_IDS = 64;
#if JVET_M0470
static const int COEF_REMAIN_BIN_REDUCTION = 5; ///< indicates the level at which the VLC transitions from Golomb-Rice to TU+EG(k)
#else
static const int COEF_REMAIN_BIN_REDUCTION = 3; ///< indicates the level at which the VLC transitions from Golomb-Rice to TU+EG(k)
#endif
static const int CU_DQP_TU_CMAX = 5; ///< max number bins for truncated unary
static const int CU_DQP_EG_k = 0; ///< expgolomb order
......
......@@ -853,6 +853,15 @@ namespace DQIntern
};
#define RICEMAX 32
#if JVET_M0470
const int32_t g_goRiceBits[4][RICEMAX] =
{
{ 32768, 65536, 98304, 131072, 163840, 196608, 262144, 262144, 327680, 327680, 327680, 327680, 393216, 393216, 393216, 393216, 393216, 393216, 393216, 393216, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752},
{ 65536, 65536, 98304, 98304, 131072, 131072, 163840, 163840, 196608, 196608, 229376, 229376, 294912, 294912, 294912, 294912, 360448, 360448, 360448, 360448, 360448, 360448, 360448, 360448, 425984, 425984, 425984, 425984, 425984, 425984, 425984, 425984},
{ 98304, 98304, 98304, 98304, 131072, 131072, 131072, 131072, 163840, 163840, 163840, 163840, 196608, 196608, 196608, 196608, 229376, 229376, 229376, 229376, 262144, 262144, 262144, 262144, 327680, 327680, 327680, 327680, 327680, 327680, 327680, 327680},
{ 131072, 131072, 131072, 131072, 131072, 131072, 131072, 131072, 163840, 163840, 163840, 163840, 163840, 163840, 163840, 163840, 196608, 196608, 196608, 196608, 196608, 196608, 196608, 196608, 229376, 229376, 229376, 229376, 229376, 229376, 229376, 229376}
};
#else
const int32_t g_goRiceBits[4][RICEMAX] =
{
{ 32768, 65536, 98304, 131072, 163840, 196608, 229376, 294912, 294912, 360448, 360448, 360448, 360448, 425984, 425984, 425984, 425984, 425984, 425984, 425984, 425984, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520, 491520 },
......@@ -860,6 +869,7 @@ namespace DQIntern
{ 98304, 98304, 98304, 98304, 131072, 131072, 131072, 131072, 163840, 163840, 163840, 163840, 196608, 196608, 196608, 196608, 229376, 229376, 229376, 229376, 262144, 262144, 262144, 262144, 294912, 294912, 294912, 294912, 360448, 360448, 360448, 360448 },
{ 131072, 131072, 131072, 131072, 131072, 131072, 131072, 131072, 163840, 163840, 163840, 163840, 163840, 163840, 163840, 163840, 196608, 196608, 196608, 196608, 196608, 196608, 196608, 196608, 229376, 229376, 229376, 229376, 229376, 229376, 229376, 229376 }
};
#endif
class State
{
......
......@@ -149,7 +149,12 @@ inline uint32_t QuantRDOQ::xGetCodedLevel( double& rd64CodedCost,
for( int uiAbsLevel = uiMaxAbsLevel; uiAbsLevel >= uiMinAbsLevel ; uiAbsLevel-- )
{
double dErr = double( lLevelDouble - ( Intermediate_Int(uiAbsLevel) << iQBits ) );
#if JVET_M0470
double dCurrCost = dErr * dErr * errorScale + xGetICost( xGetICRate( uiAbsLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, ui16AbsGoRice, true, maxLog2TrDynamicRange ) );
#else
double dCurrCost = dErr * dErr * errorScale + xGetICost( xGetICRate( uiAbsLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, ui16AbsGoRice, useLimitedPrefixLength, maxLog2TrDynamicRange ) );
#endif
dCurrCost += dCurrCostSig;
if( dCurrCost < rd64CodedCost )
......@@ -194,7 +199,11 @@ inline int QuantRDOQ::xGetICRate( const uint32_t uiAbsLevel,
int iRate = int( xGetIEPRate() ); // cost of sign bit
uint32_t symbol = ( uiAbsLevel == 0 ? goRiceZero : uiAbsLevel <= goRiceZero ? uiAbsLevel-1 : uiAbsLevel );
uint32_t length;
#if JVET_M0470
const int threshold = COEF_REMAIN_BIN_REDUCTION;
#else
const int threshold = g_auiGoRiceRange[ui16AbsGoRice];
#endif
if( symbol < ( threshold << ui16AbsGoRice ) )
{
length = symbol >> ui16AbsGoRice;
......@@ -239,7 +248,11 @@ inline int QuantRDOQ::xGetICRate( const uint32_t uiAbsLevel,
{
uint32_t symbol = ( uiAbsLevel - cthres ) >> 1;
uint32_t length;
#if JVET_M0470
const int threshold = COEF_REMAIN_BIN_REDUCTION;
#else
const int threshold = g_auiGoRiceRange[ui16AbsGoRice];
#endif
if( symbol < ( threshold << ui16AbsGoRice ) )
{
length = symbol >> ui16AbsGoRice;
......
......@@ -698,10 +698,12 @@ const uint32_t g_auiGoRicePosCoeff0[3][32] =
{1, 1, 1, 1, 2, 3, 4, 4, 4, 6, 6, 6, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16},
{1, 1, 2, 2, 2, 3, 4, 4, 4, 6, 6, 6, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16, 16}
};
#if !JVET_M0470
const uint32_t g_auiGoRiceRange[MAX_GR_ORDER_RESIDUAL] =
{
6, 5, 6, COEF_REMAIN_BIN_REDUCTION, COEF_REMAIN_BIN_REDUCTION, COEF_REMAIN_BIN_REDUCTION, COEF_REMAIN_BIN_REDUCTION, COEF_REMAIN_BIN_REDUCTION, COEF_REMAIN_BIN_REDUCTION, COEF_REMAIN_BIN_REDUCTION
};
#endif
#if HEVC_USE_SCALING_LISTS
const char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] =
......
......@@ -50,6 +50,8 @@
#include <assert.h>
#include <cassert>
#define JVET_M0470 1 // Fixed GR/TU+EG-k transition point, use limited prefix length for escape codes
#define JVET_M0257 1 // Scan only non zero-out regions of large TUs
#define JVET_M0193_PAIR_AVG_REDUCTION 1 //Use only one pairwise average candidate
......
......@@ -182,8 +182,14 @@ unsigned BinDecoderBase::decodeBinsEP( unsigned numBins )
unsigned BinDecoderBase::decodeRemAbsEP( unsigned goRicePar, bool useLimitedPrefixLength, int maxLog2TrDynamicRange )
{
#if JVET_M0470
unsigned cutoff = COEF_REMAIN_BIN_REDUCTION;
unsigned prefix = 0;
useLimitedPrefixLength = true;
#else
unsigned cutoff = g_auiGoRiceRange[ goRicePar ];
unsigned prefix = 0;
#endif
if( useLimitedPrefixLength )
{
const unsigned maxPrefix = 32 - maxLog2TrDynamicRange;
......
......@@ -207,7 +207,12 @@ void BinEncoderBase::encodeBinsEP( unsigned bins, unsigned numBins )
void BinEncoderBase::encodeRemAbsEP( unsigned bins, unsigned goRicePar, bool useLimitedPrefixLength, int maxLog2TrDynamicRange )
{
const unsigned threshold = g_auiGoRiceRange[ goRicePar ] << goRicePar;
#if JVET_M0470
const unsigned threshold = COEF_REMAIN_BIN_REDUCTION << goRicePar;
useLimitedPrefixLength = true;
#else
const unsigned threshold = g_auiGoRiceRange[goRicePar] << goRicePar;
#endif
if( bins < threshold )
{
const unsigned bitMask = ( 1 << goRicePar ) - 1;
......@@ -251,7 +256,11 @@ void BinEncoderBase::encodeRemAbsEP( unsigned bins, unsigned goRicePar, bool use
bins -= delta;
delta = 1 << (++length);
}
#if JVET_M0470
unsigned numBin = COEF_REMAIN_BIN_REDUCTION + length + 1 - goRicePar;
#else
unsigned numBin = g_auiGoRiceRange[ goRicePar ] + length + 1 - goRicePar;
#endif
encodeBinsEP( ( 1 << numBin ) - 2, numBin );
encodeBinsEP( bins, length );
}
......@@ -438,7 +447,12 @@ BitEstimatorBase::BitEstimatorBase( const BinProbModel* dummy )
void BitEstimatorBase::encodeRemAbsEP( unsigned bins, unsigned goRicePar, bool useLimitedPrefixLength, int maxLog2TrDynamicRange )
{
const unsigned threshold = g_auiGoRiceRange[ goRicePar ] << goRicePar;
#if JVET_M0470
const unsigned threshold = COEF_REMAIN_BIN_REDUCTION << goRicePar;
useLimitedPrefixLength = true;
#else
const unsigned threshold = g_auiGoRiceRange[goRicePar] << goRicePar;
#endif
if( bins < threshold )
{
m_EstFracBits += BinProbModelBase::estFracBitsEP( ( bins >> goRicePar ) + 1 + goRicePar );
......@@ -474,7 +488,11 @@ void BitEstimatorBase::encodeRemAbsEP( unsigned bins, unsigned goRicePar, bool u
bins -= delta;
delta = 1 << (++length);
}
#if JVET_M0470
m_EstFracBits += BinProbModelBase::estFracBitsEP(COEF_REMAIN_BIN_REDUCTION + 1 + (length << 1) - goRicePar);
#else
m_EstFracBits += BinProbModelBase::estFracBitsEP( g_auiGoRiceRange[ goRicePar ] + 1 + ( length << 1 ) - goRicePar );
#endif
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment