From 49ba613146b2e36001d6fcdda0c89b2142f2bb62 Mon Sep 17 00:00:00 2001 From: Nuo Mi Date: Sat, 2 Mar 2024 22:04:40 +0800 Subject: [PATCH] avcodec/vvcdec: fix boundary strength when IBC involved 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); }