...
 
Commits (28)
......@@ -2563,6 +2563,7 @@ bool EncAppCfg::xCheckParameter()
#endif
#if SHARP_LUMA_DELTA_QP
xConfirmPara( m_lumaLevelToDeltaQPMapping.mode && m_uiDeltaQpRD > 0, "Luma-level-based Delta QP cannot be used together with slice level multiple-QP optimization\n" );
xConfirmPara( m_lumaLevelToDeltaQPMapping.mode && m_RCEnableRateControl, "Luma-level-based Delta QP cannot be used together with rate control\n" );
#endif
if (m_lumaLevelToDeltaQPMapping.mode && m_lmcsEnabled)
{
......
......@@ -307,6 +307,10 @@ static const int RExt__PREDICTION_WEIGHTING_ANALYSIS_DC_PRECISION = 0; ///< Addi
static const int MAX_TIMECODE_SEI_SETS = 3; ///< Maximum number of time sets
#if JVET_S0177_SCALABLE_NESTING_SEI
static const int VCL_ASSOCIATED_SEI_LIST_SIZE = 17;
#endif
static const int MAX_CU_DEPTH = 7; ///< log2(CTUSize)
static const int MAX_CU_SIZE = 1<<MAX_CU_DEPTH;
static const int MIN_CU_LOG2 = 2;
......
......@@ -83,7 +83,11 @@ void RdCost::setLambda( double dLambda, const BitDepths &bitDepths )
m_dLambdaMotionSAD = sqrt(m_dLambda);
}
#if JVET_S0234_ACT_CRS_FIX
void RdCost::lambdaAdjustColorTrans(bool forward, ComponentID componentID, bool applyChromaScale, int* resScaleInv)
#else
void RdCost::lambdaAdjustColorTrans(bool forward, ComponentID componentID)
#endif
{
if (m_resetStore)
{
......@@ -115,6 +119,15 @@ void RdCost::lambdaAdjustColorTrans(bool forward, ComponentID componentID)
m_dLambda = m_lambdaStore[m_pairCheck][componentID];
m_DistScale = m_DistScaleStore[m_pairCheck][componentID];
#if JVET_S0234_ACT_CRS_FIX
if (applyChromaScale)
{
CHECK(m_pairCheck == 0 || componentID == COMPONENT_Y, "wrong lambda adjustment for CS");
double cResScale = (double)(1 << CSCALE_FP_PREC) / (double)(*resScaleInv);
m_dLambda = m_dLambda / (cResScale*cResScale);
m_DistScale = double(1 << SCALE_BITS) / m_dLambda;
}
#endif
if (m_pairCheck == 0)
{
CHECK(m_DistScale != m_DistScaleUnadjusted, "lambda should be adjusted to the original value");
......
......@@ -326,7 +326,11 @@ public:
inline std::vector<double>& getLumaLevelWeightTable () { return m_lumaLevelToWeightPLUT; }
#endif
#if JVET_S0234_ACT_CRS_FIX
void lambdaAdjustColorTrans(bool forward, ComponentID compID, bool applyChromaScale = false, int* resScaleInv = NULL);
#else
void lambdaAdjustColorTrans(bool forward, ComponentID compID);
#endif
void resetStore() { m_resetStore = true; }
private:
......
This diff is collapsed.
......@@ -51,12 +51,15 @@
#include <cassert>
//########### place macros to be removed in next cycle below this line ###############
#define JVET_S0133_PH_SYNTAX_OVERRIDE_ENC_FIX 1 // JVET-S0133: Encoder-only fix on the override of partition constriants in PH
#define JVET_S0179_CONDITIONAL_SIGNAL_GCI 1 // JVET-S0179: Conditional signalling of GCI fields
#define JVET_S0049_ASPECT4 1 // JVET-S0049 aspect 4: Constrain the value of pps_alf_info_in_ph_flag to be equal to 0 when the PH is in the SH
#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_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
......@@ -72,7 +75,17 @@
#define JVET_S0160_ASPECT1_ASPECT9 1 // JVET-S0160: Aspect 1 Infer the value of pps_loop_filter_across_tiles_enabled_flag to be equal to 0 (instead of 1) when not present
// Aspect 9 The value of ph_poc_msb_cycle_present_flag is required to be equal to 0 when vps_independent_layer_flag[GeneralLayerIdx[nuh_layer_id]] is equal to 0 and there is an ILRP entry in RefPicList[0] or RefPicList[1] of a slice of the current picture
#define JVET_S0248_HRD_CLEANUP 1 // JVET-S0248 Aspect7: When bp_alt_cpb_params_present_flag is equal to 1, the value of bp_du_hrd_params_present_flag shall be equal to 0.
#define JVET_S0185_PROPOSAL2_SEI_CLEANUP 1 // JVET-S0185_PROPOSAL2: Move signalling of syntax element bp_alt_cpb_params_present_flag
#define JVET_S0181_PROPOSAL1 1 // JVET-0181_Proposal1: Conditionally signal bp_sublayer_initial_cpb_removal_delay_present_flag
#define JVET_S0177_SCALABLE_NESTING_SEI 1 // JVET-S0177: Constraints on the scalable nesting SEI message
#define JVET_R0068_ASPECT6_ENC_RESTRICTION 1 // encoder restriction for JVET-R0068 apsect 6
#define JVET_S0186_SPS_CLEANUP 1 // JVET-S0186: Proposal 1, move sps_chroma_format_idc and sps_log2_ctu_size_minus5 to take place sps_reserved_zero_4bits
//########### place macros to be be kept below this line ###############
#define JVET_S0257_DUMP_360SEI_MESSAGE 1 // Software support of 360 SEI messages
......
......@@ -347,7 +347,11 @@ void DecCu::xIntraRecACTBlk(TransformUnit& tu)
CHECK(pu.intraDir[CHANNEL_TYPE_CHROMA] != DM_CHROMA_IDX, "chroma should use DM mode for adaptive color transform");
bool flag = slice.getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag()));
#if JVET_S0234_ACT_CRS_FIX
if (flag && slice.getPicHeader()->getLmcsChromaResidualScaleFlag())
#else
if (flag && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && (tu.cbf[COMPONENT_Cb] || tu.cbf[COMPONENT_Cr]))
#endif
{
const Area area = tu.Y().valid() ? tu.Y() : Area(recalcPosition(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].pos()), recalcSize(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].size()));
const CompArea &areaY = CompArea(COMPONENT_Y, tu.chromaFormat, area);
......@@ -407,11 +411,13 @@ void DecCu::xIntraRecACTBlk(TransformUnit& tu)
}
}
#if !JVET_S0234_ACT_CRS_FIX
flag = flag && (tu.blocks[compID].width*tu.blocks[compID].height > 4);
if (flag && (TU::getCbf(tu, compID) || tu.jointCbCr) && isChroma(compID) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag())
{
piResi.scaleSignal(tu.getChromaAdj(), 0, tu.cu->cs->slice->clpRng(compID));
}
#endif
cs.setDecomp(area);
}
......@@ -435,6 +441,12 @@ void DecCu::xIntraRecACTBlk(TransformUnit& tu)
tmpPred.copyFrom(piPred);
}
#if JVET_S0234_ACT_CRS_FIX
if (flag && isChroma(compID) && (tu.blocks[compID].width*tu.blocks[compID].height > 4) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag())
{
piResi.scaleSignal(tu.getChromaAdj(), 0, tu.cu->cs->slice->clpRng(compID));
}
#endif
piPred.reconstruct(piPred, piResi, tu.cu->cs->slice->clpRng(compID));
piReco.copyFrom(piPred);
......@@ -694,10 +706,12 @@ void DecCu::xReconInter(CodingUnit &cu)
if (cu.rootCbf)
{
#if !JVET_S0234_ACT_CRS_FIX
if (cu.colorTransform)
{
cs.getResiBuf(cu).colorSpaceConvert(cs.getResiBuf(cu), false, cu.cs->slice->clpRng(COMPONENT_Y));
}
#endif
#if REUSE_CU_RESULTS
const CompArea &area = cu.blocks[COMPONENT_Y];
CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size());
......@@ -788,7 +802,11 @@ void DecCu::xDecodeInterTU( TransformUnit & currTU, const ComponentID compID )
//===== reconstruction =====
const Slice &slice = *cs.slice;
#if JVET_S0234_ACT_CRS_FIX
if (!currTU.cu->colorTransform && slice.getPicHeader()->getLmcsEnabledFlag() && isChroma(compID) && (TU::getCbf(currTU, compID) || currTU.jointCbCr)
#else
if (slice.getLmcsEnabledFlag() && isChroma(compID) && (TU::getCbf(currTU, compID) || currTU.jointCbCr)
#endif
&& slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && currTU.blocks[compID].width * currTU.blocks[compID].height > 4)
{
resiBuf.scaleSignal(currTU.getChromaAdj(), 0, currTU.cu->cs->slice->clpRng(compID));
......@@ -804,6 +822,36 @@ void DecCu::xDecodeInterTexture(CodingUnit &cu)
const uint32_t uiNumVaildComp = getNumberValidComponents(cu.chromaFormat);
#if JVET_S0234_ACT_CRS_FIX
if (cu.colorTransform)
{
CodingStructure &cs = *cu.cs;
const Slice &slice = *cs.slice;
for (auto& currTU : CU::traverseTUs(cu))
{
for (uint32_t ch = 0; ch < uiNumVaildComp; ch++)
{
const ComponentID compID = ComponentID(ch);
if (slice.getPicHeader()->getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && (compID == COMPONENT_Y))
{
const CompArea &areaY = currTU.blocks[COMPONENT_Y];
int adj = m_pcReshape->calculateChromaAdjVpduNei(currTU, areaY);
currTU.setChromaAdj(adj);
}
xDecodeInterTU(currTU, compID);
}
cs.getResiBuf(currTU).colorSpaceConvert(cs.getResiBuf(currTU), false, cu.cs->slice->clpRng(COMPONENT_Y));
if (slice.getPicHeader()->getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && currTU.blocks[COMPONENT_Cb].width * currTU.blocks[COMPONENT_Cb].height > 4)
{
cs.getResiBuf(currTU.blocks[COMPONENT_Cb]).scaleSignal(currTU.getChromaAdj(), 0, currTU.cu->cs->slice->clpRng(COMPONENT_Cb));
cs.getResiBuf(currTU.blocks[COMPONENT_Cr]).scaleSignal(currTU.getChromaAdj(), 0, currTU.cu->cs->slice->clpRng(COMPONENT_Cr));
}
}
}
else
{
#endif
for (uint32_t ch = 0; ch < uiNumVaildComp; ch++)
{
const ComponentID compID = ComponentID(ch);
......@@ -821,6 +869,9 @@ void DecCu::xDecodeInterTexture(CodingUnit &cu)
xDecodeInterTU( currTU, compID );
}
}
#if JVET_S0234_ACT_CRS_FIX
}
#endif
}
void DecCu::xDeriveCUMV( CodingUnit &cu )
......
......@@ -460,7 +460,6 @@ void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, uint32_t
}
}
void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, const uint32_t nuhLayerId, uint32_t payloadSize, const VPS *vps, const SPS *sps, std::ostream *decodedMessageOutputStream)
{
uint32_t symbol;
......@@ -550,6 +549,41 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT
tmpSEIs.clear();
}
#if JVET_S0177_SCALABLE_NESTING_SEI
int vclAssociatedSeiList[VCL_ASSOCIATED_SEI_LIST_SIZE] = { 3, 19, 45, 129, 137, 144, 145, 147, 148, 149, 150, 153, 154, 155, 156, 168, 204 };
bool containBPorPTorDUIorSLI = false;
bool containNoBPorPTorDUIorSLI = false;
for (auto nestedsei : sei.m_nestedSEIs)
{
CHECK(nestedsei->payloadType() == SEI::FILLER_PAYLOAD || nestedsei->payloadType() == SEI::SCALABLE_NESTING, "An SEI message that has payloadType equal to filler payload or scalable nesting shall not be contained in a scalable nesting SEI message");
CHECK(nestedsei->payloadType() != SEI::FILLER_PAYLOAD && nestedsei->payloadType() != SEI::DECODED_PICTURE_HASH && nalUnitType != NAL_UNIT_PREFIX_SEI, "When a scalable nesting SEI message contains an SEI message that has payloadType not equal to filler payload or decoded picture harsh, the SEI NAL unit containing the scalable nesting SEI message shall have nal_unit_type equal to PREFIX_SEI_NUT");
CHECK(nestedsei->payloadType() == SEI::DECODED_PICTURE_HASH && nalUnitType != NAL_UNIT_SUFFIX_SEI, "When a scalable nesting SEI message contains an SEI message that has payloadType equal to decoded picture harsh, the SEI NAL unit containing the scalable nesting SEI message shall have nal_unit_type equal to SUFFIX_SEI_NUT");
CHECK(nestedsei->payloadType() == SEI::DECODED_PICTURE_HASH && !sei.m_snSubpicFlag, "When the scalable nesting SEI message contains an SEI message that has payloadType equal to decoded picture hash, the value of sn_subpic_flag shall be equal to 1");
CHECK(nestedsei->payloadType() == SEI::SUBPICTURE_LEVEL_INFO && sei.m_snSubpicFlag, "When the scalable nesting SEI message contains an SEI message that has payloadType equal to SLI, the value of sn_subpic_flag shall be equal to 0");
for (int i = 0; i < VCL_ASSOCIATED_SEI_LIST_SIZE; i++)
{
CHECK(nestedsei->payloadType() == vclAssociatedSeiList[i] && sei.m_snOlsFlag, "When the scalable nesting SEI message contains an SEI message that has payloadType equal to a value in vclAssociatedSeiList, the value of sn_ols_flag shall be equal to 0");
}
if (nestedsei->payloadType() == SEI::BUFFERING_PERIOD || nestedsei->payloadType() == SEI::PICTURE_TIMING || nestedsei->payloadType() == SEI::DECODING_UNIT_INFO || nestedsei->payloadType() == SEI::SUBPICTURE_LEVEL_INFO)
{
containBPorPTorDUIorSLI = true;
CHECK(!sei.m_snOlsFlag, "When the scalable nesting SEI message contains an SEI message that has payloadType equal to BP, PT, or DUI, or SLI, the value of sn_ols_flag shall be equal to 1");
}
if (!(nestedsei->payloadType() == SEI::BUFFERING_PERIOD || nestedsei->payloadType() == SEI::PICTURE_TIMING || nestedsei->payloadType() == SEI::DECODING_UNIT_INFO || nestedsei->payloadType() == SEI::SUBPICTURE_LEVEL_INFO))
{
containNoBPorPTorDUIorSLI = true;
}
}
CHECK(containBPorPTorDUIorSLI && containNoBPorPTorDUIorSLI, "When a scalable nesting SEI message contains a BP, PT, DUI, or SLI SEI message, the scalable nesting SEI message shall not contain any other SEI message with payloadType not equal to BP, PT, DUI, or SLI");
#else
bool containBPorPTorDUI = false;
bool containNoBPorPTorDUI = false;
for (auto nestedsei : sei.m_nestedSEIs)
......@@ -564,6 +598,7 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT
}
}
CHECK(containBPorPTorDUI && containNoBPorPTorDUI, "Scalable Nesting SEI cannot contain timing-related SEI and none-timing-related SEIs at the same time");
#endif
if (decodedMessageOutputStream)
{
......@@ -638,7 +673,9 @@ void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, uint32_t paylo
sei_read_code( pDecodedMessageOutputStream, 5, code, "initial_cpb_removal_delay_length_minus1" ); sei.m_initialCpbRemovalDelayLength = code + 1;
sei_read_code( pDecodedMessageOutputStream, 5, code, "cpb_removal_delay_length_minus1" ); sei.m_cpbRemovalDelayLength = code + 1;
sei_read_code( pDecodedMessageOutputStream, 5, code, "dpb_output_delay_length_minus1" ); sei.m_dpbOutputDelayLength = code + 1;
#if !JVET_S0185_PROPOSAL2_SEI_CLEANUP
sei_read_flag( pDecodedMessageOutputStream, code, "alt_cpb_params_present_flag"); sei.m_altCpbParamsPresentFlag = code;
#endif
sei_read_flag( pDecodedMessageOutputStream, code, "bp_decoding_unit_hrd_params_present_flag" ); sei.m_bpDecodingUnitHrdParamsPresentFlag = code;
if( sei.m_bpDecodingUnitHrdParamsPresentFlag )
{
......@@ -654,6 +691,10 @@ void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, uint32_t paylo
sei.m_decodingUnitDpbDuParamsInPicTimingSeiFlag = false;
}
#if JVET_S0248_HRD_CLEANUP
CHECK(sei.m_altCpbParamsPresentFlag && sei.m_bpDecodingUnitHrdParamsPresentFlag,"When bp_alt_cpb_params_present_flag is equal to 1, the value of bp_du_hrd_params_present_flag shall be equal to 0");
#endif
sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag");
sei.m_concatenationFlag = code;
sei_read_flag ( pDecodedMessageOutputStream, code, "additional_concatenation_info_present_flag");
......@@ -678,7 +719,19 @@ void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, uint32_t paylo
}
sei_read_code( pDecodedMessageOutputStream, 3, code, "bp_max_sub_layers_minus1" ); sei.m_bpMaxSubLayers = code + 1;
sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_cpb_cnt_minus1" ); sei.m_bpCpbCnt = code + 1;
#if JVET_S0181_PROPOSAL1
if (sei.m_bpMaxSubLayers - 1 > 0)
{
sei_read_flag(pDecodedMessageOutputStream, code, "bp_sublayer_initial_cpb_removal_delay_present_flag");
sei.m_sublayerInitialCpbRemovalDelayPresentFlag = code;
}
else
{
sei.m_sublayerInitialCpbRemovalDelayPresentFlag = false;
}
#else
sei_read_flag(pDecodedMessageOutputStream, code, "sublayer_initial_cpb_removal_delay_present_flag");
#endif
sei.m_sublayerInitialCpbRemovalDelayPresentFlag = code;
for (i = (sei.m_sublayerInitialCpbRemovalDelayPresentFlag ? 0 : sei.m_bpMaxSubLayers - 1); i < sei.m_bpMaxSubLayers; i++)
{
......@@ -708,6 +761,10 @@ void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, uint32_t paylo
}
sei.m_dpbOutputTidOffset[sei.m_bpMaxSubLayers-1] = 0;
}
#if JVET_S0185_PROPOSAL2_SEI_CLEANUP
sei_read_flag(pDecodedMessageOutputStream, code, "bp_alt_cpb_params_present_flag");
sei.m_altCpbParamsPresentFlag = code;
#endif
if (sei.m_altCpbParamsPresentFlag)
{
sei_read_flag(pDecodedMessageOutputStream, code, "use_alt_cpb_params_flag"); sei.m_useAltCpbParamsFlag = code;
......
......@@ -1306,8 +1306,20 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
READ_CODE( 4, uiCode, "sps_video_parameter_set_id" ); pcSPS->setVPSId( uiCode );
READ_CODE(3, uiCode, "sps_max_sub_layers_minus1"); pcSPS->setMaxTLayers (uiCode + 1);
CHECK(uiCode > 6, "Invalid maximum number of T-layer signalled");
#if JVET_S0186_SPS_CLEANUP
READ_CODE(2, uiCode, "chroma_format_idc");
pcSPS->setChromaFormatIdc(ChromaFormat(uiCode));
READ_CODE(2, uiCode, "sps_log2_ctu_size_minus5");
pcSPS->setCTUSize(1 << (uiCode + 5));
CHECK(uiCode > 2, "sps_log2_ctu_size_minus5 must be less than or equal to 2");
unsigned ctbLog2SizeY = uiCode + 5;
pcSPS->setMaxCUWidth(pcSPS->getCTUSize());
pcSPS->setMaxCUHeight(pcSPS->getCTUSize());
#else
READ_CODE(4, uiCode, "sps_reserved_zero_4bits");
CHECK(uiCode != 0, "sps_reserved_zero_4bits not equal to zero");
#endif
READ_FLAG(uiCode, "sps_ptl_dpb_hrd_params_present_flag"); pcSPS->setPtlDpbHrdParamsPresentFlag(uiCode);
if( !pcSPS->getVPSId() )
......@@ -1324,7 +1336,9 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
READ_FLAG(uiCode, "gdr_enabled_flag");
pcSPS->setGDREnabledFlag(uiCode);
#if !JVET_S0186_SPS_CLEANUP
READ_CODE(2, uiCode, "chroma_format_idc"); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) );
#endif
#if !JVET_S0052_RM_SEPARATE_COLOUR_PLANE
if( pcSPS->getChromaFormatIdc() == CHROMA_444 )
......@@ -1364,11 +1378,13 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
const uint32_t chromaArrayType = (int) pcSPS->getSeparateColourPlaneFlag() ? 0 : pcSPS->getChromaFormatIdc();
#endif
#if !JVET_S0186_SPS_CLEANUP
READ_CODE(2, uiCode, "sps_log2_ctu_size_minus5"); pcSPS->setCTUSize(1 << (uiCode + 5));
CHECK(uiCode > 2, "sps_log2_ctu_size_minus5 must be less than or equal to 2");
unsigned ctbLog2SizeY = uiCode + 5;
pcSPS->setMaxCUWidth(pcSPS->getCTUSize());
pcSPS->setMaxCUHeight(pcSPS->getCTUSize());
#endif
READ_FLAG( uiCode, "subpic_info_present_flag" ); pcSPS->setSubPicInfoPresentFlag(uiCode);
......@@ -4484,7 +4500,8 @@ void HLSyntaxReader::parseConstraintInfo(ConstraintInfo *cinfo)
READ_FLAG(symbol, "no_aps_constraint_flag"); cinfo->setNoApsConstraintFlag(symbol > 0 ? true : false);
#if JVET_S0179_CONDITIONAL_SIGNAL_GCI
READ_CODE(8, symbol, "gci_num_reserved_bits");
for (int i = 0; i < symbol; i++)
uint32_t const numReservedBits = symbol;
for (int i = 0; i < numReservedBits; i++)
{
READ_FLAG(symbol, "gci_reserved_zero_bit"); CHECK(symbol != 0, "gci_reserved_zero_bit not equal to zero");
}
......
......@@ -1040,7 +1040,10 @@ void EncCu::updateLambda (Slice* slice, const int dQP,
{
m_pcRdCost->setLambda (newLambda, slice->getSPS()->getBitDepths());
#if WCG_EXT
m_pcRdCost->saveUnadjustedLambda();
if (!m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled())
{
m_pcRdCost->saveUnadjustedLambda();
}
#endif
}
}
......
......@@ -2336,6 +2336,51 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
m_uiPrevISlicePOC = pcSlice->getPOC();
m_bInitAMaxBT = true;
}
#if JVET_S0133_PH_SYNTAX_OVERRIDE_ENC_FIX
bool identicalToSPS=true;
const SPS* sps =pcSlice->getSPS();
if (picHeader->getPicInterSliceAllowedFlag())
{
if (picHeader->getMinQTSize(pcSlice->getSliceType()) != pcSlice->getSPS()->getMinQTSize(pcSlice->getSliceType()) ||
picHeader->getMaxMTTHierarchyDepth(pcSlice->getSliceType()) != pcSlice->getSPS()->getMaxMTTHierarchyDepth() ||
picHeader->getMaxBTSize(pcSlice->getSliceType()) != pcSlice->getSPS()->getMaxBTSize() ||
picHeader->getMaxTTSize(pcSlice->getSliceType()) != pcSlice->getSPS()->getMaxTTSize()
)
{
identicalToSPS=false;
}
}
if (identicalToSPS && picHeader->getPicIntraSliceAllowedFlag())
{
if (picHeader->getMinQTSize(I_SLICE) != sps->getMinQTSize(I_SLICE) ||
picHeader->getMaxMTTHierarchyDepth(I_SLICE) != sps->getMaxMTTHierarchyDepthI() ||
picHeader->getMaxBTSize(I_SLICE) != sps->getMaxBTSizeI() ||
picHeader->getMaxTTSize(I_SLICE) != sps->getMaxTTSizeI()
)
{
identicalToSPS=false;
}
if (identicalToSPS && sps->getUseDualITree())
{
if (picHeader->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA) != sps->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA) ||
picHeader->getMaxMTTHierarchyDepth(I_SLICE, CHANNEL_TYPE_CHROMA) != sps->getMaxMTTHierarchyDepthIChroma() ||
picHeader->getMaxBTSize(I_SLICE, CHANNEL_TYPE_CHROMA) != sps->getMaxBTSizeIChroma() ||
picHeader->getMaxTTSize(I_SLICE, CHANNEL_TYPE_CHROMA) != sps->getMaxTTSizeIChroma()
)
{
identicalToSPS=false;
}
}
}
if (identicalToSPS)
{
picHeader->setSplitConsOverrideFlag(false);
}
#endif
}
// Slice info. refinement
......
......@@ -259,7 +259,20 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf )
// initialize PPS
pps0.setPicWidthInLumaSamples( m_iSourceWidth );
pps0.setPicHeightInLumaSamples( m_iSourceHeight );
#if JVET_R0068_ASPECT6_ENC_RESTRICTION
if (pps0.getPicWidthInLumaSamples() == sps0.getMaxPicWidthInLumaSamples() && pps0.getPicHeightInLumaSamples() == sps0.getMaxPicHeightInLumaSamples())
{
pps0.setConformanceWindow( sps0.getConformanceWindow() );
pps0.setConformanceWindowFlag( false );
}
else
{
pps0.setConformanceWindow( m_conformanceWindow );
pps0.setConformanceWindowFlag( m_conformanceWindow.getWindowEnabledFlag() );
}
#else
pps0.setConformanceWindow( m_conformanceWindow );
#endif
xInitPPS(pps0, sps0);
// initialize APS
xInitRPL(sps0, isFieldCoding);
......@@ -282,7 +295,20 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf )
Window conformanceWindow;
conformanceWindow.setWindow( 0, ( width - scaledWidth ) / SPS::getWinUnitX( sps0.getChromaFormatIdc() ), 0, ( height - scaledHeight ) / SPS::getWinUnitY( sps0.getChromaFormatIdc() ) );
#if JVET_R0068_ASPECT6_ENC_RESTRICTION
if (pps.getPicWidthInLumaSamples() == sps0.getMaxPicWidthInLumaSamples() && pps.getPicHeightInLumaSamples() == sps0.getMaxPicHeightInLumaSamples())
{
pps.setConformanceWindow( sps0.getConformanceWindow() );
pps.setConformanceWindowFlag( false );
}
else
{
pps.setConformanceWindow( conformanceWindow );
pps.setConformanceWindowFlag( pps.getConformanceWindow().getWindowEnabledFlag() );
}
#else
pps.setConformanceWindow( conformanceWindow );
#endif
Window scalingWindow;
scalingWindow.setWindow( 0, ( width - scaledWidth ) / SPS::getWinUnitX( sps0.getChromaFormatIdc() ), 0, ( height - scaledHeight ) / SPS::getWinUnitY( sps0.getChromaFormatIdc() ) );
......
......@@ -797,7 +797,10 @@ void EncSlice::resetQP( Picture* pic, int sliceQP, double lambda )
#endif
setUpLambda(slice, lambda, sliceQP);
#if WCG_EXT
m_pcRdCost->saveUnadjustedLambda();
if (!m_pcCfg->getLumaLevelToDeltaQPMapping().isEnabled())
{
m_pcRdCost->saveUnadjustedLambda();
}
#endif
}
......
This diff is collapsed.
......@@ -3458,6 +3458,7 @@ void IntraSearch::xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &c
}
}
#if !JVET_S0234_ACT_CRS_FIX
if (flag && uiAbsSum > 0 && isChroma(compID) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag())
{
piResi.scaleSignal(tu.getChromaAdj(), 0, slice.clpRng(compID));
......@@ -3466,6 +3467,7 @@ void IntraSearch::xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &c
crResi.scaleSignal(tu.getChromaAdj(), 0, slice.clpRng(COMPONENT_Cr));
}
}
#endif
if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless())
m_pcTrQuant->lambdaAdjustColorTrans(false);
......@@ -4156,6 +4158,16 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti
PelUnitBuf predBuf = csFull->getPredBuf(tu);
PelUnitBuf resiBuf = csFull->getResiBuf(tu);
PelUnitBuf orgResiBuf = csFull->getOrgResiBuf(tu);
#if JVET_S0234_ACT_CRS_FIX
bool doReshaping = (slice.getPicHeader()->getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && (slice.isIntra() || m_pcReshape->getCTUFlag()) && (tu.blocks[COMPONENT_Cb].width * tu.blocks[COMPONENT_Cb].height > 4));
if (doReshaping)
{
const Area area = tu.Y().valid() ? tu.Y() : Area(recalcPosition(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].pos()), recalcSize(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].size()));
const CompArea &areaY = CompArea(COMPONENT_Y, tu.chromaFormat, area);
int adj = m_pcReshape->calculateChromaAdjVpduNei(tu, areaY);
tu.setChromaAdj(adj);
}
#endif
for (int i = 0; i < getNumberValidComponents(tu.chromaFormat); i++)
{
......@@ -4187,6 +4199,14 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti
piResi.rspSignal(m_pcReshape->getFwdLUT());
piResi.subtract(tmpPred);
}
#if JVET_S0234_ACT_CRS_FIX
else if (doReshaping && (compID != COMPONENT_Y))
{
piResi.subtract(piPred);
int cResScaleInv = tu.getChromaAdj();
piResi.scaleSignal(cResScaleInv, 1, slice.clpRng(compID));
}
#endif
else
piResi.subtract(piPred);
}
......@@ -4482,6 +4502,7 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti
tu.jointCbCr = 0;
#if !JVET_S0234_ACT_CRS_FIX
bool doReshaping = (slice.getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && (slice.isIntra() || m_pcReshape->getCTUFlag()) && (cbArea.width * cbArea.height > 4));
if (doReshaping)
{
......@@ -4490,18 +4511,21 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti
int adj = m_pcReshape->calculateChromaAdjVpduNei(tu, areaY);
tu.setChromaAdj(adj);
}
#endif
CompStorage orgResiCb[5], orgResiCr[5]; // 0:std, 1-3:jointCbCr (placeholder at this stage), 4:crossComp
orgResiCb[0].create(cbArea);
orgResiCr[0].create(crArea);
orgResiCb[0].copyFrom(csFull->getOrgResiBuf(cbArea));
orgResiCr[0].copyFrom(csFull->getOrgResiBuf(crArea));
#if !JVET_S0234_ACT_CRS_FIX
if (doReshaping)
{
int cResScaleInv = tu.getChromaAdj();
orgResiCb[0].scaleSignal(cResScaleInv, 1, slice.clpRng(COMPONENT_Cb));
orgResiCr[0].scaleSignal(cResScaleInv, 1, slice.clpRng(COMPONENT_Cr));
}
#endif
// 3.1 regular chroma residual coding
csFull->getResiBuf(cbArea).copyFrom(orgResiCb[0]);
......@@ -4539,7 +4563,21 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti
}
}
if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless())
#if JVET_S0234_ACT_CRS_FIX
{
if (doReshaping)
{
int cResScaleInv = tu.getChromaAdj();
m_pcRdCost->lambdaAdjustColorTrans(true, compID, true, &cResScaleInv);
}
else
{
m_pcRdCost->lambdaAdjustColorTrans(true, compID);
}
}
#else
m_pcRdCost->lambdaAdjustColorTrans(true, compID);
#endif
TempCtx ctxBegin(m_CtxCache);
ctxBegin = m_CABACEstimator->getCtx();
......@@ -4616,6 +4654,12 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti
PelBuf piPred = csFull->getPredBuf(area);
PelBuf piResi = invColorTransResidual.bufs[compID];
#if JVET_S0234_ACT_CRS_FIX
if (doReshaping && (compID != COMPONENT_Y))
{
piResi.scaleSignal(tu.getChromaAdj(), 0, slice.clpRng(compID));
}
#endif
piReco.reconstruct(piPred, piResi, cs.slice->clpRng(compID));
if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcEncCfg->getLmcs()
......@@ -4724,6 +4768,12 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti
PelBuf piPred = csFull->getPredBuf(area);
PelBuf piResi = invColorTransResidual.bufs[compID];
#if JVET_S0234_ACT_CRS_FIX
if (doReshaping && (compID != COMPONENT_Y))
{
piResi.scaleSignal(tu.getChromaAdj(), 0, slice.clpRng(compID));
}
#endif
piReco.reconstruct(piPred, piResi, cs.slice->clpRng(compID));
if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcEncCfg->getLmcs()
& slice.getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || (isChroma(compID) && m_pcEncCfg->getReshapeIntraCMD()))))
......
......@@ -272,7 +272,9 @@ void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei)
WRITE_CODE( sei.m_cpbRemovalDelayLength - 1, 5, "cpb_removal_delay_length_minus1" );
CHECK (sei.m_dpbOutputDelayLength < 1, "sei.m_dpbOutputDelayLength must be > 0");
WRITE_CODE( sei.m_dpbOutputDelayLength - 1, 5, "dpb_output_delay_length_minus1" );
#if !JVET_S0185_PROPOSAL2_SEI_CLEANUP
WRITE_FLAG(sei.m_altCpbParamsPresentFlag, "alt_cpb_params_present_flag");
#endif
WRITE_FLAG( sei.m_bpDecodingUnitHrdParamsPresentFlag, "bp_decoding_unit_hrd_params_present_flag" );
if( sei.m_bpDecodingUnitHrdParamsPresentFlag )
{
......@@ -308,7 +310,14 @@ void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei)
}
CHECK (sei.m_bpCpbCnt < 1, "sei.m_bpCpbCnt must be > 0");
WRITE_UVLC( sei.m_bpCpbCnt - 1, "bp_cpb_cnt_minus1");
#if JVET_S0181_PROPOSAL1
if (sei.m_bpMaxSubLayers - 1 > 0)
{
WRITE_FLAG(sei.m_sublayerInitialCpbRemovalDelayPresentFlag, "bp_sublayer_initial_cpb_removal_delay_present_flag");
}
#else
WRITE_FLAG(sei.m_sublayerInitialCpbRemovalDelayPresentFlag, "sublayer_initial_cpb_removal_delay_present_flag");
#endif
for (int i = (sei.m_sublayerInitialCpbRemovalDelayPresentFlag ? 0 : sei.m_bpMaxSubLayers - 1); i < sei.m_bpMaxSubLayers; i++)
{
for( int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
......@@ -332,6 +341,9 @@ void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei)
WRITE_UVLC( sei.m_dpbOutputTidOffset[i], "dpb_output_tid_offset[i]" );
}
}
#if JVET_S0185_PROPOSAL2_SEI_CLEANUP
WRITE_FLAG(sei.m_altCpbParamsPresentFlag, "bp_alt_cpb_params_present_flag");
#endif
if (sei.m_altCpbParamsPresentFlag)
{
WRITE_FLAG(sei.m_useAltCpbParamsFlag, "use_alt_cpb_params_flag");
......
......@@ -256,8 +256,13 @@ void HLSWriter::codePPS( const PPS* pcPPS )
WRITE_UVLC( pcPPS->getPicWidthInLumaSamples(), "pic_width_in_luma_samples" );
WRITE_UVLC( pcPPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" );
Window conf = pcPPS->getConformanceWindow();
#if JVET_R0068_ASPECT6_ENC_RESTRICTION
WRITE_FLAG(pcPPS->getConformanceWindowFlag(), "pps_conformance_window_flag");
if (pcPPS->getConformanceWindowFlag())
#else
WRITE_FLAG(conf.getWindowEnabledFlag(), "pps_conformance_window_flag");
if (conf.getWindowEnabledFlag())
#endif
{
WRITE_UVLC(conf.getWindowLeftOffset(), "pps_conf_win_left_offset");
WRITE_UVLC(conf.getWindowRightOffset(), "pps_conf_win_right_offset");
......@@ -772,7 +777,12 @@ void HLSWriter::codeSPS( const SPS* pcSPS )
CHECK(pcSPS->getMaxTLayers() == 0, "Maximum number of temporal sub-layers is '0'");
WRITE_CODE(pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1");
#if JVET_S0186_SPS_CLEANUP
WRITE_CODE(int(pcSPS->getChromaFormatIdc()), 2, "chroma_format_idc");
WRITE_CODE(floorLog2(pcSPS->getCTUSize()) - 5, 2, "sps_log2_ctu_size_minus5");
#else
WRITE_CODE(0, 4, "sps_reserved_zero_4bits");
#endif
WRITE_FLAG(pcSPS->getPtlDpbHrdParamsPresentFlag(), "sps_ptl_dpb_hrd_params_present_flag");
if( !pcSPS->getVPSId() )
......@@ -786,7 +796,9 @@ void HLSWriter::codeSPS( const SPS* pcSPS )
}
WRITE_FLAG(pcSPS->getGDREnabledFlag(), "gdr_enabled_flag");
#if !JVET_S0186_SPS_CLEANUP
WRITE_CODE(int(pcSPS->getChromaFormatIdc ()), 2, "chroma_format_idc");
#endif
#if !JVET_S0052_RM_SEPARATE_COLOUR_PLANE
const ChromaFormat format = pcSPS->getChromaFormatIdc();
......@@ -818,7 +830,9 @@ void HLSWriter::codeSPS( const SPS* pcSPS )
WRITE_UVLC(conf.getWindowBottomOffset(), "sps_conf_win_bottom_offset");
}
#if !JVET_S0186_SPS_CLEANUP
WRITE_CODE(floorLog2(pcSPS->getCTUSize()) - 5, 2, "sps_log2_ctu_size_minus5");
#endif
WRITE_FLAG(pcSPS->getSubPicInfoPresentFlag(), "subpic_info_present_flag");
......