diff mbox series

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

Message ID TYSPR06MB6433EFC18DB39F3FE1CBA2CEAA5D2@TYSPR06MB6433.apcprd06.prod.outlook.com
State Accepted
Commit 49ba613146b2e36001d6fcdda0c89b2142f2bb62
Headers show
Series [FFmpeg-devel] avcodec/vvcdec: fix boundary strength when IBC involved | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Nuo Mi March 2, 2024, 2:04 p.m. UTC
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(+)

Comments

Nuo Mi March 4, 2024, 12:43 p.m. UTC | #1
On Sat, Mar 2, 2024 at 10:05 PM Nuo Mi <nuomi2021@gmail.com> wrote:

> 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
> ---
>
pushed.

>  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
>
>
diff mbox series

Patch

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);
 }