diff --git a/source/Lib/CommonLib/Quant.cpp b/source/Lib/CommonLib/Quant.cpp index a34a4faf019b8f2259d61db02f99a2484b77cf4d..9c3e68f5a7cc00778bc3679b4e27d4e0fc5d9ce4 100644 --- a/source/Lib/CommonLib/Quant.cpp +++ b/source/Lib/CommonLib/Quant.cpp @@ -155,12 +155,12 @@ QpParam::QpParam(const TransformUnit& tu, const ComponentID &compIDX, const int #if JVET_O1168_CU_CHROMA_QP_OFFSET #if JVET_O0105_ICT - chromaQpOffset += tu.cs->pps->getPpsRangeExtension().getChromaQpOffsetListEntry( tu.cu->chromaQpAdj ).u.offset[int( useJQP ? JOINT_CbCr : compID ) - 1]; + chromaQpOffset += tu.cs->pps->getChromaQpOffsetListEntry( tu.cu->chromaQpAdj ).u.offset[int( useJQP ? JOINT_CbCr : compID ) - 1]; #else - chromaQpOffset += tu.cs->pps->getPpsRangeExtension().getChromaQpOffsetListEntry( tu.cu->chromaQpAdj ).u.offset[int( tu.jointCbCr ? JOINT_CbCr : compID ) - 1]; + chromaQpOffset += tu.cs->pps->getChromaQpOffsetListEntry( tu.cu->chromaQpAdj ).u.offset[int( tu.jointCbCr ? JOINT_CbCr : compID ) - 1]; #endif #else - chromaQpOffset += tu.cs->pps->getPpsRangeExtension().getChromaQpOffsetListEntry( tu.cu->chromaQpAdj ).u.offset[int( compID ) - 1]; + chromaQpOffset += tu.cs->pps->getChromaQpOffsetListEntry( tu.cu->chromaQpAdj ).u.offset[int( compID ) - 1]; #endif } diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 0478c09e855176cd17b6fc1a4c0ae855b8f59975..19d624d032b8031a57209916e031fd33afa39355 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -1608,16 +1608,8 @@ void ChromaQpMappingTable::derivedChromaQPMappingTables() PPSRExt::PPSRExt() : m_crossComponentPredictionEnabledFlag(false) -, m_cuChromaQpOffsetSubdiv (0) -, m_chromaQpOffsetListLen (0) -// m_ChromaQpAdjTableIncludingNullEntry initialized below // m_log2SaoOffsetScale initialized below { - m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CbOffset = 0; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0. This is initialised here and never subsequently changed. - m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CrOffset = 0; -#if JVET_O1168_CU_CHROMA_QP_OFFSET - m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.JointCbCrOffset = 0; -#endif for(int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) { m_log2SaoOffsetScale[ch] = 0; @@ -1635,6 +1627,8 @@ PPS::PPS() , m_chromaCbQpOffset (0) , m_chromaCrQpOffset (0) , m_chromaCbCrQpOffset (0) +, m_cuChromaQpOffsetSubdiv (0) +, m_chromaQpOffsetListLen (0) , m_numRefIdxL0DefaultActive (1) , m_numRefIdxL1DefaultActive (1) , m_rpl1IdxPresentFlag (false) @@ -1687,6 +1681,11 @@ PPS::PPS() , m_ppsRangeExtension () , pcv (NULL) { + m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CbOffset = 0; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0. This is initialised here and never subsequently changed. + m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CrOffset = 0; +#if JVET_O1168_CU_CHROMA_QP_OFFSET + m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.JointCbCrOffset = 0; +#endif ::memset(m_virtualBoundariesPosX, 0, sizeof(m_virtualBoundariesPosX)); ::memset(m_virtualBoundariesPosY, 0, sizeof(m_virtualBoundariesPosY)); } diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 5cf7c332069b328a99ca807f75c305c281792a03..d517b36999e24b13f9b41ac55c5efb6739401298 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -1204,11 +1204,6 @@ class PPSRExt // Names aligned to text specification private: bool m_crossComponentPredictionEnabledFlag; - // Chroma QP Adjustments - int m_cuChromaQpOffsetSubdiv; - int m_chromaQpOffsetListLen; // size (excludes the null entry used in the following array). - ChromaQpAdj m_ChromaQpAdjTableIncludingNullEntry[1+MAX_QP_OFFSET_LIST_SIZE]; //!< Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise - uint32_t m_log2SaoOffsetScale[MAX_NUM_CHANNEL_TYPE]; public: @@ -1217,7 +1212,6 @@ public: bool settingsDifferFromDefaults(const bool bTransformSkipEnabledFlag) const { return (getCrossComponentPredictionEnabledFlag() ) - || (getChromaQpOffsetListEnabledFlag() ) || (getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA) !=0 ) || (getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA) !=0 ); } @@ -1225,35 +1219,6 @@ public: bool getCrossComponentPredictionEnabledFlag() const { return m_crossComponentPredictionEnabledFlag; } void setCrossComponentPredictionEnabledFlag(bool value) { m_crossComponentPredictionEnabledFlag = value; } - void clearChromaQpOffsetList() { m_chromaQpOffsetListLen = 0; } - - uint32_t getCuChromaQpOffsetSubdiv () const { return m_cuChromaQpOffsetSubdiv; } - void setCuChromaQpOffsetSubdiv ( uint32_t u ) { m_cuChromaQpOffsetSubdiv = u; } - - bool getChromaQpOffsetListEnabledFlag() const { return getChromaQpOffsetListLen()>0; } - int getChromaQpOffsetListLen() const { return m_chromaQpOffsetListLen; } - - const ChromaQpAdj& getChromaQpOffsetListEntry( int cuChromaQpOffsetIdxPlus1 ) const - { - CHECK(cuChromaQpOffsetIdxPlus1 >= m_chromaQpOffsetListLen+1, "Invalid chroma QP offset"); - return m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1]; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise - } - -#if JVET_O1168_CU_CHROMA_QP_OFFSET - void setChromaQpOffsetListEntry( int cuChromaQpOffsetIdxPlus1, int cbOffset, int crOffset, int jointCbCrOffset ) -#else - void setChromaQpOffsetListEntry( int cuChromaQpOffsetIdxPlus1, int cbOffset, int crOffset ) -#endif - { - CHECK(cuChromaQpOffsetIdxPlus1 == 0 || cuChromaQpOffsetIdxPlus1 > MAX_QP_OFFSET_LIST_SIZE, "Invalid chroma QP offset"); - m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.CbOffset = cbOffset; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise - m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.CrOffset = crOffset; -#if JVET_O1168_CU_CHROMA_QP_OFFSET - m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.JointCbCrOffset = jointCbCrOffset; -#endif - m_chromaQpOffsetListLen = std::max(m_chromaQpOffsetListLen, cuChromaQpOffsetIdxPlus1); - } - // Now: getPpsRangeExtension().getLog2SaoOffsetScale and getPpsRangeExtension().setLog2SaoOffsetScale uint32_t getLog2SaoOffsetScale(ChannelType type) const { return m_log2SaoOffsetScale[type]; } void setLog2SaoOffsetScale(ChannelType type, uint32_t uiBitShift) { m_log2SaoOffsetScale[type] = uiBitShift; } @@ -1279,6 +1244,11 @@ private: int m_chromaCrQpOffset; int m_chromaCbCrQpOffset; + // Chroma QP Adjustments + int m_cuChromaQpOffsetSubdiv; + int m_chromaQpOffsetListLen; // size (excludes the null entry used in the following array). + ChromaQpAdj m_ChromaQpAdjTableIncludingNullEntry[1+MAX_QP_OFFSET_LIST_SIZE]; //!< Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise + uint32_t m_numRefIdxL0DefaultActive; uint32_t m_numRefIdxL1DefaultActive; @@ -1415,6 +1385,34 @@ public: return (compID==COMPONENT_Y) ? 0 : (compID==COMPONENT_Cb ? m_chromaCbQpOffset : compID==COMPONENT_Cr ? m_chromaCrQpOffset : m_chromaCbCrQpOffset ); } + uint32_t getCuChromaQpOffsetSubdiv () const { return m_cuChromaQpOffsetSubdiv; } + void setCuChromaQpOffsetSubdiv ( uint32_t u ) { m_cuChromaQpOffsetSubdiv = u; } + + bool getCuChromaQpOffsetEnabledFlag() const { return getChromaQpOffsetListLen()>0; } + int getChromaQpOffsetListLen() const { return m_chromaQpOffsetListLen; } + void clearChromaQpOffsetList() { m_chromaQpOffsetListLen = 0; } + + const ChromaQpAdj& getChromaQpOffsetListEntry( int cuChromaQpOffsetIdxPlus1 ) const + { + CHECK(cuChromaQpOffsetIdxPlus1 >= m_chromaQpOffsetListLen+1, "Invalid chroma QP offset"); + return m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1]; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise + } + +#if JVET_O1168_CU_CHROMA_QP_OFFSET + void setChromaQpOffsetListEntry( int cuChromaQpOffsetIdxPlus1, int cbOffset, int crOffset, int jointCbCrOffset ) +#else + void setChromaQpOffsetListEntry( int cuChromaQpOffsetIdxPlus1, int cbOffset, int crOffset ) +#endif + { + CHECK(cuChromaQpOffsetIdxPlus1 == 0 || cuChromaQpOffsetIdxPlus1 > MAX_QP_OFFSET_LIST_SIZE, "Invalid chroma QP offset"); + m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.CbOffset = cbOffset; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise + m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.CrOffset = crOffset; +#if JVET_O1168_CU_CHROMA_QP_OFFSET + m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.JointCbCrOffset = jointCbCrOffset; +#endif + m_chromaQpOffsetListLen = std::max(m_chromaQpOffsetListLen, cuChromaQpOffsetIdxPlus1); + } + void setNumRefIdxL0DefaultActive(uint32_t ui) { m_numRefIdxL0DefaultActive=ui; } uint32_t getNumRefIdxL0DefaultActive() const { return m_numRefIdxL0DefaultActive; } void setNumRefIdxL1DefaultActive(uint32_t ui) { m_numRefIdxL1DefaultActive=ui; } diff --git a/source/Lib/CommonLib/UnitPartitioner.cpp b/source/Lib/CommonLib/UnitPartitioner.cpp index 9f3180d40494130f580409a41a7ffb705c4aeffb..83df220313c52c228d714631eef9c485e6ba0e73 100644 --- a/source/Lib/CommonLib/UnitPartitioner.cpp +++ b/source/Lib/CommonLib/UnitPartitioner.cpp @@ -367,7 +367,7 @@ void QTBTPartitioner::splitCurrArea( const PartSplit split, const CodingStructur currSubdiv++; } qgEnable &= (currSubdiv <= cs.pps->getCuQpDeltaSubdiv()); - qgChromaEnable &= (currSubdiv <= cs.pps->getPpsRangeExtension().getCuChromaQpOffsetSubdiv()); + qgChromaEnable &= (currSubdiv <= cs.pps->getCuChromaQpOffsetSubdiv()); m_partStack.back().qgEnable = qgEnable; m_partStack.back().qgChromaEnable = qgChromaEnable; if (qgEnable) diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 691b930159cb62101410835627f8c7122345335a..f32b7e01df16e471a21a9fe9c24f052e0375337e 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -3479,7 +3479,7 @@ void CABACReader::cu_chroma_qp_offset( CodingUnit& cu ) RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2( STATS__CABAC_BITS__CHROMA_QP_ADJUSTMENT, cu.blocks[cu.chType].lumaSize(), CHANNEL_TYPE_CHROMA ); // cu_chroma_qp_offset_flag - int length = cu.cs->pps->getPpsRangeExtension().getChromaQpOffsetListLen(); + int length = cu.cs->pps->getChromaQpOffsetListLen(); unsigned qpAdj = m_BinDecoder.decodeBin( Ctx::ChromaQpAdjFlag() ); if( qpAdj && length > 1 ) { diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index ea4488002ae3cdcdc6027bf3150a7067f3dc9ede..1652fdd2d8b89751912f15c9d2ff0e0e2a2f7ab2 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -485,6 +485,44 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); pcPPS->setSliceChromaQpFlag( uiCode ? true : false ); + READ_FLAG( uiCode, "cu_chroma_qp_offset_enabled_flag"); + if (uiCode == 0) + { + pcPPS->clearChromaQpOffsetList(); + pcPPS->setCuChromaQpOffsetSubdiv(0); + } + else + { + READ_UVLC(uiCode, "cu_chroma_qp_offset_subdiv"); pcPPS->setCuChromaQpOffsetSubdiv(uiCode); + uint32_t tableSizeMinus1 = 0; + READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1"); + CHECK(tableSizeMinus1 >= MAX_QP_OFFSET_LIST_SIZE, "Table size exceeds maximum"); + + for (int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++) + { + int cbOffset; + int crOffset; +#if JVET_O1168_CU_CHROMA_QP_OFFSET + int jointCbCrOffset; +#endif + READ_SVLC(cbOffset, "cb_qp_offset_list[i]"); + 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_O1168_CU_CHROMA_QP_OFFSET + READ_SVLC(jointCbCrOffset, "joint_cbcr_qp_offset_list[i]"); + CHECK(jointCbCrOffset < -12 || jointCbCrOffset > 12, "Invalid chroma QP offset"); +#endif + // table uses +1 for index (see comment inside the function) +#if JVET_O1168_CU_CHROMA_QP_OFFSET + pcPPS->setChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1, cbOffset, crOffset, jointCbCrOffset); +#else + pcPPS->setChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1, cbOffset, crOffset); +#endif + } + CHECK(pcPPS->getChromaQpOffsetListLen() != tableSizeMinus1 + 1, "Invalid chroma QP offset list lenght"); + } + READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) pcPPS->setUseWP( uiCode==1 ); READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) @@ -774,44 +812,6 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana READ_FLAG( uiCode, "cross_component_prediction_enabled_flag"); ppsRangeExtension.setCrossComponentPredictionEnabledFlag(uiCode != 0); - READ_FLAG( uiCode, "chroma_qp_offset_list_enabled_flag"); - if (uiCode == 0) - { - ppsRangeExtension.clearChromaQpOffsetList(); - ppsRangeExtension.setCuChromaQpOffsetSubdiv(0); - } - else - { - READ_UVLC(uiCode, "cu_chroma_qp_offset_subdiv"); ppsRangeExtension.setCuChromaQpOffsetSubdiv(uiCode); - uint32_t tableSizeMinus1 = 0; - READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1"); - CHECK(tableSizeMinus1 >= MAX_QP_OFFSET_LIST_SIZE, "Table size exceeds maximum"); - - for (int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++) - { - int cbOffset; - int crOffset; -#if JVET_O1168_CU_CHROMA_QP_OFFSET - int jointCbCrOffset; -#endif - READ_SVLC(cbOffset, "cb_qp_offset_list[i]"); - 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_O1168_CU_CHROMA_QP_OFFSET - READ_SVLC(jointCbCrOffset, "joint_cbcr_qp_offset_list[i]"); - CHECK(jointCbCrOffset < -12 || jointCbCrOffset > 12, "Invalid chroma QP offset"); -#endif - // table uses +1 for index (see comment inside the function) -#if JVET_O1168_CU_CHROMA_QP_OFFSET - ppsRangeExtension.setChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1, cbOffset, crOffset, jointCbCrOffset); -#else - ppsRangeExtension.setChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1, cbOffset, crOffset); -#endif - } - CHECK(ppsRangeExtension.getChromaQpOffsetListLen() != tableSizeMinus1 + 1, "Invalid chroma QP offset list lenght"); - } - READ_UVLC( uiCode, "log2_sao_offset_scale_luma"); ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, uiCode); READ_UVLC( uiCode, "log2_sao_offset_scale_chroma"); @@ -2594,7 +2594,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para } } - if (pps->getPpsRangeExtension().getChromaQpOffsetListEnabledFlag()) + if (pps->getCuChromaQpOffsetEnabledFlag()) { READ_FLAG(uiCode, "cu_chroma_qp_offset_enabled_flag"); pcSlice->setUseChromaQpAdj(uiCode != 0); } diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index b39731549a457ebb1b5588e82fe82b36f2219f63..52818c098e2365816582737a0ea852509147c20e 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -3274,7 +3274,7 @@ void CABACWriter::cu_chroma_qp_offset( const CodingUnit& cu ) else { m_BinEncoder.encodeBin( 1, Ctx::ChromaQpAdjFlag() ); - int length = cu.cs->pps->getPpsRangeExtension().getChromaQpOffsetListLen(); + int length = cu.cs->pps->getChromaQpOffsetListLen(); if( length > 1 ) { unary_max_symbol( qpAdj-1, Ctx::ChromaQpAdjIdc(), Ctx::ChromaQpAdjIdc(), length-1 ); diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 970a1d3ada037553e2035de7e4c1582a07141dde..6c26d527ad297d161d69477ef47375043d96fd33 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -735,8 +735,8 @@ void EncCu::xCompressCU( CodingStructure *&tempCS, CodingStructure *&bestCS, Par { // TODO M0133 : double check encoder decisions with respect to chroma QG detection and actual encode int lgMinCuSize = sps.getLog2MinCodingBlockSize() + - std::max<int>( 0, sps.getLog2DiffMaxMinCodingBlockSize() - int( pps.getPpsRangeExtension().getCuChromaQpOffsetSubdiv()/2 ) ); - m_cuChromaQpOffsetIdxPlus1 = ( ( uiLPelX >> lgMinCuSize ) + ( uiTPelY >> lgMinCuSize ) ) % ( pps.getPpsRangeExtension().getChromaQpOffsetListLen() + 1 ); + std::max<int>( 0, sps.getLog2DiffMaxMinCodingBlockSize() - int( pps.getCuChromaQpOffsetSubdiv()/2 ) ); + m_cuChromaQpOffsetIdxPlus1 = ( ( uiLPelX >> lgMinCuSize ) + ( uiTPelY >> lgMinCuSize ) ) % ( pps.getChromaQpOffsetListLen() + 1 ); } if( !m_modeCtrl->anyMode() ) diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index cee835e9d70fb7c83f20b5ebf921b1ef504557fe..7463fcc1feb6aead3932407fa434bb5d0e18836d 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -1390,19 +1390,19 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) if ( m_cuChromaQpOffsetSubdiv >= 0 ) { - pps.getPpsRangeExtension().setCuChromaQpOffsetSubdiv(m_cuChromaQpOffsetSubdiv); - pps.getPpsRangeExtension().clearChromaQpOffsetList(); + pps.setCuChromaQpOffsetSubdiv(m_cuChromaQpOffsetSubdiv); + pps.clearChromaQpOffsetList(); #if JVET_O1168_CU_CHROMA_QP_OFFSET - pps.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6, 6); + pps.setChromaQpOffsetListEntry(1, 6, 6, 6); #else - pps.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6); + pps.setChromaQpOffsetListEntry(1, 6, 6); #endif /* todo, insert table entries from command line (NB, 0 should not be touched) */ } else { - pps.getPpsRangeExtension().setCuChromaQpOffsetSubdiv(0); - pps.getPpsRangeExtension().clearChromaQpOffsetList(); + pps.setCuChromaQpOffsetSubdiv(0); + pps.clearChromaQpOffsetList(); } pps.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag); pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA ]); diff --git a/source/Lib/EncoderLib/EncSlice.cpp b/source/Lib/EncoderLib/EncSlice.cpp index 91823720953344c413ed591749a66b66bcad4b08..d1282d37b79d78bc39d29d1dbe1cdaf43fa2fbe1 100644 --- a/source/Lib/EncoderLib/EncSlice.cpp +++ b/source/Lib/EncoderLib/EncSlice.cpp @@ -672,7 +672,7 @@ void EncSlice::initEncSlice(Picture* pcPic, const int pocLast, const int pocCurr rpcSlice->setSliceChromaQpDelta( COMPONENT_Cr, 0 ); rpcSlice->setSliceChromaQpDelta( JOINT_CbCr, 0 ); #endif - rpcSlice->setUseChromaQpAdj( rpcSlice->getPPS()->getPpsRangeExtension().getChromaQpOffsetListEnabledFlag() ); + rpcSlice->setUseChromaQpAdj( rpcSlice->getPPS()->getCuChromaQpOffsetEnabledFlag() ); rpcSlice->setNumRefIdx(REF_PIC_LIST_0, m_pcCfg->getRPLEntry(0, iGOPid).m_numRefPicsActive); rpcSlice->setNumRefIdx(REF_PIC_LIST_1, m_pcCfg->getRPLEntry(1, iGOPid).m_numRefPicsActive); diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 4359b00ade87f15a5f53e7be04d4d2a9a04fbd35..e1af6caf873c0a08c102589abce5b232a119dda8 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -286,6 +286,22 @@ void HLSWriter::codePPS( const PPS* pcPPS ) WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0, "pps_slice_chroma_qp_offsets_present_flag" ); + WRITE_FLAG(uint32_t(pcPPS->getCuChromaQpOffsetEnabledFlag()), "cu_chroma_qp_offset_enabled_flag" ); + if (pcPPS->getCuChromaQpOffsetEnabledFlag()) + { + WRITE_UVLC(pcPPS->getCuChromaQpOffsetSubdiv(), "cu_chroma_qp_offset_subdiv"); + WRITE_UVLC(pcPPS->getChromaQpOffsetListLen() - 1, "chroma_qp_offset_list_len_minus1"); + /* skip zero index */ + for (int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < pcPPS->getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++) + { + 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_O1168_CU_CHROMA_QP_OFFSET + WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1).u.comp.JointCbCrOffset, "joint_cbcr_qp_offset_list[i]"); +#endif + } + } + WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) WRITE_FLAG( pcPPS->getTransquantBypassEnabledFlag() ? 1 : 0, "transquant_bypass_enabled_flag" ); @@ -481,22 +497,6 @@ void HLSWriter::codePPS( const PPS* pcPPS ) WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" ); - WRITE_FLAG(uint32_t(ppsRangeExtension.getChromaQpOffsetListEnabledFlag()), "chroma_qp_offset_list_enabled_flag" ); - if (ppsRangeExtension.getChromaQpOffsetListEnabledFlag()) - { - WRITE_UVLC(ppsRangeExtension.getCuChromaQpOffsetSubdiv(), "cu_chroma_qp_offset_subdiv"); - WRITE_UVLC(ppsRangeExtension.getChromaQpOffsetListLen() - 1, "chroma_qp_offset_list_len_minus1"); - /* skip zero index */ - for (int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < ppsRangeExtension.getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++) - { - WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "cb_qp_offset_list[i]"); - WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "cr_qp_offset_list[i]"); -#if JVET_O1168_CU_CHROMA_QP_OFFSET - WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1).u.comp.JointCbCrOffset, "joint_cbcr_qp_offset_list[i]"); -#endif - } - } - WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), "log2_sao_offset_scale_luma" ); WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA), "log2_sao_offset_scale_chroma" ); } @@ -1734,7 +1734,7 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) CHECK(numberValidComponents < COMPONENT_Cr+1, "Too many valid components"); } - if (pcSlice->getPPS()->getPpsRangeExtension().getChromaQpOffsetListEnabledFlag()) + if (pcSlice->getPPS()->getCuChromaQpOffsetEnabledFlag()) { WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "cu_chroma_qp_offset_enabled_flag"); }