diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp index 1e35ab2fa557689283adec96e6724e730d556044..629b23511b892ff9d5601b501b3d368b55daa73b 100644 --- a/source/App/DecoderApp/DecApp.cpp +++ b/source/App/DecoderApp/DecApp.cpp @@ -457,7 +457,7 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId ) if (!m_reconFileName.empty()) { - const Window &conf = pcPic->cs->pps->getConformanceWindow(); + const Window &conf = pcPic->getConformanceWindow(); const SPS* sps = pcPic->cs->sps; ChromaFormat chromaFormatIDC = sps->getChromaFormatIdc(); if( m_upscaledOutput ) @@ -581,7 +581,7 @@ void DecApp::xFlushOutput( PicList* pcListPic ) if (!m_reconFileName.empty()) { - const Window &conf = pcPic->cs->pps->getConformanceWindow(); + const Window &conf = pcPic->getConformanceWindow(); const SPS* sps = pcPic->cs->sps; ChromaFormat chromaFormatIDC = sps->getChromaFormatIdc(); if( m_upscaledOutput ) diff --git a/source/Lib/CommonLib/InterPrediction.cpp b/source/Lib/CommonLib/InterPrediction.cpp index 5ed8333002d80b4ae4e400646f4d59b200351e67..5a3f49a60d34e9c50b52e6ecba807aa4ab5b918c 100644 --- a/source/Lib/CommonLib/InterPrediction.cpp +++ b/source/Lib/CommonLib/InterPrediction.cpp @@ -860,7 +860,7 @@ void InterPrediction::xPredAffineBlk( const ComponentID& compID, const Predictio enablePROF &= !subblkMVSpreadOverLimit; const int profThres = 1 << (iBit + (m_isBi ? 1 : 0)); enablePROF &= !m_encOnly || pu.cu->slice->getCheckLDC() || iDMvHorX > profThres || iDMvHorY > profThres || iDMvVerX > profThres || iDMvVerY > profThres || iDMvHorX < -profThres || iDMvHorY < -profThres || iDMvVerX < -profThres || iDMvVerY < -profThres; - enablePROF &= pu.cs->pps->getPicWidthInLumaSamples() == refPic->cs->pps->getPicWidthInLumaSamples() && pu.cs->pps->getPicHeightInLumaSamples() == refPic->cs->pps->getPicHeightInLumaSamples(); + enablePROF &= pu.cs->pps->getPicWidthInLumaSamples() == refPic->getPicWidthInLumaSamples() && pu.cs->pps->getPicHeightInLumaSamples() == refPic->getPicHeightInLumaSamples(); if (compID == COMPONENT_Y) { @@ -1643,6 +1643,7 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu bioApplied = false; } } + bioApplied = PU::isRefPicSameSize( pu ) ? bioApplied : false; bool dmvrApplied = false; dmvrApplied = (pu.mvRefine) && PU::checkDMVRCondition(pu); if ((pu.lumaSize().width > MAX_BDOF_APPLICATION_REGION || pu.lumaSize().height > MAX_BDOF_APPLICATION_REGION) && pu.mergeType != MRG_TYPE_SUBPU_ATMVP && (bioApplied && !dmvrApplied)) @@ -2358,8 +2359,8 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, if( scaled ) { int row, col; - int refPicWidth = refPic->cs->pps->getPicWidthInLumaSamples(); - int refPicHeight = refPic->cs->pps->getPicHeightInLumaSamples(); + int refPicWidth = refPic->getPicWidthInLumaSamples(); + int refPicHeight = refPic->getPicHeightInLumaSamples(); #if JVET_P0088_P0353_RPR_FILTERS int xFilter = filterIndex; diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h index 9c8c5d24624356224e1b22dcd6d952ba84bdf4cc..e352118b9c7860092a3234e37a47457840544ff5 100644 --- a/source/Lib/CommonLib/Picture.h +++ b/source/Lib/CommonLib/Picture.h @@ -296,6 +296,19 @@ public: std::deque<Slice*> slices; SEIMessages SEIs; + uint32_t m_picWidthInLumaSamples; + uint32_t m_picHeightInLumaSamples; + Window m_conformanceWindow; + + void setPicWidthInLumaSamples( uint32_t u ) { m_picWidthInLumaSamples = u; } + uint32_t getPicWidthInLumaSamples() const { return m_picWidthInLumaSamples; } + void setPicHeightInLumaSamples( uint32_t u ) { m_picHeightInLumaSamples = u; } + uint32_t getPicHeightInLumaSamples() const { return m_picHeightInLumaSamples; } + + Window& getConformanceWindow() { return m_conformanceWindow; } + const Window& getConformanceWindow() const { return m_conformanceWindow; } + void setConformanceWindow( Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; } + void allocateNewSlice(); Slice *swapSliceObject(Slice * p, uint32_t i); void clearSliceBuffer(); diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 3b1548a506952bc866086713434fad873140e3b4..2890f78484c663b46ce661b2a791b09beb020ad3 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -2527,7 +2527,7 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], APS** apss, APS* lmcsAps, // reference resampling for the whole picture is not applied at decoder int xScale, yScale; - CU::getRprScaling( sps, pps, m_apcRefPicList[refList][rIdx]->slices[0]->getPPS(), xScale, yScale ); + CU::getRprScaling( sps, pps, m_apcRefPicList[refList][rIdx], xScale, yScale ); m_scalingRatio[refList][rIdx] = std::pair<int, int>( xScale, yScale ); if( m_scalingRatio[refList][rIdx] == SCALE_1X || isDecoder ) diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index ebc1aaed370b5188ee2286cc15e8d8fe83854095..646822421b4cb3d72295733c5b29ad5dd1aff855 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -1180,6 +1180,9 @@ private: int m_chromaCbQpOffset; int m_chromaCrQpOffset; +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + bool m_chromaJointCbCrQpOffsetPresentFlag; +#endif int m_chromaCbCrQpOffset; // Chroma QP Adjustments @@ -1293,6 +1296,11 @@ public: void setCuQpDeltaSubdiv( uint32_t u ) { m_cuQpDeltaSubdiv = u; } uint32_t getCuQpDeltaSubdiv() const { return m_cuQpDeltaSubdiv; } +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + bool getJointCbCrQpOffsetPresentFlag() const { return m_chromaJointCbCrQpOffsetPresentFlag; } + void setJointCbCrQpOffsetPresentFlag(bool b) { m_chromaJointCbCrQpOffsetPresentFlag = b; } +#endif + void setQpOffset(ComponentID compID, int i ) { if (compID==COMPONENT_Cb) diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 7f61ffc709714b35ab3b8e0a08becdbd371ce133..10929ac8ad36b60e35b2c2aa4182ee4d2f2f4454 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -52,8 +52,12 @@ #define JVET_P0615_CHROMAMODE_CLEANUP 1 // JVET-P0615: intra chroma mode coding cleanup +#define JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR 1 // JVET-P0667: removing signaling of qp offset table for JCCR, at SPS and PPS, when JCCR is disabled. + #define JVET_P0298_DISABLE_LEVELMAPPING_IN_BYPASS 1 // JVET-P0298: Disable level mapping in bypass mode +#define JVET_P0347_MAX_MTT_DEPTH_CONSTRAINT 1 // JVET-P0347: Max MTT Depth constraint + #define JVET_P0325_CHANGE_MERGE_CANDIDATE_ORDER 1 // JVET-P0325: reorder the spatial merge candidates #define JVET_P0578_MINIMUM_CU_SIZE_CONSTRAINT 1 // JVET-P0578: minimum CU size constraint diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 467d56ecbe11baabb1f5ca2b7a8317be905b69dc..2ca98de92fde125f01a050cdd88d5fc8b6488a95 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -100,14 +100,14 @@ void CS::setRefinedMotionField(CodingStructure &cs) } // CU tools -bool CU::getRprScaling( const SPS* sps, const PPS* curPPS, const PPS* refPPS, int& xScale, int& yScale ) +bool CU::getRprScaling( const SPS* sps, const PPS* curPPS, Picture* refPic, int& xScale, int& yScale ) { const Window& curConfWindow = curPPS->getConformanceWindow(); int curPicWidth = curPPS->getPicWidthInLumaSamples() - (curConfWindow.getWindowLeftOffset() + curConfWindow.getWindowRightOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); int curPicHeight = curPPS->getPicHeightInLumaSamples() - (curConfWindow.getWindowTopOffset() + curConfWindow.getWindowBottomOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); - const Window& refConfWindow = refPPS->getConformanceWindow(); - int refPicWidth = refPPS->getPicWidthInLumaSamples() - (refConfWindow.getWindowLeftOffset() + refConfWindow.getWindowRightOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); - int refPicHeight = refPPS->getPicHeightInLumaSamples() - (refConfWindow.getWindowTopOffset() + refConfWindow.getWindowBottomOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); + const Window& refConfWindow = refPic->getConformanceWindow(); + int refPicWidth = refPic->getPicWidthInLumaSamples() - (refConfWindow.getWindowLeftOffset() + refConfWindow.getWindowRightOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); + int refPicHeight = refPic->getPicHeightInLumaSamples() - (refConfWindow.getWindowTopOffset() + refConfWindow.getWindowBottomOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); xScale = ( ( refPicWidth << SCALE_RATIO_BITS ) + ( curPicWidth >> 1 ) ) / curPicWidth; yScale = ( ( refPicHeight << SCALE_RATIO_BITS ) + ( curPicHeight >> 1 ) ) / curPicHeight; @@ -3920,16 +3920,16 @@ bool PU::isRefPicSameSize( const PredictionUnit& pu ) if( pu.refIdx[0] >= 0 ) { - int refPicWidth = pu.cu->slice->getRefPic( REF_PIC_LIST_0, pu.refIdx[0] )->unscaledPic->cs->pps->getPicWidthInLumaSamples(); - int refPicHeight = pu.cu->slice->getRefPic( REF_PIC_LIST_0, pu.refIdx[0] )->unscaledPic->cs->pps->getPicHeightInLumaSamples(); + int refPicWidth = pu.cu->slice->getRefPic( REF_PIC_LIST_0, pu.refIdx[0] )->getPicWidthInLumaSamples(); + int refPicHeight = pu.cu->slice->getRefPic( REF_PIC_LIST_0, pu.refIdx[0] )->getPicHeightInLumaSamples(); samePicSize = refPicWidth == curPicWidth && refPicHeight == curPicHeight; } if( pu.refIdx[1] >= 0 ) { - int refPicWidth = pu.cu->slice->getRefPic( REF_PIC_LIST_1, pu.refIdx[1] )->unscaledPic->cs->pps->getPicWidthInLumaSamples(); - int refPicHeight = pu.cu->slice->getRefPic( REF_PIC_LIST_1, pu.refIdx[1] )->unscaledPic->cs->pps->getPicHeightInLumaSamples(); + int refPicWidth = pu.cu->slice->getRefPic( REF_PIC_LIST_1, pu.refIdx[1] )->getPicWidthInLumaSamples(); + int refPicHeight = pu.cu->slice->getRefPic( REF_PIC_LIST_1, pu.refIdx[1] )->getPicHeightInLumaSamples(); samePicSize = samePicSize && ( refPicWidth == curPicWidth && refPicHeight == curPicHeight ); } diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h index d9445e937802f71f9d4276a673d7d4d17376dff3..a1c766ff382a35bb7b2a6ef16892523d363d5a5d 100644 --- a/source/Lib/CommonLib/UnitTools.h +++ b/source/Lib/CommonLib/UnitTools.h @@ -119,7 +119,7 @@ namespace CU uint8_t numSbtModeRdo (uint8_t sbtAllowed); bool isSbtMode (const uint8_t sbtInfo); bool isSameSbtSize (const uint8_t sbtInfo1, const uint8_t sbtInfo2); - bool getRprScaling ( const SPS* sps, const PPS* curPPS, const PPS* refPPS, int& xScale, int& yScale ); + bool getRprScaling ( const SPS* sps, const PPS* curPPS, Picture* refPic, int& xScale, int& yScale ); } // PU tools namespace PU diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index e8f2871708dea749dee60c835f271db78ce6c602..58b680f472034e721f325330d8228222af96004f 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -922,6 +922,12 @@ void DecLib::xActivateParameterSets() m_pcPic->cs->slice = pSlice; m_pcPic->cs->sps = sps; m_pcPic->cs->pps = pps; + + Window confWin = pps->getConformanceWindow( ); + m_pcPic->setPicWidthInLumaSamples( pps->getPicWidthInLumaSamples() ); + m_pcPic->setPicHeightInLumaSamples( pps->getPicHeightInLumaSamples() ); + m_pcPic->setConformanceWindow( confWin ); + memcpy(m_pcPic->cs->alfApss, apss, sizeof(m_pcPic->cs->alfApss)); m_pcPic->cs->lmcsAps = lmcsAPS; m_pcPic->cs->scalinglistAps = scalinglistAPS; diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 09c625f2662a33307d7fd68813e92234e789587f..d11de7ca177f051d117bfdf3105d7f034b6f9a79 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -453,8 +453,23 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana CHECK( pcPPS->getQpOffset(COMPONENT_Cr) < -12, "Invalid Cr QP offset" ); CHECK( pcPPS->getQpOffset(COMPONENT_Cr) > 12, "Invalid Cr QP offset" ); +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + READ_FLAG(uiCode, "pps_joint_cbcr_qp_offset_present_flag"); + pcPPS->setJointCbCrQpOffsetPresentFlag(uiCode ? true : false); + + if (pcPPS->getJointCbCrQpOffsetPresentFlag()) + { + READ_SVLC(iCode, "pps_joint_cbcr_qp_offset"); + } + else + { + iCode = 0; + } +#else READ_SVLC( iCode, "pps_joint_cbcr_qp_offset"); +#endif pcPPS->setQpOffset(JOINT_CbCr, iCode); + CHECK( pcPPS->getQpOffset(JOINT_CbCr) < -12, "Invalid CbCr QP offset" ); CHECK( pcPPS->getQpOffset(JOINT_CbCr) > 12, "Invalid CbCr QP offset" ); @@ -485,7 +500,18 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana CHECK(cbOffset < -12 || cbOffset > 12, "Invalid chroma QP offset"); READ_SVLC(crOffset, "cr_qp_offset_list[i]"); CHECK(crOffset < -12 || crOffset > 12, "Invalid chroma QP offset"); +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + if (pcPPS->getJointCbCrQpOffsetPresentFlag()) + { + READ_SVLC(jointCbCrOffset, "joint_cbcr_qp_offset_list[i]"); + } + else + { + jointCbCrOffset = 0; + } +#else READ_SVLC(jointCbCrOffset, "joint_cbcr_qp_offset_list[i]"); +#endif CHECK(jointCbCrOffset < -12 || jointCbCrOffset > 12, "Invalid chroma QP offset"); // table uses +1 for index (see comment inside the function) pcPPS->setChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1, cbOffset, crOffset, jointCbCrOffset); @@ -1282,7 +1308,13 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) unsigned minQtLog2SizeInterY = uiCode + pcSPS->getLog2MinCodingBlockSize(); minQT[1] = 1 << minQtLog2SizeInterY; READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_inter_slice"); maxBTD[1] = uiCode; +#if JVET_P0347_MAX_MTT_DEPTH_CONSTRAINT + CHECK(uiCode > 2*(ctbLog2SizeY - log2MinCUSize), "sps_max_mtt_hierarchy_depth_inter_slice shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); +#endif READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_intra_slice_luma"); maxBTD[0] = uiCode; +#if JVET_P0347_MAX_MTT_DEPTH_CONSTRAINT + CHECK(uiCode > 2 * (ctbLog2SizeY - log2MinCUSize), "sps_max_mtt_hierarchy_depth_intra_slice_luma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); +#endif maxTTSize[0] = maxBTSize[0] = minQT[0]; if (maxBTD[0] != 0) @@ -1304,6 +1336,9 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_intra_slice_chroma"); minQT[2] = 1 << (uiCode + pcSPS->getLog2MinCodingBlockSize()); READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_intra_slice_chroma"); maxBTD[2] = uiCode; +#if JVET_P0347_MAX_MTT_DEPTH_CONSTRAINT + CHECK(uiCode > 2 * (ctbLog2SizeY - log2MinCUSize), "sps_max_mtt_hierarchy_depth_intra_slice_chroma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); +#endif maxTTSize[2] = maxBTSize[2] = minQT[2]; if (maxBTD[2] != 0) { @@ -1320,11 +1355,19 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG( uiCode, "sps_max_luma_transform_size_64_flag"); pcSPS->setLog2MaxTbSize( (uiCode ? 1 : 0) + 5 ); +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + READ_FLAG(uiCode, "sps_joint_cbcr_enabled_flag"); pcSPS->setJointCbCrEnabledFlag(uiCode ? true : false); +#endif if (pcSPS->getChromaFormatIdc() != CHROMA_400) { ChromaQpMappingTableParams chromaQpMappingTableParams; READ_FLAG(uiCode, "same_qp_table_for_chroma"); chromaQpMappingTableParams.setSameCQPTableForAllChromaFlag(uiCode); +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + int numQPTables = chromaQpMappingTableParams.getSameCQPTableForAllChromaFlag() ? 1 : (pcSPS->getJointCbCrEnabledFlag() ? 3 : 2); + for (int i = 0; i < numQPTables; i++) +#else for (int i = 0; i < (chromaQpMappingTableParams.getSameCQPTableForAllChromaFlag() ? 1 : 3); i++) +#endif { READ_UVLC(uiCode, "num_points_in_qp_table_minus1"); chromaQpMappingTableParams.setNumPtsInCQPTableMinus1(i,uiCode); std::vector<int> deltaQpInValMinus1(chromaQpMappingTableParams.getNumPtsInCQPTableMinus1(i) + 1); @@ -1341,6 +1384,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) pcSPS->derivedChromaQPMappingTables(); } + READ_FLAG( uiCode, "sps_sao_enabled_flag" ); pcSPS->setSAOEnabledFlag ( uiCode ? true : false ); READ_FLAG( uiCode, "sps_alf_enabled_flag" ); pcSPS->setALFEnabledFlag ( uiCode ? true : false ); @@ -1349,7 +1393,9 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { READ_FLAG(uiCode, "sps_bdpcm_enabled_flag"); pcSPS->setBDPCMEnabledFlag(uiCode ? true : false); } +#if !JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR READ_FLAG( uiCode, "sps_joint_cbcr_enabled_flag"); pcSPS->setJointCbCrEnabledFlag (uiCode ? true : false); +#endif READ_FLAG(uiCode, "sps_ref_wraparound_enabled_flag"); pcSPS->setWrapAroundEnabledFlag( uiCode ? true : false ); @@ -1994,6 +2040,9 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para { READ_UVLC(uiCode, "slice_log2_diff_min_qt_min_cb"); pcSlice->setMinQTSize(1 << (uiCode + sps->getLog2MinCodingBlockSize())); READ_UVLC(uiCode, "slice_max_mtt_hierarchy_depth_luma"); pcSlice->setMaxMTTHierarchyDepth(uiCode); +#if JVET_P0347_MAX_MTT_DEPTH_CONSTRAINT + CHECK(uiCode > 2 * (floorLog2(sps->getCTUSize()) - sps->getLog2MinCodingBlockSize()), "slice_max_mtt_hierarchy_depth_luma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); +#endif if (pcSlice->getMaxMTTHierarchyDepth() != 0) { READ_UVLC(uiCode, "slice_log2_diff_max_bt_min_qt"); pcSlice->setMaxBTSize(pcSlice->getMinQTSize() << uiCode); @@ -2010,6 +2059,9 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para { READ_UVLC(uiCode, "slice_log2_diff_min_qt_min_cb_chroma"); pcSlice->setMinQTSizeIChroma(1 << (uiCode + sps->getLog2MinCodingBlockSize())); READ_UVLC(uiCode, "slice_max_mtt_hierarchy_depth_chroma"); pcSlice->setMaxMTTHierarchyDepthIChroma(uiCode); +#if JVET_P0347_MAX_MTT_DEPTH_CONSTRAINT + CHECK(uiCode > 2 * (floorLog2(sps->getCTUSize()) - sps->getLog2MinCodingBlockSize()), "slice_max_mtt_hierarchy_depth_chroma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); +#endif if (pcSlice->getMaxMTTHierarchyDepthIChroma() != 0) { READ_UVLC(uiCode, "slice_log2_diff_max_bt_min_qt_chroma"); pcSlice->setMaxBTSizeIChroma(pcSlice->getMinQTSizeIChroma() << uiCode); diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index cfd0e5e35a1ecd6ce2d4a70da830dd78329e5280..27c9b67906105105f88ffba91e4040d623f99cb9 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -558,6 +558,11 @@ void EncLib::encode( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYuvTru const PPS *pps = m_ppsMap.getPS(2); const SPS *sps = m_spsMap.getPS(pps->getSPSId()); + Window confWin = pps->getConformanceWindow( ); + picCurr->setPicWidthInLumaSamples( pps->getPicWidthInLumaSamples() ); + picCurr->setPicHeightInLumaSamples( pps->getPicHeightInLumaSamples() ); + picCurr->setConformanceWindow( confWin ); + picCurr->M_BUFS(0, PIC_ORIGINAL).copyFrom(m_cGOPEncoder.getPicBg()->getRecoBuf()); picCurr->finalInit( *sps, *pps, m_apss, m_lmcsAPS, m_scalinglistAPS ); picCurr->poc = m_iPOCLast - 1; @@ -619,6 +624,11 @@ void EncLib::encode( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYuvTru const PPS *pPPS=(ppsID<0) ? m_ppsMap.getFirstPS() : m_ppsMap.getPS(ppsID); const SPS *pSPS=m_spsMap.getPS(pPPS->getSPSId()); + Window confWin = pPPS->getConformanceWindow( ); + pcPicCurr->setPicWidthInLumaSamples( pPPS->getPicWidthInLumaSamples() ); + pcPicCurr->setPicHeightInLumaSamples( pPPS->getPicHeightInLumaSamples() ); + pcPicCurr->setConformanceWindow( confWin ); + if( m_rprEnabled ) { pcPicCurr->M_BUFS( 0, PIC_ORIGINAL_INPUT ).getBuf( COMPONENT_Y ).copyFrom( pcPicYuvOrg->getBuf( COMPONENT_Y ) ); @@ -740,6 +750,11 @@ void EncLib::encode( bool flush, PelStorage* pcPicYuvOrg, PelStorage* pcPicYuvTr int ppsID=-1; // Use default PPS ID const PPS *pPPS=(ppsID<0) ? m_ppsMap.getFirstPS() : m_ppsMap.getPS(ppsID); const SPS *pSPS=m_spsMap.getPS(pPPS->getSPSId()); + Window confWin = pPPS->getConformanceWindow( ); + pcField->setPicWidthInLumaSamples( pPPS->getPicWidthInLumaSamples() ); + pcField->setPicHeightInLumaSamples( pPPS->getPicHeightInLumaSamples() ); + pcField->setConformanceWindow( confWin ); + pcField->finalInit( *pSPS, *pPPS, m_apss, m_lmcsAPS, m_scalinglistAPS ); } @@ -1028,6 +1043,11 @@ void EncLib::xInitSPS(SPS &sps) #if JVET_P0578_MINIMUM_CU_SIZE_CONSTRAINT CHECK(log2MinCUSize > std::min(6, floorLog2(sps.getMaxCUWidth())), "log2_min_luma_coding_block_size_minus2 shall be in the range of 0 to min (4, log2_ctu_size - 2)"); #endif +#if JVET_P0347_MAX_MTT_DEPTH_CONSTRAINT + CHECK(m_uiMaxMTTHierarchyDepth > 2 * (floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize()), "sps_max_mtt_hierarchy_depth_inter_slice shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); + CHECK(m_uiMaxMTTHierarchyDepthI > 2 * (floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize()), "sps_max_mtt_hierarchy_depth_intra_slice_luma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); + CHECK(m_uiMaxMTTHierarchyDepthIChroma > 2 * (floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize()), "sps_max_mtt_hierarchy_depth_intra_slice_chroma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); +#endif sps.setTransformSkipEnabledFlag(m_useTransformSkip); sps.setBDPCMEnabledFlag(m_useBDPCM); @@ -1226,6 +1246,17 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) pps.setPicInitQPMinus26( std::min( maxDQP, std::max( minDQP, baseQp ) )); } +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + if (sps.getJointCbCrEnabledFlag() == false || getChromaFormatIdc() == CHROMA_400) + { + pps.setJointCbCrQpOffsetPresentFlag(false); + } + else + { + pps.setJointCbCrQpOffsetPresentFlag(true); + } +#endif + #if ER_CHROMA_QP_WCG_PPS if (getWCGChromaQPControl().isEnabled()) { @@ -1237,14 +1268,28 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) const int crQP =(int)(dcrQP + ( dcrQP < 0 ? -0.5 : 0.5) ); pps.setQpOffset(COMPONENT_Cb, Clip3( -12, 12, min(0, cbQP) + m_chromaCbQpOffset )); pps.setQpOffset(COMPONENT_Cr, Clip3( -12, 12, min(0, crQP) + m_chromaCrQpOffset)); +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + if(pps.getJointCbCrQpOffsetPresentFlag()) + pps.setQpOffset(JOINT_CbCr, Clip3(-12, 12, (min(0, cbQP) + min(0, crQP)) / 2 + m_chromaCbCrQpOffset)); + else + pps.setQpOffset(JOINT_CbCr, 0); +#else pps.setQpOffset(JOINT_CbCr, Clip3( -12, 12, ( min(0, cbQP) + min(0, crQP) ) / 2 + m_chromaCbCrQpOffset)); +#endif } else { #endif pps.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset ); pps.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset ); +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + if (pps.getJointCbCrQpOffsetPresentFlag()) + pps.setQpOffset(JOINT_CbCr, m_chromaCbCrQpOffset); + else + pps.setQpOffset(JOINT_CbCr, 0); +#else pps.setQpOffset(JOINT_CbCr, m_chromaCbCrQpOffset ); +#endif #if ER_CHROMA_QP_WCG_PPS } #endif diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 280c6a9e6a770402cec0d44644e205af0166b815..05025487d24b1cc1cdd131c902ec0d1f042029b6 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -258,7 +258,19 @@ void HLSWriter::codePPS( const PPS* pcPPS, const SPS* pcSPS ) WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset" ); WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cr), "pps_cr_qp_offset" ); +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + if (pcSPS->getJointCbCrEnabledFlag() == false || pcSPS->getChromaFormatIdc() == CHROMA_400) + { + CHECK(pcPPS->getJointCbCrQpOffsetPresentFlag(), "pps_jcbcr_qp_offset_present_flag should be false"); + } + WRITE_FLAG(pcPPS->getJointCbCrQpOffsetPresentFlag() ? 1 : 0, "pps_joint_cbcr_qp_offset_present_flag"); + if (pcPPS->getJointCbCrQpOffsetPresentFlag()) + { + WRITE_SVLC(pcPPS->getQpOffset(JOINT_CbCr), "pps_joint_cbcr_qp_offset"); + } +#else WRITE_SVLC( pcPPS->getQpOffset(JOINT_CbCr), "pps_joint_cbcr_qp_offset" ); +#endif WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0, "pps_slice_chroma_qp_offsets_present_flag" ); @@ -272,7 +284,14 @@ void HLSWriter::codePPS( const PPS* pcPPS, const SPS* pcSPS ) { WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "cb_qp_offset_list[i]"); WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "cr_qp_offset_list[i]"); +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + if (pcPPS->getJointCbCrQpOffsetPresentFlag()) + { + WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1).u.comp.JointCbCrOffset, "joint_cbcr_qp_offset_list[i]"); + } +#else WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1).u.comp.JointCbCrOffset, "joint_cbcr_qp_offset_list[i]"); +#endif } } @@ -787,11 +806,19 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG( (pcSPS->getLog2MaxTbSize() - 5) ? 1 : 0, "sps_max_luma_transform_size_64_flag" ); +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + WRITE_FLAG(pcSPS->getJointCbCrEnabledFlag(), "sps_joint_cbcr_enabled_flag"); +#endif if (pcSPS->getChromaFormatIdc() != CHROMA_400) { const ChromaQpMappingTable& chromaQpMappingTable = pcSPS->getChromaQpMappingTable(); WRITE_FLAG(chromaQpMappingTable.getSameCQPTableForAllChromaFlag(), "same_qp_table_for_chroma"); +#if JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR + int numQPTables = chromaQpMappingTable.getSameCQPTableForAllChromaFlag() ? 1 : (pcSPS->getJointCbCrEnabledFlag() ? 3 : 2); + for (int i = 0; i < numQPTables; i++) +#else for (int i = 0; i < (chromaQpMappingTable.getSameCQPTableForAllChromaFlag() ? 1 : 3); i++) +#endif { WRITE_UVLC(chromaQpMappingTable.getNumPtsInCQPTableMinus1(i), "num_points_in_qp_table_minus1"); @@ -815,7 +842,9 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) { CHECK(pcSPS->getBDPCMEnabledFlag(), "BDPCM cannot be used when transform skip is disabled"); } +#if !JVET_P0667_QP_OFFSET_TABLE_SIGNALING_JCCR WRITE_FLAG( pcSPS->getJointCbCrEnabledFlag(), "sps_joint_cbcr_enabled_flag"); +#endif WRITE_FLAG( pcSPS->getWrapAroundEnabledFlag() ? 1 : 0, "sps_ref_wraparound_enabled_flag" ); if( pcSPS->getWrapAroundEnabledFlag() )