Commit 97f1d9ad authored by Frank Bossen's avatar Frank Bossen
Browse files

Merge branch 'JVET-M0297-ticket168Fix' into 'master'

Fix for ticket #168: Interaction between M0140 (SBT) and M0297 (MTS Zero Out)

See merge request jvet/VVCSoftware_VTM!288
parents 35652168 35a4e69c
......@@ -1687,10 +1687,18 @@ namespace DQIntern
#if JVET_M0297_32PT_MTS_ZERO_OUT
int effWidth = tuPars.m_width, effHeight = tuPars.m_height;
bool zeroOut = false;
#if JVET_M0140_SBT
#if JVET_M0464_UNI_MTS
if( ( tu.mtsIdx > 1 || ( tu.cu->sbtInfo != 0 && tuPars.m_height <= 32 && tuPars.m_width <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
if( ( ( tu.cu->emtFlag && !tu.transformSkip[ compID ] ) || ( tu.cu->sbtInfo != 0 && tuPars.m_height <= 32 && tuPars.m_width <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
#else
#if JVET_M0464_UNI_MTS
if( tu.mtsIdx > 1 && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
if( tu.cu->emtFlag && !tu.transformSkip[compID] && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
#endif
{
effHeight = ( tuPars.m_height == 32 ) ? 16 : tuPars.m_height;
......
......@@ -2818,10 +2818,27 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID )
{
cctx.initSubblock ( subSetId );
#if JVET_M0297_32PT_MTS_ZERO_OUT
residual_coding_subblock( cctx, coeff, stateTransTab, state, tu, compID );
#if JVET_M0140_SBT
#if JVET_M0464_UNI_MTS
if( ( tu.mtsIdx > 1 || ( tu.cu->sbtInfo != 0 && tu.blocks[ compID ].height <= 32 && tu.blocks[ compID ].width <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
residual_coding_subblock( cctx, coeff, stateTransTab, state );
if( ( ( tu.cu->emtFlag && !tu.transformSkip[ compID ] ) || ( tu.cu->sbtInfo != 0 && tu.blocks[ compID ].height <= 32 && tu.blocks[ compID ].width <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
#else
#if JVET_M0464_UNI_MTS
if( tu.mtsIdx > 1 && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
if( tu.cu->emtFlag && !tu.transformSkip[ compID ] && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
#endif
{
if( ( tu.blocks[ compID ].height == 32 && cctx.cgPosY() >= ( 16 >> cctx.log2CGHeight() ) ) || ( tu.blocks[ compID ].width == 32 && cctx.cgPosX() >= ( 16 >> cctx.log2CGWidth() ) ) )
{
continue;
}
}
#endif
residual_coding_subblock( cctx, coeff, stateTransTab, state );
#if !JVET_M0464_UNI_MTS
if (useEmt)
{
......@@ -3070,10 +3087,18 @@ int CABACReader::last_sig_coeff( CoeffCodingContext& cctx )
unsigned maxLastPosX = cctx.maxLastPosX();
unsigned maxLastPosY = cctx.maxLastPosY();
#if JVET_M0140_SBT
#if JVET_M0464_UNI_MTS
if( ( tu.mtsIdx > 1 || ( tu.cu->sbtInfo != 0 && tu.blocks[ compID ].width <= 32 && tu.blocks[ compID ].height <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
if( ( ( tu.cu->emtFlag && !tu.transformSkip[ compID ] ) || ( tu.cu->sbtInfo != 0 && tu.blocks[ compID ].width <= 32 && tu.blocks[ compID ].height <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
#else
#if JVET_M0464_UNI_MTS
if( tu.mtsIdx > 1 && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
if( tu.cu->emtFlag && !tu.transformSkip[ compID ] && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
#endif
{
maxLastPosX = ( tu.blocks[ compID ].width == 32 ) ? g_uiGroupIdx[ 15 ] : maxLastPosX;
......@@ -3156,11 +3181,7 @@ int CABACReader::last_sig_coeff( CoeffCodingContext& cctx )
#if JVET_M0297_32PT_MTS_ZERO_OUT
void CABACReader::residual_coding_subblock( CoeffCodingContext& cctx, TCoeff* coeff, const int stateTransTable, int& state, TransformUnit& tu, ComponentID compID )
#else
void CABACReader::residual_coding_subblock( CoeffCodingContext& cctx, TCoeff* coeff, const int stateTransTable, int& state )
#endif
{
// NOTE: All coefficients of the subblock must be set to zero before calling this function
#if RExt__DECODER_DEBUG_BIT_STATISTICS
......@@ -3183,23 +3204,7 @@ void CABACReader::residual_coding_subblock( CoeffCodingContext& cctx, TCoeff* co
bool sigGroup = ( isLast || !minSubPos );
if( !sigGroup )
{
#if JVET_M0297_32PT_MTS_ZERO_OUT
#if JVET_M0464_UNI_MTS
if( tu.mtsIdx > 1 && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
if( tu.cu->emtFlag && !tu.transformSkip[ compID ] && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
{
sigGroup = ( ( tu.blocks[compID].height == 32 && cctx.cgPosY() >= ( 16 >> cctx.log2CGHeight() ) )
|| ( tu.blocks[compID].width == 32 && cctx.cgPosX() >= ( 16 >> cctx.log2CGWidth() ) ) ) ? 0 : m_BinDecoder.decodeBin( cctx.sigGroupCtxId() );
}
else
{
sigGroup = m_BinDecoder.decodeBin(cctx.sigGroupCtxId());
}
#else
sigGroup = m_BinDecoder.decodeBin( cctx.sigGroupCtxId() );
#endif
}
if( sigGroup )
{
......
......@@ -158,11 +158,10 @@ public:
void explicit_rdpcm_mode ( TransformUnit& tu, ComponentID compID );
#if JVET_M0297_32PT_MTS_ZERO_OUT
int last_sig_coeff ( CoeffCodingContext& cctx, TransformUnit& tu, ComponentID compID );
void residual_coding_subblock ( CoeffCodingContext& cctx, TCoeff* coeff, const int stateTransTable, int& state, TransformUnit& tu, ComponentID compID );
#else
int last_sig_coeff ( CoeffCodingContext& cctx );
void residual_coding_subblock ( CoeffCodingContext& cctx, TCoeff* coeff, const int stateTransTable, int& state );
#endif
void residual_coding_subblock ( CoeffCodingContext& cctx, TCoeff* coeff, const int stateTransTable, int& state );
// cross component prediction (clause 7.3.8.12)
void cross_comp_pred ( TransformUnit& tu, ComponentID compID );
......
......@@ -2670,10 +2670,28 @@ void CABACWriter::residual_coding( const TransformUnit& tu, ComponentID compID )
{
cctx.initSubblock ( subSetId, sigGroupFlags[subSetId] );
#if JVET_M0297_32PT_MTS_ZERO_OUT
residual_coding_subblock( cctx, coeff, stateTab, state, tu, compID );
#if JVET_M0140_SBT
#if JVET_M0464_UNI_MTS
if( ( tu.mtsIdx > 1 || ( tu.cu->sbtInfo != 0 && tu.blocks[ compID ].height <= 32 && tu.blocks[ compID ].width <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
residual_coding_subblock( cctx, coeff, stateTab, state );
if( ( ( tu.cu->emtFlag && !tu.transformSkip[ compID ] ) || ( tu.cu->sbtInfo != 0 && tu.blocks[ compID ].height <= 32 && tu.blocks[ compID ].width <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
#else
#if JVET_M0464_UNI_MTS
if( tu.mtsIdx > 1 && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
if( tu.cu->emtFlag && !tu.transformSkip[ compID ] && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
#endif
{
if( ( tu.blocks[ compID ].height == 32 && cctx.cgPosY() >= ( 16 >> cctx.log2CGHeight() ) )
|| ( tu.blocks[ compID ].width == 32 && cctx.cgPosX() >= ( 16 >> cctx.log2CGWidth() ) ) )
{
continue;
}
}
#endif
residual_coding_subblock( cctx, coeff, stateTab, state );
#if !JVET_M0464_UNI_MTS
if (useEmt)
......@@ -2908,10 +2926,18 @@ void CABACWriter::last_sig_coeff( CoeffCodingContext& cctx )
unsigned maxLastPosX = cctx.maxLastPosX();
unsigned maxLastPosY = cctx.maxLastPosY();
#if JVET_M0140_SBT
#if JVET_M0464_UNI_MTS
if( ( tu.mtsIdx > 1 || ( tu.cu->sbtInfo != 0 && tu.blocks[ compID ].width <= 32 && tu.blocks[ compID ].height <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
if( ( ( tu.cu->emtFlag && !tu.transformSkip[ compID ] ) || ( tu.cu->sbtInfo != 0 && tu.blocks[ compID ].width <= 32 && tu.blocks[ compID ].height <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
#else
#if JVET_M0464_UNI_MTS
if( tu.mtsIdx > 1 && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
if( tu.cu->emtFlag && !tu.transformSkip[ compID ] && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
#endif
{
maxLastPosX = ( tu.blocks[compID].width == 32 ) ? g_uiGroupIdx[ 15 ] : maxLastPosX;
......@@ -2963,11 +2989,7 @@ void CABACWriter::last_sig_coeff( CoeffCodingContext& cctx )
#if JVET_M0297_32PT_MTS_ZERO_OUT
void CABACWriter::residual_coding_subblock( CoeffCodingContext& cctx, const TCoeff* coeff, const int stateTransTable, int& state, const TransformUnit& tu, ComponentID compID )
#else
void CABACWriter::residual_coding_subblock( CoeffCodingContext& cctx, const TCoeff* coeff, const int stateTransTable, int& state )
#endif
{
//===== init =====
const int minSubPos = cctx.minSubPos();
......@@ -2978,21 +3000,6 @@ void CABACWriter::residual_coding_subblock( CoeffCodingContext& cctx, const TCoe
//===== encode significant_coeffgroup_flag =====
if( !isLast && cctx.isNotFirst() )
{
#if JVET_M0297_32PT_MTS_ZERO_OUT
#if JVET_M0464_UNI_MTS
if( tu.mtsIdx > 1 && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#else
if( tu.cu->emtFlag && !tu.transformSkip[ compID ] && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
#endif
{
if( ( tu.blocks[compID].height == 32 && cctx.cgPosY() >= ( 16 >> cctx.log2CGHeight() ) )
|| ( tu.blocks[compID].width == 32 && cctx.cgPosX() >= ( 16 >> cctx.log2CGWidth() ) ) )
{
return;
}
}
#endif
if( cctx.isSigGroup() )
{
m_BinEncoder.encodeBin( 1, cctx.sigGroupCtxId() );
......
......@@ -172,11 +172,10 @@ public:
void explicit_rdpcm_mode ( const TransformUnit& tu, ComponentID compID );
#if JVET_M0297_32PT_MTS_ZERO_OUT
void last_sig_coeff ( CoeffCodingContext& cctx, const TransformUnit& tu, ComponentID compID );
void residual_coding_subblock ( CoeffCodingContext& cctx, const TCoeff* coeff, const int stateTransTable, int& state, const TransformUnit& tu, ComponentID compID);
#else
void last_sig_coeff ( CoeffCodingContext& cctx );
void residual_coding_subblock ( CoeffCodingContext& cctx, const TCoeff* coeff, const int stateTransTable, int& state );
#endif
void residual_coding_subblock ( CoeffCodingContext& cctx, const TCoeff* coeff, const int stateTransTable, int& state );
// cross component prediction (clause 7.3.8.12)
void cross_comp_pred ( const TransformUnit& tu, ComponentID compID );
......
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