Commit 2c4349e6 authored by Frank Bossen's avatar Frank Bossen

Fix #1141: Valid range check for sps_max_num_merge_cand_minus_max_num_gpm_cand

parent b0bbd231
......@@ -2022,14 +2022,20 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
{
READ_FLAG(uiCode, "sps_gpm_enabled_flag");
pcSPS->setUseGeo(uiCode != 0);
if (pcSPS->getUseGeo() && pcSPS->getMaxNumMergeCand() >= 3)
if (pcSPS->getUseGeo())
{
READ_UVLC(uiCode, "max_num_merge_cand_minus_max_num_gpm_cand");
CHECK(pcSPS->getMaxNumMergeCand() < uiCode, "Incorrrect max number of GEO candidates!");
pcSPS->setMaxNumGeoCand((uint32_t)(pcSPS->getMaxNumMergeCand() - uiCode));
if (pcSPS->getMaxNumMergeCand() >= 3)
{
READ_UVLC(uiCode, "max_num_merge_cand_minus_max_num_gpm_cand");
CHECK(pcSPS->getMaxNumMergeCand() - 2 < uiCode,
"max_num_merge_cand_minus_max_num_gpm_cand must not be greater than the number of merge candidates minus 2");
pcSPS->setMaxNumGeoCand((uint32_t)(pcSPS->getMaxNumMergeCand() - uiCode));
}
else
{
pcSPS->setMaxNumGeoCand(2);
}
}
else if (pcSPS->getUseGeo())
pcSPS->setMaxNumGeoCand(2);
}
else
{
......
......@@ -1201,10 +1201,17 @@ void HLSWriter::codeSPS( const SPS* pcSPS )
if (pcSPS->getMaxNumMergeCand() >= 2)
{
WRITE_FLAG(pcSPS->getUseGeo() ? 1 : 0, "sps_gpm_enabled_flag");
if (pcSPS->getUseGeo() && pcSPS->getMaxNumMergeCand() >= 3)
if (pcSPS->getUseGeo())
{
CHECK(pcSPS->getMaxNumMergeCand() < pcSPS->getMaxNumGeoCand(), "Incorrrect max number of GEO candidates!");
WRITE_UVLC(pcSPS->getMaxNumMergeCand() - pcSPS->getMaxNumGeoCand(), "max_num_merge_cand_minus_max_num_gpm_cand");
CHECK(pcSPS->getMaxNumMergeCand() < pcSPS->getMaxNumGeoCand(),
"The number of GPM candidates must not be greater than the number of merge candidates");
CHECK(2 > pcSPS->getMaxNumGeoCand(),
"The number of GPM candidates must not be smaller than 2");
if (pcSPS->getMaxNumMergeCand() >= 3)
{
WRITE_UVLC(pcSPS->getMaxNumMergeCand() - pcSPS->getMaxNumGeoCand(),
"max_num_merge_cand_minus_max_num_gpm_cand");
}
}
}
......
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