Commit c2588780 authored by Nan Hu's avatar Nan Hu

JVET-O0047/O0058/O0064/O0067/O0290/O0301/O0430: use fixed-length codes (2...

JVET-O0047/O0058/O0064/O0067/O0290/O0301/O0430: use fixed-length codes (2 bits) for alf clipping indices, always signal alf clipping indices
parent ca678b5b
......@@ -50,6 +50,8 @@
#include <assert.h>
#include <cassert>
#define JVET_O0064_SIMP_ALF_CLIP_CODING 1 // JVET-O0047/O0058/O0064/O0067/O0290/O0301/O0430: use FLC for alf clipping indices, always signal alf clipping indices
#define JVET_O1109_UNFIY_CRS 1 // JVET-O1109: Unified CRS derivation
#define JVET_O0590_REDUCE_DMVR_ORIG_MV_COST 1 // Reduce the DMVR cost of the original MV
......
......@@ -2723,6 +2723,7 @@ void HLSyntaxReader::alfFilter( AlfSliceParam& alfSliceParam, const bool isChrom
// Clipping values coding
if ( alfSliceParam.nonLinearFlag[isChroma] )
{
#if !JVET_O0064_SIMP_ALF_CLIP_CODING
READ_UVLC( code, "clip_min_golomb_order" );
kMin = code + 1;
......@@ -2755,22 +2756,30 @@ void HLSyntaxReader::alfFilter( AlfSliceParam& alfSliceParam, const bool isChrom
}
}
}
#endif
// Filter coefficients
for( int ind = 0; ind < numFilters; ++ind )
{
#if !JVET_O0064_SIMP_ALF_CLIP_CODING
if( !isChroma && !alfSliceParam.alfLumaCoeffFlag[ind] && alfSliceParam.alfLumaCoeffDeltaFlag )
{
std::fill_n( clipp + ind * MAX_NUM_ALF_LUMA_COEFF, alfShape.numCoeff, 0 );
continue;
}
#endif
for( int i = 0; i < alfShape.numCoeff - 1; i++ )
{
#if JVET_O0064_SIMP_ALF_CLIP_CODING
READ_CODE(2, code, "alf_clipping_index");
clipp[ind * MAX_NUM_ALF_LUMA_COEFF + i] = code;
#else
if( recCoeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] )
clipp[ind * MAX_NUM_ALF_LUMA_COEFF + i] = alfGolombDecode( kMinTab[alfShape.golombIdx[i]], false );
else
clipp[ind * MAX_NUM_ALF_LUMA_COEFF + i] = 0;
#endif
}
}
}
......
......@@ -1024,6 +1024,16 @@ int EncAdaptiveLoopFilter::getCoeffRate( AlfSliceParam& alfSliceParam, bool isCh
if( m_alfSliceParamTemp.nonLinearFlag[isChroma] )
{
#if JVET_O0064_SIMP_ALF_CLIP_CODING
for (int i = 0; i < alfShape.numCoeff - 1; i++)
{
if (!abs(alfSliceParam.chromaCoeff[i]))
{
alfSliceParam.chromaClipp[i] = 0;
}
}
iBits += ((alfShape.numCoeff - 1) << 1);
#else
memset( m_bitsCoeffScan, 0, sizeof( m_bitsCoeffScan ) );
// vlc for all
for( int i = 0; i < alfShape.numCoeff - 1; i++ )
......@@ -1059,6 +1069,7 @@ int EncAdaptiveLoopFilter::getCoeffRate( AlfSliceParam& alfSliceParam, bool isCh
continue;
iBits += lengthGolomb( alfSliceParam.chromaClipp[i], m_kMinTab[alfShape.golombIdx[i]], false ); // alf_coeff_chroma[i], alf_coeff_luma_delta[i][j]
}
#endif
}
return iBits;
}
......@@ -1326,6 +1337,19 @@ int EncAdaptiveLoopFilter::getCostFilterCoeffForce0( AlfFilterShape& alfShape, i
if( m_alfSliceParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] )
{
#if JVET_O0064_SIMP_ALF_CLIP_CODING
for (int ind = 0; ind < numFilters; ++ind)
{
for (int i = 0; i < alfShape.numCoeff - 1; i++)
{
if (!abs(pDiffQFilterCoeffIntPP[ind][i]))
{
m_filterClippSet[ind][i] = 0;
}
len += 2;
}
}
#else
memset( m_bitsCoeffScan, 0, sizeof( m_bitsCoeffScan ) );
for( int ind = 0; ind < numFilters; ++ind )
......@@ -1366,6 +1390,7 @@ int EncAdaptiveLoopFilter::getCostFilterCoeffForce0( AlfFilterShape& alfShape, i
}
}
}
#endif
}
return len;
......@@ -1433,6 +1458,19 @@ int EncAdaptiveLoopFilter::getCostFilterCoeff( AlfFilterShape& alfShape, int **p
int EncAdaptiveLoopFilter::getCostFilterClipp( AlfFilterShape& alfShape, int **pDiffQFilterCoeffIntPP, const int numFilters )
{
#if JVET_O0064_SIMP_ALF_CLIP_CODING
for (int filterIdx = 0; filterIdx < numFilters; ++filterIdx)
{
for (int i = 0; i < alfShape.numCoeff - 1; i++)
{
if (!abs(pDiffQFilterCoeffIntPP[filterIdx][i]))
{
m_filterClippSet[filterIdx][i] = 0;
}
}
}
return (numFilters * (alfShape.numCoeff - 1)) << 1;
#else
memset( m_bitsCoeffScan, 0, sizeof( m_bitsCoeffScan ) );
for( int filterIdx = 0; filterIdx < numFilters; ++filterIdx )
{
......@@ -1451,6 +1489,7 @@ int EncAdaptiveLoopFilter::getCostFilterClipp( AlfFilterShape& alfShape, int **p
return len //min_golomb_order
+ getMaxGolombIdx( alfShape.filterType ) //golomb_order_increase_flag
+ lengthFilterClipps( alfShape, numFilters, pDiffQFilterCoeffIntPP, m_kMinTab ); // Filter clippings
#endif
}
int EncAdaptiveLoopFilter::lengthFilterCoeffs( AlfFilterShape& alfShape, const int numFilters, int **FilterCoeff, int* kMinTab )
......@@ -1467,6 +1506,7 @@ int EncAdaptiveLoopFilter::lengthFilterCoeffs( AlfFilterShape& alfShape, const i
return bitCnt;
}
#if !JVET_O0064_SIMP_ALF_CLIP_CODING
int EncAdaptiveLoopFilter::lengthFilterClipps( AlfFilterShape& alfShape, const int numFilters, int **FilterCoeff, int* kMinTab )
{
int bitCnt = 0;
......@@ -1482,6 +1522,7 @@ int EncAdaptiveLoopFilter::lengthFilterClipps( AlfFilterShape& alfShape, const i
}
return bitCnt;
}
#endif
double EncAdaptiveLoopFilter::getDistForce0( AlfFilterShape& alfShape, const int numFilters, double errorTabForce0Coeff[MAX_NUM_ALF_CLASSES][2], bool* codedVarBins )
{
......@@ -1511,6 +1552,21 @@ double EncAdaptiveLoopFilter::getDistForce0( AlfFilterShape& alfShape, const int
}
}
#if JVET_O0064_SIMP_ALF_CLIP_CODING
if (m_alfSliceParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA])
{
for (int ind = 0; ind < numFilters; ++ind)
{
for (int i = 0; i < alfShape.numCoeff - 1; i++)
{
if (!abs(m_filterCoeffSet[ind][i]))
{
m_filterClippSet[ind][i] = 0;
}
}
}
}
#else
if( m_alfSliceParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] )
{
memset( m_bitsCoeffScan, 0, sizeof( m_bitsCoeffScan ) );
......@@ -1540,6 +1596,7 @@ double EncAdaptiveLoopFilter::getDistForce0( AlfFilterShape& alfShape, const int
}
}
}
#endif
double distForce0 = getDistCoeffForce0( codedVarBins, errorTabForce0Coeff, bitsVarBin, numFilters );
......
......@@ -319,7 +319,9 @@ private:
int getCostFilterCoeff( AlfFilterShape& alfShape, int **pDiffQFilterCoeffIntPP, const int numFilters );
int getCostFilterClipp( AlfFilterShape& alfShape, int **pDiffQFilterCoeffIntPP, const int numFilters );
int lengthFilterCoeffs( AlfFilterShape& alfShape, const int numFilters, int **FilterCoeff, int* kMinTab );
#if !JVET_O0064_SIMP_ALF_CLIP_CODING
int lengthFilterClipps( AlfFilterShape& alfShape, const int numFilters, int **FilterCoeff, int* kMinTab );
#endif
double getDistForce0( AlfFilterShape& alfShape, const int numFilters, double errorTabForce0Coeff[MAX_NUM_ALF_CLASSES][2], bool* codedVarBins );
int getCoeffRate( AlfSliceParam& alfSliceParam, bool isChroma );
......
......@@ -1909,6 +1909,15 @@ void HLSWriter::alfFilter( const AlfSliceParam& alfSliceParam, const bool isChro
// Clipping values coding
if( alfSliceParam.nonLinearFlag[isChroma] )
{
#if JVET_O0064_SIMP_ALF_CLIP_CODING
for (int ind = 0; ind < numFilters; ++ind)
{
for (int i = 0; i < alfShape.numCoeff - 1; i++)
{
WRITE_CODE(clipp[ind* MAX_NUM_ALF_LUMA_COEFF + i], 2, "alf_clipping_index");
}
}
#else
memset( bitsCoeffScan, 0, sizeof( bitsCoeffScan ) );
short recCoeff[MAX_NUM_ALF_CLASSES * MAX_NUM_ALF_LUMA_COEFF];
......@@ -1978,6 +1987,7 @@ void HLSWriter::alfFilter( const AlfSliceParam& alfSliceParam, const bool isChro
alfGolombEncode( clipp[ind* MAX_NUM_ALF_LUMA_COEFF + i], kMinTab[alfShape.golombIdx[i]], false ); // alf_coeff_chroma[i], alf_coeff_luma_delta[i][j]
}
}
#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