Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • jvet/VVCSoftware_VTM
  • chenhuanbang/VVCSoftware_VTM
  • ezhizng/VVCSoftware_VTM
  • XZheng/VVCSoftware_VTM
  • YanZhang/VVCSoftware_VTM
  • xiaozhongxu/VVCSoftware_VTM
  • bossen/VVCSoftware_VTM
  • XiangLi/VVCSoftware_VTM
  • s.iwamura/VVCSoftware_VTM
  • yuling.hsiao/VVCSoftware_VTM
  • ccc2384823/VVCSoftware_VTM
  • yuchisu/VVCSoftware_VTM
  • schwarz/VVCSoftware_VTM
  • philippe.hanhart/VVCSoftware_VTM
  • nanh/VVCSoftware_VTM
  • guillaume.laroche/VVCSoftware_VTM
  • Kenneth/VVCSoftware_VTM
  • jonatan/VVCSoftware_VTM
  • Alexey/VVCSoftware_VTM
  • saintspear/VVCSoftware_VTM
  • xinzhao/VVCSoftware_VTM
  • Seungsoo/VVCSoftware_VTM
  • jamesxxiu/VVCSoftware_VTM
  • leolzhao/VVCSoftware_VTM
  • ywchen/VVCSoftware_VTM
  • kevin625/VVCSoftware_VTM
  • Zhang/VVCSoftware_VTM
  • zhangkai/VVCSoftware_VTM
  • YCSun/VVCSoftware_VTM
  • ksuehring/VVCSoftware_VTM
  • AbeKiyo/VVCSoftware_VTM
  • naeri.park/VVCSoftware_VTM
  • ling/VVCSoftware_VTM
  • aikiho/VVCSoftware_VTM
  • JangwonChoi/VVCSoftware_VTM
  • Shelly/VVCSoftware_VTM
  • blaeser/VVCSoftware_VTM
  • crhelmrich/VVCSoftware_VTM
  • keydel/VVCSoftware_VTM
  • adam_wieckowski/VVCSoftware_VTM
  • hashimry/VVCSoftware_VTM
  • yimingli/VVCSoftware_VTM
  • zhipin/VVCSoftware_VTM
  • chernyak/VVCSoftware_VTM
  • jvet-l-ahg-14/VVCSoftware_VTM
  • sauer/VVCSoftware_VTM
  • fbarbier/VVCSoftware_VTM
  • misrak/VVCSoftware_VTM
  • ikai/VVCSoftware_VTM
  • tlu/VVCSoftware_VTM
  • Yasugi/VVCSoftware_VTM
  • peterchuang/VVCSoftware_VTM
  • wanght99/VVCSoftware_VTM
  • yuhan/VVCSoftware_VTM
  • hongbin/VVCSoftware_VTM
  • jiahaoli/VVCSoftware_VTM
  • cfd/VVCSoftware_VTM
  • ruoyangyu/VVCSoftware_VTM
  • chujoh/VVCSoftware_VTM
  • lijingya/VVCSoftware_VTM
  • hinz/VVCSoftware_VTM
  • tamse.anish/VVCSoftware_VTM
  • mcoban/VVCSoftware_VTM
  • george/VVCSoftware_VTM
  • jeeva.raj/VVCSoftware_VTM
  • antoine/VVCSoftware_VTM
  • moonmo.koo/VVCSoftware_VTM
  • deluxan/VVCSoftware_VTM
  • bheng/VVCSoftware_VTM
  • lzz8246/VVCSoftware_VTM
  • delagrangep/VVCSoftware_VTM
  • jiechen/VVCSoftware_VTM
  • hendry197/VVCSoftware_VTM
  • LGE_VCC/VVCSoftware_VTM
  • asegall/VVCSoftware_VTM
  • pbcowan/VVCSoftware_VTM
  • forayr/VVCSoftware_VTM
  • JT/VVCSoftware_VTM
  • Zhou/VVCSoftware_VTM
  • yjpiao/VVCSoftware_VTM
  • fabrice.leleannec/VVCSoftware_VTM
  • tpoirier/VVCSoftware_VTM
  • PoHan.Lin/VVCSoftware_VTM
  • jzxu/VVCSoftware_VTM
  • junghak.nam/VVCSoftware_VTM
  • guichunli/VVCSoftware_VTM
  • xianglinwang/VVCSoftware_VTM
  • chunchic/VVCSoftware_VTM
  • chrisr12/VVCSoftware_VTM
  • ks_kashyap/VVCSoftware_VTM
  • minhua/VVCSoftware_VTM
  • Sheng-Yen.Lin/VVCSoftware_VTM
  • hegilmez/VVCSoftware_VTM
  • swongah/VVCSoftware_VTM
  • merkle/VVCSoftware_VTM
  • sunyucheng/VVCSoftware_VTM
  • kirchhoffer/VVCSoftware_VTM
  • vdrugeon/VVCSoftware_VTM
  • jennylai/VVCSoftware_VTM
  • rickxu/VVCSoftware_VTM
  • seuhong/VVCSoftware_VTM
  • chollmann/VVCSoftware_VTM
  • jvet-n-ce8-public/VVCSoftware_VTM
  • martin.m.pettersson/VVCSoftware_VTM
  • siekmann/VVCSoftware_VTM
  • aramasub/VVCSoftware_VTM
  • zhiyilin/VVCSoftware_VTM
  • EricLin/VVCSoftware_VTM
  • mengwang/VVCSoftware_VTM
  • m.sarwer/VVCSoftware_VTM
  • agnesedong/VVCSoftware_VTM
  • geonjungko/VVCSoftware_VTM
  • bray/VVCSoftware_VTM
  • yhchao/VVCSoftware_VTM
  • Zhu/VVCSoftware_VTM
  • ykato/VVCSoftware_VTM
  • ZhipinDeng/VVCSoftware_VTM
  • jasonjung/VVCSoftware_VTM
  • hanhuang/VVCSoftware_VTM
  • seregin/VVCSoftware_VTM
  • wchen1014/VVCSoftware_VTM
  • Auyeung/VVCSoftware_VTM
  • Morris/VVCSoftware_VTM
  • lphamvan/VVCSoftware_VTM
  • dmehlem/VVCSoftware_VTM
  • shih-ta.hsiang/VVCSoftware_VTM
  • ysanchez/VVCSoftware_VTM
  • baegn74/VVCSoftware_VTM
  • kazui/VVCSoftware_VTM
  • yuwenhe_vvc/VVCSoftware_VTM
  • rickard/VVCSoftware_VTM
  • wangyang.cs/VVCSoftware_VTM
  • xwmeng/VVCSoftware_VTM
  • takeshi.tsukuba/VVCSoftware_VTM
  • yixindu/VVCSoftware_VTM
  • baixiu.wz/VVCSoftware_VTM
  • hm.jang/VVCSoftware_VTM
  • Ted/VVCSoftware_VTM
  • nguyen/VVCSoftware_VTM
  • chaohsiu/VVCSoftware_VTM
  • francoise/VVCSoftware_VTM
  • Yin/VVCSoftware_VTM
  • Morigami/VVCSoftware_VTM
  • sagar.kotecha/VVCSoftware_VTM
  • hwsun/VVCSoftware_VTM
  • pierrick.bouvier/VVCSoftware_VTM
  • XiangMa/VVCSoftware_VTM
  • LouiseLee/VVCSoftware_VTM
  • chenps/VVCSoftware_VTM
  • karls/VVCSoftware_VTM
  • biaowang/VVCSoftware_VTM
  • hangao/VVCSoftware_VTM
  • Jin/VVCSoftware_VTM
  • analci/VVCSoftware_VTM
  • KuiFan/VVCSoftware_VTM
  • hobingzhang/VVCSoftware_VTM
  • audrey.turquin/VVCSoftware_VTM
  • rlliao/VVCSoftware_VTM
  • winken/VVCSoftware_VTM
  • hallapur/VVCSoftware_VTM
  • T.Hashimoto/VVCSoftware_VTM
  • AnandMeher/VVCSoftware_VTM
  • semihese/VVCSoftware_VTM
  • ouedraogo/VVCSoftware_VTM
  • arthurcerveira/VVCSoftware_VTM
  • sunmi.yoo/VVCSoftware_VTM
  • Cynthia/VVCSoftware_VTM
  • yang/VVCSoftware_VTM
  • yuyoon/VVCSoftware_VTM
  • jslee/VVCSoftware_VTM
  • weimin.zeng/VVCSoftware_VTM
  • edrthomas/VVCSoftware_VTM
  • Mitsuru.Katsumata/VVCSoftware_VTM
  • adybrowne/VVCSoftware_VTM
  • jack.enhorn/VVCSoftware_VTM
  • Palanivel/VVCSoftware_VTM
  • olena.chubach/VVCSoftware_VTM
  • juvenalluo/VVCSoftware_VTM
  • yylee/VVCSoftware_VTM
  • bross/VVCSoftware_VTM
  • jvet-ahg-nnvc/VVCSoftware_VTM
  • jacob/VVCSoftware_VTM
  • dmytro.rusanovskyy/VVCSoftware_VTM
  • karamnaser/VVCSoftware_VTM
  • milos.radosavljevic/VVCSoftware_VTM
  • Keming/VVCSoftware_VTM
  • pj/VVCSoftware_VTM
  • cwkuo/VVCSoftware_VTM
  • BD/VVCSoftware_VTM
  • bartnik/VVCSoftware_VTM
  • Fangjun.Pu/VVCSoftware_VTM
  • nikolay.shostak/VVCSoftware_VTM
  • kirill.suverov/VVCSoftware_VTM
  • Xile_Zhou/VVCSoftware_VTM
  • ksuehring/vvc-software-vtm-nnvc
  • guether/VVCSoftware_VTM
  • salmonc/VVCSoftware_VTM
  • eeehey/VVCSoftware_VTM
  • marie-pierre.gallasso/VVCSoftware_VTM
  • jvet-ahg-fgt/VTM
  • liaojq/VVCSoftware_VTM
  • axel.ricard/VVCSoftware_VTM
  • XiangLi/nnvc
  • sw.xie/VVCSoftware_VTM
  • jeeva.raj/vvc-software-vtm-tu-c
  • XiangLi/tu-c
  • msantamaria/nnvc
  • cjj490168650/VVCSoftware_VTM
  • Yun_li/VVCSoftware_VTM
  • Zhengang/vvc-software-vtm
  • lvzhuoyi/vvc-software-vtm-nnvc
  • Kenneth/vvc-software-vtm-nn
  • biatekt/vvc-software-vtm
  • jvet-ahg-gcc/VVCSoftware_VTM
  • JINGYING/VVCSoftware_VTM
  • furban/VVCSoftware_VTM
  • yanning/VVCSoftware_VTM
  • zhuochen/VVCSoftware_VTM
  • Kaifa/VVCSoftware_VTM_AJ0048
  • yueli/VVCSoftware_VTM
  • tokumo/VVCSoftware_VTM
221 results
Show changes
Commits on Source (22)
Showing
with 347 additions and 11 deletions
......@@ -130,6 +130,7 @@ LMCSEnable : 1 # LMCS: 0: disable, 1:enable
LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG
LMCSUpdateCtrl : 2 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP
MIP : 1
PROF : 1
# Fast tools
PBIntraFast : 1
......
......@@ -2515,20 +2515,26 @@ bool EncAppCfg::xCheckParameter()
xConfirmPara( m_uiMinQT[1] < 1<<MIN_CU_LOG2, "Minimum QT size should be larger than or equal to 4");
xConfirmPara( m_uiCTUSize < 16, "Maximum partition width size should be larger than or equal to 16");
xConfirmPara( m_uiCTUSize < 16, "Maximum partition height size should be larger than or equal to 16");
#if !JVET_O0640_PICTURE_SIZE_CONSTRAINT
xConfirmPara( (m_iSourceWidth % (1<<MIN_CU_LOG2))!=0, "Resulting coded frame width must be a multiple of the minimum unit size");
xConfirmPara( (m_iSourceHeight % (1<<MIN_CU_LOG2))!=0, "Resulting coded frame height must be a multiple of the minimum unit size");
xConfirmPara( (m_iSourceWidth % (1<<MIN_CU_LOG2))!=0, "Resulting coded frame width must be a multiple of the minimum unit size");
xConfirmPara( (m_iSourceHeight % (1<<MIN_CU_LOG2))!=0, "Resulting coded frame height must be a multiple of the minimum unit size");
xConfirmPara( (m_iSourceWidth % (1<<MIN_CU_LOG2))!=0, "Resulting coded frame width must be a multiple of the minimum unit size");
xConfirmPara( (m_iSourceHeight % (1<<MIN_CU_LOG2))!=0, "Resulting coded frame height must be a multiple of the minimum unit size");
#endif
xConfirmPara( m_uiMaxCUDepth < 1, "MaxPartitionDepth must be greater than zero");
xConfirmPara( (m_uiMaxCUWidth >> m_uiMaxCUDepth) < 4, "Minimum partition width size should be larger than or equal to 8");
xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8");
xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16");
xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16");
#if JVET_O0640_PICTURE_SIZE_CONSTRAINT
xConfirmPara( (m_iSourceWidth % (std::max(8, int(m_uiMaxCUWidth >> (m_uiMaxCUDepth - 1))))) != 0, "Resulting coded frame width must be a multiple of Max(8, the minimum CU size)");
xConfirmPara( (m_iSourceHeight % (std::max(8, int(m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1))))) != 0, "Resulting coded frame height must be a multiple of Max(8, the minimum CU size)");
#else
xConfirmPara( (m_iSourceWidth % (m_uiMaxCUWidth >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame width must be a multiple of the minimum CU size");
xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame height must be a multiple of the minimum CU size");
#endif
#if MAX_TB_SIZE_SIGNALLING
xConfirmPara( m_log2MaxTbSize > 6, "Log2MaxTbSize must be 6 or smaller." );
#endif
......
......@@ -115,7 +115,7 @@ protected:
static const int m_classToFilterMapping[NUM_FIXED_FILTER_SETS][MAX_NUM_ALF_CLASSES];
static const int m_fixedFilterSetCoeff[ALF_FIXED_FILTER_NUM][MAX_NUM_ALF_LUMA_COEFF];
short m_fixedFilterSetCoeffDec[NUM_FIXED_FILTER_SETS][MAX_NUM_ALF_CLASSES * MAX_NUM_ALF_LUMA_COEFF];
#if JVET_O0090_ALF_CHROMA_FILTER_ALTERNATIVES_CTB
#if JVET_O0090_ALF_CHROMA_FILTER_ALTERNATIVES_CTB || JVET_O_MAX_NUM_ALF_APS_8
short m_coeffApsLuma[ALF_CTB_MAX_NUM_APS][MAX_NUM_ALF_LUMA_COEFF * MAX_NUM_ALF_CLASSES];
short m_clippApsLuma[ALF_CTB_MAX_NUM_APS][MAX_NUM_ALF_LUMA_COEFF * MAX_NUM_ALF_CLASSES];
#else
......
......@@ -70,6 +70,9 @@ CodingStructure::CodingStructure(CUCache& cuCache, PUCache& puCache, TUCache& tu
#if JVET_O0070_PROF
, bestParent ( nullptr )
#endif
#if JVET_O1170_CHECK_BV_AT_DECODER
, resetIBCBuffer (false)
#endif
{
for( uint32_t i = 0; i < MAX_NUM_COMPONENT; i++ )
{
......@@ -1442,4 +1445,4 @@ IbcLumaCoverage CodingStructure::getIbcLumaCoverage(const CompArea& chromaArea)
return coverage;
}
#endif
\ No newline at end of file
#endif
......@@ -97,7 +97,11 @@ public:
bool isLossless;
const SPS *sps;
const PPS *pps;
#if JVET_O_MAX_NUM_ALF_APS_8
APS* alfApss[ALF_CTB_MAX_NUM_APS];
#else
APS* alfApss[MAX_NUM_APS];
#endif
APS * lmcsAps;
const VPS *vps;
const PreCalcValues* pcv;
......@@ -195,10 +199,6 @@ public:
LutMotionCand motionLut;
#if JVET_O1170_CHECK_BV_AT_DECODER
bool resetIBCBuffer;
#endif
void addMiToLut(static_vector<MotionInfo, MAX_NUM_HMVP_CANDS>& lut, const MotionInfo &mi);
private:
......@@ -237,7 +237,10 @@ public:
#if JVET_O0070_PROF
CodingStructure *bestParent;
#endif
#if JVET_O1170_CHECK_BV_AT_DECODER
bool resetIBCBuffer;
#endif
MotionBuf getMotionBuf( const Area& _area );
MotionBuf getMotionBuf( const UnitArea& _area ) { return getMotionBuf( _area.Y() ); }
MotionBuf getMotionBuf() { return getMotionBuf( area.Y() ); }
......
......@@ -187,7 +187,11 @@ static const int MAX_NUM_ALF_COEFF = MAX_ALF_FILTE
static const int MAX_ALF_PADDING_SIZE = 4;
static const int ALF_FIXED_FILTER_NUM = 64;
#if JVET_O_MAX_NUM_ALF_APS_8
static const int ALF_CTB_MAX_NUM_APS = 8;
#else
static const int ALF_CTB_MAX_NUM_APS = 6;
#endif
static const int NUM_FIXED_FILTER_SETS = 16;
static const int NUM_TOTAL_FILTER_SETS = NUM_FIXED_FILTER_SETS + ALF_CTB_MAX_NUM_APS;
......
......@@ -695,7 +695,11 @@ namespace DQIntern
{
CHECKD( lambda <= 0.0, "Lambda must be greater than 0" );
#if JVET_O0919_TS_MIN_QP
const int qpDQ = cQP.Qp(tu.mtsIdx==MTS_SKIP && isLuma(compID)) + 1;
#else
const int qpDQ = cQP.Qp + 1;
#endif
const int qpPer = qpDQ / 6;
const int qpRem = qpDQ - 6 * qpPer;
const SPS& sps = *tu.cs->sps;
......@@ -764,7 +768,11 @@ namespace DQIntern
}
//----- set dequant parameters -----
#if JVET_O0919_TS_MIN_QP
const int qpDQ = cQP.Qp(tu.mtsIdx==MTS_SKIP && isLuma(compID)) + 1;
#else
const int qpDQ = cQP.Qp + 1;
#endif
const int qpPer = qpDQ / 6;
const int qpRem = qpDQ - 6 * qpPer;
const SPS& sps = *tu.cs->sps;
......@@ -1745,7 +1753,11 @@ void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeff
if( tu.cs->slice->getDepQuantEnabledFlag() && (tu.mtsIdx != MTS_SKIP || !isLuma(compID)) )
{
//===== scaling matrix ====
#if JVET_O0919_TS_MIN_QP
const int qpDQ = cQP.Qp(tu.mtsIdx==MTS_SKIP && isLuma(compID)) + 1;
#else
const int qpDQ = cQP.Qp + 1;
#endif
const int qpPer = qpDQ / 6;
const int qpRem = qpDQ - 6 * qpPer;
const CompArea &rect = tu.blocks[compID];
......@@ -1768,7 +1780,11 @@ void DepQuant::dequant( const TransformUnit &tu, CoeffBuf &dstCoeff, const Compo
{
if( tu.cs->slice->getDepQuantEnabledFlag() && (tu.mtsIdx != MTS_SKIP || !isLuma(compID)) )
{
#if JVET_O0919_TS_MIN_QP
const int qpDQ = cQP.Qp(tu.mtsIdx==MTS_SKIP && isLuma(compID)) + 1;
#else
const int qpDQ = cQP.Qp + 1;
#endif
const int qpPer = qpDQ / 6;
const int qpRem = qpDQ - 6 * qpPer;
const CompArea &rect = tu.blocks[compID];
......
......@@ -961,7 +961,11 @@ Slice *Picture::swapSliceObject(Slice * p, uint32_t i)
slices[i] = p;
pTmp->setSPS(0);
pTmp->setPPS(0);
#if JVET_O_MAX_NUM_ALF_APS_8
memset(pTmp->getAlfAPSs(), 0, sizeof(*pTmp->getAlfAPSs())*ALF_CTB_MAX_NUM_APS);
#else
memset(pTmp->getAlfAPSs(), 0, sizeof(*pTmp->getAlfAPSs())*MAX_NUM_APS);
#endif
pTmp->setLmcsAPS(0);
return pTmp;
......
......@@ -65,6 +65,9 @@
QpParam::QpParam(const int qpy,
const ChannelType chType,
const int qpBdOffset,
#if JVET_O0919_TS_MIN_QP
const int minQpPrimeTsMinus4,
#endif
const int chromaQPOffset,
const ChromaFormat chFmt,
const int dqp )
......@@ -91,9 +94,26 @@ QpParam::QpParam(const int qpy,
baseQp = Clip3( 0, MAX_QP+qpBdOffset, baseQp + dqp );
#if JVET_O0919_TS_MIN_QP
Qps[0] =baseQp;
pers[0]=baseQp/6;
rems[0]=baseQp%6;
int baseQpTS = baseQp;
if( isLuma( chType ) )
{
baseQpTS = std::max(baseQpTS , 4 + minQpPrimeTsMinus4);
}
Qps[1] = baseQpTS;
pers[1] = baseQpTS / 6;
rems[1] = baseQpTS % 6;
#else
Qp =baseQp;
per=baseQp/6;
rem=baseQp%6;
#endif
}
QpParam::QpParam(const TransformUnit& tu, const ComponentID &compIDX, const int QP /*= -MAX_INT*/)
......@@ -126,7 +146,11 @@ QpParam::QpParam(const TransformUnit& tu, const ComponentID &compIDX, const int
int dqp = 0;
#if JVET_O0919_TS_MIN_QP
*this = QpParam(QP <= -MAX_INT ? tu.cu->qp : QP, toChannelType(compID), tu.cs->sps->getQpBDOffset(toChannelType(compID)), tu.cs->sps->getMinQpPrimeTsMinus4(toChannelType(compID)), chromaQpOffset, tu.chromaFormat, dqp);
#else
*this = QpParam(QP <= -MAX_INT ? tu.cu->qp : QP, toChannelType(compID), tu.cs->sps->getQpBDOffset(toChannelType(compID)), chromaQpOffset, tu.chromaFormat, dqp);
#endif
}
......@@ -397,8 +421,13 @@ void Quant::dequant(const TransformUnit &tu,
const bool needSqrtAdjustment = TU::needsBlockSizeTrafoScale( tu, compID );
const int iTransformShift = (bClipTransformShiftTo0 ? std::max<int>(0, originalTransformShift) : originalTransformShift) + (needSqrtAdjustment?-1:0);
#if JVET_O0919_TS_MIN_QP
const int QP_per = cQP.per(isTransformSkip);
const int QP_rem = cQP.rem(isTransformSkip);
#else
const int QP_per = cQP.per;
const int QP_rem = cQP.rem;
#endif
const int rightShift = (IQUANT_SHIFT - (iTransformShift + QP_per)) + (enableScalingLists ? LOG2_SCALING_LIST_NEUTRAL_VALUE : 0);
......@@ -943,7 +972,11 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf
CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list");
const uint32_t uiLog2TrWidth = g_aucLog2[uiWidth];
const uint32_t uiLog2TrHeight = g_aucLog2[uiHeight];
#if JVET_O0919_TS_MIN_QP
int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem(useTransformSkip), uiLog2TrWidth, uiLog2TrHeight);
#else
int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem, uiLog2TrWidth, uiLog2TrHeight);
#endif
const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, useTransformSkip);
......@@ -951,7 +984,11 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf
// compensated by a bit-shift (the quantised result will be sqrt(2) * larger than required).
// The quantScale table and shift is used to compensate for this.
const bool needSqrtAdjustment= TU::needsBlockSizeTrafoScale( tu, compID );
#if JVET_O0919_TS_MIN_QP
const int defaultQuantisationCoefficient = g_quantScales[needSqrtAdjustment?1:0][cQP.rem(useTransformSkip)];
#else
const int defaultQuantisationCoefficient = g_quantScales[needSqrtAdjustment?1:0][cQP.rem];
#endif
int iTransformShift = getTransformShift(channelBitDepth, rect.size(), maxLog2TrDynamicRange) + ( needSqrtAdjustment?-1:0);
if (useTransformSkip && sps.getSpsRangeExtension().getExtendedPrecisionProcessingFlag())
......@@ -960,7 +997,11 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf
}
#if JVET_O0919_TS_MIN_QP
const int iQBits = QUANT_SHIFT + cQP.per(useTransformSkip) + iTransformShift;
#else
const int iQBits = QUANT_SHIFT + cQP.per + iTransformShift;
#endif
// QBits will be OK for any internal bit depth as the reduction in transform shift is balanced by an increase in Qp_per due to QpBDOffset
const int64_t iAdd = int64_t(tu.cs->slice->isIRAP() ? 171 : 85) << int64_t(iQBits - 9);
......@@ -1014,7 +1055,11 @@ bool Quant::xNeedRDOQ(TransformUnit &tu, const ComponentID &compID, const CCoeff
const uint32_t uiLog2TrWidth = g_aucLog2[uiWidth];
const uint32_t uiLog2TrHeight = g_aucLog2[uiHeight];
#if JVET_O0919_TS_MIN_QP
int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem(useTransformSkip), uiLog2TrWidth, uiLog2TrHeight);
#else
int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem, uiLog2TrWidth, uiLog2TrHeight);
#endif
const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, (useTransformSkip != 0));
......@@ -1024,7 +1069,11 @@ bool Quant::xNeedRDOQ(TransformUnit &tu, const ComponentID &compID, const CCoeff
* Then a QP+3 (sqrt(2)) or QP-3 (1/sqrt(2)) method could be used to get the required result
*/
const bool needSqrtAdjustment= TU::needsBlockSizeTrafoScale( tu, compID );
#if JVET_O0919_TS_MIN_QP
const int defaultQuantisationCoefficient = g_quantScales[needSqrtAdjustment?1:0][cQP.rem(useTransformSkip)];
#else
const int defaultQuantisationCoefficient = g_quantScales[needSqrtAdjustment?1:0][cQP.rem];
#endif
int iTransformShift = getTransformShift(channelBitDepth, rect.size(), maxLog2TrDynamicRange) + (needSqrtAdjustment?-1:0);
if (useTransformSkip && sps.getSpsRangeExtension().getExtendedPrecisionProcessingFlag())
......@@ -1033,7 +1082,11 @@ bool Quant::xNeedRDOQ(TransformUnit &tu, const ComponentID &compID, const CCoeff
}
#if JVET_O0919_TS_MIN_QP
const int iQBits = QUANT_SHIFT + cQP.per(useTransformSkip) + iTransformShift;
#else
const int iQBits = QUANT_SHIFT + cQP.per + iTransformShift;
#endif
assert(iQBits>=0);
// QBits will be OK for any internal bit depth as the reduction in transform shift is balanced by an increase in Qp_per due to QpBDOffset
......@@ -1066,13 +1119,22 @@ void Quant::transformSkipQuantOneSample(TransformUnit &tu, const ComponentID &co
const int iTransformShift = getTransformShift(channelBitDepth, rect.size(), maxLog2TrDynamicRange);
const int scalingListType = getScalingListType(tu.cu->predMode, compID);
const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, true);
#if JVET_O0919_TS_MIN_QP
const bool useTransformSkip = tu.mtsIdx == MTS_SKIP && isLuma(compID);
const int defaultQuantisationCoefficient = g_quantScales[0][cQP.rem(useTransformSkip)];
#else
const int defaultQuantisationCoefficient = g_quantScales[0][cQP.rem];
#endif
CHECK( scalingListType >= SCALING_LIST_NUM, "Invalid scaling list" );
const uint32_t uiLog2TrWidth = g_aucLog2[uiWidth];
const uint32_t uiLog2TrHeight = g_aucLog2[uiHeight];
#if JVET_O0919_TS_MIN_QP
const int *const piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem(useTransformSkip), uiLog2TrWidth, uiLog2TrHeight);
#else
const int *const piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem, uiLog2TrWidth, uiLog2TrHeight);
#endif
/* for 422 chroma blocks, the effective scaling applied during transformation is not a power of 2, hence it cannot be
* implemented as a bit-shift (the quantised result will be sqrt(2) * larger than required). Alternatively, adjust the
......@@ -1080,7 +1142,11 @@ void Quant::transformSkipQuantOneSample(TransformUnit &tu, const ComponentID &co
* Then a QP+3 (sqrt(2)) or QP-3 (1/sqrt(2)) method could be used to get the required result
*/
#if JVET_O0919_TS_MIN_QP
const int iQBits = QUANT_SHIFT + cQP.per(useTransformSkip) + iTransformShift;
#else
const int iQBits = QUANT_SHIFT + cQP.per + iTransformShift;
#endif
// QBits will be OK for any internal bit depth as the reduction in transform shift is balanced by an increase in Qp_per due to QpBDOffset
const int iAdd = int64_t(bUseHalfRoundingPoint ? 256 : (tu.cs->slice->isIRAP() ? 171 : 85)) << int64_t(iQBits - 9);
TCoeff transformedCoefficient;
......@@ -1117,8 +1183,13 @@ void Quant::invTrSkipDeQuantOneSample(TransformUnit &tu, const ComponentID &comp
const CompArea &rect = tu.blocks[compID];
const uint32_t uiWidth = rect.width;
const uint32_t uiHeight = rect.height;
#if JVET_O0919_TS_MIN_QP
const int QP_per = cQP.per(tu.mtsIdx==MTS_SKIP && isLuma(compID));
const int QP_rem = cQP.rem(tu.mtsIdx==MTS_SKIP && isLuma(compID));
#else
const int QP_per = cQP.per;
const int QP_rem = cQP.rem;
#endif
const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(toChannelType(compID));
const int channelBitDepth = sps.getBitDepth(toChannelType(compID));
const int iTransformShift = getTransformShift(channelBitDepth, rect.size(), maxLog2TrDynamicRange);
......
......@@ -65,17 +65,30 @@ struct TrQuantParams
};
/// QP struct
#if JVET_O0919_TS_MIN_QP
class QpParam
#else
struct QpParam
#endif
{
#if JVET_O0919_TS_MIN_QP
int Qps[2];
int pers[2];
int rems[2];
#else
int Qp;
int per;
int rem;
#endif
private:
QpParam(const int qpy,
const ChannelType chType,
const int qpBdOffset,
#if JVET_O0919_TS_MIN_QP
const int minQpPrimeTsMinus4,
#endif
const int chromaQPOffset,
const ChromaFormat chFmt,
const int dqp );
......@@ -84,6 +97,12 @@ public:
QpParam(const TransformUnit& tu, const ComponentID &compID, const int QP = -MAX_INT);
#if JVET_O0919_TS_MIN_QP
int Qp ( const bool ts ) const { return Qps [ts?1:0]; }
int per( const bool ts ) const { return pers[ts?1:0]; }
int rem( const bool ts ) const { return rems[ts?1:0]; }
#endif
}; // END STRUCT DEFINITION QpParam
/// transform and quantization class
......
......@@ -628,13 +628,25 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
const bool needSqrtAdjustment= TU::needsBlockSizeTrafoScale( tu, compID );
#if JVET_O0919_TS_MIN_QP
const bool isTransformSkip = tu.mtsIdx==MTS_SKIP && isLuma(compID);
const double *const pdErrScale = xGetErrScaleCoeffSL(scalingListType, uiLog2BlockWidth, uiLog2BlockHeight, cQP.rem(isTransformSkip));
const int *const piQCoef = getQuantCoeff(scalingListType, cQP.rem(isTransformSkip), uiLog2BlockWidth, uiLog2BlockHeight);
#else
const double *const pdErrScale = xGetErrScaleCoeffSL(scalingListType, uiLog2BlockWidth, uiLog2BlockHeight, cQP.rem);
const int *const piQCoef = getQuantCoeff(scalingListType, cQP.rem, uiLog2BlockWidth, uiLog2BlockHeight);
const bool isTransformSkip = tu.mtsIdx==MTS_SKIP && isLuma(compID);
#endif
const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip);
#if JVET_O0919_TS_MIN_QP
const int defaultQuantisationCoefficient = g_quantScales[ needSqrtAdjustment ?1:0][cQP.rem(isTransformSkip)];
const double defaultErrorScale = xGetErrScaleCoeffNoScalingList(scalingListType, (uiLog2BlockWidth-1), (uiLog2BlockHeight-1), cQP.rem(isTransformSkip));
const int iQBits = QUANT_SHIFT + cQP.per(isTransformSkip) + iTransformShift + (needSqrtAdjustment?-1:0); // Right shift of non-RDOQ quantizer; level = (coeff*uiQ + offset)>>q_bits
#else
const int defaultQuantisationCoefficient = g_quantScales[ needSqrtAdjustment ?1:0][cQP.rem];
const double defaultErrorScale = xGetErrScaleCoeffNoScalingList(scalingListType, (uiLog2BlockWidth-1), (uiLog2BlockHeight-1), cQP.rem);
const int iQBits = QUANT_SHIFT + cQP.per + iTransformShift + (needSqrtAdjustment?-1:0); // Right shift of non-RDOQ quantizer; level = (coeff*uiQ + offset)>>q_bits
#endif
const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange);
......@@ -1078,10 +1090,17 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
if( cctx.signHiding() && uiAbsSum>=2)
{
#if JVET_O0919_TS_MIN_QP
const double inverseQuantScale = double(g_invQuantScales[0][cQP.rem(isTransformSkip)]);
int64_t rdFactor = (int64_t)(inverseQuantScale * inverseQuantScale * (1 << (2 * cQP.per(isTransformSkip))) / m_dLambda / 16
/ (1 << (2 * DISTORTION_PRECISION_ADJUSTMENT(channelBitDepth)))
+ 0.5);
#else
const double inverseQuantScale = double(g_invQuantScales[0][cQP.rem]);
int64_t rdFactor = (int64_t)(inverseQuantScale * inverseQuantScale * (1 << (2 * cQP.per)) / m_dLambda / 16
/ (1 << (2 * DISTORTION_PRECISION_ADJUSTMENT(channelBitDepth)))
+ 0.5);
#endif
int lastCG = -1;
int absSum = 0 ;
......@@ -1252,9 +1271,16 @@ void QuantRDOQ::xRateDistOptQuantTS( TransformUnit &tu, const ComponentID &compI
#endif
const bool needsSqrt2Scale = TU::needsSqrt2Scale( tu, compID ); // should always be false - transform-skipped blocks don't require sqrt(2) compensation.
#if JVET_O0919_TS_MIN_QP
const bool isTransformSkip = tu.mtsIdx==MTS_SKIP && isLuma(compID);
const int qBits = QUANT_SHIFT + qp.per(isTransformSkip) + transformShift + ( needsSqrt2Scale ? -1 : 0 ); // Right shift of non-RDOQ quantizer; level = (coeff*uiQ + offset)>>q_bits
const int quantisationCoefficient = g_quantScales[needsSqrt2Scale?1:0][qp.rem(isTransformSkip)];
const double errorScale = xGetErrScaleCoeff( TU::needsSqrt2Scale( tu, compID ), width, height, qp.rem(isTransformSkip), maxLog2TrDynamicRange, channelBitDepth );
#else
const int qBits = QUANT_SHIFT + qp.per + transformShift + (needsSqrt2Scale?-1:0); // Right shift of non-RDOQ quantizer; level = (coeff*uiQ + offset)>>q_bits
const int quantisationCoefficient = g_quantScales[needsSqrt2Scale?1:0][qp.rem];
const double errorScale = xGetErrScaleCoeff( TU::needsSqrt2Scale( tu, compID ), width, height, qp.rem, maxLog2TrDynamicRange, channelBitDepth );
#endif
const TCoeff entropyCodingMaximum = ( 1 << maxLog2TrDynamicRange ) - 1;
......@@ -1500,13 +1526,25 @@ void QuantRDOQ::forwardRDPCM( TransformUnit &tu, const ComponentID &compID, cons
#endif
const bool needsSqrt2Scale = TU::needsSqrt2Scale(tu, compID); // should always be false - transform-skipped blocks don't require sqrt(2) compensation.
#if JVET_O0919_TS_MIN_QP
const bool isTransformSkip = tu.mtsIdx==MTS_SKIP && isLuma(compID);
const int qBits = QUANT_SHIFT + qp.per(isTransformSkip) + transformShift + ( needsSqrt2Scale ? -1 : 0 ); // Right shift of non-RDOQ quantizer; level = (coeff*uiQ + offset)>>q_bits
const int quantisationCoefficient = g_quantScales[needsSqrt2Scale ? 1 : 0][qp.rem(isTransformSkip)];
const double errorScale = xGetErrScaleCoeff(TU::needsSqrt2Scale(tu, compID), width, height, qp.rem(isTransformSkip), maxLog2TrDynamicRange, channelBitDepth);
#else
const int qBits = QUANT_SHIFT + qp.per + transformShift + (needsSqrt2Scale ? -1 : 0); // Right shift of non-RDOQ quantizer; level = (coeff*uiQ + offset)>>q_bits
const int quantisationCoefficient = g_quantScales[needsSqrt2Scale ? 1 : 0][qp.rem];
const double errorScale = xGetErrScaleCoeff(TU::needsSqrt2Scale(tu, compID), width, height, qp.rem, maxLog2TrDynamicRange, channelBitDepth);
#endif
TrQuantParams trQuantParams;
#if JVET_O0919_TS_MIN_QP
trQuantParams.rightShift = (IQUANT_SHIFT - (transformShift + qp.per(isTransformSkip)));
trQuantParams.qScale = g_invQuantScales[needsSqrt2Scale ? 1 : 0][qp.rem(isTransformSkip)];
#else
trQuantParams.rightShift = (IQUANT_SHIFT - (transformShift + qp.per));
trQuantParams.qScale = g_invQuantScales[needsSqrt2Scale ? 1 : 0][qp.rem];
#endif
const TCoeff entropyCodingMaximum = (1 << maxLog2TrDynamicRange) - 1;
......
......@@ -735,6 +735,9 @@ private:
// Parameter
BitDepths m_bitDepths;
int m_qpBDOffset[MAX_NUM_CHANNEL_TYPE];
#if JVET_O0919_TS_MIN_QP
int m_minQpMinus4[MAX_NUM_CHANNEL_TYPE]; // QP_internal - QP_input;
#endif
int m_pcmBitDepths[MAX_NUM_CHANNEL_TYPE];
bool m_bPCMFilterDisableFlag;
......@@ -936,6 +939,10 @@ public:
int getDifferentialLumaChromaBitDepth() const { return int(m_bitDepths.recon[CHANNEL_TYPE_LUMA]) - int(m_bitDepths.recon[CHANNEL_TYPE_CHROMA]); }
int getQpBDOffset(ChannelType type) const { return m_qpBDOffset[type]; }
void setQpBDOffset(ChannelType type, int i) { m_qpBDOffset[type] = i; }
#if JVET_O0919_TS_MIN_QP
int getMinQpPrimeTsMinus4(ChannelType type) const { return m_minQpMinus4[type]; }
void setMinQpPrimeTsMinus4(ChannelType type, int i) { m_minQpMinus4[type] = i; }
#endif
void setSAOEnabledFlag(bool bVal) { m_saoEnabledFlag = bVal; }
bool getSAOEnabledFlag() const { return m_saoEnabledFlag; }
......@@ -1563,7 +1570,11 @@ private:
uint32_t m_uiMaxTTSizeIChroma;
uint32_t m_uiMaxBTSize;
#if JVET_O_MAX_NUM_ALF_APS_8
APS* m_alfApss[ALF_CTB_MAX_NUM_APS];
#else
APS* m_alfApss[MAX_NUM_APS];
#endif
bool m_tileGroupAlfEnabledFlag[MAX_NUM_COMPONENT];
int m_tileGroupNumAps;
std::vector<int> m_tileGroupLumaApsId;
......@@ -2067,7 +2078,11 @@ protected:
ParameterSetMap<APS> m_apsMap;
ParameterSetMap<DPS> m_dpsMap;
#if JVET_O_MAX_NUM_ALF_APS_8
APS* m_apss[ALF_CTB_MAX_NUM_APS];
#else
APS* m_apss[MAX_NUM_APS];
#endif
int m_activeDPSId; // -1 for nothing active
int m_activeSPSId; // -1 for nothing active
......
......@@ -50,6 +50,9 @@
#include <assert.h>
#include <cassert>
#define JVET_O0640_PICTURE_SIZE_CONSTRAINT 1 // JVET-O0640: Picture width and height shall be a multiple of Max(8, minCU size)
#define JVET_O_MAX_NUM_ALF_APS_8 1 // JVET-O: number of ALF APSs is reduced to 8
#define JVET_O0070_PROF 1 // JVET-O0070 method 4-2.1a: Prediction refinement with optical flow for affine mode
......@@ -100,6 +103,8 @@
#define JVET_O0366_AFFINE_BCW 1 // JVET-O0366: Simplifications on BCW index derivation process
#define JVET_O0919_TS_MIN_QP 1 // JVET-O0919: Minimum QP for Transform Skip Mode
#define JVET_O1168_CU_CHROMA_QP_OFFSET 1 // JVET-O1168: cu chroma QP offset
#define JVET_O0368_LFNST_WITH_DCT2_ONLY 1 // JVET-O0368/O0292/O0521/O0466: disable LFNST for non-DCT2 MTS candidates normatively
......
......@@ -206,10 +206,8 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri
{
std::copy( pic->getAlfCtuEnableFlag()[compIdx].begin(), pic->getAlfCtuEnableFlag()[compIdx].end(), pcEncPic->getAlfCtuEnableFlag()[compIdx].begin() );
}
#if JVET_N0415_CTB_ALF
pcEncPic->resizeAlfCtbFilterIndex(pic->cs->pcv->sizeInCtus);
memcpy( pcEncPic->getAlfCtbFilterIndex(), pic->getAlfCtbFilterIndex(), sizeof(short)*pic->cs->pcv->sizeInCtus );
#endif
#if JVET_O0090_ALF_CHROMA_FILTER_ALTERNATIVES_CTB
std::copy( pic->getAlfCtuAlternative(COMPONENT_Cb).begin(), pic->getAlfCtuAlternative(COMPONENT_Cb).end(), pcEncPic->getAlfCtuAlternative(COMPONENT_Cb).begin() );
......@@ -742,7 +740,11 @@ void DecLib::xActivateParameterSets()
if (m_bFirstSliceInPicture)
{
APS** apss = m_parameterSetManager.getAPSs();
#if JVET_O_MAX_NUM_ALF_APS_8
memset(apss, 0, sizeof(*apss) * ALF_CTB_MAX_NUM_APS);
#else
memset(apss, 0, sizeof(*apss) * MAX_NUM_APS);
#endif
const PPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); // this is a temporary PPS object. Do not store this value
CHECK(pps == 0, "No PPS present");
......@@ -937,7 +939,11 @@ void DecLib::xActivateParameterSets()
{
EXIT("Error - a new PPS has been decoded while processing a picture");
}
#if JVET_O_MAX_NUM_ALF_APS_8
for (int i = 0; i < ALF_CTB_MAX_NUM_APS; i++)
#else
for (int i = 0; i < MAX_NUM_APS; i++)
#endif
{
APS* aps = m_parameterSetManager.getAPS(i, ALF_APS);
if (aps && m_parameterSetManager.getAPSChangedFlag(i, ALF_APS))
......@@ -1437,6 +1443,7 @@ void DecLib::xDecodeVPS( InputNALUnit& nalu )
VPS* vps = new VPS();
m_HLSReader.setBitstream( &nalu.getBitstream() );
m_HLSReader.parseVPS( vps );
delete vps;
}
void DecLib::xDecodeDPS( InputNALUnit& nalu )
......
......@@ -1102,6 +1102,11 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode);
pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (int) (6*uiCode) );
#if JVET_O0919_TS_MIN_QP
READ_UVLC( uiCode, "min_qp_prime_ts_minus4" );
pcSPS->setMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA, uiCode);
#endif
READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode );
CHECK(uiCode > 12, "Invalid code");
READ_FLAG( uiCode, "sps_idr_rpl_present_flag" ); pcSPS->setIDRRefParamListPresent( (bool) uiCode);
......@@ -1184,6 +1189,12 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
READ_UVLC(uiCode, "log2_min_luma_coding_block_size_minus2");
int log2MinCUSize = uiCode + 2;
pcSPS->setLog2MinCodingBlockSize(log2MinCUSize);
#if JVET_O0640_PICTURE_SIZE_CONSTRAINT
CHECK((pcSPS->getPicWidthInLumaSamples() % (std::max(8, int(pcSPS->getMaxCUWidth() >> (pcSPS->getMaxCodingDepth() - 1))))) != 0, "Coded frame width must be a multiple of Max(8, the minimum unit size)");
CHECK((pcSPS->getPicHeightInLumaSamples() % (std::max(8, int(pcSPS->getMaxCUHeight() >> (pcSPS->getMaxCodingDepth() - 1))))) != 0, "Coded frame height must be a multiple of Max(8, the minimum unit size)");
#endif
READ_FLAG(uiCode, "partition_constraints_override_enabled_flag"); pcSPS->setSplitConsOverrideEnabledFlag(uiCode);
READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_intra_tile_group_luma"); minQT[0] = 1 << (uiCode + pcSPS->getLog2MinCodingBlockSize());
READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_inter_tile_group"); minQT[1] = 1 << (uiCode + pcSPS->getLog2MinCodingBlockSize());
......@@ -1807,7 +1818,11 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
if (uiCode)
{
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
#if JVET_O_MAX_NUM_ALF_APS_8
READ_CODE(3, uiCode, "tile_group_num_APS");
#else
xReadTruncBinCode(uiCode, ALF_CTB_MAX_NUM_APS + 1);
#endif
#else
if (pcSlice->isIntra())
{
......@@ -1815,7 +1830,11 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
}
else
{
#if JVET_O_MAX_NUM_ALF_APS_8
READ_CODE(3, uiCode, "tile_group_num_APS");
#else
xReadTruncBinCode(uiCode, ALF_CTB_MAX_NUM_APS + 1);
#endif
}
#endif
int numAps = uiCode;
......@@ -1823,7 +1842,11 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
std::vector<int> apsId(numAps, -1);
for (int i = 0; i < numAps; i++)
{
#if JVET_O_MAX_NUM_ALF_APS_8
READ_CODE(3, uiCode, "tile_group_aps_id");
#else
READ_CODE(5, uiCode, "tile_group_aps_id");
#endif
apsId[i] = uiCode;
}
......@@ -1844,7 +1867,11 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
if (alfChromaIdc)
{
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
#if JVET_O_MAX_NUM_ALF_APS_8
READ_CODE(3, uiCode, "tile_group_aps_id_chroma");
#else
READ_CODE(5, uiCode, "tile_group_aps_id_chroma");
#endif
#else
if (pcSlice->isIntra() && pcSlice->getTileGroupNumAps() == 1)
{
......@@ -1852,7 +1879,11 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
}
else
{
#if JVET_O_MAX_NUM_ALF_APS_8
READ_CODE(3, uiCode, "tile_group_aps_id_chroma");
#else
READ_CODE(5, uiCode, "tile_group_aps_id_chroma");
#endif
}
#endif
pcSlice->setTileGroupApsIdChroma(uiCode);
......
......@@ -501,7 +501,11 @@ void EncAdaptiveLoopFilter::create( const EncCfg* encCfg, const int picWidth, co
m_diffFilterCoeff[i] = new int[MAX_NUM_ALF_LUMA_COEFF];
}
#if JVET_O_MAX_NUM_ALF_APS_8
m_apsIdStart = ALF_CTB_MAX_NUM_APS;
#else
m_apsIdStart = (int)MAX_NUM_APS;
#endif
m_ctbDistortionFixedFilter = new double[m_numCTUsInPic];
for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++)
{
......@@ -654,15 +658,27 @@ void EncAdaptiveLoopFilter::ALFProcess(CodingStructure& cs, const double *lambda
{
if (cs.slice->getPendingRasInit() || cs.slice->isIDRorBLA())
{
#if JVET_O_MAX_NUM_ALF_APS_8
memset(cs.slice->getAlfAPSs(), 0, sizeof(*cs.slice->getAlfAPSs())*ALF_CTB_MAX_NUM_APS);
m_apsIdStart = ALF_CTB_MAX_NUM_APS;
#else
memset(cs.slice->getAlfAPSs(), 0, sizeof(*cs.slice->getAlfAPSs())*MAX_NUM_APS);
m_apsIdStart = (int)MAX_NUM_APS;
#endif
m_apsMap->clear();
#if JVET_O_MAX_NUM_ALF_APS_8
for (int i = 0; i < ALF_CTB_MAX_NUM_APS; i++)
#else
for (int i = 0; i < MAX_NUM_APS; i++)
#endif
{
APS* alfAPS = m_apsMap->getPS((i << NUM_APS_TYPE_LEN) + ALF_APS);
m_apsMap->clearChangedFlag((i << NUM_APS_TYPE_LEN) + ALF_APS);
if (alfAPS)
{
alfAPS->getAlfAPSParam().reset();
alfAPS = nullptr;
}
}
}
AlfParam alfParam;
......@@ -2963,16 +2979,28 @@ void EncAdaptiveLoopFilter::setCtuEnableFlag( uint8_t** ctuFlags, ChannelType ch
std::vector<int> EncAdaptiveLoopFilter::getAvaiApsIdsLuma(CodingStructure& cs, int &newApsId)
{
APS** apss = cs.slice->getAlfAPSs();
#if JVET_O_MAX_NUM_ALF_APS_8
for (int i = 0; i < ALF_CTB_MAX_NUM_APS; i++)
#else
for (int i = 0; i < MAX_NUM_APS; i++)
#endif
{
apss[i] = m_apsMap->getPS((i << NUM_APS_TYPE_LEN) + ALF_APS);
}
std::vector<int> result;
int apsIdChecked = 0, curApsId = m_apsIdStart;
#if JVET_O_MAX_NUM_ALF_APS_8
if (curApsId < ALF_CTB_MAX_NUM_APS)
#else
if (curApsId < int(MAX_NUM_APS))
#endif
{
#if JVET_O_MAX_NUM_ALF_APS_8
while (apsIdChecked < ALF_CTB_MAX_NUM_APS && !cs.slice->isIntra() && result.size() < ALF_CTB_MAX_NUM_APS && !cs.slice->getPendingRasInit() && !cs.slice->isIDRorBLA())
#else
while (apsIdChecked < MAX_NUM_APS && !cs.slice->isIntra() && result.size() < (ALF_CTB_MAX_NUM_APS - 1) && !cs.slice->getPendingRasInit() && !cs.slice->isIDRorBLA())
#endif
{
APS* curAPS = cs.slice->getAlfAPSs()[curApsId];
if (curAPS && curAPS->getTemporalId() <= cs.slice->getTLayer() && curAPS->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_LUMA])
......@@ -2980,7 +3008,11 @@ std::vector<int> EncAdaptiveLoopFilter::getAvaiApsIdsLuma(CodingStructure& cs, i
result.push_back(curApsId);
}
apsIdChecked++;
#if JVET_O_MAX_NUM_ALF_APS_8
curApsId = (curApsId + 1) % ALF_CTB_MAX_NUM_APS;
#else
curApsId = (curApsId + 1) % MAX_NUM_APS;
#endif
}
}
cs.slice->setTileGroupNumAps((int)result.size());
......@@ -2988,10 +3020,17 @@ std::vector<int> EncAdaptiveLoopFilter::getAvaiApsIdsLuma(CodingStructure& cs, i
newApsId = m_apsIdStart - 1;
if (newApsId < 0)
{
#if JVET_O_MAX_NUM_ALF_APS_8
newApsId = ALF_CTB_MAX_NUM_APS - 1;
#else
newApsId = (int)MAX_NUM_APS - 1;
#endif
}
#if JVET_O_MAX_NUM_ALF_APS_8
CHECK(newApsId >= ALF_CTB_MAX_NUM_APS, "Wrong APS index assignment in getAvaiApsIdsLuma");
#else
CHECK(newApsId >= (int)MAX_NUM_APS, "Wrong APS index assignment in getAvaiApsIdsLuma");
#endif
return result;
}
void EncAdaptiveLoopFilter::initDistortion()
......@@ -3059,6 +3098,12 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar
int numIter = useNewFilter ? 2 : 1;
for (int numTemporalAps = 0; numTemporalAps <= apsIds.size(); numTemporalAps++)
{
#if JVET_O_MAX_NUM_ALF_APS_8
if (numTemporalAps + useNewFilter >= ALF_CTB_MAX_NUM_APS)
{
continue;
}
#endif
cs.slice->setTileGroupNumAps(numTemporalAps + useNewFilter);
int numFilterSet = NUM_FIXED_FILTER_SETS + numTemporalAps + useNewFilter;
if (numTemporalAps == apsIds.size() && numTemporalAps > 0 && useNewFilter && newApsId == apsIds.back()) //last temporalAPS is occupied by new filter set and this temporal APS becomes unavailable
......@@ -3069,7 +3114,11 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar
{
m_alfParamTemp = alfParamNewFilters;
m_alfParamTemp.enabledFlag[CHANNEL_TYPE_LUMA] = true;
#if JVET_O_MAX_NUM_ALF_APS_8
double curCost = 3 * m_lambda[CHANNEL_TYPE_LUMA];
#else
double curCost = getTBlength(numTemporalAps + useNewFilter, ALF_CTB_MAX_NUM_APS + 1) * m_lambda[CHANNEL_TYPE_LUMA];
#endif
if (iter > 0) //re-derive new filter-set
{
double dDistOrgNewFilter = 0;
......@@ -3229,9 +3278,17 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar
}
} //for(ctbIdx)
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
#if JVET_O_MAX_NUM_ALF_APS_8
int tmpBits = bitsNewFilter + 3 * (numFilterSet - NUM_FIXED_FILTER_SETS);
#else
int tmpBits = bitsNewFilter + 5 * (numFilterSet - NUM_FIXED_FILTER_SETS) + getTBlength(numFilterSet - NUM_FIXED_FILTER_SETS, ALF_CTB_MAX_NUM_APS + 1);
#endif
#else
#if JVET_O_MAX_NUM_ALF_APS_8
int tmpBits = bitsNewFilter + 3 * (numFilterSet - NUM_FIXED_FILTER_SETS) + (cs.slice->isIntra() ? 1 : 3);
#else
int tmpBits = bitsNewFilter + 5 * (numFilterSet - NUM_FIXED_FILTER_SETS) + (cs.slice->isIntra() ? 1 : getTBlength(numFilterSet - NUM_FIXED_FILTER_SETS, ALF_CTB_MAX_NUM_APS + 1));
#endif
#endif
curCost += tmpBits * m_lambda[COMPONENT_Y];
if (curCost < costMin)
......@@ -3291,6 +3348,7 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar
newAPS->setAPSType(ALF_APS);
}
newAPS->setAlfAPSParam(alfParamNewFiltersBest);
newAPS->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_CHROMA] = false;
m_apsMap->setChangedFlag((newApsId << NUM_APS_TYPE_LEN) + ALF_APS);
m_apsIdStart = newApsId;
}
......@@ -3330,7 +3388,11 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar
curId--;
if (curId < 0)
{
#if JVET_O_MAX_NUM_ALF_APS_8
curId = ALF_CTB_MAX_NUM_APS - 1;
#else
curId = (int)MAX_NUM_APS - 1;
#endif
}
if (std::find(bestApsIds.begin(), bestApsIds.end(), curId) == bestApsIds.end())
{
......@@ -3338,7 +3400,11 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar
}
}
}
#if JVET_O_MAX_NUM_ALF_APS_8
for (int curApsId = 0; curApsId < ALF_CTB_MAX_NUM_APS; curApsId++)
#else
for (int curApsId = 0; curApsId < MAX_NUM_APS; curApsId++)
#endif
{
if ((cs.slice->getPendingRasInit() || cs.slice->isIDRorBLA() || cs.slice->isIntra()) && curApsId != newApsIdChroma)
{
......@@ -3346,9 +3412,17 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar
}
APS* curAPS = m_apsMap->getPS((curApsId << NUM_APS_TYPE_LEN) + ALF_APS);
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
#if JVET_O_MAX_NUM_ALF_APS_8
double curCost = m_lambda[CHANNEL_TYPE_CHROMA] * 3;
#else
double curCost = m_lambda[CHANNEL_TYPE_CHROMA] * 5;
#endif
#else
#if JVET_O_MAX_NUM_ALF_APS_8
double curCost = (cs.slice->isIntra() && cs.slice->getTileGroupNumAps() == 1) ? 0 : (m_lambda[CHANNEL_TYPE_CHROMA] * 3);
#else
double curCost = (cs.slice->isIntra() && cs.slice->getTileGroupNumAps() == 1) ? 0 : (m_lambda[CHANNEL_TYPE_CHROMA] * 5);
#endif
#endif
if (curApsId == newApsIdChroma)
{
......@@ -3501,6 +3575,10 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar
newAPS->getAlfAPSParam().reset();
}
newAPS->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_CHROMA] = true;
if (!alfParamNewFiltersBest.newFilterFlag[CHANNEL_TYPE_LUMA])
{
newAPS->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_LUMA] = false;
}
#if JVET_O0090_ALF_CHROMA_FILTER_ALTERNATIVES_CTB
newAPS->getAlfAPSParam().numAlternativesChroma = alfParamNewFilters.numAlternativesChroma;
for( int altIdx = 0; altIdx < MAX_NUM_ALF_ALTERNATIVES_CHROMA; ++altIdx )
......
......@@ -2494,7 +2494,11 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
if (pcSlice->getSPS()->getALFEnabledFlag() && pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y))
{
#if JVET_O_MAX_NUM_ALF_APS_8
for (int apsId = 0; apsId < ALF_CTB_MAX_NUM_APS; apsId++)
#else
for (int apsId = 0; apsId < MAX_NUM_APS; apsId++) //HD: shouldn't this be looping over slice_alf_aps_id_luma[ i ]? By looping over MAX_NUM_APS, it is possible unused ALF APS is written. Please check!
#endif
{
ParameterSetMap<APS> *apsMap = m_pcEncLib->getApsMap();
......
......@@ -983,6 +983,9 @@ void EncLib::xInitSPS(SPS &sps)
{
sps.setBitDepth (ChannelType(channelType), m_bitDepth[channelType] );
sps.setQpBDOffset (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8)));
#if JVET_O0919_TS_MIN_QP
sps.setMinQpPrimeTsMinus4(ChannelType(channelType), (6 * (m_bitDepth[channelType] - m_inputBitDepth[channelType])));
#endif
sps.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType] );
}
......
......@@ -138,7 +138,11 @@ private:
CacheModel m_cacheModel;
#endif
#if JVET_O_MAX_NUM_ALF_APS_8
APS* m_apss[ALF_CTB_MAX_NUM_APS];
#else
APS* m_apss[MAX_NUM_APS];
#endif
APS* m_lmcsAPS;
......
......@@ -748,6 +748,10 @@ void HLSWriter::codeSPS( const SPS* pcSPS )
const bool chromaEnabled = isChromaEnabled(format);
WRITE_UVLC( chromaEnabled ? (pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA) - 8):0, "bit_depth_chroma_minus8" );
#if JVET_O0919_TS_MIN_QP
WRITE_UVLC( pcSPS->getMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA), "min_qp_prime_ts_minus4" );
#endif
WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" );
WRITE_FLAG( pcSPS->getIDRRefParamListPresent(), "sps_idr_rpl_present_flag" );
// KJS: Marakech decision: sub-layers added back
......@@ -1274,7 +1278,11 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
if (alfEnabled)
{
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
#if JVET_O_MAX_NUM_ALF_APS_8
WRITE_CODE(pcSlice->getTileGroupNumAps(), 3, "tile_group_num_aps");
#else
xWriteTruncBinCode(pcSlice->getTileGroupNumAps(), ALF_CTB_MAX_NUM_APS + 1);
#endif
#else
if (pcSlice->isIntra())
{
......@@ -1282,13 +1290,21 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
}
else
{
#if JVET_O_MAX_NUM_ALF_APS_8
WRITE_CODE(pcSlice->getTileGroupNumAps(), 3, "tile_group_num_aps");
#else
xWriteTruncBinCode(pcSlice->getTileGroupNumAps(), ALF_CTB_MAX_NUM_APS + 1);
#endif
}
#endif
const std::vector<int>& apsId = pcSlice->getTileGroupApsIdLuma();
for (int i = 0; i < pcSlice->getTileGroupNumAps(); i++)
{
#if JVET_O_MAX_NUM_ALF_APS_8
WRITE_CODE(apsId[i], 3, "tile_group_aps_id");
#else
WRITE_CODE(apsId[i], 5, "tile_group_aps_id");
#endif
}
const int alfChromaIdc = pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cb) + pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cr) * 2 ;
......@@ -1303,7 +1319,11 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
if (alfChromaIdc)
{
#if JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL
#if JVET_O_MAX_NUM_ALF_APS_8
WRITE_CODE(pcSlice->getTileGroupApsIdChroma(), 3, "tile_group_aps_id_chroma");
#else
WRITE_CODE(pcSlice->getTileGroupApsIdChroma(), 5, "tile_group_aps_id_chroma");
#endif
#else
if (pcSlice->isIntra()&& pcSlice->getTileGroupNumAps() == 1)
{
......@@ -1311,7 +1331,11 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice )
}
else
{
#if JVET_O_MAX_NUM_ALF_APS_8
WRITE_CODE(pcSlice->getTileGroupApsIdChroma(), 3, "tile_group_aps_id_chroma");
#else
WRITE_CODE(pcSlice->getTileGroupApsIdChroma(), 5, "tile_group_aps_id_chroma");
#endif
}
#endif
}
......