diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index 2c2191cf71694f9cb7af3b02e457209e9e48ca54..a55f541f832892123dce0fba6d2ea5159e15111c 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -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 diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index 906b6a820563e713170d48837b573273a6f05967..5373fe7ceb7e60811f9f5b14c43cc5a9a9b9239a 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -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 { diff --git a/source/Lib/CommonLib/QuantRDOQ.cpp b/source/Lib/CommonLib/QuantRDOQ.cpp index c7b1bcbefc6e9a79b564e05596f25bb3d179cfe3..fa0e835589ff0e64904fe768e117d1b94cbc0243 100644 --- a/source/Lib/CommonLib/QuantRDOQ.cpp +++ b/source/Lib/CommonLib/QuantRDOQ.cpp @@ -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; diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp index d6116e6a257aa24ed9a90607072468d5d43d682e..85e3526dde46b53530932c070129462bec35cf7e 100644 --- a/source/Lib/CommonLib/Rom.cpp +++ b/source/Lib/CommonLib/Rom.cpp @@ -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] = diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index f88f4350765e4d1fce240eb222552111824a2288..e0b9f53ec64fb8facf295b444a348b4cde3df195 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -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 diff --git a/source/Lib/DecoderLib/BinDecoder.cpp b/source/Lib/DecoderLib/BinDecoder.cpp index 6486ebe33d38be96d304fdc5b91666194f5975c7..d86ba85529a7db610aa0eda10d8fde4538d9a277 100644 --- a/source/Lib/DecoderLib/BinDecoder.cpp +++ b/source/Lib/DecoderLib/BinDecoder.cpp @@ -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; diff --git a/source/Lib/EncoderLib/BinEncoder.cpp b/source/Lib/EncoderLib/BinEncoder.cpp index c67efa03fc38b80a5da45fd2755993c137c9096f..b80f248043c025257609c5e20cd200f323859972 100644 --- a/source/Lib/EncoderLib/BinEncoder.cpp +++ b/source/Lib/EncoderLib/BinEncoder.cpp @@ -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 } }