Commit 1ba29db8 authored by Frank Bossen's avatar Frank Bossen

Add option to encode intra MPM index according to JVET-B0051

parent 93fe2cee
......@@ -961,9 +961,15 @@ const CtxSet ContextSetCfg::IPredMode[] =
{
ContextSetCfg::addCtxSet
({
#if JVET_B0051_NON_MPM_MODE
{ 183, CNU, CNU, CNU, 184 },
{ 154, CNU, CNU, CNU, 184 },
{ 184, CNU, CNU, CNU, 184 },
#else
{ 183, CNU, CNU, CNU, },
{ 154, CNU, CNU, CNU, },
{ 184, CNU, CNU, CNU, },
#endif
}),
ContextSetCfg::addCtxSet
({
......
......@@ -197,7 +197,12 @@ const Int g_aiMMLM_MinSize[] = { 0, 0 };
const Int g_aiNonLMPosThrs[] = { 3, 1, 0 };
Int g_aiLMCodeWord[LM_SYMBOL_NUM][16];
#if JVET_B0051_NON_MPM_MODE
const Int g_ipred_mode_table[] = { 1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13,13,14,14,14,15,15,15 };
#endif
#endif
// initialize ROM variables
Void initROM()
{
......
......@@ -305,6 +305,9 @@ extern const Int g_aiNonLMPosThrs[];
extern const UChar g_NonMPM[257];
#if JVET_B0051_NON_MPM_MODE
extern const Int g_ipred_mode_table[];
#endif
#endif
......
......@@ -57,6 +57,10 @@
#ifndef JEM_COMP
#define JEM_COMP ( 1 && JEM_TOOLS )
#endif
#ifndef JVET_B0051_NON_MPM_MODE
#define JVET_B0051_NON_MPM_MODE ( 1 && JEM_TOOLS )
#endif
#ifndef QTBT_AS_IN_JEM
#define QTBT_AS_IN_JEM 1
......
......@@ -1412,6 +1412,19 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu )
#if JEM_TOOLS
if( use65Ang )
{
#if JVET_B0051_NON_MPM_MODE
unsigned selected_flag = m_BinDecoder.decodeBin(Ctx::IPredMode[0](4));
if (selected_flag)
{
ipred_mode = m_BinDecoder.decodeBinsEP(4);
ipred_mode <<= 2;
}
else
{
xReadTruncBinCode(ipred_mode, 45);
ipred_mode += g_ipred_mode_table[ipred_mode];
}
#else
ipred_mode = m_BinDecoder.decodeBinsEP( 4 );
ipred_mode <<= 2;
int RealNumIntraMode = cu.cs->sps->getSpsNext().getRealNumIntraMode();
......@@ -1419,6 +1432,7 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu )
{
ipred_mode += m_BinDecoder.decodeBinsEP( 2 );
}
#endif
}
else
#endif
......
......@@ -1497,9 +1497,23 @@ void CABACWriter::intra_luma_pred_modes( const CodingUnit& cu )
}
}
#if JVET_B0051_NON_MPM_MODE
m_BinEncoder.encodeBin(((ipred_mode % 4) == 0) ? 1 : 0, Ctx::IPredMode[0](4)); // flag to indicate if it is selected mode or non-selected mode
if (ipred_mode % 4 == 0)
{
m_BinEncoder.encodeBinsEP(ipred_mode >> 2, 4); // selected mode is 4-bit FLC coded
}
else
{
ipred_mode -= ipred_mode >> 2;
ipred_mode--;
xWriteTruncBinCode(ipred_mode, 45); // Non-selected mode is truncated binary coded
}
#else
int RealNumIntraMode = cu.cs->sps->getSpsNext().getRealNumIntraMode();
if( ipred_mode < ( RealNumIntraMode - 8 ) ) { m_BinEncoder.encodeBinsEP( ipred_mode, 6 ); }
else { m_BinEncoder.encodeBinsEP( ipred_mode >> 2, 4 ); }
#endif
}
else
#endif
......@@ -1590,9 +1604,23 @@ void CABACWriter::intra_luma_pred_mode( const PredictionUnit& pu )
ipred_mode--;
}
}
#if JVET_B0051_NON_MPM_MODE
m_BinEncoder.encodeBin(((ipred_mode % 4) == 0) ? 1 : 0, Ctx::IPredMode[0](4)); // flag to indicate if it is selected mode or non-selected mode
if (ipred_mode % 4 == 0)
{
m_BinEncoder.encodeBinsEP(ipred_mode >> 2, 4); // selected mode is 4-bit FLC coded
}
else
{
ipred_mode -= ipred_mode >> 2;
ipred_mode--;
xWriteTruncBinCode(ipred_mode, 45); // Non-selected mode is truncated binary coded
}
#else
int RealNumIntraMode = pu.cs->sps->getSpsNext().getRealNumIntraMode();
if( ipred_mode < ( RealNumIntraMode - 8 ) ) { m_BinEncoder.encodeBinsEP( ipred_mode, 6 ); }
else { m_BinEncoder.encodeBinsEP( ( ipred_mode >> 2 ), 4 ); }
#endif
}
else
#endif
......
Markdown is supported
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