[FFmpeg-devel] [PATCH] avcodec/vvcdec: fix boundary strength when IBC involved

Nuo Mi nuomi2021 at gmail.com
Sat Mar 2 16:04:40 EET 2024


The following cases should set bs to 1:
If the prediction modes are not the same.
If both prediction modes are MODE_IBC, but the motion vector delta is larger than 8 of 1/16 pixels.
see 8.8.3.5

How to reproduce it:
vvencapp -i sintel_trailer_2k_1080p24.y4m --preset fast --additional "IBC=1" -o sintel.266
ffmpeg -i sintel.266 -f md5 -
md5 will mismatch

Found-by: 6ws at https://github.com/ffvvc/FFmpeg/issues/187#issuecomment-1962842135
---
 libavcodec/vvc/vvc_filter.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/vvc/vvc_filter.c b/libavcodec/vvc/vvc_filter.c
index 379d90d02b..dded447bfa 100644
--- a/libavcodec/vvc/vvc_filter.c
+++ b/libavcodec/vvc/vvc_filter.c
@@ -309,6 +309,10 @@ static int boundary_strength(const VVCLocalContext *lc, const MvField *curr, con
     const RefPicList *neigh_rpl)
 {
     RefPicList *rpl = lc->sc->rpl;
+
+    if (curr->pred_flag == PF_IBC)
+        return FFABS(neigh->mv[0].x - curr->mv[0].x) >= 8 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 8;
+
     if (curr->pred_flag == PF_BI &&  neigh->pred_flag == PF_BI) {
         // same L0 and L1
         if (rpl[0].list[curr->ref_idx[0]] == neigh_rpl[0].list[neigh->ref_idx[0]]  &&
@@ -497,6 +501,7 @@ static av_always_inline int deblock_bs(const VVCLocalContext *lc,
     const int cb_p             = (y_p >> log2_min_cb_size) * min_cb_width  + (x_p >>  log2_min_cb_size);
     const int cb_q             = (y_q >> log2_min_cb_size) * min_cb_width  + (x_q >>  log2_min_cb_size);
     const uint8_t intra        = fc->tab.cpm[chroma][cb_p] == MODE_INTRA || fc->tab.cpm[chroma][cb_q] == MODE_INTRA;
+    const uint8_t same_mode    = fc->tab.cpm[chroma][cb_p] == fc->tab.cpm[chroma][cb_q];
 
     if (pcmf)
         return 0;
@@ -517,6 +522,9 @@ static av_always_inline int deblock_bs(const VVCLocalContext *lc,
     if ((off_to_cb && ((off_to_cb % 8) || !has_sub_block)))
         return 0;                                     // inside a cu, not aligned to 8 or with no subblocks
 
+    if (!same_mode)
+        return 1;
+
     return boundary_strength(lc, mvf_q, mvf_p, rpl_p);
 }
 
-- 
2.25.1



More information about the ffmpeg-devel mailing list