From b6355a0e21df8d56183c4469bfb69375fb2f770c Mon Sep 17 00:00:00 2001 From: Brian Heng <brian.heng@broadcom.com> Date: Tue, 15 Oct 2019 18:05:56 -0700 Subject: [PATCH] JVET-P0042: Fix InterDir Ctx - Fix overlap in context between the bi-pred flag for 8x8 CUs and the L0/L1 flag for all size CUs. --- source/Lib/CommonLib/Contexts.cpp | 10 ++++++++++ source/Lib/CommonLib/TypeDef.h | 2 ++ source/Lib/DecoderLib/CABACReader.cpp | 12 ++++++++++++ source/Lib/EncoderLib/CABACWriter.cpp | 5 +++++ 4 files changed, 29 insertions(+) diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index 3ff28063f..a70b6c8ff 100755 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -346,6 +346,15 @@ const CtxSet ContextSetCfg::DeltaQP = ContextSetCfg::addCtxSet { DWS, DWS, }, }); +#if JVET_P0042_FIX_INTER_DIR_CTX +const CtxSet ContextSetCfg::InterDir = ContextSetCfg::addCtxSet +({ + { 6, 13, 5, 4, 25, 48, }, + { 7, 6, 5, 4, 33, 34, }, + { CNU, CNU, CNU, CNU, CNU, CNU, }, + { 0, 0, 1, 4, 0, 0, }, +}); +#else const CtxSet ContextSetCfg::InterDir = ContextSetCfg::addCtxSet ({ { 6, 13, 5, 4, 25, }, @@ -353,6 +362,7 @@ const CtxSet ContextSetCfg::InterDir = ContextSetCfg::addCtxSet { CNU, CNU, CNU, CNU, CNU, }, { 0, 0, 1, 4, 0, }, }); +#endif const CtxSet ContextSetCfg::RefPic = ContextSetCfg::addCtxSet ({ diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 56871e4b7..83b4aa5c4 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #include <assert.h> #include <cassert> +#define JVET_P0042_FIX_INTER_DIR_CTX 1 // JVET-P0042: Fix overlap in context between the bi-pred flag for 8x8 CUs and the L0/L1 flag for all size CUs + #define JVET_O0145_ENTRYPOINT_SIGNALLING 0 // JVET-O0145: Not signalling num_entry_point_offsets but derive it at decoder #define JVET_O0625_ALF_PADDING 1 // JVET-O0625/O0654/O0662: Unified padding method in ALF diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 07da5efc9..18f9cf99d 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -2391,13 +2391,25 @@ void CABACReader::inter_pred_idc( PredictionUnit& pu ) return; } } +#if JVET_P0042_FIX_INTER_DIR_CTX + if( m_BinDecoder.decodeBin( Ctx::InterDir(5) ) ) +#else if( m_BinDecoder.decodeBin( Ctx::InterDir(4) ) ) +#endif { +#if JVET_P0042_FIX_INTER_DIR_CTX + DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", 2, pu.lumaPos().x, pu.lumaPos().y ); +#else DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=4 value=%d pos=(%d,%d)\n", 2, pu.lumaPos().x, pu.lumaPos().y ); +#endif pu.interDir = 2; return; } +#if JVET_P0042_FIX_INTER_DIR_CTX + DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", 1, pu.lumaPos().x, pu.lumaPos().y ); +#else DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=4 value=%d pos=(%d,%d)\n", 1, pu.lumaPos().x, pu.lumaPos().y ); +#endif pu.interDir = 1; return; } diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 911603b73..38fc232ba 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -2195,8 +2195,13 @@ void CABACWriter::inter_pred_idc( const PredictionUnit& pu ) m_BinEncoder.encodeBin( 0, Ctx::InterDir(ctxId) ); } } +#if JVET_P0042_FIX_INTER_DIR_CTX + m_BinEncoder.encodeBin( ( pu.interDir == 2 ), Ctx::InterDir( 5 ) ); + DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=5 value=%d pos=(%d,%d)\n", pu.interDir, pu.lumaPos().x, pu.lumaPos().y ); +#else m_BinEncoder.encodeBin( ( pu.interDir == 2 ), Ctx::InterDir( 4 ) ); DTRACE( g_trace_ctx, D_SYNTAX, "inter_pred_idc() ctx=4 value=%d pos=(%d,%d)\n", pu.interDir, pu.lumaPos().x, pu.lumaPos().y ); +#endif } -- GitLab