Commit e6ddfe4b authored by Jonatan Samuelsson's avatar Jonatan Samuelsson
Browse files

Merge branch 'master' into 'RPR'

# Conflicts:
#   source/Lib/CommonLib/TypeDef.h
parents 0776f1a6 12fd7464
Pipeline #2932 passed with stage
......@@ -346,6 +346,15 @@ const CtxSet ContextSetCfg::DeltaQP = ContextSetCfg::addCtxSet
{ DWS, DWS, },
});
#if JVET_P0042_FIX_INTER_DIR_CTX
const CtxSet ContextSetCfg::InterDir = ContextSetCfg::addCtxSet
({
{ 6, 13, 5, 4, 25, 48, },
{ 7, 6, 5, 4, 33, 34, },
{ CNU, CNU, CNU, CNU, CNU, CNU, },
{ 0, 0, 1, 4, 0, 0, },
});
#else
const CtxSet ContextSetCfg::InterDir = ContextSetCfg::addCtxSet
({
{ 6, 13, 5, 4, 25, },
......@@ -353,6 +362,7 @@ const CtxSet ContextSetCfg::InterDir = ContextSetCfg::addCtxSet
{ CNU, CNU, CNU, CNU, CNU, },
{ 0, 0, 1, 4, 0, },
});
#endif
const CtxSet ContextSetCfg::RefPic = ContextSetCfg::addCtxSet
({
......
......@@ -336,8 +336,14 @@ void IntraPrediction::xPredIntraPlanar( const CPelBuf &pSrc, PelBuf &pDst )
{
const uint32_t width = pDst.width;
const uint32_t height = pDst.height;
#if JVET_P0329_PLANAR_SIMPLIFICATION
const uint32_t log2W = floorLog2( width );
const uint32_t log2H = floorLog2( height );
#else
const uint32_t log2W = floorLog2(width < 2 ? 2 : width);
const uint32_t log2H = floorLog2(height < 2 ? 2 : height);
#endif
int leftColumn[MAX_CU_SIZE + 1], topRow[MAX_CU_SIZE + 1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];
const uint32_t offset = 1 << (log2W + log2H);
......
......@@ -547,10 +547,15 @@ const uint8_t g_aucIntraModeNumFast_NotUseMPM[MAX_CU_DEPTH] =
};
const uint8_t g_chroma422IntraAngleMappingTable[NUM_INTRA_MODE] =
#if JVET_P0111_CHROMA_422_FIX
// * H * D * * * * * * * * V * * * * * * * *
//0, 1, 2, 3, 4, 5, 6, 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, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, DM
{ 0, 1, 61, 62, 63, 64, 65, 66, 2, 3, 5, 6, 8, 10, 12, 13, 14, 16, 18, 20, 22, 23, 24, 26, 28, 30, 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 41, 42, 43, 43, 44, 44, 45, 45, 46, 47, 48, 48, 49, 49, 50, 51, 51, 52, 52, 53, 54, 55, 55, 56, 56, 57, 57, 58, 59, 59, 60, DM_CHROMA_IDX };
#else
// H D V
//0, 1, 2, 3, 4, 5, 6, 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, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, DM
{ 0, 1, 61, 62, 63, 64, 65, 66, 2, 3, 4, 6, 8, 10, 12, 13, 14, 16, 18, 20, 22, 23, 24, 26, 28, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 44, 44, 45, 46, 46, 46, 47, 48, 48, 48, 49, 50, 51, 52, 52, 52, 53, 54, 54, 54, 55, 56, 56, 56, 57, 58, 59, 60, DM_CHROMA_IDX };
#endif
......
......@@ -50,7 +50,15 @@
#include <assert.h>
#include <cassert>
#define JVET_P0516_PLT_BINARIZATION 1 // JVET-P0516: PLT is always signaled when pred mode is euqal to 1 (intra mode)
#define JVET_P0164_ALF_SYNTAX_SIMP 1 // JVET-p0164: simplify alf syntax with method2
#define JVET_P0042_FIX_INTER_DIR_CTX 1 // JVET-P0042: Fix overlap in context between the bi-pred flag for 8x8 CUs and the L0/L1 flag for all size CUs
#define JVET_P0111_CHROMA_422_FIX 1 // JVET-P0422: Bug fix of chroma 422 intra mode mapping
#define JVET_P0329_PLANAR_SIMPLIFICATION 1 // JVET-P0329: simplify planar prediction by comparison removal
#define JVET_P0516_PLT_BINARIZATION 1 // JVET-P0516: PLT is always signaled when pred mode is euqal to 1 (intra mode)
#define JVET_P0562_TS_RESIDUAL_CODING_SIMP 1 // JVET-P0562: Fix the Rice parameter equal to 1 for the remainder of TS residual coding
......
......@@ -2395,13 +2395,25 @@ void CABACReader::inter_pred_idc( PredictionUnit& pu )
return;
}
}
#if JVET_P0042_FIX_INTER_DIR_CTX
if( m_BinDecoder.decodeBin( Ctx::InterDir(5) ) )
#else
if( m_BinDecoder.decodeBin( Ctx::InterDir(4) ) )
#endif
{
#if JVET_P0042_FIX_INTER_DIR_CTX
DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", 2, pu.lumaPos().x, pu.lumaPos().y );
#else
DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=4 value=%d pos=(%d,%d)\n", 2, pu.lumaPos().x, pu.lumaPos().y );
#endif
pu.interDir = 2;
return;
}
#if JVET_P0042_FIX_INTER_DIR_CTX
DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", 1, pu.lumaPos().x, pu.lumaPos().y );
#else
DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=4 value=%d pos=(%d,%d)\n", 1, pu.lumaPos().x, pu.lumaPos().y );
#endif
pu.interDir = 1;
return;
}
......
......@@ -2885,6 +2885,7 @@ int HLSyntaxReader::alfGolombDecode( const int k, const bool signed_val )
void HLSyntaxReader::alfFilter( AlfParam& alfParam, const bool isChroma, const int altIdx )
{
uint32_t code;
#if !JVET_P0164_ALF_SYNTAX_SIMP
if( !isChroma )
{
READ_FLAG( code, "alf_luma_coeff_delta_flag" );
......@@ -2895,6 +2896,7 @@ void HLSyntaxReader::alfFilter( AlfParam& alfParam, const bool isChroma, const i
std::memset( alfParam.alfLumaCoeffFlag, true, sizeof( alfParam.alfLumaCoeffFlag ) );
}
}
#endif
// derive maxGolombIdx
AlfFilterShape alfShape( isChroma ? 5 : 7 );
......@@ -2902,6 +2904,7 @@ void HLSyntaxReader::alfFilter( AlfParam& alfParam, const bool isChroma, const i
short* coeff = isChroma ? alfParam.chromaCoeff[altIdx] : alfParam.lumaCoeff;
short* clipp = isChroma ? alfParam.chromaClipp[altIdx] : alfParam.lumaClipp;
#if !JVET_P0164_ALF_SYNTAX_SIMP
if( !isChroma )
{
if( alfParam.alfLumaCoeffDeltaFlag )
......@@ -2913,15 +2916,18 @@ void HLSyntaxReader::alfFilter( AlfParam& alfParam, const bool isChroma, const i
}
}
}
#endif
// Filter coefficients
for( int ind = 0; ind < numFilters; ++ind )
{
#if !JVET_P0164_ALF_SYNTAX_SIMP
if( !isChroma && !alfParam.alfLumaCoeffFlag[ind] && alfParam.alfLumaCoeffDeltaFlag )
{
memset( coeff + ind * MAX_NUM_ALF_LUMA_COEFF, 0, sizeof( *coeff ) * alfShape.numCoeff );
continue;
}
#endif
for( int i = 0; i < alfShape.numCoeff - 1; i++ )
{
......
......@@ -2200,8 +2200,13 @@ void CABACWriter::inter_pred_idc( const PredictionUnit& pu )
m_BinEncoder.encodeBin( 0, Ctx::InterDir(ctxId) );
}
}
#if JVET_P0042_FIX_INTER_DIR_CTX
m_BinEncoder.encodeBin( ( pu.interDir == 2 ), Ctx::InterDir( 5 ) );
DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", pu.interDir, pu.lumaPos().x, pu.lumaPos().y );
#else
m_BinEncoder.encodeBin( ( pu.interDir == 2 ), Ctx::InterDir( 4 ) );
DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=4 value=%d pos=(%d,%d)\n", pu.interDir, pu.lumaPos().x, pu.lumaPos().y );
#endif
}
......
......@@ -1296,7 +1296,11 @@ double EncAdaptiveLoopFilter::mergeFiltersAndCost( AlfParam& alfParam, AlfFilter
int EncAdaptiveLoopFilter::getNonFilterCoeffRate( AlfParam& alfParam )
{
#if JVET_P0164_ALF_SYNTAX_SIMP
int len = 0 // alf_coefficients_delta_flag
#else
int len = 1 // alf_coefficients_delta_flag
#endif
+ 2 // slice_alf_chroma_idc u(2)
+ lengthUvlc (alfParam.numLumaFilters - 1); // alf_luma_num_filters_signalled_minus1 ue(v)
......@@ -1314,7 +1318,11 @@ int EncAdaptiveLoopFilter::getNonFilterCoeffRate( AlfParam& alfParam )
int EncAdaptiveLoopFilter::getCostFilterCoeffForce0( AlfFilterShape& alfShape, int **pDiffQFilterCoeffIntPP, const int numFilters, bool* codedVarBins )
{
#if JVET_P0164_ALF_SYNTAX_SIMP
int len = 0;
#else
int len = numFilters; //filter_coefficient_flag[i]
#endif
// Filter coefficients
for( int ind = 0; ind < numFilters; ++ind )
{
......@@ -1325,6 +1333,15 @@ int EncAdaptiveLoopFilter::getCostFilterCoeffForce0( AlfFilterShape& alfShape, i
len += lengthGolomb( abs( pDiffQFilterCoeffIntPP[ind][i] ), 3 ); // alf_coeff_luma_delta[i][j]
}
}
#if JVET_P0164_ALF_SYNTAX_SIMP
else
{
for (int i = 0; i < alfShape.numCoeff - 1; i++)
{
len += lengthGolomb(0, 3); // alf_coeff_luma_delta[i][j]
}
}
#endif
}
if( m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] )
......@@ -1398,6 +1415,13 @@ double EncAdaptiveLoopFilter::getDistForce0( AlfFilterShape& alfShape, const int
}
}
#if JVET_P0164_ALF_SYNTAX_SIMP
static int zeroBitsVarBin = 0;
for (int i = 0; i < alfShape.numCoeff - 1; i++)
{
zeroBitsVarBin += lengthGolomb(0, 3);
}
#endif
if( m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] )
{
for (int ind = 0; ind < numFilters; ++ind)
......@@ -1412,18 +1436,30 @@ double EncAdaptiveLoopFilter::getDistForce0( AlfFilterShape& alfShape, const int
}
}
#if JVET_P0164_ALF_SYNTAX_SIMP
double distForce0 = getDistCoeffForce0( codedVarBins, errorTabForce0Coeff, bitsVarBin, zeroBitsVarBin, numFilters);
#else
double distForce0 = getDistCoeffForce0( codedVarBins, errorTabForce0Coeff, bitsVarBin, numFilters );
#endif
return distForce0;
}
#if JVET_P0164_ALF_SYNTAX_SIMP
double EncAdaptiveLoopFilter::getDistCoeffForce0( bool* codedVarBins, double errorForce0CoeffTab[MAX_NUM_ALF_CLASSES][2], int* bitsVarBin, int zeroBitsVarBin, const int numFilters)
#else
double EncAdaptiveLoopFilter::getDistCoeffForce0( bool* codedVarBins, double errorForce0CoeffTab[MAX_NUM_ALF_CLASSES][2], int* bitsVarBin, const int numFilters )
#endif
{
double distForce0 = 0;
std::memset( codedVarBins, 0, sizeof( *codedVarBins ) * MAX_NUM_ALF_CLASSES );
for( int filtIdx = 0; filtIdx < numFilters; filtIdx++ )
{
#if JVET_P0164_ALF_SYNTAX_SIMP
double costDiff = (errorForce0CoeffTab[filtIdx][0] + m_lambda[COMPONENT_Y] * zeroBitsVarBin) - (errorForce0CoeffTab[filtIdx][1] + m_lambda[COMPONENT_Y] * bitsVarBin[filtIdx]);
#else
double costDiff = errorForce0CoeffTab[filtIdx][0] - ( errorForce0CoeffTab[filtIdx][1] + m_lambda[COMPONENT_Y] * bitsVarBin[filtIdx] );
#endif
codedVarBins[filtIdx] = costDiff > 0 ? true : false;
distForce0 += errorForce0CoeffTab[filtIdx][codedVarBins[filtIdx] ? 1 : 0];
}
......
......@@ -313,7 +313,11 @@ private:
const int numClasses, const int numCoeff, double& distUnfilter );
void roundFiltCoeff( int *filterCoeffQuant, double *filterCoeff, const int numCoeff, const int factor );
#if JVET_P0164_ALF_SYNTAX_SIMP
double getDistCoeffForce0( bool* codedVarBins, double errorForce0CoeffTab[MAX_NUM_ALF_CLASSES][2], int* bitsVarBin, int zeroBitsVarBin, const int numFilters);
#else
double getDistCoeffForce0( bool* codedVarBins, double errorForce0CoeffTab[MAX_NUM_ALF_CLASSES][2], int* bitsVarBin, const int numFilters );
#endif
int lengthUvlc( int uiCode );
int getNonFilterCoeffRate( AlfParam& alfParam );
......
......@@ -1836,16 +1836,19 @@ void HLSWriter::alfGolombEncode( int coeff, int k, const bool signed_coeff )
void HLSWriter::alfFilter( const AlfParam& alfParam, const bool isChroma, const int altIdx )
{
#if !JVET_P0164_ALF_SYNTAX_SIMP
if( !isChroma )
{
WRITE_FLAG( alfParam.alfLumaCoeffDeltaFlag, "alf_luma_coeff_delta_flag" );
}
#endif
AlfFilterShape alfShape(isChroma ? 5 : 7);
const short* coeff = isChroma ? alfParam.chromaCoeff[altIdx] : alfParam.lumaCoeff;
const short* clipp = isChroma ? alfParam.chromaClipp[altIdx] : alfParam.lumaClipp;
const int numFilters = isChroma ? 1 : alfParam.numLumaFilters;
// vlc for all
#if !JVET_P0164_ALF_SYNTAX_SIMP
if( !isChroma )
{
if( alfParam.alfLumaCoeffDeltaFlag )
......@@ -1856,14 +1859,17 @@ void HLSWriter::alfFilter( const AlfParam& alfParam, const bool isChroma, const
}
}
}
#endif
// Filter coefficients
for( int ind = 0; ind < numFilters; ++ind )
{
#if !JVET_P0164_ALF_SYNTAX_SIMP
if( !isChroma && !alfParam.alfLumaCoeffFlag[ind] && alfParam.alfLumaCoeffDeltaFlag )
{
continue;
}
#endif
for( int i = 0; i < alfShape.numCoeff - 1; i++ )
{
......
Supports Markdown
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