Commit db63c508 authored by Frank Bossen's avatar Frank Bossen
Browse files

Merge branch 'JVET-N0103' into 'master'

JVET-N0103: Coefficient group size harmonization

See merge request jvet/VVCSoftware_VTM!452
parents 42c0f6a3 202f81b2
......@@ -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_N0103_CGSIZE_HARMONIZATION
, m_log2CGWidth ( g_log2SbbSize[ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][0] )
, m_log2CGHeight ( g_log2SbbSize[ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][1] )
#else
, 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] )
#endif
, m_log2CGSize (m_log2CGWidth + m_log2CGHeight)
, m_widthInGroups(std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_width) >> m_log2CGWidth)
, m_heightInGroups(std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_height) >> m_log2CGHeight)
......@@ -68,8 +73,13 @@ CoeffCodingContext::CoeffCodingContext(const TransformUnit& tu, ComponentID comp
#else
, m_scanType (SCAN_DIAG)
#endif
#if JVET_N0103_CGSIZE_HARMONIZATION
, m_scan (g_scanOrder [SCAN_GROUPED_4x4][m_scanType][gp_sizeIdxInfo->idxFrom(m_width )][gp_sizeIdxInfo->idxFrom(m_height )])
, m_scanCG (g_scanOrder [SCAN_UNGROUPED ][m_scanType][gp_sizeIdxInfo->idxFrom(m_widthInGroups)][gp_sizeIdxInfo->idxFrom(m_heightInGroups)])
#else
, m_scan (g_scanOrder [m_chType][SCAN_GROUPED_4x4][m_scanType][gp_sizeIdxInfo->idxFrom(m_width )][gp_sizeIdxInfo->idxFrom(m_height )])
, m_scanCG (g_scanOrder [m_chType][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])
, m_maxLastPosX(g_uiGroupIdx[std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_width) - 1])
......
......@@ -128,8 +128,13 @@ namespace DQIntern
Rom() : m_scansInitialized(false) {}
~Rom() { xUninitScanArrays(); }
void init () { xInitScanArrays(); }
#if JVET_N0103_CGSIZE_HARMONIZATION
const NbInfoSbb* getNbInfoSbb( int hd, int vd ) const { return m_scanId2NbInfoSbbArray[hd][vd]; }
const NbInfoOut* getNbInfoOut( int hd, int vd ) const { return m_scanId2NbInfoOutArray[hd][vd]; }
#else
const NbInfoSbb* getNbInfoSbb( int hd, int vd, int ch ) const { return m_scanId2NbInfoSbbArray[hd][vd][ch]; }
const NbInfoOut* getNbInfoOut( int hd, int vd, int ch ) const { return m_scanId2NbInfoOutArray[hd][vd][ch]; }
#endif
const TUParameters* getTUPars ( const CompArea& area, const ComponentID compID ) const
{
return m_tuParameters[g_aucLog2[area.width]][g_aucLog2[area.height]][toChannelType(compID)];
......@@ -139,8 +144,13 @@ namespace DQIntern
void xUninitScanArrays ();
private:
bool m_scansInitialized;
#if JVET_N0103_CGSIZE_HARMONIZATION
NbInfoSbb* m_scanId2NbInfoSbbArray[ MAX_CU_DEPTH+1 ][ MAX_CU_DEPTH+1 ];
NbInfoOut* m_scanId2NbInfoOutArray[ MAX_CU_DEPTH+1 ][ MAX_CU_DEPTH+1 ];
#else
NbInfoSbb* m_scanId2NbInfoSbbArray[ MAX_CU_DEPTH+1 ][ MAX_CU_DEPTH+1 ][ MAX_NUM_CHANNEL_TYPE ];
NbInfoOut* m_scanId2NbInfoOutArray[ MAX_CU_DEPTH+1 ][ MAX_CU_DEPTH+1 ][ MAX_NUM_CHANNEL_TYPE ];
#endif
TUParameters* m_tuParameters [ MAX_CU_DEPTH+1 ][ MAX_CU_DEPTH+1 ][ MAX_NUM_CHANNEL_TYPE ];
};
......@@ -157,8 +167,10 @@ namespace DQIntern
uint32_t raster2id[ MAX_CU_SIZE * MAX_CU_SIZE ];
::memset(raster2id, 0, sizeof(raster2id));
#if !JVET_N0103_CGSIZE_HARMONIZATION
for( int ch = 0; ch < MAX_NUM_CHANNEL_TYPE; ch++ )
{
#endif
for( int hd = 0; hd <= MAX_CU_DEPTH; hd++ )
{
for( int vd = 0; vd <= MAX_CU_DEPTH; vd++ )
......@@ -169,17 +181,28 @@ namespace DQIntern
}
const uint32_t blockWidth = (1 << hd);
const uint32_t blockHeight = (1 << vd);
#if JVET_N0103_CGSIZE_HARMONIZATION
const uint32_t log2CGWidth = g_log2SbbSize[hd][vd][0];
const uint32_t log2CGHeight = g_log2SbbSize[hd][vd][1];
#else
const uint32_t log2CGWidth = g_log2SbbSize[ch][hd][vd][0];
const uint32_t log2CGHeight = g_log2SbbSize[ch][hd][vd][1];
#endif
const uint32_t groupWidth = 1 << log2CGWidth;
const uint32_t groupHeight = 1 << log2CGHeight;
const uint32_t groupSize = groupWidth * groupHeight;
const CoeffScanType scanType = SCAN_DIAG;
const SizeType blkWidthIdx = gp_sizeIdxInfo->idxFrom( blockWidth );
const SizeType blkHeightIdx = gp_sizeIdxInfo->idxFrom( blockHeight );
#if JVET_N0103_CGSIZE_HARMONIZATION
const ScanElement * scanId2RP = g_scanOrder[SCAN_GROUPED_4x4][scanType][blkWidthIdx][blkHeightIdx];
NbInfoSbb*& sId2NbSbb = m_scanId2NbInfoSbbArray[hd][vd];
NbInfoOut*& sId2NbOut = m_scanId2NbInfoOutArray[hd][vd];
#else
const ScanElement * scanId2RP = g_scanOrder[ch][SCAN_GROUPED_4x4][scanType][blkWidthIdx][blkHeightIdx];
NbInfoSbb*& sId2NbSbb = m_scanId2NbInfoSbbArray[hd][vd][ch];
NbInfoOut*& sId2NbOut = m_scanId2NbInfoOutArray[hd][vd][ch];
#endif
// consider only non-zero-out region
const uint32_t blkWidthNZOut = std::min<unsigned>( JVET_C0024_ZERO_OUT_TH, blockWidth );
const uint32_t blkHeightNZOut= std::min<unsigned>( JVET_C0024_ZERO_OUT_TH, blockHeight );
......@@ -289,10 +312,19 @@ namespace DQIntern
nbOut.maxDist -= scanId;
}
#if JVET_N0103_CGSIZE_HARMONIZATION
for( int chId = 0; chId < MAX_NUM_CHANNEL_TYPE; chId++ )
{
m_tuParameters[hd][vd][chId] = new TUParameters( *this, blockWidth, blockHeight, ChannelType(chId) );
}
#else
m_tuParameters[hd][vd][ch] = new TUParameters( *this, blockWidth, blockHeight, ChannelType(ch) );
#endif
}
}
#if !JVET_N0103_CGSIZE_HARMONIZATION
}
#endif
m_scansInitialized = true;
}
......@@ -302,6 +334,32 @@ namespace DQIntern
{
return;
}
#if JVET_N0103_CGSIZE_HARMONIZATION
for( int hd = 0; hd <= MAX_CU_DEPTH; hd++ )
{
for( int vd = 0; vd <= MAX_CU_DEPTH; vd++ )
{
NbInfoSbb*& sId2NbSbb = m_scanId2NbInfoSbbArray[hd][vd];
NbInfoOut*& sId2NbOut = m_scanId2NbInfoOutArray[hd][vd];
if( sId2NbSbb )
{
delete [] sId2NbSbb;
}
if( sId2NbOut )
{
delete [] sId2NbOut;
}
for( int chId = 0; chId < MAX_NUM_CHANNEL_TYPE; chId++ )
{
TUParameters*& tuPars = m_tuParameters[hd][vd][chId];
if( tuPars )
{
delete tuPars;
}
}
}
}
#else
for( int hd = 0; hd <= MAX_CU_DEPTH; hd++ )
{
for( int vd = 0; vd <= MAX_CU_DEPTH; vd++ )
......@@ -326,6 +384,7 @@ namespace DQIntern
}
}
}
#endif
m_scansInitialized = false;
}
......@@ -341,8 +400,13 @@ namespace DQIntern
const uint32_t nonzeroWidth = std::min<uint32_t>(JVET_C0024_ZERO_OUT_TH, m_width);
const uint32_t nonzeroHeight = std::min<uint32_t>(JVET_C0024_ZERO_OUT_TH, m_height);
m_numCoeff = nonzeroWidth * nonzeroHeight;
#if JVET_N0103_CGSIZE_HARMONIZATION
m_log2SbbWidth = g_log2SbbSize[ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][0];
m_log2SbbHeight = g_log2SbbSize[ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][1];
#else
m_log2SbbWidth = g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][0];
m_log2SbbHeight = g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][1];
#endif
m_log2SbbSize = m_log2SbbWidth + m_log2SbbHeight;
m_sbbSize = ( 1 << m_log2SbbSize );
m_sbbMask = m_sbbSize - 1;
......@@ -359,12 +423,21 @@ namespace DQIntern
SizeType vsbb = gp_sizeIdxInfo->idxFrom( m_heightInSbb );
SizeType hsId = gp_sizeIdxInfo->idxFrom( m_width );
SizeType vsId = gp_sizeIdxInfo->idxFrom( m_height );
#if JVET_N0103_CGSIZE_HARMONIZATION
m_scanSbbId2SbbPos = g_scanOrder [ SCAN_UNGROUPED ][ m_scanType ][ hsbb ][ vsbb ];
m_scanId2BlkPos = g_scanOrder [ SCAN_GROUPED_4x4 ][ m_scanType ][ hsId ][ vsId ];
int log2W = g_aucLog2[ m_width ];
int log2H = g_aucLog2[ m_height ];
m_scanId2NbInfoSbb = rom.getNbInfoSbb( log2W, log2H );
m_scanId2NbInfoOut = rom.getNbInfoOut( log2W, log2H );
#else
m_scanSbbId2SbbPos = g_scanOrder [ chType ][ SCAN_UNGROUPED ][ m_scanType ][ hsbb ][ vsbb ];
m_scanId2BlkPos = g_scanOrder [ chType ][ SCAN_GROUPED_4x4 ][ m_scanType ][ hsId ][ vsId ];
int log2W = g_aucLog2[ m_width ];
int log2H = g_aucLog2[ m_height ];
m_scanId2NbInfoSbb = rom.getNbInfoSbb( log2W, log2H, chType );
m_scanId2NbInfoOut = rom.getNbInfoOut( log2W, log2H, chType );
#endif
m_scanInfo = new ScanInfo[ m_numCoeff ];
for( int scanIdx = 0; scanIdx < m_numCoeff; scanIdx++ )
{
......@@ -736,7 +809,11 @@ namespace DQIntern
#else
const CoeffScanType scanType = SCAN_DIAG;
#endif
#if JVET_N0103_CGSIZE_HARMONIZATION
const ScanElement *scan = g_scanOrder[SCAN_GROUPED_4x4][scanType][hsId][vsId];
#else
const ScanElement *scan = g_scanOrder[toChannelType(compID)][SCAN_GROUPED_4x4][scanType][hsId][vsId];
#endif
const TCoeff* qCoeff = tu.getCoeffs( compID ).buf;
TCoeff* tCoeff = recCoeff.buf;
......
......@@ -269,6 +269,20 @@ uint32_t deriveWeightIdxBits(uint8_t gbiIdx) // Note: align this with TEncSbac::
return numBits;
}
#if JVET_N0103_CGSIZE_HARMONIZATION
uint32_t g_log2SbbSize[MAX_CU_DEPTH + 1][MAX_CU_DEPTH + 1][2] =
//===== luma/chroma =====
{
{ { 0,0 },{ 0,1 },{ 0,2 },{ 0,3 },{ 0,4 },{ 0,4 },{ 0,4 },{ 0,4 } },
{ { 1,0 },{ 1,1 },{ 1,1 },{ 1,3 },{ 1,3 },{ 1,3 },{ 1,3 },{ 1,3 } },
{ { 2,0 },{ 1,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } },
{ { 3,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } },
{ { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } },
{ { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } },
{ { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } },
{ { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }
};
#else
uint32_t g_log2SbbSize[2][MAX_CU_DEPTH+1][MAX_CU_DEPTH+1][2] =
{
//===== luma =====
......@@ -294,6 +308,7 @@ uint32_t g_log2SbbSize[2][MAX_CU_DEPTH+1][MAX_CU_DEPTH+1][2] =
{ {0,0}, {1,1}, {2,2}, {2,2}, {2,2}, {2,2}, {2,2}, {2,2} }
},
};
#endif
// initialize ROM variables
void initROM()
{
......@@ -325,8 +340,10 @@ void initROM()
SizeIndexInfoLog2 sizeInfo;
sizeInfo.init(MAX_CU_SIZE);
#if !JVET_N0103_CGSIZE_HARMONIZATION
for( int ch = 0; ch < MAX_NUM_CHANNEL_TYPE; ch++ )
{
#endif
// initialize scan orders
for (uint32_t blockHeightIdx = 0; blockHeightIdx < sizeInfo.numAllHeights(); blockHeightIdx++)
{
......@@ -350,7 +367,11 @@ void initROM()
scan = new ScanElement[totalValues];
}
#if JVET_N0103_CGSIZE_HARMONIZATION
g_scanOrder[SCAN_UNGROUPED][scanType][blockWidthIdx][blockHeightIdx] = scan;
#else
g_scanOrder[ch][SCAN_UNGROUPED][scanType][blockWidthIdx][blockHeightIdx] = scan;
#endif
if (scan == nullptr)
{
......@@ -374,7 +395,11 @@ void initROM()
//--------------------------------------------------------------------------------------------------
//grouped scan orders
#if JVET_N0103_CGSIZE_HARMONIZATION
const uint32_t* log2Sbb = g_log2SbbSize[g_aucLog2[blockWidth]][g_aucLog2[blockHeight]];
#else
const uint32_t* log2Sbb = g_log2SbbSize[ch][ g_aucLog2[blockWidth] ][ g_aucLog2[blockHeight] ];
#endif
const uint32_t log2CGWidth = log2Sbb[0];
const uint32_t log2CGHeight = log2Sbb[1];
......@@ -392,7 +417,11 @@ void initROM()
ScanElement *scan = new ScanElement[totalValues];
#if JVET_N0103_CGSIZE_HARMONIZATION
g_scanOrder[SCAN_GROUPED_4x4][scanType][blockWidthIdx][blockHeightIdx] = scan;
#else
g_scanOrder[ch][SCAN_GROUPED_4x4][scanType][blockWidthIdx][blockHeightIdx] = scan;
#endif
if ( blockWidth > JVET_C0024_ZERO_OUT_TH || blockHeight > JVET_C0024_ZERO_OUT_TH )
{
......@@ -434,7 +463,9 @@ void initROM()
//--------------------------------------------------------------------------------------------------
}
}
#if !JVET_N0103_CGSIZE_HARMONIZATION
}
#endif
for( int idxH = MAX_CU_DEPTH - MIN_CU_LOG2; idxH >= 0; --idxH )
{
......@@ -464,6 +495,22 @@ void destroyROM()
unsigned numWidths = gp_sizeIdxInfo->numAllWidths();
unsigned numHeights = gp_sizeIdxInfo->numAllHeights();
#if JVET_N0103_CGSIZE_HARMONIZATION
for (uint32_t groupTypeIndex = 0; groupTypeIndex < SCAN_NUMBER_OF_GROUP_TYPES; groupTypeIndex++)
{
for (uint32_t scanOrderIndex = 0; scanOrderIndex < SCAN_NUMBER_OF_TYPES; scanOrderIndex++)
{
for (uint32_t blockWidthIdx = 0; blockWidthIdx <= numWidths; blockWidthIdx++)
{
for (uint32_t blockHeightIdx = 0; blockHeightIdx <= numHeights; blockHeightIdx++)
{
delete[] g_scanOrder[groupTypeIndex][scanOrderIndex][blockWidthIdx][blockHeightIdx];
g_scanOrder[groupTypeIndex][scanOrderIndex][blockWidthIdx][blockHeightIdx] = nullptr;
}
}
}
}
#else
for( uint32_t ch = 0; ch < MAX_NUM_CHANNEL_TYPE; ch++ )
{
for( uint32_t groupTypeIndex = 0; groupTypeIndex < SCAN_NUMBER_OF_GROUP_TYPES; groupTypeIndex++ )
......@@ -481,6 +528,7 @@ void destroyROM()
}
}
}
#endif
delete gp_sizeIdxInfo;
gp_sizeIdxInfo = nullptr;
......@@ -574,7 +622,11 @@ UnitScale g_miScaling( MIN_CU_LOG2, MIN_CU_LOG2 );
// ====================================================================================================================
// scanning order table
#if JVET_N0103_CGSIZE_HARMONIZATION
ScanElement *g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1];
#else
ScanElement *g_scanOrder[2][SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1];
#endif
const uint32_t g_uiMinInGroup[LAST_SIGNIFICANT_GROUPS] = { 0,1,2,3,4,6,8,12,16,24,32,48,64,96 };
const uint32_t g_uiGroupIdx[MAX_TB_SIZEY] = { 0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11 };
......
......@@ -67,9 +67,15 @@ struct ScanElement
uint16_t y;
};
#if JVET_N0103_CGSIZE_HARMONIZATION
extern uint32_t g_log2SbbSize[MAX_CU_DEPTH + 1][MAX_CU_DEPTH + 1][2];
extern ScanElement
*g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1];
#else
extern uint32_t g_log2SbbSize [2][MAX_CU_DEPTH+1][MAX_CU_DEPTH+1][2];
extern ScanElement
*g_scanOrder[2][SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1];
#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)
......
......@@ -50,6 +50,8 @@
#include <assert.h>
#include <cassert>
#define JVET_N0103_CGSIZE_HARMONIZATION 1 // Chroma CG sizes aligned to luma CG sizes
#define JVET_N0146_DMVR_BDOF_CONDITION 1 // JVET-N146/N0162/N0442/N0153/N0262/N0440/N0086 applicable condition of DMVR and BDOF
#define JVET_N0470_SMVD_FIX 1 // remove mvd_l1_zero_flag condition, align to spec text.
......
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