Commit 5c3994bf authored by Remy Foray's avatar Remy Foray

Fix #357: num_ref_idx_lx_active_minus1 parsing

parent 2444ec96
......@@ -96,6 +96,8 @@ public:
void setNumberOfLongtermPictures(int numberOfLtrp);
int getNumberOfLongtermPictures() const;
int getNumRefEntries() const { return m_numberOfShorttermPictures + m_numberOfLongtermPictures; }
void setPOC(int idx, int POC);
int getPOC(int idx) const;
......
......@@ -1854,16 +1854,32 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
{
pcSlice->setEnableTMVPFlag(false);
}
if (!pcSlice->isIntra())
if ((!pcSlice->isIntra() && pcSlice->getRPL0()->getNumRefEntries() > 1) ||
(pcSlice->isInterB() && pcSlice->getRPL1()->getNumRefEntries() > 1) )
{
READ_FLAG( uiCode, "num_ref_idx_active_override_flag");
if (uiCode)
{
READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 );
if(pcSlice->getRPL0()->getNumRefEntries() > 1)
{
READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" );
}
else
{
uiCode = 0;
}
pcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 );
if (pcSlice->isInterB())
{
READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 );
if(pcSlice->getRPL1()->getNumRefEntries() > 1)
{
READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" );
}
else
{
uiCode = 0;
}
pcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 );
}
else
{
......@@ -1872,17 +1888,43 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
}
else
{
pcSlice->setNumRefIdx(REF_PIC_LIST_0, pps->getNumRefIdxL0DefaultActive());
if(pcSlice->getRPL0()->getNumRefEntries() >= pps->getNumRefIdxL0DefaultActive())
{
pcSlice->setNumRefIdx(REF_PIC_LIST_0, pps->getNumRefIdxL0DefaultActive());
}
else
{
pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getRPL0()->getNumRefEntries());
}
if (pcSlice->isInterB())
{
pcSlice->setNumRefIdx(REF_PIC_LIST_1, pps->getNumRefIdxL1DefaultActive());
if(pcSlice->getRPL1()->getNumRefEntries() >= pps->getNumRefIdxL1DefaultActive())
{
pcSlice->setNumRefIdx(REF_PIC_LIST_1, pps->getNumRefIdxL1DefaultActive());
}
else
{
pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getRPL1()->getNumRefEntries());
}
}
else
{
pcSlice->setNumRefIdx(REF_PIC_LIST_1,0);
pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
}
}
}
else
{
if(!pcSlice->isIntra())
{
pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getRPL0()->getNumRefEntries());
}
if(pcSlice->isInterB())
{
pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getRPL1()->getNumRefEntries());
}
}
// }
if (pcSlice->isInterB())
......
......@@ -1295,27 +1295,43 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
//check if numrefidxes match the defaults. If not, override
if( !pcSlice->isIntra() )
if ((!pcSlice->isIntra() && pcSlice->getRPL0()->getNumRefEntries() > 1) ||
(pcSlice->isInterB() && pcSlice->getRPL1()->getNumRefEntries() > 1) )
{
bool overrideFlag = ( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) != pcSlice->getPPS()->getNumRefIdxL0DefaultActive() || ( pcSlice->isInterB() && pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) != pcSlice->getPPS()->getNumRefIdxL1DefaultActive() ) );
int defaultL0 = std::min<int>(pcSlice->getRPL0()->getNumRefEntries(), pcSlice->getPPS()->getNumRefIdxL0DefaultActive());
int defaultL1 = pcSlice->isInterB() ? std::min<int>(pcSlice->getRPL1()->getNumRefEntries(), pcSlice->getPPS()->getNumRefIdxL1DefaultActive()) : 0;
bool overrideFlag = ( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) != defaultL0 || ( pcSlice->isInterB() && pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) != defaultL1 ) );
WRITE_FLAG( overrideFlag ? 1 : 0, "num_ref_idx_active_override_flag" );
if( overrideFlag )
{
WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, "num_ref_idx_l0_active_minus1" );
if( pcSlice->isInterB() )
if(pcSlice->getRPL0()->getNumRefEntries() > 1)
{
WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, "num_ref_idx_l0_active_minus1" );
}
else
{
pcSlice->setNumRefIdx( REF_PIC_LIST_0, 1);
}
if( pcSlice->isInterB() && pcSlice->getRPL1()->getNumRefEntries() > 1)
{
WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, "num_ref_idx_l1_active_minus1" );
}
else
{
pcSlice->setNumRefIdx( REF_PIC_LIST_1, 0 );
pcSlice->setNumRefIdx( REF_PIC_LIST_1, pcSlice->isInterB() ? 1 : 0);
}
}
else
{
pcSlice->setNumRefIdx( REF_PIC_LIST_0, defaultL0 );
pcSlice->setNumRefIdx( REF_PIC_LIST_1, defaultL1 );
}
}
else
{
pcSlice->setNumRefIdx( REF_PIC_LIST_0, 0 );
pcSlice->setNumRefIdx( REF_PIC_LIST_1, 0 );
pcSlice->setNumRefIdx( REF_PIC_LIST_0, pcSlice->isIntra() ? 0 : 1 );
pcSlice->setNumRefIdx( REF_PIC_LIST_1, pcSlice->isInterB() ? 1 : 0 );
}
......
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