diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index d72aae3197d1ad75d4a8a0a3a98ece67ffa37de0..fdebb6bcdcd39884552c3bbe06854ad6f7cb0530 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -918,6 +918,66 @@ void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& param } } +#if JVET_Q0795_CCALF + CcAlfFilterParam &filterParam = pSlice->m_ccAlfFilterParam; + // cleanup before copying + for ( int filterIdx = 0; filterIdx < MAX_NUM_CC_ALF_FILTERS; filterIdx++ ) + { + memset( filterParam.ccAlfCoeff[COMPONENT_Cb - 1][filterIdx], 0, sizeof(filterParam.ccAlfCoeff[COMPONENT_Cb - 1][filterIdx]) ); + memset( filterParam.ccAlfCoeff[COMPONENT_Cr - 1][filterIdx], 0, sizeof(filterParam.ccAlfCoeff[COMPONENT_Cr - 1][filterIdx]) ); + } + memset( filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cb - 1], false, sizeof(filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cb - 1]) ); + memset( filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cr - 1], false, sizeof(filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cr - 1]) ); + + if(pSlice->getTileGroupCcAlfCbEnabledFlag()) + { + int apsId = pSlice->getTileGroupCcAlfCbApsId(); + APS *aps = parameterSetManager.getAPS(apsId, ALF_APS); + if(aps) + { + apss[apsId] = aps; + if (false == parameterSetManager.activateAPS(apsId, ALF_APS)) + { + THROW("APS activation failed!"); + } + + CHECK( aps->getTemporalId() > pSlice->getTLayer(), "TemporalId shall be less than or equal to the TemporalId of the coded slice NAL unit" ); + //ToDO: APS NAL unit containing the APS RBSP shall have nuh_layer_id either equal to the nuh_layer_id of a coded slice NAL unit that referrs it, or equal to the nuh_layer_id of a direct dependent layer of the layer containing a coded slice NAL unit that referrs it. + + filterParam.ccAlfFilterCount[COMPONENT_Cb - 1] = aps->getCcAlfAPSParam().ccAlfFilterCount[COMPONENT_Cb - 1]; + for (int filterIdx=0; filterIdx < filterParam.ccAlfFilterCount[COMPONENT_Cb - 1]; filterIdx++ ) + { + filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cb - 1][filterIdx] = aps->getCcAlfAPSParam().ccAlfFilterIdxEnabled[COMPONENT_Cb - 1][filterIdx]; + memcpy(filterParam.ccAlfCoeff[COMPONENT_Cb - 1][filterIdx], aps->getCcAlfAPSParam().ccAlfCoeff[COMPONENT_Cb - 1][filterIdx], sizeof(aps->getCcAlfAPSParam().ccAlfCoeff[COMPONENT_Cb - 1][filterIdx])); + } + } + } + + if(pSlice->getTileGroupCcAlfCrEnabledFlag()) + { + int apsId = pSlice->getTileGroupCcAlfCrApsId(); + APS *aps = parameterSetManager.getAPS(apsId, ALF_APS); + if(aps) + { + apss[apsId] = aps; + if (false == parameterSetManager.activateAPS(apsId, ALF_APS)) + { + THROW("APS activation failed!"); + } + + CHECK( aps->getTemporalId() > pSlice->getTLayer(), "TemporalId shall be less than or equal to the TemporalId of the coded slice NAL unit" ); + //ToDO: APS NAL unit containing the APS RBSP shall have nuh_layer_id either equal to the nuh_layer_id of a coded slice NAL unit that referrs it, or equal to the nuh_layer_id of a direct dependent layer of the layer containing a coded slice NAL unit that referrs it. + + filterParam.ccAlfFilterCount[COMPONENT_Cr - 1] = aps->getCcAlfAPSParam().ccAlfFilterCount[COMPONENT_Cr - 1]; + for (int filterIdx=0; filterIdx < filterParam.ccAlfFilterCount[COMPONENT_Cr - 1]; filterIdx++ ) + { + filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cr - 1][filterIdx] = aps->getCcAlfAPSParam().ccAlfFilterIdxEnabled[COMPONENT_Cr - 1][filterIdx]; + memcpy(filterParam.ccAlfCoeff[COMPONENT_Cr - 1][filterIdx], aps->getCcAlfAPSParam().ccAlfCoeff[COMPONENT_Cr - 1][filterIdx], sizeof(aps->getCcAlfAPSParam().ccAlfCoeff[COMPONENT_Cr - 1][filterIdx])); + } + } + } +#endif + if (picHeader->getLmcsEnabledFlag() && lmcsAPS == nullptr) { lmcsAPS = parameterSetManager.getAPS(picHeader->getLmcsAPSId(), LMCS_APS); @@ -993,60 +1053,6 @@ void DecLib::xActivateParameterSets( const int layerId ) APS* scalinglistAPS = nullptr; activateAPS(&m_picHeader, m_apcSlicePilot, m_parameterSetManager, apss, lmcsAPS, scalinglistAPS); -#if JVET_Q0795_CCALF - CcAlfFilterParam &filterParam = m_apcSlicePilot->m_ccAlfFilterParam; - - // CC ALF Cb APS - int apsCcAlfCbId = m_apcSlicePilot->getTileGroupCcAlfCbApsId(); - APS *apsCcAlfCb = m_parameterSetManager.getAPS(apsCcAlfCbId, ALF_APS); - if (apsCcAlfCb) - { - m_parameterSetManager.clearAPSChangedFlag(apsCcAlfCbId, ALF_APS); - apss[apsCcAlfCbId] = apsCcAlfCb; - if (false == m_parameterSetManager.activateAPS(apsCcAlfCbId, ALF_APS)) - { - THROW("APS activation failed!"); - } - // cleanup before copying - for ( int filterIdx = 0; filterIdx < MAX_NUM_CC_ALF_FILTERS; filterIdx++ ) - { - memset( filterParam.ccAlfCoeff[COMPONENT_Cb - 1][filterIdx], 0, sizeof(filterParam.ccAlfCoeff[COMPONENT_Cb - 1][filterIdx]) ); - } - memset( filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cb - 1], false, sizeof(filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cb - 1]) ); - filterParam.ccAlfFilterCount[COMPONENT_Cb - 1] = apsCcAlfCb->getCcAlfAPSParam().ccAlfFilterCount[COMPONENT_Cb - 1]; - for (int filterIdx=0; filterIdx < filterParam.ccAlfFilterCount[COMPONENT_Cb - 1]; filterIdx++ ) - { - filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cb - 1][filterIdx] = apsCcAlfCb->getCcAlfAPSParam().ccAlfFilterIdxEnabled[COMPONENT_Cb - 1][filterIdx]; - memcpy(filterParam.ccAlfCoeff[COMPONENT_Cb - 1][filterIdx], apsCcAlfCb->getCcAlfAPSParam().ccAlfCoeff[COMPONENT_Cb - 1][filterIdx], sizeof(apsCcAlfCb->getCcAlfAPSParam().ccAlfCoeff[COMPONENT_Cb - 1][filterIdx])); - } - } - - // CC ALF Cr APS - int apsCcAlfCrId = m_apcSlicePilot->getTileGroupCcAlfCrApsId(); - APS *apsCcAlfCr = m_parameterSetManager.getAPS(apsCcAlfCrId, ALF_APS); - if (apsCcAlfCr) - { - m_parameterSetManager.clearAPSChangedFlag(apsCcAlfCrId, ALF_APS); - apss[apsCcAlfCrId] = apsCcAlfCr; - if (false == m_parameterSetManager.activateAPS(apsCcAlfCrId, ALF_APS)) - { - THROW("APS activation failed!"); - } - // cleanup before copying - for ( int filterIdx = 0; filterIdx < MAX_NUM_CC_ALF_FILTERS; filterIdx++ ) - { - memset( filterParam.ccAlfCoeff[COMPONENT_Cr - 1][filterIdx], 0, sizeof(filterParam.ccAlfCoeff[COMPONENT_Cr - 1][filterIdx]) ); - } - memset( filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cr - 1], false, sizeof(filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cr - 1]) ); - filterParam.ccAlfFilterCount[COMPONENT_Cr - 1] = apsCcAlfCr->getCcAlfAPSParam().ccAlfFilterCount[COMPONENT_Cr - 1]; - for (int filterIdx=0; filterIdx < filterParam.ccAlfFilterCount[COMPONENT_Cr - 1]; filterIdx++ ) - { - filterParam.ccAlfFilterIdxEnabled[COMPONENT_Cr - 1][filterIdx] = apsCcAlfCr->getCcAlfAPSParam().ccAlfFilterIdxEnabled[COMPONENT_Cr - 1][filterIdx]; - memcpy(filterParam.ccAlfCoeff[COMPONENT_Cr - 1][filterIdx], apsCcAlfCr->getCcAlfAPSParam().ccAlfCoeff[COMPONENT_Cr - 1][filterIdx], sizeof(apsCcAlfCr->getCcAlfAPSParam().ccAlfCoeff[COMPONENT_Cr - 1][filterIdx])); - } - } -#endif - xParsePrefixSEImessages(); #if RExt__HIGH_BIT_DEPTH_SUPPORT==0 diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 28265b0930857e414eeda1da1776c10f447302b3..68d4bdba0d209c2cc817d7c8d129be65ee6c6015 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -3131,6 +3131,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par if (sps->getCCALFEnabledFlag() && pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y)) { READ_FLAG(uiCode, "slice_cc_alf_cb_enabled_flag"); + pcSlice->setTileGroupCcAlfCbEnabledFlag(uiCode); filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] = (uiCode == 1) ? true : false; pcSlice->setTileGroupCcAlfCbApsId(-1); if (filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1]) @@ -3141,6 +3142,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } // Cr READ_FLAG(uiCode, "slice_cc_alf_cr_enabled_flag"); + pcSlice->setTileGroupCcAlfCrEnabledFlag(uiCode); filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] = (uiCode == 1) ? true : false; pcSlice->setTileGroupCcAlfCrApsId(-1); if (filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1])