Commit 1d805b83 authored by Nan Hu's avatar Nan Hu

JVET-O0288: remove slice type dependency in ALF

parent fe65302c
......@@ -50,6 +50,8 @@
#include <assert.h>
#include <cassert>
#define JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL 1 // JVET-O0288: remove slice type dependency in ALF
#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_O0669_REMOVE_ALF_COEFF_PRED 1 // JVET-O0425/O0427/O0669: remove prediction in ALF coefficients coding
......
......@@ -1810,6 +1810,9 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
int alfChromaIdc = 0;
if (uiCode)
{
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
xReadTruncBinCode(uiCode, ALF_CTB_MAX_NUM_APS + 1);
#else
if (pcSlice->isIntra())
{
READ_FLAG(uiCode, "tile_group_num_APS");
......@@ -1818,6 +1821,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
{
xReadTruncBinCode(uiCode, ALF_CTB_MAX_NUM_APS + 1);
}
#endif
int numAps = uiCode;
pcSlice->setTileGroupNumAps(numAps);
std::vector<int> apsId(numAps, -1);
......@@ -1832,6 +1836,9 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
alfChromaIdc = truncatedUnaryEqProb(3); //alf_chroma_idc
if (alfChromaIdc)
{
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
READ_CODE(5, uiCode, "tile_group_aps_id_chroma");
#else
if (pcSlice->isIntra() && pcSlice->getTileGroupNumAps() == 1)
{
uiCode = apsId[0];
......@@ -1840,6 +1847,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
{
READ_CODE(5, uiCode, "tile_group_aps_id_chroma");
}
#endif
pcSlice->setTileGroupApsIdChroma(uiCode);
}
}
......
......@@ -2758,7 +2758,11 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfSliceParam& a
curCost += costOff;
}
} //for(ctbIdx)
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
int tmpBits = bitsNewFilter + 5 * (numFilterSet - NUM_FIXED_FILTER_SETS) + getTBlength(numFilterSet - NUM_FIXED_FILTER_SETS, ALF_CTB_MAX_NUM_APS + 1);
#else
int tmpBits = bitsNewFilter + 5 * (numFilterSet - NUM_FIXED_FILTER_SETS) + (cs.slice->isIntra() ? 1 : getTBlength(numFilterSet - NUM_FIXED_FILTER_SETS, ALF_CTB_MAX_NUM_APS + 1));
#endif
curCost += tmpBits * m_lambda[COMPONENT_Y];
if (curCost < costMin)
{
......@@ -2863,7 +2867,11 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfSliceParam& a
continue;
}
APS* curAPS = m_apsMap->getPS((curApsId << NUM_APS_TYPE_LEN) + ALF_APS);
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
double curCost = m_lambda[CHANNEL_TYPE_CHROMA] * 5;
#else
double curCost = (cs.slice->isIntra() && cs.slice->getTileGroupNumAps() == 1) ? 0 : (m_lambda[CHANNEL_TYPE_CHROMA] * 5);
#endif
if (curApsId == newApsIdChroma)
{
m_alfSliceParamTemp = alfSliceParamNewFilters;
......
......@@ -1261,7 +1261,9 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
if (alfEnabled)
{
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
xWriteTruncBinCode(pcSlice->getTileGroupNumAps(), ALF_CTB_MAX_NUM_APS + 1);
#else
if (pcSlice->isIntra())
{
WRITE_FLAG(pcSlice->getTileGroupNumAps(), "tile_group_num_APS");
......@@ -1270,7 +1272,7 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
{
xWriteTruncBinCode(pcSlice->getTileGroupNumAps(), ALF_CTB_MAX_NUM_APS + 1);
}
#endif
const std::vector<int>& apsId = pcSlice->getTileGroupApsIdLuma();
for (int i = 0; i < pcSlice->getTileGroupNumAps(); i++)
{
......@@ -1281,6 +1283,9 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
truncatedUnaryEqProb(alfChromaIdc, 3); // alf_chroma_idc
if (alfChromaIdc)
{
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
WRITE_CODE(pcSlice->getTileGroupApsIdChroma(), 5, "tile_group_aps_id_chroma");
#else
if (pcSlice->isIntra()&& pcSlice->getTileGroupNumAps() == 1)
{
CHECK(pcSlice->getTileGroupApsIdChroma() != apsId[0], "wrong tile group chroma aps id");
......@@ -1289,6 +1294,7 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
{
WRITE_CODE(pcSlice->getTileGroupApsIdChroma(), 5, "tile_group_aps_id_chroma");
}
#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