Commit a10dae76 authored by Xiang Li's avatar Xiang Li

Merge branch 'fix1141' into 'master'

Fix #1141: Valid range check for sps_max_num_merge_cand_minus_max_num_gpm_cand

See merge request !1800
parents acfb50b6 2c4349e6
......@@ -2025,14 +2025,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
{
......
......@@ -1202,10 +1202,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