diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 9715ee9015f340906dca96376edd91fea96a4479..39eb30175a5bd55af6ca6c6f914430aa210e9608 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -51,6 +51,10 @@ #include <cassert> //########### place macros to be removed in next cycle below this line ############### +#define JVET_R0185_OLS_DPB_CLEANUP 1 // JVET-R0185: Replace if( !vps_all_independent_layers_flag ) condition on vps_num_dpb_params syntax element with if(!each_layer_is_an_ols_flag) + // Change vps_num_dpb_params to vps_num_dpb_params_minus1 and change the semantics to a “two-way” constraint + // Signal DPB parameters for OLS in this case only if(!each_layer_is_an_ols_flag) + #define JVET_R0058 1 // JVET-R0058: the combination of RPR, subpictures, and scalability #define JVET_R0078_DISABLE_CHROMA_DBF_OFFSET_SINGALLING 1 // JVET-R0078: disable chroma DBF offset signalling diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 4c56591428e658bd920fa28dcab09f13e000ad71..8d6dc924164f941172cb84213d8d3b98c78de09e 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -2521,119 +2521,129 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) } #endif +#if JVET_R0185_OLS_DPB_CLEANUP + if( !pcVPS->getEachLayerIsAnOlsFlag() ) + { + READ_UVLC( uiCode, "vps_num_dpb_params_minus1" ); pcVPS->m_numDpbParams = uiCode + 1; +#else if( !pcVPS->getAllIndependentLayersFlag() ) { READ_UVLC( uiCode, "vps_num_dpb_params" ); pcVPS->m_numDpbParams = uiCode; } +#endif #if JVET_R0191_ASPECT3 - CHECK( pcVPS->m_numDpbParams > pcVPS->getNumMultiLayeredOlss(),"The value of vps_num_dpb_params_minus1 shall be in the range of 0 to NumMultiLayerOlss - 1, inclusive"); - std::vector<bool> isDPBParamReferred(pcVPS->m_numDpbParams, false); + CHECK( pcVPS->m_numDpbParams > pcVPS->getNumMultiLayeredOlss(),"The value of vps_num_dpb_params_minus1 shall be in the range of 0 to NumMultiLayerOlss - 1, inclusive"); + std::vector<bool> isDPBParamReferred(pcVPS->m_numDpbParams, false); #endif - if( pcVPS->m_numDpbParams > 0 && pcVPS->getMaxSubLayers() > 1 ) - { - READ_FLAG( uiCode, "vps_sublayer_dpb_params_present_flag" ); pcVPS->m_sublayerDpbParamsPresentFlag = uiCode; - } - - pcVPS->m_dpbParameters.resize( pcVPS->m_numDpbParams ); - - for( int i = 0; i < pcVPS->m_numDpbParams; i++ ) - { -#if JVET_R0107_VPS_SIGNALING - if (!pcVPS->getAllLayersSameNumSublayersFlag()) + if( pcVPS->m_numDpbParams > 0 && pcVPS->getMaxSubLayers() > 1 ) { - READ_CODE(3, uiCode, "dpb_max_temporal_id[i]"); - pcVPS->m_dpbMaxTemporalId.push_back(uiCode); + READ_FLAG( uiCode, "vps_sublayer_dpb_params_present_flag" ); pcVPS->m_sublayerDpbParamsPresentFlag = uiCode; } - else + + pcVPS->m_dpbParameters.resize( pcVPS->m_numDpbParams ); + + for( int i = 0; i < pcVPS->m_numDpbParams; i++ ) { - pcVPS->m_dpbMaxTemporalId.push_back(pcVPS->getMaxSubLayers() - 1); - } +#if JVET_R0107_VPS_SIGNALING + if (!pcVPS->getAllLayersSameNumSublayersFlag()) + { + READ_CODE(3, uiCode, "dpb_max_temporal_id[i]"); + pcVPS->m_dpbMaxTemporalId.push_back(uiCode); + } + else + { + pcVPS->m_dpbMaxTemporalId.push_back(pcVPS->getMaxSubLayers() - 1); + } #else - if( pcVPS->getMaxSubLayers() == 1 ) - { - // When vps_max_sublayers_minus1 is equal to 0, the value of dpb_max_temporal_id[ i ] is inferred to be equal to 0. - pcVPS->m_dpbMaxTemporalId.push_back( 0 ); - } - else - { - if( pcVPS->getAllLayersSameNumSublayersFlag() ) + if( pcVPS->getMaxSubLayers() == 1 ) { - // When vps_max_sublayers_minus1 is greater than 0 and vps_all_layers_same_num_sublayers_flag is equal to 1, the value of dpb_max_temporal_id[ i ] is inferred to be equal to vps_max_sublayers_minus1. - pcVPS->m_dpbMaxTemporalId.push_back( pcVPS->getMaxSubLayers() - 1 ); + // When vps_max_sublayers_minus1 is equal to 0, the value of dpb_max_temporal_id[ i ] is inferred to be equal to 0. + pcVPS->m_dpbMaxTemporalId.push_back( 0 ); } else { - READ_CODE( 3, uiCode, "dpb_max_temporal_id[i]" ); pcVPS->m_dpbMaxTemporalId.push_back( uiCode ); + if( pcVPS->getAllLayersSameNumSublayersFlag() ) + { + // When vps_max_sublayers_minus1 is greater than 0 and vps_all_layers_same_num_sublayers_flag is equal to 1, the value of dpb_max_temporal_id[ i ] is inferred to be equal to vps_max_sublayers_minus1. + pcVPS->m_dpbMaxTemporalId.push_back( pcVPS->getMaxSubLayers() - 1 ); + } + else + { + READ_CODE( 3, uiCode, "dpb_max_temporal_id[i]" ); pcVPS->m_dpbMaxTemporalId.push_back( uiCode ); + } } - } #endif - for( int j = ( pcVPS->m_sublayerDpbParamsPresentFlag ? 0 : pcVPS->m_dpbMaxTemporalId[i] ); j <= pcVPS->m_dpbMaxTemporalId[i]; j++ ) - { - READ_UVLC( uiCode, "max_dec_pic_buffering_minus1[i]" ); pcVPS->m_dpbParameters[i].m_maxDecPicBuffering[j] = uiCode; - READ_UVLC( uiCode, "max_num_reorder_pics[i]" ); pcVPS->m_dpbParameters[i].m_numReorderPics[j] = uiCode; - READ_UVLC( uiCode, "max_latency_increase_plus1[i]" ); pcVPS->m_dpbParameters[i].m_maxLatencyIncreasePlus1[j] = uiCode; - } + for( int j = ( pcVPS->m_sublayerDpbParamsPresentFlag ? 0 : pcVPS->m_dpbMaxTemporalId[i] ); j <= pcVPS->m_dpbMaxTemporalId[i]; j++ ) + { + READ_UVLC( uiCode, "max_dec_pic_buffering_minus1[i]" ); pcVPS->m_dpbParameters[i].m_maxDecPicBuffering[j] = uiCode; + READ_UVLC( uiCode, "max_num_reorder_pics[i]" ); pcVPS->m_dpbParameters[i].m_numReorderPics[j] = uiCode; + READ_UVLC( uiCode, "max_latency_increase_plus1[i]" ); pcVPS->m_dpbParameters[i].m_maxLatencyIncreasePlus1[j] = uiCode; + } - for( int j = ( pcVPS->m_sublayerDpbParamsPresentFlag ? pcVPS->m_dpbMaxTemporalId[i] : 0 ); j < pcVPS->m_dpbMaxTemporalId[i]; j++ ) - { - // When max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to maxSubLayersMinus1 - 1, inclusive, due to subLayerInfoFlag being equal to 0, it is inferred to be equal to max_dec_pic_buffering_minus1[ maxSubLayersMinus1 ]. - pcVPS->m_dpbParameters[i].m_maxDecPicBuffering[j] = pcVPS->m_dpbParameters[i].m_maxDecPicBuffering[pcVPS->m_dpbMaxTemporalId[i]]; + for( int j = ( pcVPS->m_sublayerDpbParamsPresentFlag ? pcVPS->m_dpbMaxTemporalId[i] : 0 ); j < pcVPS->m_dpbMaxTemporalId[i]; j++ ) + { + // When max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to maxSubLayersMinus1 - 1, inclusive, due to subLayerInfoFlag being equal to 0, it is inferred to be equal to max_dec_pic_buffering_minus1[ maxSubLayersMinus1 ]. + pcVPS->m_dpbParameters[i].m_maxDecPicBuffering[j] = pcVPS->m_dpbParameters[i].m_maxDecPicBuffering[pcVPS->m_dpbMaxTemporalId[i]]; - // When max_num_reorder_pics[ i ] is not present for i in the range of 0 to maxSubLayersMinus1 - 1, inclusive, due to subLayerInfoFlag being equal to 0, it is inferred to be equal to max_num_reorder_pics[ maxSubLayersMinus1 ]. - pcVPS->m_dpbParameters[i].m_numReorderPics[j] = pcVPS->m_dpbParameters[i].m_numReorderPics[pcVPS->m_dpbMaxTemporalId[i]]; + // When max_num_reorder_pics[ i ] is not present for i in the range of 0 to maxSubLayersMinus1 - 1, inclusive, due to subLayerInfoFlag being equal to 0, it is inferred to be equal to max_num_reorder_pics[ maxSubLayersMinus1 ]. + pcVPS->m_dpbParameters[i].m_numReorderPics[j] = pcVPS->m_dpbParameters[i].m_numReorderPics[pcVPS->m_dpbMaxTemporalId[i]]; - // When max_latency_increase_plus1[ i ] is not present for i in the range of 0 to maxSubLayersMinus1 - 1, inclusive, due to subLayerInfoFlag being equal to 0, it is inferred to be equal to max_latency_increase_plus1[ maxSubLayersMinus1 ]. - pcVPS->m_dpbParameters[i].m_maxLatencyIncreasePlus1[j] = pcVPS->m_dpbParameters[i].m_maxLatencyIncreasePlus1[pcVPS->m_dpbMaxTemporalId[i]]; + // When max_latency_increase_plus1[ i ] is not present for i in the range of 0 to maxSubLayersMinus1 - 1, inclusive, due to subLayerInfoFlag being equal to 0, it is inferred to be equal to max_latency_increase_plus1[ maxSubLayersMinus1 ]. + pcVPS->m_dpbParameters[i].m_maxLatencyIncreasePlus1[j] = pcVPS->m_dpbParameters[i].m_maxLatencyIncreasePlus1[pcVPS->m_dpbMaxTemporalId[i]]; + } } - } #if JVET_R0099_DPB_HRD_PARAMETERS_SIGNALLING - for (int i = 1; i < pcVPS->m_numMultiLayeredOlss; i++) - { + for (int i = 1; i < pcVPS->m_numMultiLayeredOlss; i++) + { #else - for( int i = 0; i < pcVPS->getTotalNumOLSs(); i++ ) - { - if( pcVPS->m_numLayersInOls[i] > 1 ) + for( int i = 0; i < pcVPS->getTotalNumOLSs(); i++ ) { -#endif - READ_UVLC( uiCode, "ols_dpb_pic_width[i]" ); pcVPS->setOlsDpbPicWidth( i, uiCode ); - READ_UVLC( uiCode, "ols_dpb_pic_height[i]" ); pcVPS->setOlsDpbPicHeight( i, uiCode ); - if( pcVPS->m_numDpbParams > 1 ) + if( pcVPS->m_numLayersInOls[i] > 1 ) { - READ_UVLC( uiCode, "ols_dpb_params_idx[i]" ); pcVPS->setOlsDpbParamsIdx( i, uiCode ); - } +#endif + READ_UVLC( uiCode, "ols_dpb_pic_width[i]" ); pcVPS->setOlsDpbPicWidth( i, uiCode ); + READ_UVLC( uiCode, "ols_dpb_pic_height[i]" ); pcVPS->setOlsDpbPicHeight( i, uiCode ); + if( pcVPS->m_numDpbParams > 1 ) + { + READ_UVLC( uiCode, "ols_dpb_params_idx[i]" ); pcVPS->setOlsDpbParamsIdx( i, uiCode ); + } #if JVET_R0191_ASPECT3 #if JVET_R0099_DPB_HRD_PARAMETERS_SIGNALLING - else if (pcVPS->m_numDpbParams == 0) - { - pcVPS->setOlsDpbParamsIdx(i, 0); - } - else - { - pcVPS->setOlsDpbParamsIdx(i, i); - } + else if (pcVPS->m_numDpbParams == 0) + { + pcVPS->setOlsDpbParamsIdx(i, 0); + } + else + { + pcVPS->setOlsDpbParamsIdx(i, i); + } #else - else - { - pcVPS->setOlsDpbParamsIdx( i, 0 ); - } + else + { + pcVPS->setOlsDpbParamsIdx( i, 0 ); + } #endif - isDPBParamReferred[pcVPS->getOlsDpbParamsIdx(i)] = true; + isDPBParamReferred[pcVPS->getOlsDpbParamsIdx(i)] = true; #endif #if !JVET_R0099_DPB_HRD_PARAMETERS_SIGNALLING - } + } #endif - } + } #if JVET_R0191_ASPECT3 - for( int i = 0; i < pcVPS->m_numDpbParams; i++ ) - { - CHECK( !isDPBParamReferred[i],"Each dpb_parameters( ) syntax structure in the VPS shall be referred to by at least one value of vps_ols_dpb_params_idx[i] for i in the range of 0 to NumMultiLayerOlss - 1, inclusive"); + for( int i = 0; i < pcVPS->m_numDpbParams; i++ ) + { + CHECK( !isDPBParamReferred[i],"Each dpb_parameters( ) syntax structure in the VPS shall be referred to by at least one value of vps_ols_dpb_params_idx[i] for i in the range of 0 to NumMultiLayerOlss - 1, inclusive"); + } +#endif +#if JVET_R0185_OLS_DPB_CLEANUP } #endif + if (!pcVPS->getEachLayerIsAnOlsFlag()) { READ_FLAG(uiCode, "vps_general_hrd_params_present_flag"); pcVPS->setVPSGeneralHrdParamsPresentFlag(uiCode); diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 1d312e738f91793fcf59fa85ec97e55e37d20f23..6140112e3a601e5dcaa1169f315e2224d1c7c40d 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -1590,76 +1590,87 @@ void HLSWriter::codeVPS(const VPS* pcVPS) WRITE_CODE(pcVPS->getOlsPtlIdx(i), 8, "ols_ptl_idx"); } +#if JVET_R0185_OLS_DPB_CLEANUP + if( !pcVPS->getEachLayerIsAnOlsFlag() ) + { + WRITE_UVLC( pcVPS->m_numDpbParams - 1, "vps_num_dpb_params_minus1" ); + + if( pcVPS->getMaxSubLayers() > 1 ) +#else if( !pcVPS->getAllIndependentLayersFlag() ) { WRITE_UVLC( pcVPS->m_numDpbParams, "vps_num_dpb_params" ); } if( pcVPS->m_numDpbParams > 0 && pcVPS->getMaxSubLayers() > 1 ) - { - WRITE_FLAG( pcVPS->m_sublayerDpbParamsPresentFlag, "vps_sublayer_dpb_params_present_flag" ); - } - - for( int i = 0; i < pcVPS->m_numDpbParams; i++ ) - { -#if JVET_R0107_VPS_SIGNALING - if (!pcVPS->getAllLayersSameNumSublayersFlag()) +#endif { - WRITE_CODE(pcVPS->m_dpbMaxTemporalId[i], 3, "dpb_max_temporal_id[i]"); + WRITE_FLAG( pcVPS->m_sublayerDpbParamsPresentFlag, "vps_sublayer_dpb_params_present_flag" ); } - else + + for( int i = 0; i < pcVPS->m_numDpbParams; i++ ) { - CHECK(pcVPS->m_dpbMaxTemporalId[i] != pcVPS->getMaxSubLayers() - 1, "When vps_all_layers_same_num_sublayers_flag is equal to 1, the value of dpb_max_temporal_id[ i ] is inferred to be equal to vps_max_sublayers_minus1"); - } +#if JVET_R0107_VPS_SIGNALING + if (!pcVPS->getAllLayersSameNumSublayersFlag()) + { + WRITE_CODE(pcVPS->m_dpbMaxTemporalId[i], 3, "dpb_max_temporal_id[i]"); + } + else + { + CHECK(pcVPS->m_dpbMaxTemporalId[i] != pcVPS->getMaxSubLayers() - 1, "When vps_all_layers_same_num_sublayers_flag is equal to 1, the value of dpb_max_temporal_id[ i ] is inferred to be equal to vps_max_sublayers_minus1"); + } #else - if( pcVPS->getMaxSubLayers() == 1 ) - { - CHECK( pcVPS->m_dpbMaxTemporalId[i] != 0, "When vps_max_sublayers_minus1 is equal to 0, the value of dpb_max_temporal_id[ i ] is inferred to be equal to 0" ); - } - else - { - if( pcVPS->getAllLayersSameNumSublayersFlag() ) + if( pcVPS->getMaxSubLayers() == 1 ) { - CHECK( pcVPS->m_dpbMaxTemporalId[i] != pcVPS->getMaxSubLayers() - 1, "When vps_max_sublayers_minus1 is greater than 0 and vps_all_layers_same_num_sublayers_flag is equal to 1, the value of dpb_max_temporal_id[ i ] is inferred to be equal to vps_max_sublayers_minus1" ); + CHECK( pcVPS->m_dpbMaxTemporalId[i] != 0, "When vps_max_sublayers_minus1 is equal to 0, the value of dpb_max_temporal_id[ i ] is inferred to be equal to 0" ); } else { - WRITE_CODE( pcVPS->m_dpbMaxTemporalId[i], 3, "dpb_max_temporal_id[i]" ); + if( pcVPS->getAllLayersSameNumSublayersFlag() ) + { + CHECK( pcVPS->m_dpbMaxTemporalId[i] != pcVPS->getMaxSubLayers() - 1, "When vps_max_sublayers_minus1 is greater than 0 and vps_all_layers_same_num_sublayers_flag is equal to 1, the value of dpb_max_temporal_id[ i ] is inferred to be equal to vps_max_sublayers_minus1" ); + } + else + { + WRITE_CODE( pcVPS->m_dpbMaxTemporalId[i], 3, "dpb_max_temporal_id[i]" ); + } } - } #endif - for( int j = ( pcVPS->m_sublayerDpbParamsPresentFlag ? 0 : pcVPS->m_dpbMaxTemporalId[i] ); j <= pcVPS->m_dpbMaxTemporalId[i]; j++ ) - { - WRITE_UVLC( pcVPS->m_dpbParameters[i].m_maxDecPicBuffering[j], "max_dec_pic_buffering_minus1[i]" ); - WRITE_UVLC( pcVPS->m_dpbParameters[i].m_numReorderPics[j], "max_num_reorder_pics[i]" ); - WRITE_UVLC( pcVPS->m_dpbParameters[i].m_maxLatencyIncreasePlus1[j], "max_latency_increase_plus1[i]" ); + for( int j = ( pcVPS->m_sublayerDpbParamsPresentFlag ? 0 : pcVPS->m_dpbMaxTemporalId[i] ); j <= pcVPS->m_dpbMaxTemporalId[i]; j++ ) + { + WRITE_UVLC( pcVPS->m_dpbParameters[i].m_maxDecPicBuffering[j], "max_dec_pic_buffering_minus1[i]" ); + WRITE_UVLC( pcVPS->m_dpbParameters[i].m_numReorderPics[j], "max_num_reorder_pics[i]" ); + WRITE_UVLC( pcVPS->m_dpbParameters[i].m_maxLatencyIncreasePlus1[j], "max_latency_increase_plus1[i]" ); + } } - } #if JVET_R0099_DPB_HRD_PARAMETERS_SIGNALLING - for( int i = 1; i < pcVPS->m_numMultiLayeredOlss; i++) - { + for( int i = 1; i < pcVPS->m_numMultiLayeredOlss; i++) + { #else - for( int i = 0; i < pcVPS->getTotalNumOLSs(); i++ ) - { - if( pcVPS->m_numLayersInOls[i] > 1 ) + for( int i = 0; i < pcVPS->getTotalNumOLSs(); i++ ) { + if( pcVPS->m_numLayersInOls[i] > 1 ) + { #endif - WRITE_UVLC( pcVPS->getOlsDpbPicSize( i ).width, "ols_dpb_pic_width[i]" ); - WRITE_UVLC( pcVPS->getOlsDpbPicSize( i ).height, "ols_dpb_pic_height[i]" ); + WRITE_UVLC( pcVPS->getOlsDpbPicSize( i ).width, "ols_dpb_pic_width[i]" ); + WRITE_UVLC( pcVPS->getOlsDpbPicSize( i ).height, "ols_dpb_pic_height[i]" ); #if JVET_R0099_DPB_HRD_PARAMETERS_SIGNALLING - if( (pcVPS->m_numDpbParams > 1) && (pcVPS->m_numDpbParams != pcVPS->m_numMultiLayeredOlss) ) + if( (pcVPS->m_numDpbParams > 1) && (pcVPS->m_numDpbParams != pcVPS->m_numMultiLayeredOlss) ) #else - if( pcVPS->m_numDpbParams > 1 ) + if( pcVPS->m_numDpbParams > 1 ) #endif - { - WRITE_UVLC( pcVPS->getOlsDpbParamsIdx( i ), "ols_dpb_params_idx[i]" ); - } + { + WRITE_UVLC( pcVPS->getOlsDpbParamsIdx( i ), "ols_dpb_params_idx[i]" ); + } #if !JVET_R0099_DPB_HRD_PARAMETERS_SIGNALLING - } + } #endif + } +#if JVET_R0185_OLS_DPB_CLEANUP } +#endif if (!pcVPS->getEachLayerIsAnOlsFlag()) { WRITE_FLAG(pcVPS->getVPSGeneralHrdParamsPresentFlag(), "vps_general_hrd_params_present_flag");