diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 5003572316446365c1ba906b7bed209d56d9e9d9..2d125860e06914c9d6d005dbe4ad3136a8061afb 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -3208,7 +3208,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag if( (pps->getUseWP() || pps->getWPBiPred()) && pps->getWpInfoInPhFlag() ) { - parsePredWeightTable(picHeader, sps); + parsePredWeightTable(picHeader, pps, sps); } } // inherit constraint values from SPS @@ -4767,7 +4767,7 @@ void HLSyntaxReader::parsePredWeightTable( Slice* pcSlice, const SPS *sps ) CHECK(uiTotalSignalledWeightFlags>24, "Too many weight flag signalled"); } -void HLSyntaxReader::parsePredWeightTable(PicHeader *picHeader, const SPS *sps) +void HLSyntaxReader::parsePredWeightTable(PicHeader *picHeader, const PPS *pps, const SPS *sps) { WPScalingParam * wp; const ChromaFormat chFmt = sps->getChromaFormatIdc(); @@ -4898,7 +4898,7 @@ void HLSyntaxReader::parsePredWeightTable(PicHeader *picHeader, const SPS *sps) if (numRef == 0) { - if (picHeader->getRPL(1)->getNumRefEntries() > 0) + if (pps->getWPBiPred() && picHeader->getRPL(1)->getNumRefEntries() > 0) { READ_UVLC(numLxWeights, "num_l1_weights"); } diff --git a/source/Lib/DecoderLib/VLCReader.h b/source/Lib/DecoderLib/VLCReader.h index 5c2534500abb22be92c477132e12c59451c54b66..dfd0b53ad39547614869620a78cc027d6558bb75 100644 --- a/source/Lib/DecoderLib/VLCReader.h +++ b/source/Lib/DecoderLib/VLCReader.h @@ -180,7 +180,7 @@ public: void parseRemainingBytes ( bool noTrailingBytesExpected ); void parsePredWeightTable( Slice* pcSlice, const SPS *sps ); - void parsePredWeightTable ( PicHeader *picHeader, const SPS *sps ); + void parsePredWeightTable ( PicHeader *picHeader, const PPS *pps, const SPS *sps ); void parseScalingList ( ScalingList *scalingList, bool aps_chromaPresentFlag ); void decodeScalingList ( ScalingList *scalingList, uint32_t scalingListId, bool isPredictor); void parseReshaper ( SliceReshapeInfo& sliceReshaperInfo, const SPS* pcSPS, const bool isIntra ); diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 84628f2c13b9eb7ee2650b3822f8521bfe882d43..8b3531db3b9b43b8c3069a445787067e4e407f85 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -2006,7 +2006,7 @@ WRITE_FLAG(picHeader->getGdrOrIrapPicFlag(), "ph_gdr_or_irap_pic_flag"); if ((pps->getUseWP() || pps->getWPBiPred()) && pps->getWpInfoInPhFlag()) { - xCodePredWeightTable(picHeader, sps); + xCodePredWeightTable(picHeader, pps, sps); } } // inherit constraint values from SPS @@ -2835,7 +2835,7 @@ void HLSWriter::xCodePredWeightTable( Slice* pcSlice ) } } -void HLSWriter::xCodePredWeightTable(PicHeader *picHeader, const SPS *sps) +void HLSWriter::xCodePredWeightTable(PicHeader *picHeader, const PPS *pps, const SPS *sps) { WPScalingParam * wp; const ChromaFormat format = sps->getChromaFormatIdc(); @@ -2915,7 +2915,11 @@ void HLSWriter::xCodePredWeightTable(PicHeader *picHeader, const SPS *sps) if (numRef == 0) { numLxWeights = picHeader->getNumL1Weights(); - if (picHeader->getRPL(1)->getNumRefEntries() > 0) + if (pps->getWPBiPred() == 0) + { + numLxWeights = 0; + } + else if (picHeader->getRPL(1)->getNumRefEntries() > 0) { WRITE_UVLC(numLxWeights, "num_l1_weights"); } diff --git a/source/Lib/EncoderLib/VLCWriter.h b/source/Lib/EncoderLib/VLCWriter.h index 5496858cc8bce0f75547af3e7f636f2e0908e6f6..db61a5196338f149f2243bef447ad2d7de99fd84 100644 --- a/source/Lib/EncoderLib/VLCWriter.h +++ b/source/Lib/EncoderLib/VLCWriter.h @@ -125,7 +125,7 @@ private: void xCodeRefPicList( const ReferencePictureList* rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount, const bool isForbiddenZeroDeltaPoc, int rplIdx); bool xFindMatchingLTRP ( Slice* pcSlice, uint32_t *ltrpsIndex, int ltrpPOC, bool usedFlag ); void xCodePredWeightTable ( Slice* pcSlice ); - void xCodePredWeightTable ( PicHeader *picHeader, const SPS *sps ); + void xCodePredWeightTable ( PicHeader *picHeader, const PPS *pps, const SPS *sps ); void xCodeScalingList ( const ScalingList* scalingList, uint32_t scalinListId, bool isPredictor); public: void setBitstream ( OutputBitstream* p ) { m_pcBitIf = p; }