Commit 01835e0b authored by Frank Bossen's avatar Frank Bossen
Browse files

Merge branch 'master' into 'S0266_VUI'

# Conflicts:
#   source/Lib/CommonLib/TypeDef.h
parents 667cd717 7d9aef0f
......@@ -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:
......
......@@ -656,9 +656,9 @@ void Slice::checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureLi
for (int i = 0; i < numEntriesL0; i++)
{
if (m_pRPL0->isInterLayerRefPic(i))
if (pRPL0->isInterLayerRefPic(i))
{
int refLayerId = m_pcPic->cs->vps->getLayerId(m_pcPic->cs->vps->getDirectRefLayerIdx(layerIdx, m_pRPL0->getInterLayerRefPicIdx(i)));
int refLayerId = m_pcPic->cs->vps->getLayerId(m_pcPic->cs->vps->getDirectRefLayerIdx(layerIdx, pRPL0->getInterLayerRefPicIdx(i)));
pcRefPic = xGetRefPic(rcListPic, getPOC(), refLayerId);
refPicPOC = pcRefPic->getPOC();
}
......@@ -715,9 +715,9 @@ void Slice::checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureLi
for (int i = 0; i < numEntriesL1; i++)
{
if (m_pRPL1->isInterLayerRefPic(i))
if (pRPL1->isInterLayerRefPic(i))
{
int refLayerId = m_pcPic->cs->vps->getLayerId(m_pcPic->cs->vps->getDirectRefLayerIdx(layerIdx, m_pRPL1->getInterLayerRefPicIdx(i)));
int refLayerId = m_pcPic->cs->vps->getLayerId(m_pcPic->cs->vps->getDirectRefLayerIdx(layerIdx, pRPL1->getInterLayerRefPicIdx(i)));
pcRefPic = xGetRefPic(rcListPic, getPOC(), refLayerId);
refPicPOC = pcRefPic->getPOC();
}
......@@ -1248,119 +1248,118 @@ void Slice::checkSubpicTypeConstraints(PicList& rcListPic, const ReferencePictur
"for all the subpictures that are in the picture and contain at least one P or B slice");
}
// below constraints are invoked only if the current slice is the first slice of a subpicture
if (getCtuAddrInSlice(0) != getPPS()->getSubPic(curSubpicIdx).getFirstCTUInSubPic())
{
return;
}
int nalUnitType = getNalUnitType();
int prevGDRSubpicPOC = getPrevGDRSubpicPOC();
int prevIRAPSubpicPOC = getPrevIRAPSubpicPOC();
int prevIRAPSubpicType = getPrevIRAPSubpicType();
if (prevIRAPSubpicPOC > getPOC() && (nalUnitType < NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalUnitType > NAL_UNIT_CODED_SLICE_CRA))
{
CHECK(nalUnitType != NAL_UNIT_CODED_SLICE_RASL && nalUnitType != NAL_UNIT_CODED_SLICE_RADL,
"When a subpicture is a leading subpicture of an IRAP subpicture, it shall be a RADL or RASL subpicture");
}
if (prevIRAPSubpicPOC <= getPOC())
if (getCtuAddrInSlice(0) == getPPS()->getSubPic(curSubpicIdx).getFirstCTUInSubPic())
{
CHECK(nalUnitType == NAL_UNIT_CODED_SLICE_RASL || nalUnitType == NAL_UNIT_CODED_SLICE_RADL,
"When a subpicture is not a leading subpicture of an IRAP subpicture, it shall not be a RADL or RASL subpicture");
}
CHECK(nalUnitType == NAL_UNIT_CODED_SLICE_RASL && (prevIRAPSubpicType == NAL_UNIT_CODED_SLICE_IDR_N_LP || prevIRAPSubpicType == NAL_UNIT_CODED_SLICE_IDR_W_RADL),
"No RASL subpictures shall be present in the bitstream that are associated with an IDR subpicture");
// subpicture type related constraints invoked only if the current slice is the first slice of a subpicture
int prevGDRSubpicPOC = getPrevGDRSubpicPOC();
int prevIRAPSubpicType = getPrevIRAPSubpicType();
CHECK(nalUnitType == NAL_UNIT_CODED_SLICE_RADL && prevIRAPSubpicType == NAL_UNIT_CODED_SLICE_IDR_N_LP,
"No RADL subpictures shall be present in the bitstream that are associated with an IDR subpicture having nal_unit_type equal to IDR_N_LP");
//constraints related to current subpicture type and its preceding subpicture types
PicList::iterator iterPic = rcListPic.begin();
int numNonLeadingPic = 0;
while (iterPic != rcListPic.end())
{
Picture* bufPic = *(iterPic++);
if (!bufPic->reconstructed)
if (prevIRAPSubpicPOC > getPOC() && (nalUnitType < NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalUnitType > NAL_UNIT_CODED_SLICE_CRA))
{
continue;
CHECK(nalUnitType != NAL_UNIT_CODED_SLICE_RASL && nalUnitType != NAL_UNIT_CODED_SLICE_RADL,
"When a subpicture is a leading subpicture of an IRAP subpicture, it shall be a RADL or RASL subpicture");
}
if (bufPic->poc == getPOC())
if (prevIRAPSubpicPOC <= getPOC())
{
continue;
CHECK(nalUnitType == NAL_UNIT_CODED_SLICE_RASL || nalUnitType == NAL_UNIT_CODED_SLICE_RADL,
"When a subpicture is not a leading subpicture of an IRAP subpicture, it shall not be a RADL or RASL subpicture");
}
//identify the subpicture in the reference picture buffer that with nuh_layer_id equal to current subpicture layerId and subpicture index equal to current subpicIdx
bool isBufPicOutput = false;
int bufSubpicType = NAL_UNIT_INVALID;
int bufSubpicPrevIRAPSubpicPOC = 0;
for (int i = 0; i < bufPic->numSlices; i++)
CHECK(nalUnitType == NAL_UNIT_CODED_SLICE_RASL && (prevIRAPSubpicType == NAL_UNIT_CODED_SLICE_IDR_N_LP || prevIRAPSubpicType == NAL_UNIT_CODED_SLICE_IDR_W_RADL),
"No RASL subpictures shall be present in the bitstream that are associated with an IDR subpicture");
CHECK(nalUnitType == NAL_UNIT_CODED_SLICE_RADL && prevIRAPSubpicType == NAL_UNIT_CODED_SLICE_IDR_N_LP,
"No RADL subpictures shall be present in the bitstream that are associated with an IDR subpicture having nal_unit_type equal to IDR_N_LP");
//constraints related to current subpicture type and its preceding subpicture types
PicList::iterator iterPic = rcListPic.begin();
int numNonLeadingPic = 0;
while (iterPic != rcListPic.end())
{
if (bufPic->sliceSubpicIdx[i] == curSubpicIdx)
Picture* bufPic = *(iterPic++);
if (!bufPic->reconstructed)
{
isBufPicOutput = bufPic->slices[i]->getPicHeader()->getPicOutputFlag();
bufSubpicType = bufPic->slices[i]->getNalUnitType();
bufSubpicPrevIRAPSubpicPOC = bufPic->slices[i]->getPrevIRAPSubpicPOC();
break;
continue;
}
if (bufPic->poc == getPOC())
{
continue;
}
}
if ((nalUnitType == NAL_UNIT_CODED_SLICE_CRA || nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) &&
!getPicHeader()->getNoOutputOfPriorPicsFlag() && isBufPicOutput == 1 && bufPic->layerId == m_nuhLayerId )
{
CHECK(bufPic->poc >= getPOC(), "Any subpicture, with nuh_layer_id equal to a particular value layerId and subpicture index equal to a particular value subpicIdx, that "
"precedes, in decoding order, an IRAP subpicture with nuh_layer_id equal to layerId and subpicture index equal to subpicIdx shall precede, in output order, the "
"IRAP subpicture");
}
//identify the subpicture in the reference picture buffer that with nuh_layer_id equal to current subpicture layerId and subpicture index equal to current subpicIdx
bool isBufPicOutput = false;
int bufSubpicType = NAL_UNIT_INVALID;
int bufSubpicPrevIRAPSubpicPOC = 0;
for (int i = 0; i < bufPic->numSlices; i++)
{
if (bufPic->sliceSubpicIdx[i] == curSubpicIdx)
{
isBufPicOutput = bufPic->slices[i]->getPicHeader()->getPicOutputFlag();
bufSubpicType = bufPic->slices[i]->getNalUnitType();
bufSubpicPrevIRAPSubpicPOC = bufPic->slices[i]->getPrevIRAPSubpicPOC();
break;
}
}
if (nalUnitType == NAL_UNIT_CODED_SLICE_RADL && isBufPicOutput == 1 && bufPic->layerId == m_nuhLayerId &&
prevIRAPSubpicPOC > bufSubpicPrevIRAPSubpicPOC && prevIRAPSubpicPOC != bufPic->poc)
{
CHECK(bufPic->poc >= getPOC(), "Any subpicture, with nuh_layer_id equal to a particular value layerId and subpicture index equal to a particular value subpicIdx, that "
"precedes, in decoding order, an IRAP subpicture with nuh_layer_id equal to layerId and subpicture index equal to subpicIdx shall precede, in output order, all "
"its associated RADL subpictures");
}
if ((nalUnitType == NAL_UNIT_CODED_SLICE_CRA || nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) &&
!getPicHeader()->getNoOutputOfPriorPicsFlag() && isBufPicOutput == 1 && bufPic->layerId == m_nuhLayerId)
{
CHECK(bufPic->poc >= getPOC(), "Any subpicture, with nuh_layer_id equal to a particular value layerId and subpicture index equal to a particular value subpicIdx, that "
"precedes, in decoding order, an IRAP subpicture with nuh_layer_id equal to layerId and subpicture index equal to subpicIdx shall precede, in output order, the "
"IRAP subpicture");
}
if ( (getPOC() == getPicHeader()->getRecoveryPocCnt() + prevGDRSubpicPOC) && !getPicHeader()->getNoOutputOfPriorPicsFlag() && isBufPicOutput == 1 &&
bufPic->layerId == m_nuhLayerId && nalUnitType != NAL_UNIT_CODED_SLICE_GDR && getPicHeader()->getRecoveryPocCnt() != -1 )
{
CHECK(bufPic->poc >= getPOC(), "Any subpicture, with nuh_layer_id equal to a particular value layerId and subpicture index equal to a particular value subpicIdx, that "
"precedes, in decoding order, a subpicture with nuh_layer_id equal to layerId and subpicture index equal to subpicIdx in a recovery point picture shall precede "
"that subpicture in the recovery point picture in output order");
}
if (nalUnitType == NAL_UNIT_CODED_SLICE_RADL && isBufPicOutput == 1 && bufPic->layerId == m_nuhLayerId &&
prevIRAPSubpicPOC > bufSubpicPrevIRAPSubpicPOC && prevIRAPSubpicPOC != bufPic->poc)
{
CHECK(bufPic->poc >= getPOC(), "Any subpicture, with nuh_layer_id equal to a particular value layerId and subpicture index equal to a particular value subpicIdx, that "
"precedes, in decoding order, an IRAP subpicture with nuh_layer_id equal to layerId and subpicture index equal to subpicIdx shall precede, in output order, all "
"its associated RADL subpictures");
}
if (nalUnitType == NAL_UNIT_CODED_SLICE_RASL && prevIRAPSubpicType == NAL_UNIT_CODED_SLICE_CRA && bufSubpicType == NAL_UNIT_CODED_SLICE_RADL &&
prevIRAPSubpicPOC == bufSubpicPrevIRAPSubpicPOC )
{
CHECK(bufPic->poc <= getPOC(), "Any RASL subpicture associated with a CRA subpicture shall precede any RADL subpicture associated with the CRA subpicture in output order");
}
if ((getPOC() == getPicHeader()->getRecoveryPocCnt() + prevGDRSubpicPOC) && !getPicHeader()->getNoOutputOfPriorPicsFlag() && isBufPicOutput == 1 &&
bufPic->layerId == m_nuhLayerId && nalUnitType != NAL_UNIT_CODED_SLICE_GDR && getPicHeader()->getRecoveryPocCnt() != -1)
{
CHECK(bufPic->poc >= getPOC(), "Any subpicture, with nuh_layer_id equal to a particular value layerId and subpicture index equal to a particular value subpicIdx, that "
"precedes, in decoding order, a subpicture with nuh_layer_id equal to layerId and subpicture index equal to subpicIdx in a recovery point picture shall precede "
"that subpicture in the recovery point picture in output order");
}
if (nalUnitType == NAL_UNIT_CODED_SLICE_RASL && prevIRAPSubpicType == NAL_UNIT_CODED_SLICE_CRA && bufPic->layerId == m_nuhLayerId && bufPic->poc < prevIRAPSubpicPOC)
{
if (bufSubpicType == NAL_UNIT_CODED_SLICE_IDR_N_LP || bufSubpicType == NAL_UNIT_CODED_SLICE_IDR_W_RADL ||
bufSubpicType == NAL_UNIT_CODED_SLICE_CRA || bufSubpicType == NAL_UNIT_CODED_SLICE_GDR )
if (nalUnitType == NAL_UNIT_CODED_SLICE_RASL && prevIRAPSubpicType == NAL_UNIT_CODED_SLICE_CRA && bufSubpicType == NAL_UNIT_CODED_SLICE_RADL &&
prevIRAPSubpicPOC == bufSubpicPrevIRAPSubpicPOC)
{
CHECK(bufPic->poc <= getPOC(), "Any RASL subpicture associated with a CRA subpicture shall precede any RADL subpicture associated with the CRA subpicture in output order");
}
if (nalUnitType == NAL_UNIT_CODED_SLICE_RASL && prevIRAPSubpicType == NAL_UNIT_CODED_SLICE_CRA && bufPic->layerId == m_nuhLayerId && bufPic->poc < prevIRAPSubpicPOC)
{
CHECK(bufPic->poc >= getPOC(), "Any RASL subpicture, with nuh_layer_id equal to a particular value layerId and subpicture index equal to a particular value subpicIdx, "
if (bufSubpicType == NAL_UNIT_CODED_SLICE_IDR_N_LP || bufSubpicType == NAL_UNIT_CODED_SLICE_IDR_W_RADL ||
bufSubpicType == NAL_UNIT_CODED_SLICE_CRA || bufSubpicType == NAL_UNIT_CODED_SLICE_GDR)
{
CHECK(bufPic->poc >= getPOC(), "Any RASL subpicture, with nuh_layer_id equal to a particular value layerId and subpicture index equal to a particular value subpicIdx, "
"associated with a CRA subpicture shall follow, in output order, any IRAP or GDR subpicture , with nuh_layer_id equal to layerId and subpicture index equal to "
"subpicIdx, that precedes the CRA subpicture in decoding order");
}
}
}
if ((nalUnitType == NAL_UNIT_CODED_SLICE_RASL || nalUnitType == NAL_UNIT_CODED_SLICE_RADL) &&
bufSubpicType != NAL_UNIT_CODED_SLICE_RASL && bufSubpicType != NAL_UNIT_CODED_SLICE_RADL &&
bufSubpicPrevIRAPSubpicPOC == prevIRAPSubpicPOC && bufPic->layerId == m_nuhLayerId )
{
numNonLeadingPic++;
int th = bufPic->cs->sps->getFieldSeqFlag()? 1: 0;
CHECK(bufPic->poc > prevIRAPSubpicPOC && numNonLeadingPic > th, "If field_seq_flag is equal to 0 and the current subpicture, with nuh_layer_id equal to a particular value "
"layerId and subpicture index equal to a particular value subpicIdx, is a leading subpicture associated with an IRAP subpicture, it shall precede, in decoding order, "
"all non-leading subpictures that are associated with the same IRAP subpicture. Otherwise, let subpicA and subpicB be the first and the last leading subpictures, in "
"decoding order, associated with an IRAP subpicture, respectively, there shall be at most one non-leading subpicture with nuh_layer_id equal to layerId and subpicture "
"index equal to subpicIdx preceding subpicA in decoding order, and there shall be no non-leading picture with nuh_layer_id equal to layerId and subpicture index equal "
"to subpicIdx between picA and picB in decoding order");
}
if ((nalUnitType == NAL_UNIT_CODED_SLICE_RASL || nalUnitType == NAL_UNIT_CODED_SLICE_RADL) &&
bufSubpicType != NAL_UNIT_CODED_SLICE_RASL && bufSubpicType != NAL_UNIT_CODED_SLICE_RADL &&
bufSubpicPrevIRAPSubpicPOC == prevIRAPSubpicPOC && bufPic->layerId == m_nuhLayerId)
{
numNonLeadingPic++;
int th = bufPic->cs->sps->getFieldSeqFlag() ? 1 : 0;
CHECK(bufPic->poc > prevIRAPSubpicPOC && numNonLeadingPic > th, "If field_seq_flag is equal to 0 and the current subpicture, with nuh_layer_id equal to a particular value "
"layerId and subpicture index equal to a particular value subpicIdx, is a leading subpicture associated with an IRAP subpicture, it shall precede, in decoding order, "
"all non-leading subpictures that are associated with the same IRAP subpicture. Otherwise, let subpicA and subpicB be the first and the last leading subpictures, in "
"decoding order, associated with an IRAP subpicture, respectively, there shall be at most one non-leading subpicture with nuh_layer_id equal to layerId and subpicture "
"index equal to subpicIdx preceding subpicA in decoding order, and there shall be no non-leading picture with nuh_layer_id equal to layerId and subpicture index equal "
"to subpicIdx between picA and picB in decoding order");
}
}
}
//subpic RPL related constraints
......@@ -1377,9 +1376,9 @@ void Slice::checkSubpicTypeConstraints(PicList& rcListPic, const ReferencePictur
int layerIdx = m_pcPic->cs->vps == nullptr ? 0 : m_pcPic->cs->vps->getGeneralLayerIdx(m_pcPic->layerId);
for (int i = 0; i < numEntriesL0; i++)
{
if (m_pRPL0->isInterLayerRefPic(i))
if (pRPL0->isInterLayerRefPic(i))
{
int refLayerId = m_pcPic->cs->vps->getLayerId(m_pcPic->cs->vps->getDirectRefLayerIdx(layerIdx, m_pRPL0->getInterLayerRefPicIdx(i)));
int refLayerId = m_pcPic->cs->vps->getLayerId(m_pcPic->cs->vps->getDirectRefLayerIdx(layerIdx, pRPL0->getInterLayerRefPicIdx(i)));
pcRefPic = xGetRefPic(rcListPic, getPOC(), refLayerId);
refPicPOC = pcRefPic->getPOC();
}
......@@ -1451,9 +1450,9 @@ void Slice::checkSubpicTypeConstraints(PicList& rcListPic, const ReferencePictur
for (int i = 0; i < numEntriesL1; i++)
{
if (m_pRPL1->isInterLayerRefPic(i))
if (pRPL1->isInterLayerRefPic(i))
{
int refLayerId = m_pcPic->cs->vps->getLayerId(m_pcPic->cs->vps->getDirectRefLayerIdx(layerIdx, m_pRPL1->getInterLayerRefPicIdx(i)));
int refLayerId = m_pcPic->cs->vps->getLayerId(m_pcPic->cs->vps->getDirectRefLayerIdx(layerIdx, pRPL1->getInterLayerRefPicIdx(i)));
pcRefPic = xGetRefPic(rcListPic, getPOC(), refLayerId);
refPicPOC = pcRefPic->getPOC();
}
......
......@@ -61,6 +61,7 @@
#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
......@@ -76,6 +77,19 @@
#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_S0048_SCALING_OFFSET 1 // JVET-S0048 Aspect2: change the constraint on the value ranges of scaling window offsets to be more flexible
#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
......
......@@ -127,8 +127,28 @@ bool CU::getRprScaling( const SPS* sps, const PPS* curPPS, Picture* refPic, int&
CHECK(curPicWidth > refPicWidth * 8, "curPicWidth shall be less than or equal to refPicWidth * 8");
CHECK(curPicHeight > refPicHeight * 8, "curPicHeight shall be less than or equal to refPicHeight * 8");
#if JVET_S0048_SCALING_OFFSET
int subWidthC = SPS::getWinUnitX(sps->getChromaFormatIdc());
int subHeightC = SPS::getWinUnitY(sps->getChromaFormatIdc());
CHECK(subWidthC * curScalingWindow.getWindowLeftOffset() < (-curPicWidthY) * 15, "The value of SubWidthC * pps_scaling_win_left_offset shall be greater than or equal to -pps_pic_width_in_luma_samples * 15");
CHECK(subWidthC * curScalingWindow.getWindowLeftOffset() >= curPicWidthY, "The value of SubWidthC * pps_scaling_win_left_offset shall be less than pic_width_in_luma_samples");
CHECK(subWidthC * curScalingWindow.getWindowRightOffset() < (-curPicWidthY) * 15, "The value of SubWidthC * pps_scaling_win_right_offset shall be greater than or equal to -pps_pic_width_in_luma_samples * 15");
CHECK(subWidthC * curScalingWindow.getWindowRightOffset() >= curPicWidthY, "The value of SubWidthC * pps_scaling_win_right_offset shall be less than pic_width_in_luma_samples");
CHECK(subHeightC * curScalingWindow.getWindowTopOffset() < (-curPicHeightY) * 15, "The value of SubHeightC * pps_scaling_win_top_offset shall be greater than or equal to -pps_pic_height_in_luma_samples * 15");
CHECK(subHeightC * curScalingWindow.getWindowTopOffset() >= curPicHeightY, "The value of SubHeightC * pps_scaling_win_top_offset shall be less than pps_pic_height_in_luma_samples");
CHECK(subHeightC * curScalingWindow.getWindowBottomOffset() < (-curPicHeightY) * 15, "The value of SubHeightC *pps_scaling_win_bottom_offset shall be greater than or equal to -pps_pic_height_in_luma_samples * 15");
CHECK(subHeightC * curScalingWindow.getWindowBottomOffset() >= curPicHeightY, "The value of SubHeightC *pps_scaling_win_bottom_offset shall be less than pps_pic_height_in_luma_samples");
CHECK(subWidthC * (curScalingWindow.getWindowLeftOffset() + curScalingWindow.getWindowRightOffset()) < (-curPicWidthY) * 15, "The value of SubWidthC * ( pps_scaling_win_left_offset + pps_scaling_win_right_offset ) shall be greater than or equal to -pps_pic_width_in_luma_samples * 15");
CHECK(subWidthC * (curScalingWindow.getWindowLeftOffset() + curScalingWindow.getWindowRightOffset()) >= curPicWidthY, "The value of SubWidthC * ( pps_scaling_win_left_offset + pps_scaling_win_right_offset ) shall be less than pic_width_in_luma_samples");
CHECK(subHeightC * (curScalingWindow.getWindowTopOffset() + curScalingWindow.getWindowBottomOffset()) < (-curPicHeightY) * 15, "The value of SubHeightC * ( pps_scaling_win_top_offset + pps_scaling_win_bottom_offset ) shall be greater than or equal to -pps_pic_height_in_luma_samples * 15");
CHECK(subHeightC * (curScalingWindow.getWindowTopOffset() + curScalingWindow.getWindowBottomOffset()) >= curPicHeightY, "The value of SubHeightC * ( pps_scaling_win_top_offset + pps_scaling_win_bottom_offset ) shall be less than pic_height_in_luma_samples");
#else
CHECK(SPS::getWinUnitX(sps->getChromaFormatIdc()) * (abs(curScalingWindow.getWindowLeftOffset()) + abs(curScalingWindow.getWindowRightOffset())) > curPPS->getPicWidthInLumaSamples(), "The value of SubWidthC * ( Abs(pps_scaling_win_left_offset) + Abs(pps_scaling_win_right_offset) ) shall be less than pic_width_in_luma_samples");
CHECK(SPS::getWinUnitY(sps->getChromaFormatIdc()) * (abs(curScalingWindow.getWindowTopOffset()) + abs(curScalingWindow.getWindowBottomOffset())) > curPPS->getPicHeightInLumaSamples(), "The value of SubHeightC * ( Abs(pps_scaling_win_top_offset) + Abs(pps_scaling_win_bottom_offset) ) shall be less than pic_height_in_luma_samples");
#endif
return refPic->isRefScaled( curPPS );
}
......
......@@ -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