Commit 0ddd2170 authored by Xin Zhao's avatar Xin Zhao
Browse files

JVET-O0545: Configurable maximum transform size

parent eae3419a
......@@ -2528,6 +2528,9 @@ bool EncAppCfg::xCheckParameter()
#if MAX_TB_SIZE_SIGNALLING
xConfirmPara( m_log2MaxTbSize > 6, "Log2MaxTbSize must be 6 or smaller." );
#endif
#if JVET_O0545_MAX_TB_SIGNALLING
xConfirmPara( m_log2MaxTbSize < 5, "Log2MaxTbSize must be 5 or greater." );
#endif
xConfirmPara( m_maxNumMergeCand < 1, "MaxNumMergeCand must be 1 or greater.");
xConfirmPara( m_maxNumMergeCand > MRG_MAX_NUM_CANDS, "MaxNumMergeCand must be no more than MRG_MAX_NUM_CANDS." );
......
......@@ -314,7 +314,12 @@ static const int MAX_CU_SIZE = 1<<MAX_CU_DEPTH;
static const int MIN_CU_LOG2 = 2;
static const int MIN_PU_SIZE = 4;
static const int MAX_NUM_PARTS_IN_CTU = ( ( MAX_CU_SIZE * MAX_CU_SIZE ) >> ( MIN_CU_LOG2 << 1 ) );
#if JVET_O0545_MAX_TB_SIGNALLING
static const int MAX_NUM_TUS = 16;
static const int MAX_LOG2_DIFF_CU_TR_SIZE = 3;
#else
static const int MAX_LOG2_DIFF_CU_TR_SIZE = 2;
#endif
static const int MAX_CU_TILING_PARTITIONS = 1 << ( MAX_LOG2_DIFF_CU_TR_SIZE << 1 );
static const int JVET_C0024_ZERO_OUT_TH = 32;
......
......@@ -1997,7 +1997,11 @@ void IntraPrediction::xGetLMParameters(const PredictionUnit &pu, const Component
void IntraPrediction::initIntraMip( const PredictionUnit &pu )
{
#if JVET_O0545_MAX_TB_SIGNALLING
CHECK( pu.lwidth() > pu.cs->sps->getMaxTbSize() || pu.lheight() > pu.cs->sps->getMaxTbSize(), "Error: block size not supported for MIP" );
#else
CHECK( pu.lwidth() > MIP_MAX_WIDTH || pu.lheight() > MIP_MAX_HEIGHT, "Error: block size not supported for MIP" );
#endif
// derive above and left availability
AvailableInfo availInfo = PU::getAvailableInfoLuma(pu);
......@@ -2009,7 +2013,11 @@ void IntraPrediction::initIntraMip( const PredictionUnit &pu )
void IntraPrediction::predIntraMip( const ComponentID compId, PelBuf &piPred, const PredictionUnit &pu )
{
CHECK( compId != COMPONENT_Y, "Error: chroma not supported" );
#if JVET_O0545_MAX_TB_SIGNALLING
CHECK( pu.lwidth() > pu.cs->sps->getMaxTbSize() || pu.lheight() > pu.cs->sps->getMaxTbSize(), "Error: block size not supported for MIP" );
#else
CHECK( pu.lwidth() > MIP_MAX_WIDTH || pu.lheight() > MIP_MAX_HEIGHT, "Error: block size not supported for MIP" );
#endif
CHECK( pu.lwidth() != (1 << g_aucLog2[pu.lwidth()]) || pu.lheight() != (1 << g_aucLog2[pu.lheight()]), "Error: expecting blocks of size 2^M x 2^N" );
// generate mode-specific prediction
......
......@@ -138,6 +138,8 @@
#define JVET_O0669_REMOVE_ALF_COEFF_PRED 1 // JVET-O0425/O0427/O0669: remove prediction in ALF coefficients coding
#define JVET_O0545_MAX_TB_SIGNALLING 1 // JVET-O0545: Configurable maximum transform size
#define JVET_O0541_IMPLICIT_MTS_CONDITION 1 // JVET_O0541: Decouple the intra implicit transform selection from an inter MTS related SPS flag
#define JVET_O0163_REMOVE_SWITCHING_TMV 1 // JVET-O0163/JVET-O0588: Remove switching between L0 and L1 for temporal MV
#define JVET_O0655_422_CHROMA_DM_MAPPING_FIX 1 // JVET-O0655: modify chroma DM derivation table for 4:2:2 chroma format
......@@ -205,7 +207,11 @@
#define APPLY_SBT_SL_ON_MTS 1 // apply save & load fast algorithm on inter MTS when SBT is on
#define FIX_PCM 1 // Fix PCM bugs in VTM3
#if JVET_O0545_MAX_TB_SIGNALLING
#define MAX_TB_SIZE_SIGNALLING 1
#else
#define MAX_TB_SIZE_SIGNALLING 0
#endif
#define EMULATION_PREVENTION_FIX 1 // fix for start code emulation reported in #270. Diverges from specification text
......@@ -218,8 +224,10 @@ typedef std::pair<int, int> TrCost;
#define REUSE_CU_RESULTS 1
#if REUSE_CU_RESULTS
#define REUSE_CU_RESULTS_WITH_MULTIPLE_TUS 1
#if !JVET_O0545_MAX_TB_SIGNALLING
#define MAX_NUM_TUS 4
#endif
#endif
// clang-format on
......
......@@ -1005,9 +1005,15 @@ static const int g_zScanToY[1 << ( g_maxRtGridSize << 1 )] =
0, 0, 1, 1, 0, 0, 1, 1,
2, 2, 3, 3, 2, 2, 3, 3,
4, 4, 5, 5, 4, 4, 5, 5,
#if JVET_O0545_MAX_TB_SIGNALLING
6, 6, 7, 7, 6, 6, 7, 7,
4, 4, 5, 5, 4, 4, 5, 5,
6, 6, 7, 7, 6, 6, 7, 7,
#else
6, 6, 7, 7, 6, 5, 7, 7,
4, 4, 5, 5, 4, 4, 5, 5,
6, 6, 7, 7, 6, 5, 7, 7,
#endif
};
static const int g_rsScanToZ[1 << ( g_maxRtGridSize << 1 )] =
{
......@@ -1025,11 +1031,16 @@ Partitioning PartitionerImpl::getMaxTuTiling( const UnitArea &cuArea, const Codi
{
static_assert( MAX_LOG2_DIFF_CU_TR_SIZE <= g_maxRtGridSize, "Z-scan tables are only provided for MAX_LOG2_DIFF_CU_TR_SIZE for up to 3 (8x8 tiling)!" );
#if JVET_O0545_MAX_TB_SIGNALLING
const Size area = cuArea.lumaSize();
const int maxTrSize = (area.width>64 || area.height>64) ? 64 : cs.sps->getMaxTbSize();
#else
const CompArea area = cuArea.Y().valid() ? cuArea.Y() : cuArea.Cb();
#if MAX_TB_SIZE_SIGNALLING
const int maxTrSize = cs.sps->getMaxTbSize() >> ( isLuma( area.compID ) ? 0 : 1 );
#else
const int maxTrSize = MAX_TB_SIZEY >> ( isLuma( area.compID ) ? 0 : 1 );
#endif
#endif
const int numTilesH = std::max<int>( 1, area.width / maxTrSize );
const int numTilesV = std::max<int>( 1, area.height / maxTrSize );
......
......@@ -3720,7 +3720,11 @@ void CABACReader::mip_flag( CodingUnit& cu )
cu.mipFlag = false;
return;
}
#if JVET_O0545_MAX_TB_SIGNALLING
if( cu.lwidth() > cu.cs->sps->getMaxTbSize() || cu.lheight() > cu.cs->sps->getMaxTbSize())
#else
if( cu.lwidth() > MIP_MAX_WIDTH || cu.lheight() > MIP_MAX_HEIGHT )
#endif
{
cu.mipFlag = false;
return;
......@@ -3752,7 +3756,11 @@ void CABACReader::mip_pred_modes( CodingUnit &cu )
void CABACReader::mip_pred_mode( PredictionUnit &pu )
{
#if JVET_O0545_MAX_TB_SIGNALLING
CHECK( pu.lwidth() > pu.cs->sps->getMaxTbSize() || pu.lheight() > pu.cs->sps->getMaxTbSize(), "Error: block size not supported" );
#else
CHECK( pu.lwidth() > MIP_MAX_WIDTH || pu.lheight() > MIP_MAX_HEIGHT, "Error: block size not supported" );
#endif
const int numModes = getNumModesMip( pu.Y() ); CHECKD( numModes > MAX_NUM_MIP_MODE, "Error: too many MIP modes" );
......
......@@ -1221,9 +1221,13 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
#if MAX_TB_SIZE_SIGNALLING
#if JVET_O0545_MAX_TB_SIGNALLING
READ_UVLC( uiCode, "sps_max_luma_transform_size_64_flag"); pcSPS->setLog2MaxTbSize( uiCode + 5 );
#else
// KJS: Not in syntax
READ_UVLC( uiCode, "log2_max_luma_transform_block_size_minus2" ); pcSPS->setLog2MaxTbSize( uiCode + 2 );
#endif
#endif
#if JVET_O0244_DELTA_POC
READ_FLAG( uiCode, "sps_weighted_pred_flag" ); pcSPS->setUseWP( uiCode ? true : false );
READ_FLAG( uiCode, "sps_weighted_bipred_flag" ); pcSPS->setUseWPBiPred( uiCode ? true : false );
......@@ -1329,7 +1333,11 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
READ_FLAG(uiCode, "sbt_enable_flag"); pcSPS->setUseSBT(uiCode != 0);
if( pcSPS->getUseSBT() )
{
#if JVET_O0545_MAX_TB_SIGNALLING
READ_FLAG(uiCode, "max_sbt_size_64_flag"); pcSPS->setMaxSbtSize(std::min((int)(1 << pcSPS->getLog2MaxTbSize()), uiCode != 0 ? 64 : 32));
#else
READ_FLAG(uiCode, "max_sbt_size_64_flag"); pcSPS->setMaxSbtSize(uiCode != 0 ? 64 : 32);
#endif
}
// KJS: not in draft yet
READ_FLAG(uiCode, "sps_reshaper_enable_flag"); pcSPS->setUseReshaper(uiCode == 1);
......
......@@ -2962,8 +2962,12 @@ void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx )
unsigned cctx = 0;
#if JVET_O0368_LFNST_WITH_DCT2_ONLY
if ( CS::isDualITree(*cu.cs) ) cctx++;
#else
#if JVET_O0545_MAX_TB_SIGNALLING
if( ( cu.firstTU->mtsIdx < MTS_DST7_DST7 || !TU::getCbf(*cu.firstTU, COMPONENT_Y) ) && CS::isDualITree( *cu.cs ) ) cctx++;
#else
if( cu.firstTU->mtsIdx < MTS_DST7_DST7 && CS::isDualITree( *cu.cs ) ) cctx++;
#endif
#endif
const uint32_t idxLFNST = cu.lfnstIdx;
......@@ -3623,7 +3627,11 @@ void CABACWriter::mip_flag( const CodingUnit& cu )
{
return;
}
#if JVET_O0545_MAX_TB_SIGNALLING
if( cu.lwidth() > cu.cs->sps->getMaxTbSize() || cu.lheight() > cu.cs->sps->getMaxTbSize())
#else
if( cu.lwidth() > MIP_MAX_WIDTH || cu.lheight() > MIP_MAX_HEIGHT )
#endif
{
return;
}
......
......@@ -4183,10 +4183,12 @@ void EncCu::xEncodeInterResidual( CodingStructure *&tempCS
sbtOffRootCbf = cu->rootCbf;
currBestSbt = CU::getSbtInfo( cu->firstTU->mtsIdx > MTS_SKIP ? SBT_OFF_MTS : SBT_OFF_DCT, 0 );
currBestTrs = cu->firstTU->mtsIdx;
#if !JVET_O0545_MAX_TB_SIGNALLING
if( cu->lwidth() <= MAX_TB_SIZEY && cu->lheight() <= MAX_TB_SIZEY )
{
CHECK( tempCS->tus.size() != 1, "tu must be only one" );
}
#endif
#if WCG_EXT
DTRACE_MODE_COST( *tempCS, m_pcRdCost->getLambda( true ) );
......
......@@ -912,7 +912,11 @@ void EncLib::xInitSPS(SPS &sps)
sps.setUseSBT ( m_SBT );
if( sps.getUseSBT() )
{
#if JVET_O0545_MAX_TB_SIGNALLING
sps.setMaxSbtSize ( std::min((int)(1 << m_log2MaxTbSize), m_iSourceWidth >= 1920 ? 64 : 32) );
#else
sps.setMaxSbtSize ( m_iSourceWidth >= 1920 ? 64 : 32 );
#endif
}
sps.setUseSMVD ( m_SMVD );
sps.setUseGBi ( m_GBi );
......
......@@ -6258,7 +6258,11 @@ void InterSearch::setWpScalingDistParam( int iRefIdx, RefPicList eRefPicListCur,
void InterSearch::xEncodeInterResidualQT(CodingStructure &cs, Partitioner &partitioner, const ComponentID &compID)
{
const UnitArea& currArea = partitioner.currArea();
#if JVET_O0545_MAX_TB_SIGNALLING
const TransformUnit &currTU = *cs.getTU(isLuma(partitioner.chType) ? currArea.lumaPos() : currArea.chromaPos(), partitioner.chType);
#else
const TransformUnit &currTU = *cs.getTU(currArea.lumaPos(), partitioner.chType);
#endif
const CodingUnit &cu = *currTU.cu;
const unsigned currDepth = partitioner.currTrDepth;
......@@ -6281,7 +6285,11 @@ void InterSearch::xEncodeInterResidualQT(CodingStructure &cs, Partitioner &parti
CHECK(CU::isIntra(cu), "Inter search provided with intra CU");
if( cu.chromaFormat != CHROMA_400 )
if( cu.chromaFormat != CHROMA_400
#if JVET_O0545_MAX_TB_SIGNALLING
&& (!CS::isDualITree(cs) || isChroma(partitioner.chType))
#endif
)
{
#if !JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
const bool firstCbfOfCU = ( currDepth == 0 );
......@@ -6314,7 +6322,11 @@ void InterSearch::xEncodeInterResidualQT(CodingStructure &cs, Partitioner &parti
}
}
if( !bSubdiv && !( cu.sbtInfo && currTU.noResidual ) )
if( !bSubdiv && !( cu.sbtInfo && currTU.noResidual )
#if JVET_O0545_MAX_TB_SIGNALLING
&& !isChroma(partitioner.chType)
#endif
)
{
m_CABACEstimator->cbf_comp( cs, TU::getCbfAtDepth( currTU, COMPONENT_Y, currDepth ), currArea.Y(), currDepth );
}
......@@ -6655,7 +6667,11 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par
if (bCheckFull)
{
#if JVET_O0545_MAX_TB_SIGNALLING
TransformUnit &tu = csFull->addTU(CS::getArea(cs, currArea, partitioner.chType), partitioner.chType);
#else
TransformUnit &tu = csFull->addTU(CS::isDualITree(cs) ? cu : currArea, partitioner.chType);
#endif
tu.depth = currDepth;
tu.mtsIdx = MTS_DCT2_DCT2;
tu.checkTuNoResidual( partitioner.currPartIdx() );
......@@ -6695,7 +6711,11 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par
saveCS.picture = cs.picture;
saveCS.area.repositionTo(currArea);
saveCS.clearTUs();
#if JVET_O0545_MAX_TB_SIGNALLING
TransformUnit & bestTU = saveCS.addTU(CS::getArea(cs, currArea, partitioner.chType), partitioner.chType);
#else
TransformUnit & bestTU = saveCS.addTU(CS::isDualITree(cs) ? cu : currArea, partitioner.chType);
#endif
for( uint32_t c = 0; c < numTBlocks; c++ )
{
......
......@@ -365,7 +365,11 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner,
//===== determine set of modes to be tested (using prediction signal only) =====
int numModesAvailable = NUM_LUMA_MODE; // total number of Intra modes
const bool fastMip = sps.getUseMIP() && m_pcEncCfg->getUseFastMIP();
#if JVET_O0545_MAX_TB_SIGNALLING
const bool mipAllowed = sps.getUseMIP() && ( cu.lfnstIdx == 0 ) && isLuma( partitioner.chType ) && pu.lwidth() <= cu.cs->sps->getMaxTbSize() && pu.lheight() <= cu.cs->sps->getMaxTbSize();
#else
const bool mipAllowed = sps.getUseMIP() && ( cu.lfnstIdx == 0 ) && isLuma( partitioner.chType ) && pu.lwidth() <= MIP_MAX_WIDTH && pu.lheight() <= MIP_MAX_HEIGHT;
#endif
const bool testMip = mipAllowed && mipModesAvailable( pu.Y() ) && !(fastMip && (cu.lwidth() > 2 * cu.lheight() || cu.lheight() > 2 * cu.lwidth()));
static_vector<ModeInfo, FAST_UDI_MAX_RDMODE_NUM> uiRdModeList;
......
......@@ -828,9 +828,13 @@ void HLSWriter::codeSPS( const SPS* pcSPS )
}
#if MAX_TB_SIZE_SIGNALLING
#if JVET_O0545_MAX_TB_SIGNALLING
WRITE_UVLC( pcSPS->getLog2MaxTbSize() - 5, "sps_max_luma_transform_size_64_flag" );
#else
// KJS: Not in syntax
WRITE_UVLC( pcSPS->getLog2MaxTbSize() - 2, "log2_max_luma_transform_block_size_minus2" );
#endif
#endif
#if JVET_O0244_DELTA_POC
WRITE_FLAG( pcSPS->getUseWP() ? 1 : 0, "sps_weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE)
WRITE_FLAG( pcSPS->getUseWPBiPred() ? 1 : 0, "sps_weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment