WIP : JVET-M0102 -> Intra Sub-Partitions (ISP)

There is a conflict with JVET_M0427_INLOOP_RESHAPER that is triggering a debug assertion that checks that the width is not 1.
parent 6e31833c
......@@ -389,12 +389,14 @@ void AreaBuf<Pel>::rspSignal(std::vector<Pel>& pLUT)
{
Pel* dst = buf;
Pel* src = buf;
#if !JVET_M0102_INTRA_SUBPARTITIONS
if (width == 1)
{
THROW("Blocks of width = 1 not supported");
}
else
{
#endif
for (unsigned y = 0; y < height; y++)
{
for (unsigned x = 0; x < width; x++)
......@@ -404,7 +406,9 @@ void AreaBuf<Pel>::rspSignal(std::vector<Pel>& pLUT)
dst += stride;
src += stride;
}
#if !JVET_M0102_INTRA_SUBPARTITIONS
}
#endif
}
template<>
......@@ -456,13 +460,14 @@ template<>
Pel AreaBuf <Pel> ::computeAvg() const
{
const Pel* src = buf;
#if !JVET_M0102_INTRA_SUBPARTITIONS
if (width == 1)
{
THROW("Blocks of width = 1 not supported");
}
else
{
#endif
int32_t acc = 0;
#define AVG_INC \
src += stride;
......@@ -471,7 +476,9 @@ Pel AreaBuf <Pel> ::computeAvg() const
#undef AVG_INC
#undef AVG_OP
return Pel((acc + (area() >> 1)) / area());
#if !JVET_M0102_INTRA_SUBPARTITIONS
}
#endif
}
#endif
......
......@@ -68,6 +68,10 @@ enum CodingStatisticsType
STATS__CABAC_BITS__MVD_EP,
STATS__CABAC_BITS__AFFINE_FLAG,
STATS__CABAC_BITS__AFFINE_TYPE,
#if JVET_M0102_INTRA_SUBPARTITIONS
STATS__CABAC_BITS__ISP_MODE_FLAG,
STATS__CABAC_BITS__ISP_SPLIT_FLAG,
#endif
STATS__CABAC_BITS__TRANSFORM_SUBDIV_FLAG,
STATS__CABAC_BITS__QT_ROOT_CBF,
STATS__CABAC_BITS__DELTA_QP_EP,
......@@ -150,6 +154,10 @@ static inline const char* getName(CodingStatisticsType name)
"CABAC_BITS__MVD_EP",
"CABAC_BITS__AFFINE_FLAG",
"CABAC_BITS__AFFINE_TYPE",
#if JVET_M0102_INTRA_SUBPARTITIONS
"CABAC_BITS__ISP_MODE_FLAG",
"CABAC_BITS__ISP_SPLIT_FLAG",
#endif
"CABAC_BITS__TRANSFORM_SUBDIV_FLAG",
"CABAC_BITS__QT_ROOT_CBF",
"CABAC_BITS__DELTA_QP_EP",
......
......@@ -259,7 +259,11 @@ const PredictionUnit * CodingStructure::getPU( const Position &pos, const Channe
}
}
#if JVET_M0102_INTRA_SUBPARTITIONS
TransformUnit* CodingStructure::getTU( const Position &pos, const ChannelType effChType, const int subTuIdx )
#else
TransformUnit* CodingStructure::getTU( const Position &pos, const ChannelType effChType )
#endif
{
const CompArea &_blk = area.blocks[effChType];
......@@ -272,13 +276,45 @@ TransformUnit* CodingStructure::getTU( const Position &pos, const ChannelType ef
{
const unsigned idx = m_tuIdx[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )];
#if JVET_M0102_INTRA_SUBPARTITIONS
if( idx != 0 )
{
unsigned extraIdx = 0;
if( isLuma( effChType ) )
{
const TransformUnit& tu = *tus[idx - 1];
if( tu.cu->ispMode ) // Intra SubPartitions mode
{
//we obtain the offset to index the corresponding sub-partition
if( subTuIdx != -1 )
{
extraIdx = subTuIdx;
}
else
{
while( pos != tus[idx - 1 + extraIdx]->blocks[getFirstComponentOfChannel( effChType )].pos() )
{
extraIdx++;
}
}
}
}
return tus[idx - 1 + extraIdx];
}
#else
if( idx != 0 ) return tus[ idx - 1 ];
#endif
else if( m_isTuEnc ) return parent->getTU( pos, effChType );
else return nullptr;
}
}
#if JVET_M0102_INTRA_SUBPARTITIONS
const TransformUnit * CodingStructure::getTU( const Position &pos, const ChannelType effChType, const int subTuIdx ) const
#else
const TransformUnit * CodingStructure::getTU( const Position &pos, const ChannelType effChType ) const
#endif
{
const CompArea &_blk = area.blocks[effChType];
......@@ -290,8 +326,34 @@ const TransformUnit * CodingStructure::getTU( const Position &pos, const Channel
else
{
const unsigned idx = m_tuIdx[effChType][rsAddr( pos, _blk.pos(), _blk.width, unitScale[effChType] )];
#if JVET_M0102_INTRA_SUBPARTITIONS
if( idx != 0 )
{
unsigned extraIdx = 0;
if( isLuma( effChType ) )
{
const TransformUnit& tu = *tus[idx - 1];
if( tu.cu->ispMode ) // Intra SubPartitions mode
{
//we obtain the offset to index the corresponding sub-partition
if( subTuIdx != -1 )
{
extraIdx = subTuIdx;
}
else
{
while( pos != tus[idx - 1 + extraIdx]->blocks[effChType].pos() )
{
extraIdx++;
}
}
}
}
return tus[idx - 1 + extraIdx];
}
#else
if( idx != 0 ) return tus[idx - 1];
#endif
else if( m_isTuEnc ) return parent->getTU( pos, effChType );
else return nullptr;
}
......@@ -418,6 +480,9 @@ TransformUnit& CodingStructure::addTU( const UnitArea &unit, const ChannelType c
tu->UnitArea::operator=( unit );
tu->initData();
tu->next = nullptr;
#if JVET_M0102_INTRA_SUBPARTITIONS
tu->prev = nullptr;
#endif
tu->cs = this;
tu->cu = m_isTuEnc ? cus[0] : getCU( unit.blocks[chType].pos(), chType );
tu->chType = chType;
......@@ -433,6 +498,9 @@ TransformUnit& CodingStructure::addTU( const UnitArea &unit, const ChannelType c
if( prevTU && prevTU->cu == tu->cu )
{
prevTU->next = tu;
#if JVET_M0102_INTRA_SUBPARTITIONS
tu->prev = prevTU;
#endif
#if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISM
CHECK( prevTU->cacheId != tu->cacheId, "Inconsintent cacheId between previous and current TU" );
......@@ -470,11 +538,25 @@ TransformUnit& CodingStructure::addTU( const UnitArea &unit, const ChannelType c
const CompArea &_selfBlk = area.blocks[i];
const CompArea &_blk = tu-> blocks[i];
#if JVET_M0102_INTRA_SUBPARTITIONS
bool isIspTu = tu->cu != nullptr && tu->cu->ispMode && isLuma( _blk.compID );
bool isFirstIspTu = false;
if( isIspTu )
{
isFirstIspTu = CU::isISPFirst( *tu->cu, _blk, getFirstComponentOfChannel( ChannelType( i ) ) );
}
if( !isIspTu || isFirstIspTu )
#endif
{
const UnitScale& scale = unitScale[_blk.compID];
const Area scaledSelf = scale.scale( _selfBlk );
#if JVET_M0102_INTRA_SUBPARTITIONS
const Area scaledBlk = isIspTu ? scale.scale( tu->cu->blocks[i] ) : scale.scale( _blk );
#else
const Area scaledBlk = scale.scale( _blk );
#endif
unsigned *idxPtr = m_tuIdx[i] + rsAddr( scaledBlk.pos(), scaledSelf.pos(), scaledSelf.width );
CHECK( *idxPtr, "Overwriting a pre-existing value, should be '0'!" );
AreaBuf<uint32_t>( idxPtr, scaledSelf.width, scaledBlk.size() ).fill( idx );
......@@ -1000,6 +1082,9 @@ void CodingStructure::initStructData( const int &QP, const bool &_isLosses, cons
fracBits = 0;
dist = 0;
cost = MAX_DOUBLE;
#if JVET_M0102_INTRA_SUBPARTITIONS
lumaCost = MAX_DOUBLE;
#endif
interHad = std::numeric_limits<Distortion>::max();
}
......
......@@ -129,11 +129,19 @@ public:
const CodingUnit *getCU(const Position &pos, const ChannelType _chType) const;
const PredictionUnit *getPU(const Position &pos, const ChannelType _chType) const;
#if JVET_M0102_INTRA_SUBPARTITIONS
const TransformUnit *getTU(const Position &pos, const ChannelType _chType, const int subTuIdx = -1) const;
#else
const TransformUnit *getTU(const Position &pos, const ChannelType _chType) const;
#endif
CodingUnit *getCU(const Position &pos, const ChannelType _chType);
PredictionUnit *getPU(const Position &pos, const ChannelType _chType);
#if JVET_M0102_INTRA_SUBPARTITIONS
TransformUnit *getTU(const Position &pos, const ChannelType _chType, const int subTuIdx = -1);
#else
TransformUnit *getTU(const Position &pos, const ChannelType _chType);
#endif
const CodingUnit *getCU(const ChannelType &_chType) const { return getCU(area.blocks[_chType].pos(), _chType); }
const PredictionUnit *getPU(const ChannelType &_chType) const { return getPU(area.blocks[_chType].pos(), _chType); }
......@@ -171,6 +179,9 @@ public:
static_vector<double, NUM_ENC_FEATURES> features;
double cost;
#if JVET_M0102_INTRA_SUBPARTITIONS
double lumaCost;
#endif
uint64_t fracBits;
Distortion dist;
Distortion interHad;
......
......@@ -72,6 +72,9 @@ struct Size
bool operator!=(const Size &other) const { return (width != other.width) || (height != other.height); }
bool operator==(const Size &other) const { return (width == other.width) && (height == other.height); }
uint32_t area() const { return (uint32_t) width * (uint32_t) height; }
#if REUSE_CU_RESULTS_WITH_MULTIPLE_TUS
void resizeTo(const Size newSize) { width = newSize.width; height = newSize.height; }
#endif
};
struct Area : public Position, public Size
......
......@@ -50,8 +50,13 @@ CoeffCodingContext::CoeffCodingContext(const TransformUnit& tu, ComponentID comp
, m_chType (toChannelType(m_compID))
, m_width (tu.block(m_compID).width)
, m_height (tu.block(m_compID).height)
#if JVET_M0102_INTRA_SUBPARTITIONS
, m_log2CGWidth ( g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][0] )
, m_log2CGHeight ( g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][1] )
#else
, m_log2CGWidth ((m_width & 3) || (m_height & 3) ? 1 : 2)
, m_log2CGHeight ((m_width & 3) || (m_height & 3) ? 1 : 2)
#endif
, m_log2CGSize (m_log2CGWidth + m_log2CGHeight)
#if JVET_M0257
, m_widthInGroups(std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_width) >> m_log2CGWidth)
......@@ -74,10 +79,17 @@ CoeffCodingContext::CoeffCodingContext(const TransformUnit& tu, ComponentID comp
#else
, m_scanType (SCAN_DIAG)
#endif
#if JVET_M0102_INTRA_SUBPARTITIONS
, m_scan (g_scanOrder [m_chType][SCAN_GROUPED_4x4][m_scanType][gp_sizeIdxInfo->idxFrom(m_width )][gp_sizeIdxInfo->idxFrom(m_height )])
, m_scanPosX (g_scanOrderPosXY[m_chType][SCAN_GROUPED_4x4][m_scanType][gp_sizeIdxInfo->idxFrom(m_width )][gp_sizeIdxInfo->idxFrom(m_height )][0])
, m_scanPosY (g_scanOrderPosXY[m_chType][SCAN_GROUPED_4x4][m_scanType][gp_sizeIdxInfo->idxFrom(m_width )][gp_sizeIdxInfo->idxFrom(m_height )][1])
, m_scanCG (g_scanOrder [m_chType][SCAN_UNGROUPED ][m_scanType][gp_sizeIdxInfo->idxFrom(m_widthInGroups)][gp_sizeIdxInfo->idxFrom(m_heightInGroups)])
#else
, m_scan (g_scanOrder [SCAN_GROUPED_4x4][m_scanType][gp_sizeIdxInfo->idxFrom(m_width )][gp_sizeIdxInfo->idxFrom(m_height )])
, m_scanPosX (g_scanOrderPosXY[SCAN_GROUPED_4x4][m_scanType][gp_sizeIdxInfo->idxFrom(m_width )][gp_sizeIdxInfo->idxFrom(m_height )][0])
, m_scanPosY (g_scanOrderPosXY[SCAN_GROUPED_4x4][m_scanType][gp_sizeIdxInfo->idxFrom(m_width )][gp_sizeIdxInfo->idxFrom(m_height )][1])
, m_scanCG (g_scanOrder[SCAN_UNGROUPED ][m_scanType][gp_sizeIdxInfo->idxFrom(m_widthInGroups)][gp_sizeIdxInfo->idxFrom(m_heightInGroups)])
#endif
, m_CtxSetLastX (Ctx::LastX[m_chType])
, m_CtxSetLastY (Ctx::LastY[m_chType])
#if JVET_M0257
......@@ -314,8 +326,17 @@ unsigned DeriveCtx::CtxCUsplit( const CodingStructure& cs, Partitioner& partitio
}
#endif
#if JVET_M0102_INTRA_SUBPARTITIONS
unsigned DeriveCtx::CtxQtCbf( const ComponentID compID, const unsigned trDepth, const bool prevCbCbf, const int ispIdx )
{
if( ispIdx && isLuma( compID ) )
{
return 2 + (int)prevCbCbf;
}
#else
unsigned DeriveCtx::CtxQtCbf( const ComponentID compID, const unsigned trDepth, const bool prevCbCbf )
{
#endif
if( compID == COMPONENT_Cr )
{
return ( prevCbCbf ? 1 : 0 );
......
......@@ -308,7 +308,11 @@ void CtxSplit ( const CodingStructure& cs, Partitioner& partitioner, uns
unsigned CtxCUsplit ( const CodingStructure& cs, Partitioner& partitioner );
unsigned CtxBTsplit ( const CodingStructure& cs, Partitioner& partitioner );
#endif
#if JVET_M0102_INTRA_SUBPARTITIONS
unsigned CtxQtCbf ( const ComponentID compID, const unsigned trDepth, const bool prevCbCbf = false, const int ispIdx = 0 );
#else
unsigned CtxQtCbf ( const ComponentID compID, const unsigned trDepth, const bool prevCbCbf );
#endif
unsigned CtxInterDir ( const PredictionUnit& pu );
unsigned CtxSkipFlag ( const CodingUnit& cu );
unsigned CtxIMVFlag ( const CodingUnit& cu );
......
......@@ -745,6 +745,24 @@ const CtxSet ContextSetCfg::QtRootCbf = ContextSetCfg::addCtxSet
const CtxSet ContextSetCfg::QtCbf[] =
{
#if JVET_M0102_INTRA_SUBPARTITIONS
#if JVET_M0453_CABAC_ENGINE
ContextSetCfg::addCtxSet
({
{ 155, 127, CNU, CNU},
{ 141, 127, CNU, CNU},
{ CNU, 126, CNU, CNU},
{ 4, 5, DWS, DWS},
}),
#else
ContextSetCfg::addCtxSet
({
{ 140, 141, CNU, CNU},
{ 155, 127, CNU, CNU},
{ CNU, 126, CNU, CNU},
}),
#endif
#else
ContextSetCfg::addCtxSet
({
#if JVET_M0453_CABAC_ENGINE
......@@ -758,6 +776,7 @@ const CtxSet ContextSetCfg::QtCbf[] =
{ CNU, 126, },
#endif
}),
#endif
ContextSetCfg::addCtxSet
({
#if JVET_M0453_CABAC_ENGINE
......@@ -1208,6 +1227,18 @@ const CtxSet ContextSetCfg::EMTCuFlag = ContextSetCfg::addCtxSet
});
#endif
#if JVET_M0102_INTRA_SUBPARTITIONS
const CtxSet ContextSetCfg::ISPMode = ContextSetCfg::addCtxSet
({
{ CNU, CNU },
{ CNU, CNU },
{ CNU, CNU },
#if JVET_M0453_CABAC_ENGINE
{ DWS, DWS },
#endif
});
#endif
const CtxSet ContextSetCfg::CrossCompPred = ContextSetCfg::addCtxSet
({
{ 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,},
......
......@@ -306,6 +306,9 @@ public:
static const CtxSet TriangleIdx;
#if JVET_M0444_SMVD
static const CtxSet SmvdFlag;
#endif
#if JVET_M0102_INTRA_SUBPARTITIONS
static const CtxSet ISPMode;
#endif
static const unsigned NumberOfContexts;
......
This diff is collapsed.
This diff is collapsed.
......@@ -91,10 +91,18 @@ protected:
void xPredIntraAng ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const uint32_t dirMode, const ClpRng& clpRng, const bool bEnableEdgeFilters, const SPS& sps
, int multiRefIdx
, const bool enableBoundaryFilter = true );
#else
#if JVET_M0102_INTRA_SUBPARTITIONS
void xPredIntraAng ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const uint32_t dirMode, const ClpRng& clpRng, const SPS& sps,
int multiRefIdx,
const bool useFilteredPredSamples,
const bool useISP = false,
const Size cuSize = Size( 0, 0 ) );
#else
void xPredIntraAng ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const uint32_t dirMode, const ClpRng& clpRng, const SPS& sps
, int multiRefIdx
, const bool useFilteredPredSamples );
#endif
#endif
Pel xGetPredValDc ( const CPelBuf &pSrc, const Size &dstSize );
......
......@@ -508,6 +508,9 @@ void LoopFilter::xSetLoopfilterParam( const CodingUnit& cu )
m_stLFCUParam.leftEdge = ( 0 < pos.x ) && isAvailable ( cu, *cu.cs->getCU( pos.offset( -1, 0 ), cu.chType ), !slice.getLFCrossSliceBoundaryFlag());
m_stLFCUParam.topEdge = ( 0 < pos.y ) && isAvailable ( cu, *cu.cs->getCU( pos.offset( 0, -1 ), cu.chType ), !slice.getLFCrossSliceBoundaryFlag());
#endif
#if JVET_M0102_INTRA_SUBPARTITIONS
m_stLFCUParam.internalEdge &= !cu.ispMode;
#endif
}
unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const DeblockEdgeDir edgeDir, const Position& localPos ) const
......
......@@ -581,6 +581,9 @@ void QuantRDOQ::quant(TransformUnit &tu, const ComponentID &compID, const CCoeff
bool useRDOQ = useTransformSkip ? m_useRDOQTS : m_useRDOQ;
#if JVET_M0102_INTRA_SUBPARTITIONS
if( !tu.cu->ispMode || !isLuma(compID) )
#endif
{
useRDOQ &= uiWidth > 2;
useRDOQ &= uiHeight > 2;
......@@ -624,6 +627,9 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
const bool extendedPrecision = sps.getSpsRangeExtension().getExtendedPrecisionProcessingFlag();
const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(chType);
#if JVET_M0102_INTRA_SUBPARTITIONS
const bool useIntraSubPartitions = tu.cu->ispMode && isLuma(compID);
#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
* uiLog2TrSize applied in iTransformShift, such that the result is 1/sqrt(2) the required result (i.e. smaller)
......@@ -1030,10 +1036,49 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
}
else
{
#if JVET_M0102_INTRA_SUBPARTITIONS
bool previousCbf = tu.cbf[COMPONENT_Cb];
bool lastCbfIsInferred = false;
if( useIntraSubPartitions )
{
bool rootCbfSoFar = false;
bool isLastSubPartition = CU::isISPLast(*tu.cu, tu.Y(), compID);
uint32_t nTus = tu.cu->ispMode == HOR_INTRA_SUBPARTITIONS ? tu.cu->lheight() >> g_aucLog2[tu.lheight()] : tu.cu->lwidth() >> g_aucLog2[tu.lwidth()];
if( isLastSubPartition )
{
TransformUnit* tuPointer = tu.cu->firstTU;
for( int tuIdx = 0; tuIdx < nTus - 1; tuIdx++ )
{
rootCbfSoFar |= TU::getCbfAtDepth(*tuPointer, COMPONENT_Y, tu.depth);
tuPointer = tuPointer->next;
}
if( !rootCbfSoFar )
{
lastCbfIsInferred = true;
}
}
if( !lastCbfIsInferred )
{
previousCbf = TU::getPrevTuCbfAtDepth(tu, compID, tu.depth);
}
}
BinFracBits fracBitsQtCbf = fracBits.getFracBitsArray( Ctx::QtCbf[compID]( DeriveCtx::CtxQtCbf( rect.compID, tu.depth, previousCbf, useIntraSubPartitions ) ) );
if( !lastCbfIsInferred )
{
d64BestCost = d64BlockUncodedCost + xGetICost(fracBitsQtCbf.intBits[0]);
d64BaseCost += xGetICost(fracBitsQtCbf.intBits[1]);
}
else
{
d64BestCost = d64BlockUncodedCost;
}
#else
BinFracBits fracBitsQtCbf = fracBits.getFracBitsArray( Ctx::QtCbf[compID]( DeriveCtx::CtxQtCbf( rect.compID, tu.depth, tu.cbf[COMPONENT_Cb] ) ) );
d64BestCost = d64BlockUncodedCost + xGetICost( fracBitsQtCbf.intBits[0] );
d64BaseCost += xGetICost( fracBitsQtCbf.intBits[1] );
#endif
}
int lastBitsX[LAST_SIGNIFICANT_GROUPS] = { 0 };
......
This diff is collapsed.
......@@ -64,8 +64,14 @@ void generateTrafoBlockSizeScaling( SizeIndexInfo& sizeIdxInfo );
// ====================================================================================================================
// flexible conversion from relative to absolute index
#if JVET_M0102_INTRA_SUBPARTITIONS
extern uint32_t g_log2SbbSize [2][MAX_CU_DEPTH+1][MAX_CU_DEPTH+1][2];
extern uint32_t* g_scanOrder [2][SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1];
extern uint32_t* g_scanOrderPosXY[2][SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1][2];
#else
extern uint32_t* g_scanOrder [SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1];
extern uint32_t* g_scanOrderPosXY[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1][2];
#endif
extern const int g_quantScales [SCALING_LIST_REM_NUM]; // Q(QP%6)
extern const int g_invQuantScales[SCALING_LIST_REM_NUM]; // IQ(QP%6)
......
......@@ -296,12 +296,21 @@ void TrQuant::getTrTypes ( TransformUnit tu, const ComponentID compID, int &trTy
#else
bool emtActivated = CU::isIntra( *tu.cu ) ? tu.cs->sps->getSpsNext().getUseIntraEMT() : tu.cs->sps->getSpsNext().getUseInterEMT();
#endif
#if JVET_M0303_IMPLICIT_MTS
bool mtsImplicit = CU::isIntra( *tu.cu ) && tu.cs->sps->getSpsNext().getUseImplicitMTS() && compID == COMPONENT_Y;
#endif
trTypeHor = DCT2;
trTypeVer = DCT2;
#if JVET_M0102_INTRA_SUBPARTITIONS
if (tu.cu->ispMode && isLuma(compID))
{
TU::getTransformTypeISP(tu, compID, trTypeHor, trTypeVer);
return;
}
#endif
#if JVET_M0464_UNI_MTS
if ( mtsActivated )
......@@ -386,10 +395,28 @@ void TrQuant::xT( const TransformUnit &tu, const ComponentID &compID, const CPel
}
}
#if JVET_M0102_INTRA_SUBPARTITIONS
if( width > 1 && height > 1 ) // 2-D transform
{
#endif
TCoeff *tmp = ( TCoeff * ) alloca( width * height * sizeof( TCoeff ) );
fastFwdTrans[trTypeHor][transformWidthIndex ](block, tmp, shift_1st, height, 0, skipWidth);
fastFwdTrans[trTypeVer][transformHeightIndex](tmp, dstCoeff.buf, shift_2nd, width, skipWidth, skipHeight);
#if JVET_M0102_INTRA_SUBPARTITIONS
}
else if( height == 1 ) //1-D horizontal transform
{
CHECKD( ( transformWidthIndex < 0 ), "There is a problem with the width." );
fastFwdTrans[trTypeHor][transformWidthIndex]( block, dstCoeff.buf, shift_1st, 1, 0, skipWidth );
}
else //if (iWidth == 1) //1-D vertical transform
{
CHECKD( ( transformHeightIndex < 0 ), "There is a problem with the height." );
int newShift = ( ( g_aucLog2[height] ) + bitDepth + TRANSFORM_MATRIX_SHIFT ) - maxLog2TrDynamicRange + COM16_C806_TRANS_PREC;
fastFwdTrans[trTypeVer][transformHeightIndex]( block, dstCoeff.buf, newShift, 1, 0, skipHeight );
}
#endif
}
void TrQuant::xIT( const TransformUnit &tu, const ComponentID &compID, const CCoeffBuf &pCoeff, PelBuf &pResidual )
......@@ -416,11 +443,32 @@ void TrQuant::xIT( const TransformUnit &tu, const ComponentID &compID, const CCo
getTrTypes ( tu, compID, trTypeHor, trTypeVer );
#if !JVET_M0102_INTRA_SUBPARTITIONS
TCoeff *tmp = ( TCoeff * ) alloca( width * height * sizeof( TCoeff ) );
#endif
TCoeff *block = ( TCoeff * ) alloca( width * height * sizeof( TCoeff ) );
#if JVET_M0102_INTRA_SUBPARTITIONS
if( width > 1 && height > 1 ) //2-D transform
{
TCoeff *tmp = ( TCoeff * ) alloca( width * height * sizeof( TCoeff ) );
#endif
fastInvTrans[trTypeVer][transformHeightIndex](pCoeff.buf, tmp, shift_1st, width, skipWidth, skipHeight, clipMinimum, clipMaximum);
fastInvTrans[trTypeHor][transformWidthIndex] (tmp, block, shift_2nd, height, 0, skipWidth, clipMinimum, clipMaximum);
#if JVET_M0102_INTRA_SUBPARTITIONS
}
else if( width == 1 ) //1-D vertical transform
{
CHECK( ( transformHeightIndex < 0 ), "There is a problem with the height." );
int newShift = ( TRANSFORM_MATRIX_SHIFT + maxLog2TrDynamicRange - 1 ) - bitDepth + COM16_C806_TRANS_PREC;
fastInvTrans[trTypeVer][transformHeightIndex]( pCoeff.buf, block, newShift + 1, 1, 0, skipHeight, clipMinimum, clipMaximum );
}
else //if(iHeight == 1) //1-D horizontal transform
{
CHECK( ( transformWidthIndex < 0 ), "There is a problem with the width." );
fastInvTrans[trTypeHor][transformWidthIndex]( pCoeff.buf, block, shift_2nd + 1, 1, 0, skipWidth, clipMinimum, clipMaximum );
}
#endif
Pel *resiBuf = pResidual.buf;
int resiStride = pResidual.stride;
......@@ -496,7 +544,11 @@ void TrQuant::xQuant(TransformUnit &tu, const ComponentID &compID, const CCoeffB
}
#if JVET_M0464_UNI_MTS
#if JVET_M0102_INTRA_SUBPARTITIONS
void TrQuant::transformNxN( TransformUnit &tu, const ComponentID &compID, const QpParam &cQP, std::vector<TrMode>* trModes, const int maxCand, double* diagRatio, double* horVerRatio )
#else
void TrQuant::transformNxN(TransformUnit &tu, const ComponentID &compID, const QpParam &cQP, std::vector<TrMode>* trModes, const int maxCand)
#endif
{
CodingStructure &cs = *tu.cs;
const SPS &sps = *cs.sps;
......@@ -545,6 +597,11 @@ void TrQuant::transformNxN(TransformUnit &tu, const ComponentID &compID, const Q
it++;
}
#if JVET_M0102_INTRA_SUBPARTITIONS
// it gets the distribution of the DCT-II coefficients energy, which will be useful to discard ISP tests
CoeffBuf coeffsDCT( m_mtsCoeffs[0], rect );
xGetCoeffEnergy( tu, compID, coeffsDCT, diagRatio, horVerRatio );
#endif
int numTests = 0;
std::vector<TrCost>::iterator itC = trCosts.begin();
const double fac = facBB[g_aucLog2[std::max(width, height)]-2];
......@@ -561,10 +618,18 @@ void TrQuant::transformNxN(TransformUnit &tu, const ComponentID &compID, const Q
#endif
#if JVET_M0464_UNI_MTS