From f4f2f4d4008f0cb77b608eabfe80fb5edd3aa536 Mon Sep 17 00:00:00 2001 From: Karl Sharman <karl.sharman@sony.com> Date: Sat, 25 Jul 2020 02:58:07 +0200 Subject: [PATCH] JVET-S0094 changes for chroma format and bit depth constraints Made changes to constraints for chroma format and bit depth, according to meeting notes on JVET-S0094. Also added encoder and decoder side checks. --- source/App/EncoderApp/EncApp.cpp | 4 ++++ source/App/EncoderApp/EncAppCfg.cpp | 11 +++++++++++ source/Lib/CommonLib/Slice.h | 5 +++++ source/Lib/CommonLib/TypeDef.h | 3 +++ source/Lib/DecoderLib/VLCReader.cpp | 7 +++++++ source/Lib/EncoderLib/VLCWriter.cpp | 5 +++++ 6 files changed, 35 insertions(+) diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 308adde92..a5f72c3f1 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -257,7 +257,11 @@ void EncApp::xInitLibCfg() #endif m_cEncLib.setOnePictureOnlyConstraintFlag ( m_onePictureOnlyConstraintFlag ); m_cEncLib.setIntraOnlyConstraintFlag ( m_intraConstraintFlag ); // NOTE: This setting is not used, and is confused with setIntraConstraintFlag +#if JVET_S0094_CHROMAFORMAT_BITDEPTH_CONSTRAINT + m_cEncLib.setMaxBitDepthConstraintIdc ( m_bitDepthConstraint ); +#else m_cEncLib.setMaxBitDepthConstraintIdc ( m_bitDepthConstraint - 8 ); +#endif m_cEncLib.setMaxChromaFormatConstraintIdc ( m_chromaFormatConstraint ); m_cEncLib.setFrameConstraintFlag ( m_bFrameConstraintFlag ); // NOTE: This setting is neither used nor setup, and is confused with setFrameOnlyConstraintFlag m_cEncLib.setNoQtbttDualTreeIntraConstraintFlag ( !m_dualTree ); diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 70f3c99b4..e0b25d8bb 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -1806,9 +1806,20 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } else // m_profile == Profile::NONE { +#if JVET_S0094_CHROMAFORMAT_BITDEPTH_CONSTRAINT + m_bitDepthConstraint = 16; // max value - unconstrained. +#else m_bitDepthConstraint = 8+15; // max value - unconstrained. +#endif } } +#if JVET_S0094_CHROMAFORMAT_BITDEPTH_CONSTRAINT + CHECK(m_bitDepthConstraint < m_internalBitDepth[CHANNEL_TYPE_LUMA], "MaxBitDepthConstraint setting does not allow the specified luma bit depth to be coded."); + CHECK(m_bitDepthConstraint < m_internalBitDepth[CHANNEL_TYPE_CHROMA], "MaxBitDepthConstraint setting does not allow the specified chroma bit depth to be coded."); + CHECK(m_chromaFormatConstraint < m_chromaFormatIDC, "MaxChromaFormatConstraint setting does not allow the specified chroma format to be coded."); + CHECK(m_chromaFormatConstraint >= NUM_CHROMA_FORMAT, "Bad value given for MaxChromaFormatConstraint setting.") + CHECK(m_bitDepthConstraint < 8 || m_bitDepthConstraint>16, "MaxBitDepthConstraint setting must be in the range 8 to 16 (inclusive)"); +#endif } diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 63e614221..903d222b2 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -326,8 +326,13 @@ public: , m_oneSubpicPerPicConstraintFlag(false) , m_frameOnlyConstraintFlag (false) , m_intraOnlyConstraintFlag (false) +#if JVET_S0094_CHROMAFORMAT_BITDEPTH_CONSTRAINT + , m_maxBitDepthConstraintIdc ( 16) + , m_maxChromaFormatConstraintIdc(CHROMA_444) +#else , m_maxBitDepthConstraintIdc ( 0) , m_maxChromaFormatConstraintIdc(CHROMA_420) +#endif , m_onePictureOnlyConstraintFlag (false) , m_lowerBitRateConstraintFlag (false ) diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 8081fc0c0..2ce67a655 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -68,6 +68,9 @@ #define JVET_S0074_SPS_REORDER 1 // JVET-S0074: aspect 1, rearrange some syntax elements in SPS #define JVET_S0234_ACT_CRS_FIX 1 // JVET-S0234: perform chroma residual scaling in RGB domain when ACT is on + +#define JVET_S0094_CHROMAFORMAT_BITDEPTH_CONSTRAINT 1 // JVET-S0094: 0 for constraint flags for chroma format and bit depth mean unconstrained, by coding these constraints as subtractive + #define JVET_S0132_HLS_REORDER 1 // Rearrange syntax elements in SPS and PPS #define JVET_S0221_NUM_VB_CHECK 1 // JVET_S0221: Constraints on the number of virtual boundaries diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 3ee87217a..4ed26653d 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -4481,8 +4481,15 @@ void HLSyntaxReader::parseConstraintInfo(ConstraintInfo *cinfo) READ_FLAG(symbol, "general_one_picture_only_constraint_flag" ); cinfo->setOnePictureOnlyConstraintFlag(symbol ? true : false); READ_FLAG(symbol, "intra_only_constraint_flag" ); cinfo->setIntraOnlyConstraintFlag(symbol ? true : false); +#if JVET_S0094_CHROMAFORMAT_BITDEPTH_CONSTRAINT + READ_CODE(4, symbol, "gci_sixteen_minus_max_bitdepth_constraint_idc" ); cinfo->setMaxBitDepthConstraintIdc(symbol>8 ? 16 : (16-symbol)); + CHECK(symbol>8, "gci_sixteen_minus_max_bitdepth_constraint_idc shall be in the range 0 to 8, inclusive"); + READ_CODE(2, symbol, "gci_three_minus_max_chroma_format_constraint_idc" ); cinfo->setMaxChromaFormatConstraintIdc((ChromaFormat)(3-symbol)); + printf("Decoded %d, %d\n", cinfo->getMaxBitDepthConstraintIdc(), cinfo->getMaxChromaFormatConstraintIdc()); +#else READ_CODE(4, symbol, "max_bitdepth_constraint_idc" ); cinfo->setMaxBitDepthConstraintIdc(symbol); READ_CODE(2, symbol, "max_chroma_format_constraint_idc" ); cinfo->setMaxChromaFormatConstraintIdc((ChromaFormat)symbol); +#endif READ_FLAG(symbol, "single_layer_constraint_flag"); cinfo->setSingleLayerConstraintFlag(symbol ? true : false); READ_FLAG(symbol, "all_layers_independent_constraint_flag"); cinfo->setAllLayersIndependentConstraintFlag(symbol ? true : false); #if !JVET_S0050_GCI diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 6f58f7311..0c981e8f9 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -2611,8 +2611,13 @@ void HLSWriter::codeConstraintInfo ( const ConstraintInfo* cinfo ) WRITE_FLAG(cinfo->getOnePictureOnlyConstraintFlag(), "general_one_picture_only_constraint_flag" ); WRITE_FLAG(cinfo->getIntraOnlyConstraintFlag(), "intra_only_constraint_flag" ); +#if JVET_S0094_CHROMAFORMAT_BITDEPTH_CONSTRAINT + WRITE_CODE(16-cinfo->getMaxBitDepthConstraintIdc(), 4, "gci_sixteen_minus_max_bitdepth_constraint_idc" ); + WRITE_CODE(3-cinfo->getMaxChromaFormatConstraintIdc(), 2, "gci_three_minus_max_chroma_format_constraint_idc" ); +#else WRITE_CODE(cinfo->getMaxBitDepthConstraintIdc(), 4, "max_bitdepth_constraint_idc" ); WRITE_CODE(cinfo->getMaxChromaFormatConstraintIdc(), 2, "max_chroma_format_constraint_idc" ); +#endif WRITE_FLAG(cinfo->getSingleLayerConstraintFlag(), "single_layer_constraint_flag"); WRITE_FLAG(cinfo->getAllLayersIndependentConstraintFlag(), "all_layers_independent_constraint_flag"); WRITE_FLAG(cinfo->getNoResChangeInClvsConstraintFlag(), "no_res_change_in_clvs_constraint_flag"); -- GitLab