Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 02/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc to mc
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 03/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc_uni to mc_uni Nuo Mi
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/inter.c | 47 +++++++++++++-----------------------------
 1 file changed, 14 insertions(+), 33 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 3f0718cb5a..8657541eaf 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -142,6 +142,8 @@ static void emulated_edge_bilinear(const VVCLocalContext *lc, uint8_t *dst, cons
     }
 }
 
+#define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off)                               \
+    emulated_edge(lc, dst, src, src_stride, x_off, y_off, block_w, block_h, is_chroma)
 
 #define EMULATED_EDGE_LUMA(dst, src, src_stride, x_off, y_off)                      \
     emulated_edge(lc, dst, src, src_stride, x_off, y_off, block_w, block_h, 0)
@@ -209,47 +211,29 @@ static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1,
     return 1;
 }
 
-static void luma_mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,
-    int x_off, int y_off, const int block_w, const int block_h)
-{
-    const VVCFrameContext *fc   = lc->fc;
-    const uint8_t *src          = ref->data[0];
-    ptrdiff_t src_stride        = ref->linesize[0];
-    const int idx               = av_log2(block_w) - 1;
-    const int mx                = mv->x & 0xf;
-    const int my                = mv->y & 0xf;
-    const int8_t *hf            = ff_vvc_inter_luma_filters[0][mx];
-    const int8_t *vf            = ff_vvc_inter_luma_filters[0][my];
-
-    x_off += mv->x >> 4;
-    y_off += mv->y >> 4;
-    src   += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
-
-    EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
-
-    fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
-}
+#define INTER_FILTER(t, frac)  (is_chroma ? ff_vvc_inter_chroma_filters[t][frac] : ff_vvc_inter_luma_filters[t][frac])
 
-static void chroma_mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,
+static void mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,
     int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
 {
     const VVCFrameContext *fc   = lc->fc;
     const uint8_t *src          = ref->data[c_idx];
     ptrdiff_t src_stride        = ref->linesize[c_idx];
-    int hs                      = fc->ps.sps->hshift[c_idx];
-    int vs                      = fc->ps.sps->vshift[c_idx];
+    const int is_chroma         = !!c_idx;
+    const int hs                = fc->ps.sps->hshift[c_idx];
+    const int vs                = fc->ps.sps->vshift[c_idx];
     const int idx               = av_log2(block_w) - 1;
-    const intptr_t mx           = av_mod_uintp2(mv->x, 4 + hs) << (1 - hs);
-    const intptr_t my           = av_mod_uintp2(mv->y, 4 + vs) << (1 - vs);
-    const int8_t *hf            = ff_vvc_inter_chroma_filters[0][mx];
-    const int8_t *vf            = ff_vvc_inter_chroma_filters[0][my];
+    const intptr_t mx           = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - hs);
+    const intptr_t my           = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - vs);
+    const int8_t *hf            = INTER_FILTER(0, mx);
+    const int8_t *vf            = INTER_FILTER(0, my);
 
     x_off += mv->x >> (4 + hs);
     y_off += mv->y >> (4 + vs);
     src  += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
-    EMULATED_EDGE_CHROMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
-    fc->vvcdsp.inter.put[CHROMA][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
+    MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
+    fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
 }
 
 static void luma_mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
@@ -543,10 +527,7 @@ static void pred_gpm_blk(VVCLocalContext *lc)
             VVCFrame *ref = lc->sc->rpl[lx].ref[mv->ref_idx[lx]];
             if (!ref)
                 return;
-            if (c_idx)
-                chroma_mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height, c_idx);
-            else
-                luma_mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height);
+            mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height, c_idx);
         }
         fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y);
     }
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 03/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc_uni to mc_uni
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 02/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc to mc Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 04/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc_bi to mc_bi Nuo Mi
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/inter.c | 80 +++++++++++++-----------------------------
 1 file changed, 25 insertions(+), 55 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 8657541eaf..6d866c1bad 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -236,33 +236,35 @@ static void mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *
     fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
 }
 
-static void luma_mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
+static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
     const AVFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
-    const int hf_idx, const int vf_idx)
+    const int c_idx, const int hf_idx, const int vf_idx)
 {
     const VVCFrameContext *fc   = lc->fc;
+    const uint8_t *src          = ref->data[c_idx];
+    ptrdiff_t src_stride        = ref->linesize[c_idx];
     const int lx                = mvf->pred_flag - PF_L0;
-    const Mv *mv                = mvf->mv + lx;
-    const uint8_t *src          = ref->data[0];
-    ptrdiff_t src_stride        = ref->linesize[0];
+    const int hs                = fc->ps.sps->hshift[c_idx];
+    const int vs                = fc->ps.sps->vshift[c_idx];
     const int idx               = av_log2(block_w) - 1;
-    const int mx                = mv->x & 0xf;
-    const int my                = mv->y & 0xf;
-    const int8_t *hf            = ff_vvc_inter_luma_filters[hf_idx][mx];
-    const int8_t *vf            = ff_vvc_inter_luma_filters[vf_idx][my];
+    const Mv *mv                = &mvf->mv[lx];
+    const int is_chroma         = !!c_idx;
+    const intptr_t mx           = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - hs);
+    const intptr_t my           = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - vs);
+    const int8_t *hf            = INTER_FILTER(hf_idx, mx);
+    const int8_t *vf            = INTER_FILTER(vf_idx, my);
     int denom, wx, ox;
 
-    x_off += mv->x >> 4;
-    y_off += mv->y >> 4;
-    src   += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
-
-    EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
+    x_off += mv->x >> (4 + hs);
+    y_off += mv->y >> (4 + vs);
+    src  += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
-    if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, LUMA)) {
-        fc->vvcdsp.inter.put_uni_w[LUMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
+    MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
+    if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, c_idx)) {
+        fc->vvcdsp.inter.put_uni_w[is_chroma][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
             block_h, denom, wx, ox, hf, vf, block_w);
     } else {
-        fc->vvcdsp.inter.put_uni[LUMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
+        fc->vvcdsp.inter.put_uni[is_chroma][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
             block_h, hf, vf, block_w);
     }
 }
@@ -312,38 +314,6 @@ static void luma_mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_st
         fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
 }
 
-static void chroma_mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
-    const uint8_t *src, ptrdiff_t src_stride, int x_off, int y_off,
-    const int block_w, const int block_h, const MvField *mvf, const int c_idx,
-    const int hf_idx, const int vf_idx)
-{
-    const VVCFrameContext *fc   = lc->fc;
-    const int lx                = mvf->pred_flag - PF_L0;
-    const int hs                = fc->ps.sps->hshift[1];
-    const int vs                = fc->ps.sps->vshift[1];
-    const int idx               = av_log2(block_w) - 1;
-    const Mv *mv                = &mvf->mv[lx];
-    const intptr_t mx           = av_mod_uintp2(mv->x, 4 + hs) << (1 - hs);
-    const intptr_t my           = av_mod_uintp2(mv->y, 4 + vs) << (1 - vs);
-    const int8_t *hf            = ff_vvc_inter_chroma_filters[hf_idx][mx];
-    const int8_t *vf            = ff_vvc_inter_chroma_filters[vf_idx][my];
-    int denom, wx, ox;
-
-    x_off += mv->x >> (4 + hs);
-    y_off += mv->y >> (4 + vs);
-    src  += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
-
-
-    EMULATED_EDGE_CHROMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
-    if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, c_idx)) {
-        fc->vvcdsp.inter.put_uni_w[CHROMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
-            block_h, denom, wx, ox, hf, vf, block_w);
-    } else {
-        fc->vvcdsp.inter.put_uni[CHROMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
-            block_h, hf, vf, block_w);
-    }
-}
-
 static void chroma_mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
     const AVFrame *ref0, const AVFrame *ref1, const int x_off, const int y_off,
     const int block_w, const int block_h,  const MvField *mvf, const int c_idx,
@@ -573,8 +543,8 @@ static void pred_regular_luma(VVCLocalContext *lc, const int hf_idx, const int v
 
     if (mv->pred_flag != PF_BI) {
         const int lx = mv->pred_flag - PF_L0;
-        luma_mc_uni(lc, inter, inter_stride, ref[lx]->frame,
-            mv, x0, y0, sbw, sbh, hf_idx, vf_idx);
+        mc_uni(lc, inter, inter_stride, ref[lx]->frame, mv,
+            x0, y0, sbw, sbh, LUMA, hf_idx, vf_idx);
     } else {
         luma_mc_bi(lc, inter, inter_stride, ref[0]->frame,
             &mv->mv[0], x0, y0, sbw, sbh, ref[1]->frame, &mv->mv[1], mv,
@@ -627,10 +597,10 @@ static void pred_regular_chroma(VVCLocalContext *lc, const MvField *mv,
         if (!ref[lx])
             return;
 
-        chroma_mc_uni(lc, inter1, inter1_stride, ref[lx]->frame->data[1], ref[lx]->frame->linesize[1],
-            x0_c, y0_c, w_c, h_c, mv, CB, hf_idx, vf_idx);
-        chroma_mc_uni(lc, inter2, inter2_stride, ref[lx]->frame->data[2], ref[lx]->frame->linesize[2],
-            x0_c, y0_c, w_c, h_c, mv, CR, hf_idx, vf_idx);
+        mc_uni(lc, inter1, inter1_stride, ref[lx]->frame, mv,
+            x0_c, y0_c, w_c, h_c, CB, hf_idx, vf_idx);
+        mc_uni(lc, inter2, inter2_stride, ref[lx]->frame, mv,
+            x0_c, y0_c, w_c, h_c, CR, hf_idx, vf_idx);
     } else {
         if (!ref[0] || !ref[1])
             return;
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 04/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc_bi to mc_bi
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 02/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc to mc Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 03/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc_uni to mc_uni Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 05/18] avcodec/vvcdec: misc, remove unused EMULATED_EDGE_{LUMA, CHROMA}, EMULATED_EDGE_DMVR_{LUAM, CHROMA} Nuo Mi
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/inter.c | 95 +++++++++++++-----------------------------
 1 file changed, 30 insertions(+), 65 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 6d866c1bad..9132bfaee2 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -151,6 +151,9 @@ static void emulated_edge_bilinear(const VVCLocalContext *lc, uint8_t *dst, cons
 #define EMULATED_EDGE_CHROMA(dst, src, src_stride, x_off, y_off)                    \
     emulated_edge(lc, dst, src, src_stride, x_off, y_off, block_w, block_h, 1)
 
+#define MC_EMULATED_EDGE_DMVR(dst, src, src_stride, x_sb, y_sb, x_off, y_off)                               \
+    emulated_edge_dmvr(lc, dst, src, src_stride, x_sb, y_sb, x_off, y_off, block_w, block_h, is_chroma)
+
 #define EMULATED_EDGE_DMVR_LUMA(dst, src, src_stride, x_sb, y_sb, x_off, y_off)     \
     emulated_edge_dmvr(lc, dst, src, src_stride, x_sb, y_sb, x_off, y_off, block_w, block_h, 0)
 
@@ -269,43 +272,45 @@ static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride
     }
 }
 
-static void luma_mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
-    const AVFrame *ref0, const Mv *mv0, const int x_off, const int y_off, const int block_w, const int block_h,
-    const AVFrame *ref1, const Mv *mv1, const MvField *mvf, const int hf_idx, const int vf_idx,
-    const MvField *orig_mv, const int sb_bdof_flag)
+static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
+    const AVFrame *ref0, const AVFrame *ref1, const MvField *mvf, const MvField *orig_mv,
+    const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx,
+    const int sb_bdof_flag, const int hf_idx, const int vf_idx)
 {
     const VVCFrameContext *fc   = lc->fc;
     const PredictionUnit *pu    = &lc->cu->pu;
+    const int hs                = fc->ps.sps->hshift[c_idx];
+    const int vs                = fc->ps.sps->vshift[c_idx];
     const int idx               = av_log2(block_w) - 1;
     const AVFrame *ref[]        = { ref0, ref1 };
     int16_t *tmp[]              = { lc->tmp + sb_bdof_flag * PROF_TEMP_OFFSET, lc->tmp1 + sb_bdof_flag * PROF_TEMP_OFFSET };
     int denom, w0, w1, o0, o1;
-    const int weight_flag       = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, LUMA, pu->dmvr_flag);
+    const int weight_flag       = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, pu->dmvr_flag);
+    const int is_chroma         = !!c_idx;
 
     for (int i = L0; i <= L1; i++) {
         const Mv *mv            = mvf->mv + i;
-        const int mx            = mv->x & 0xf;
-        const int my            = mv->y & 0xf;
-        const int ox            = x_off + (mv->x >> 4);
-        const int oy            = y_off + (mv->y >> 4);
-        ptrdiff_t src_stride    = ref[i]->linesize[0];
-        const uint8_t *src      = ref[i]->data[0] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
-        const int8_t *hf        = ff_vvc_inter_luma_filters[hf_idx][mx];
-        const int8_t *vf        = ff_vvc_inter_luma_filters[vf_idx][my];
+        const int mx            = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - hs);
+        const int my            = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - vs);
+        const int ox            = x_off + (mv->x >> (4 + hs));
+        const int oy            = y_off + (mv->y >> (4 + vs));
+        ptrdiff_t src_stride    = ref[i]->linesize[c_idx];
+        const uint8_t *src      = ref[i]->data[c_idx] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
+        const int8_t *hf        = INTER_FILTER(hf_idx, mx);
+        const int8_t *vf        = INTER_FILTER(vf_idx, my);
 
         if (pu->dmvr_flag) {
-            const int x_sb = x_off + (orig_mv->mv[i].x >> 4);
-            const int y_sb = y_off + (orig_mv->mv[i].y >> 4);
+            const int x_sb = x_off + (orig_mv->mv[i].x >> (4 + hs));
+            const int y_sb = y_off + (orig_mv->mv[i].y >> (4 + vs));
 
-            EMULATED_EDGE_DMVR_LUMA(lc->edge_emu_buffer, &src, &src_stride, x_sb, y_sb, ox, oy);
+            MC_EMULATED_EDGE_DMVR(lc->edge_emu_buffer,  &src, &src_stride, x_sb, y_sb, ox, oy);
         } else {
-            EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
+            MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
         }
-        fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](tmp[i], src, src_stride, block_h, hf, vf, block_w);
+        fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](tmp[i],  src, src_stride, block_h, hf, vf, block_w);
         if (sb_bdof_flag)
             fc->vvcdsp.inter.bdof_fetch_samples(tmp[i], src, src_stride, mx, my, block_w, block_h);
     }
-
     if (sb_bdof_flag)
         fc->vvcdsp.inter.apply_bdof(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
     else if (weight_flag)
@@ -314,45 +319,6 @@ static void luma_mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_st
         fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
 }
 
-static void chroma_mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
-    const AVFrame *ref0, const AVFrame *ref1, const int x_off, const int y_off,
-    const int block_w, const int block_h,  const MvField *mvf, const int c_idx,
-    const int hf_idx, const int vf_idx, const MvField *orig_mv, const int dmvr_flag, const int ciip_flag)
-{
-    const VVCFrameContext *fc   = lc->fc;
-    const int hs                = fc->ps.sps->hshift[1];
-    const int vs                = fc->ps.sps->vshift[1];
-    const int idx               = av_log2(block_w) - 1;
-    const AVFrame *ref[]        = { ref0, ref1 };
-    int16_t *tmp[]              = { lc->tmp, lc->tmp1 };
-    int denom, w0, w1, o0, o1;
-    const int weight_flag       = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, dmvr_flag);
-
-    for (int i = L0; i <= L1; i++) {
-        const Mv *mv            = mvf->mv + i;
-        const int mx            = av_mod_uintp2(mv->x, 4 + hs) << (1 - hs);
-        const int my            = av_mod_uintp2(mv->y, 4 + vs) << (1 - vs);
-        const int ox            = x_off + (mv->x >> (4 + hs));
-        const int oy            = y_off + (mv->y >> (4 + vs));
-        ptrdiff_t src_stride    = ref[i]->linesize[c_idx];
-        const uint8_t *src      = ref[i]->data[c_idx] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
-        const int8_t *hf        = ff_vvc_inter_chroma_filters[hf_idx][mx];
-        const int8_t *vf        = ff_vvc_inter_chroma_filters[vf_idx][my];
-        if (dmvr_flag) {
-            const int x_sb = x_off + (orig_mv->mv[i].x >> (4 + hs));
-            const int y_sb = y_off + (orig_mv->mv[i].y >> (4 + vs));
-            EMULATED_EDGE_DMVR_CHROMA(lc->edge_emu_buffer,  &src, &src_stride, x_sb, y_sb, ox, oy);
-        } else {
-            EMULATED_EDGE_CHROMA(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
-        }
-        fc->vvcdsp.inter.put[CHROMA][idx][!!my][!!mx](tmp[i],  src, src_stride, block_h, hf, vf, block_w);
-    }
-    if (weight_flag)
-        fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1);
-    else
-        fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
-}
-
 static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
     const AVFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
     const int cb_prof_flag, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
@@ -546,9 +512,8 @@ static void pred_regular_luma(VVCLocalContext *lc, const int hf_idx, const int v
         mc_uni(lc, inter, inter_stride, ref[lx]->frame, mv,
             x0, y0, sbw, sbh, LUMA, hf_idx, vf_idx);
     } else {
-        luma_mc_bi(lc, inter, inter_stride, ref[0]->frame,
-            &mv->mv[0], x0, y0, sbw, sbh, ref[1]->frame, &mv->mv[1], mv,
-            hf_idx, vf_idx, orig_mv, sb_bdof_flag);
+        mc_bi(lc, inter, inter_stride, ref[0]->frame, ref[1]->frame, mv, orig_mv,
+            x0, y0, sbw, sbh, LUMA, sb_bdof_flag, hf_idx, vf_idx);
     }
 
     if (ciip_flag) {
@@ -605,11 +570,11 @@ static void pred_regular_chroma(VVCLocalContext *lc, const MvField *mv,
         if (!ref[0] || !ref[1])
             return;
 
-        chroma_mc_bi(lc, inter1, inter1_stride, ref[0]->frame, ref[1]->frame,
-            x0_c, y0_c, w_c, h_c, mv, CB, hf_idx, vf_idx, orig_mv, dmvr_flag, lc->cu->ciip_flag);
+        mc_bi(lc, inter1, inter1_stride, ref[0]->frame, ref[1]->frame, mv, orig_mv,
+            x0_c, y0_c, w_c, h_c, CB, 0, hf_idx, vf_idx);
 
-        chroma_mc_bi(lc, inter2, inter2_stride, ref[0]->frame, ref[1]->frame,
-            x0_c, y0_c, w_c, h_c, mv, CR, hf_idx, vf_idx, orig_mv, dmvr_flag, lc->cu->ciip_flag);
+        mc_bi(lc, inter2, inter2_stride, ref[0]->frame, ref[1]->frame, mv, orig_mv,
+            x0_c, y0_c, w_c, h_c, CR, 0, hf_idx, vf_idx);
 
     }
     if (do_ciip) {
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 05/18] avcodec/vvcdec: misc, remove unused EMULATED_EDGE_{LUMA, CHROMA}, EMULATED_EDGE_DMVR_{LUAM, CHROMA}
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (2 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 04/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc_bi to mc_bi Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 06/18] avcodec/vvcdec: refact, unify pred_regular_{luma, chroma} to pred_regular Nuo Mi
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/inter.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 9132bfaee2..cc93184ca0 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -142,25 +142,13 @@ static void emulated_edge_bilinear(const VVCLocalContext *lc, uint8_t *dst, cons
     }
 }
 
-#define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off)                               \
+#define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off)                                                \
     emulated_edge(lc, dst, src, src_stride, x_off, y_off, block_w, block_h, is_chroma)
 
-#define EMULATED_EDGE_LUMA(dst, src, src_stride, x_off, y_off)                      \
-    emulated_edge(lc, dst, src, src_stride, x_off, y_off, block_w, block_h, 0)
-
-#define EMULATED_EDGE_CHROMA(dst, src, src_stride, x_off, y_off)                    \
-    emulated_edge(lc, dst, src, src_stride, x_off, y_off, block_w, block_h, 1)
-
 #define MC_EMULATED_EDGE_DMVR(dst, src, src_stride, x_sb, y_sb, x_off, y_off)                               \
     emulated_edge_dmvr(lc, dst, src, src_stride, x_sb, y_sb, x_off, y_off, block_w, block_h, is_chroma)
 
-#define EMULATED_EDGE_DMVR_LUMA(dst, src, src_stride, x_sb, y_sb, x_off, y_off)     \
-    emulated_edge_dmvr(lc, dst, src, src_stride, x_sb, y_sb, x_off, y_off, block_w, block_h, 0)
-
-#define EMULATED_EDGE_DMVR_CHROMA(dst, src, src_stride, x_sb, y_sb, x_off, y_off)   \
-    emulated_edge_dmvr(lc, dst, src, src_stride, x_sb, y_sb, x_off, y_off, block_w, block_h, 1)
-
-#define EMULATED_EDGE_BILINEAR(dst, src, src_stride, x_off, y_off)                  \
+#define MC_EMULATED_EDGE_BILINEAR(dst, src, src_stride, x_off, y_off)                                       \
     emulated_edge_bilinear(lc, dst, src, src_stride, x_off, y_off, pred_w, pred_h)
 
 // part of 8.5.6.6 Weighted sample prediction process
@@ -336,12 +324,13 @@ static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst
     const int8_t *vf            = ff_vvc_inter_luma_filters[2][my];
     int denom, wx, ox;
     const int weight_flag       = derive_weight_uni(&denom, &wx, &ox, lc, mvf, LUMA);
+    const int is_chroma         = 0;
 
     x_off += mv->x >> 4;
     y_off += mv->y >> 4;
     src   += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
-    EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
+    MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
     if (cb_prof_flag) {
         fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
         fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
@@ -369,6 +358,7 @@ static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_
     const int idx               = av_log2(block_w) - 1;
     int denom, w0, w1, o0, o1;
     const int weight_flag       = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, LUMA, 0);
+    const int is_chroma         = 0;
 
     for (int i = L0; i <= L1; i++) {
         const Mv *mv            = mvf->mv + i;
@@ -381,7 +371,7 @@ static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_
         const int8_t *hf        = ff_vvc_inter_luma_filters[2][mx];
         const int8_t *vf        = ff_vvc_inter_luma_filters[2][my];
 
-        EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
+        MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
         if (!pu->cb_prof_flag[i]) {
             fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](tmp[i], src, src_stride, block_h, hf, vf, block_w);
         } else {
@@ -654,7 +644,7 @@ static void dmvr_mv_refine(VVCLocalContext *lc, MvField *mvf, MvField *orig_mv,
         const int oy            = y_off + (mv->y >> 4) - sr_range;
         ptrdiff_t src_stride    = ref[i]->linesize[LUMA];
         const uint8_t *src      = ref[i]->data[LUMA] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
-        EMULATED_EDGE_BILINEAR(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
+        MC_EMULATED_EDGE_BILINEAR(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
         fc->vvcdsp.inter.dmvr[!!my][!!mx](tmp[i], src, src_stride, pred_h, mx, my, pred_w);
     }
 
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 06/18] avcodec/vvcdec: refact, unify pred_regular_{luma, chroma} to pred_regular
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (3 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 05/18] avcodec/vvcdec: misc, remove unused EMULATED_EDGE_{LUMA, CHROMA}, EMULATED_EDGE_DMVR_{LUAM, CHROMA} Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 07/18] avcodec/vvcdec: refact out VVCRefPic from RefPicList Nuo Mi
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/ctu.h   |   3 +-
 libavcodec/vvc/inter.c | 133 +++++++++++++----------------------------
 2 files changed, 41 insertions(+), 95 deletions(-)

diff --git a/libavcodec/vvc/ctu.h b/libavcodec/vvc/ctu.h
index 4e38ecf54a..337d0e7c28 100644
--- a/libavcodec/vvc/ctu.h
+++ b/libavcodec/vvc/ctu.h
@@ -380,8 +380,7 @@ typedef struct VVCLocalContext {
     DECLARE_ALIGNED(32, int16_t, tmp)[MAX_PB_SIZE * MAX_PB_SIZE];
     DECLARE_ALIGNED(32, int16_t, tmp1)[MAX_PB_SIZE * MAX_PB_SIZE];
     DECLARE_ALIGNED(32, int16_t, tmp2)[MAX_PB_SIZE * MAX_PB_SIZE];
-    DECLARE_ALIGNED(32, uint8_t, ciip_tmp1)[MAX_PB_SIZE * MAX_PB_SIZE * 2];
-    DECLARE_ALIGNED(32, uint8_t, ciip_tmp2)[MAX_PB_SIZE * MAX_PB_SIZE * 2];
+    DECLARE_ALIGNED(32, uint8_t, ciip_tmp)[MAX_PB_SIZE * MAX_PB_SIZE * 2];
     DECLARE_ALIGNED(32, uint8_t, sao_buffer)[(MAX_CTU_SIZE + 2 * SAO_PADDING_SIZE) * EDGE_EMU_BUFFER_STRIDE * 2];
     DECLARE_ALIGNED(32, uint8_t, alf_buffer_luma)[(MAX_CTU_SIZE + 2 * ALF_PADDING_SIZE) * EDGE_EMU_BUFFER_STRIDE * 2];
     DECLARE_ALIGNED(32, uint8_t, alf_buffer_chroma)[(MAX_CTU_SIZE + 2 * ALF_PADDING_SIZE) * EDGE_EMU_BUFFER_STRIDE * 2];
diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index cc93184ca0..3bf06d6d53 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -482,98 +482,48 @@ static int ciip_derive_intra_weight(const VVCLocalContext *lc, const int x0, con
     return w;
 }
 
-static void pred_regular_luma(VVCLocalContext *lc, const int hf_idx, const int vf_idx, const MvField *mv,
-    const int x0, const int y0, const int sbw, const int sbh, const MvField *orig_mv, const int sb_bdof_flag)
+static void pred_regular(VVCLocalContext *lc, const MvField *mvf, const MvField *orig_mvf,
+    const int x0, const int y0, const int sbw, const int sbh, const int sb_bdof_flag, const int c_start)
 {
-    const SliceContext *sc          = lc->sc;
-    const VVCFrameContext *fc       = lc->fc;
-    const int ciip_flag             = lc->cu->ciip_flag;
-    uint8_t *dst                    = POS(0, x0, y0);
-    const ptrdiff_t dst_stride      = fc->frame->linesize[0];
-    uint8_t *inter                  = ciip_flag ? (uint8_t *)lc->ciip_tmp1 : dst;
-    const ptrdiff_t inter_stride    = ciip_flag ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst_stride;
-    VVCFrame *ref[2];
-
-    if (pred_get_refs(lc, ref, mv) < 0)
-        return;
-
-    if (mv->pred_flag != PF_BI) {
-        const int lx = mv->pred_flag - PF_L0;
-        mc_uni(lc, inter, inter_stride, ref[lx]->frame, mv,
-            x0, y0, sbw, sbh, LUMA, hf_idx, vf_idx);
-    } else {
-        mc_bi(lc, inter, inter_stride, ref[0]->frame, ref[1]->frame, mv, orig_mv,
-            x0, y0, sbw, sbh, LUMA, sb_bdof_flag, hf_idx, vf_idx);
-    }
-
-    if (ciip_flag) {
-        const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
-        fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 0);
-        if (sc->sh.r->sh_lmcs_used_flag)
-            fc->vvcdsp.lmcs.filter(inter, inter_stride, sbw, sbh, &fc->ps.lmcs.fwd_lut);
-        fc->vvcdsp.inter.put_ciip(dst, dst_stride, sbw, sbh, inter, inter_stride, intra_weight);
-
-    }
-}
-
-static void pred_regular_chroma(VVCLocalContext *lc, const MvField *mv,
-    const int x0, const int y0, const int sbw, const int sbh, const MvField *orig_mv, const int dmvr_flag)
-{
-    const VVCFrameContext *fc   = lc->fc;
-    const int hs                = fc->ps.sps->hshift[1];
-    const int vs                = fc->ps.sps->vshift[1];
-    const int x0_c              = x0 >> hs;
-    const int y0_c              = y0 >> vs;
-    const int w_c               = sbw >> hs;
-    const int h_c               = sbh >> vs;
-    const int do_ciip           = lc->cu->ciip_flag && (w_c > 2);
-
-    uint8_t* dst1               = POS(1, x0, y0);
-    uint8_t* dst2               = POS(2, x0, y0);
-    const ptrdiff_t dst1_stride = fc->frame->linesize[1];
-    const ptrdiff_t dst2_stride = fc->frame->linesize[2];
-
-    uint8_t *inter1 = do_ciip ? (uint8_t *)lc->ciip_tmp1 : dst1;
-    const ptrdiff_t inter1_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst1_stride;
-
-    uint8_t *inter2 = do_ciip ? (uint8_t *)lc->ciip_tmp2 : dst2;
-    const ptrdiff_t inter2_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst2_stride;
-
-    //fix me
-    const int hf_idx = 0;
-    const int vf_idx = 0;
+    const VVCFrameContext *fc = lc->fc;
+    const int c_end           = fc->ps.sps->r->sps_chroma_format_idc ? CR : LUMA;
     VVCFrame *ref[2];
 
-    if (pred_get_refs(lc, ref, mv) < 0)
+    if (pred_get_refs(lc, ref, mvf) < 0)
         return;
 
-    if (mv->pred_flag != PF_BI) {
-        const int lx = mv->pred_flag - PF_L0;
-        if (!ref[lx])
-            return;
-
-        mc_uni(lc, inter1, inter1_stride, ref[lx]->frame, mv,
-            x0_c, y0_c, w_c, h_c, CB, hf_idx, vf_idx);
-        mc_uni(lc, inter2, inter2_stride, ref[lx]->frame, mv,
-            x0_c, y0_c, w_c, h_c, CR, hf_idx, vf_idx);
-    } else {
-        if (!ref[0] || !ref[1])
-            return;
-
-        mc_bi(lc, inter1, inter1_stride, ref[0]->frame, ref[1]->frame, mv, orig_mv,
-            x0_c, y0_c, w_c, h_c, CB, 0, hf_idx, vf_idx);
-
-        mc_bi(lc, inter2, inter2_stride, ref[0]->frame, ref[1]->frame, mv, orig_mv,
-            x0_c, y0_c, w_c, h_c, CR, 0, hf_idx, vf_idx);
-
-    }
-    if (do_ciip) {
-        const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
-        fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 1);
-        fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 2);
-        fc->vvcdsp.inter.put_ciip(dst1, dst1_stride, w_c, h_c, inter1, inter1_stride, intra_weight);
-        fc->vvcdsp.inter.put_ciip(dst2, dst2_stride, w_c, h_c, inter2, inter2_stride, intra_weight);
-
+    for (int c_idx = c_start; c_idx <= c_end; c_idx++) {
+        uint8_t *dst                 = POS(c_idx, x0, y0);
+        const ptrdiff_t dst_stride   = fc->frame->linesize[c_idx];
+        const int hs                 = fc->ps.sps->hshift[c_idx];
+        const int vs                 = fc->ps.sps->vshift[c_idx];
+        const int x                  = x0 >> hs;
+        const int y                  = y0 >> vs;
+        const int w                  = sbw >> hs;
+        const int h                  = sbh >> vs;
+        const int is_luma            = !c_idx;
+        const int do_ciip            = lc->cu->ciip_flag && (is_luma || (w > 2));
+        uint8_t *inter               = do_ciip ? (uint8_t *)lc->ciip_tmp : dst;
+        const ptrdiff_t inter_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst_stride;
+        const int hf_idx             = is_luma ? lc->cu->pu.mi.hpel_if_idx : 0;
+        const int vf_idx             = is_luma ? lc->cu->pu.mi.hpel_if_idx : 0;
+        const int do_bdof            = is_luma && sb_bdof_flag;
+
+        if (mvf->pred_flag != PF_BI) {
+            const int lx = mvf->pred_flag - PF_L0;
+            mc_uni(lc, inter, inter_stride, ref[lx]->frame, mvf,
+                x, y, w, h, c_idx, hf_idx, vf_idx);
+        } else {
+            mc_bi(lc, inter, inter_stride, ref[0]->frame, ref[1]->frame, mvf, orig_mvf,
+                x, y, w, h, c_idx, do_bdof, hf_idx, vf_idx);
+        }
+        if (do_ciip) {
+            const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
+            fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, c_idx);
+            if (!c_idx && lc->sc->sh.r->sh_lmcs_used_flag)
+                fc->vvcdsp.lmcs.filter(inter, inter_stride, w, h, &fc->ps.lmcs.fwd_lut);
+            fc->vvcdsp.inter.put_ciip(dst, dst_stride, w, h, inter, inter_stride, intra_weight);
+        }
     }
 }
 
@@ -720,7 +670,6 @@ static void derive_sb_mv(VVCLocalContext *lc, MvField *mv, MvField *orig_mv, int
 
 static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip)
 {
-    const VVCFrameContext *fc   = lc->fc;
     const CodingUnit *cu        = lc->cu;
     PredictionUnit *pu          = &lc->cu->pu;
     const MotionInfo *mi        = &pu->mi;
@@ -742,9 +691,7 @@ static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip)
                 ff_vvc_set_neighbour_available(lc, x0, y0, sbw, sbh);
 
             derive_sb_mv(lc, &mv, &orig_mv, &sb_bdof_flag, x0, y0, sbw, sbh);
-            pred_regular_luma(lc, mi->hpel_if_idx, mi->hpel_if_idx, &mv, x0, y0, sbw, sbh, &orig_mv, sb_bdof_flag);
-            if (fc->ps.sps->r->sps_chroma_format_idc)
-                pred_regular_chroma(lc, &mv, x0, y0, sbw, sbh, &orig_mv, pu->dmvr_flag);
+            pred_regular(lc, &mv, &orig_mv, x0, y0, sbw, sbh, sb_bdof_flag, LUMA);
         }
     }
 }
@@ -804,9 +751,9 @@ static void pred_affine_blk(VVCLocalContext *lc)
             if (fc->ps.sps->r->sps_chroma_format_idc) {
                 if (!av_mod_uintp2(sby, vs) && !av_mod_uintp2(sbx, hs)) {
                     MvField mvc;
-                    derive_affine_mvc(&mvc, fc, mv, x, y, sbw, sbh);
-                    pred_regular_chroma(lc, &mvc, x, y, sbw<<hs, sbh<<vs, NULL, 0);
 
+                    derive_affine_mvc(&mvc, fc, mv, x, y, sbw, sbh);
+                    pred_regular(lc, &mvc, NULL, x, y, sbw << hs, sbh << vs, 0, CB);
                 }
             }
 
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 07/18] avcodec/vvcdec: refact out VVCRefPic from RefPicList
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (4 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 06/18] avcodec/vvcdec: refact, unify pred_regular_{luma, chroma} to pred_regular Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 08/18] avcodec/vvcdec: refact, pred_get_refs return VVCRefPic instead of VVCFrame Nuo Mi
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/ctu.c    | 10 +++++-----
 libavcodec/vvc/dec.c    |  4 ++--
 libavcodec/vvc/dec.h    | 10 +++++++---
 libavcodec/vvc/filter.c | 22 +++++++++++-----------
 libavcodec/vvc/inter.c  |  4 ++--
 libavcodec/vvc/mvs.c    | 36 ++++++++++++++++++------------------
 libavcodec/vvc/refs.c   | 11 ++++++-----
 libavcodec/vvc/thread.c |  2 +-
 8 files changed, 52 insertions(+), 47 deletions(-)

diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
index 53f92ca10f..242caa58f7 100644
--- a/libavcodec/vvc/ctu.c
+++ b/libavcodec/vvc/ctu.c
@@ -1263,8 +1263,8 @@ static void derive_mmvd(const VVCLocalContext *lc, MvField *mvf, const Mv *mmvd_
         const RefPicList *rpl = sc->rpl;
         const int poc = lc->fc->ps.ph.poc;
         const int diff[] = {
-            poc - rpl[0].list[mvf->ref_idx[0]],
-            poc - rpl[1].list[mvf->ref_idx[1]]
+            poc - rpl[L0].refs[mvf->ref_idx[L0]].poc,
+            poc - rpl[L1].refs[mvf->ref_idx[L1]].poc
         };
         const int sign = FFSIGN(diff[0]) != FFSIGN(diff[1]);
 
@@ -1275,7 +1275,7 @@ static void derive_mmvd(const VVCLocalContext *lc, MvField *mvf, const Mv *mmvd_
             const int i = FFABS(diff[0]) < FFABS(diff[1]);
             const int o = !i;
             mmvd[i] = *mmvd_offset;
-            if (!rpl[0].isLongTerm[mvf->ref_idx[0]] && !rpl[1].isLongTerm[mvf->ref_idx[1]]) {
+            if (!rpl[L0].refs[mvf->ref_idx[L0]].is_lt && !rpl[L1].refs[mvf->ref_idx[L1]].is_lt) {
                 ff_vvc_mv_scale(&mmvd[o], mmvd_offset, diff[i], diff[o]);
             }
             else {
@@ -1699,8 +1699,8 @@ static void derive_dmvr_bdof_flag(const VVCLocalContext *lc, PredictionUnit *pu)
     pu->bdof_flag = 0;
 
     if (mi->pred_flag == PF_BI &&
-        (poc - rpl0->list[ref_idx[L0]] == rpl1->list[ref_idx[L1]] - poc) &&
-        !rpl0->isLongTerm[ref_idx[L0]] && !rpl1->isLongTerm[ref_idx[L1]] &&
+        (poc - rpl0->refs[ref_idx[L0]].poc == rpl1->refs[ref_idx[L1]].poc - poc) &&
+        !rpl0->refs[ref_idx[L0]].is_lt && !rpl1->refs[ref_idx[L1]].is_lt &&
         !cu->ciip_flag &&
         !mi->bcw_idx &&
         !w->weight_flag[L0][LUMA][mi->ref_idx[L0]] && !w->weight_flag[L1][LUMA][mi->ref_idx[L1]] &&
diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 25cdb39cab..b4c35330eb 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -403,8 +403,8 @@ static int8_t smvd_find(const VVCFrameContext *fc, const SliceContext *sc, int l
     int8_t idx                    = -1;
     int old_diff                  = -1;
     for (int i = 0; i < rsh->num_ref_idx_active[lx]; i++) {
-        if (!rpl->isLongTerm[i]) {
-            int diff = poc - rpl->list[i];
+        if (!rpl->refs[i].is_lt) {
+            int diff = poc - rpl->refs[i].poc;
             if (find(idx, diff, old_diff)) {
                 idx = i;
                 old_diff = diff;
diff --git a/libavcodec/vvc/dec.h b/libavcodec/vvc/dec.h
index 4dacefc06a..205427f681 100644
--- a/libavcodec/vvc/dec.h
+++ b/libavcodec/vvc/dec.h
@@ -42,10 +42,14 @@
 #define L0                      0
 #define L1                      1
 
+typedef struct VVCRefPic {
+    struct VVCFrame *ref;
+    int poc;
+    int is_lt;                  // is long term reference
+} VVCRefPic;
+
 typedef struct RefPicList {
-    struct VVCFrame *ref[VVC_MAX_REF_ENTRIES];
-    int list[VVC_MAX_REF_ENTRIES];
-    int isLongTerm[VVC_MAX_REF_ENTRIES];
+    VVCRefPic refs[VVC_MAX_REF_ENTRIES];
     int nb_refs;
 } RefPicList;
 
diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 8f44255ce4..7844d34eac 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -321,9 +321,9 @@ static int boundary_strength(const VVCLocalContext *lc, const MvField *curr, con
 
     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]]  &&
-            rpl[0].list[curr->ref_idx[0]] == rpl[1].list[curr->ref_idx[1]] &&
-            neigh_rpl[0].list[neigh->ref_idx[0]] == neigh_rpl[1].list[neigh->ref_idx[1]]) {
+        if (rpl[L0].refs[curr->ref_idx[L0]].poc == neigh_rpl[L0].refs[neigh->ref_idx[L0]].poc  &&
+            rpl[L0].refs[curr->ref_idx[L0]].poc == rpl[L1].refs[curr->ref_idx[L1]].poc &&
+            neigh_rpl[L0].refs[neigh->ref_idx[L0]].poc == neigh_rpl[L1].refs[neigh->ref_idx[L1]].poc) {
             if ((FFABS(neigh->mv[0].x - curr->mv[0].x) >= 8 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 8 ||
                  FFABS(neigh->mv[1].x - curr->mv[1].x) >= 8 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 8) &&
                 (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 8 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 8 ||
@@ -331,15 +331,15 @@ static int boundary_strength(const VVCLocalContext *lc, const MvField *curr, con
                 return 1;
             else
                 return 0;
-        } else if (neigh_rpl[0].list[neigh->ref_idx[0]] == rpl[0].list[curr->ref_idx[0]] &&
-                   neigh_rpl[1].list[neigh->ref_idx[1]] == rpl[1].list[curr->ref_idx[1]]) {
+        } else if (neigh_rpl[L0].refs[neigh->ref_idx[L0]].poc == rpl[L0].refs[curr->ref_idx[L0]].poc &&
+                   neigh_rpl[L1].refs[neigh->ref_idx[L1]].poc == rpl[L1].refs[curr->ref_idx[L1]].poc) {
             if (FFABS(neigh->mv[0].x - curr->mv[0].x) >= 8 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 8 ||
                 FFABS(neigh->mv[1].x - curr->mv[1].x) >= 8 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 8)
                 return 1;
             else
                 return 0;
-        } else if (neigh_rpl[1].list[neigh->ref_idx[1]] == rpl[0].list[curr->ref_idx[0]] &&
-                   neigh_rpl[0].list[neigh->ref_idx[0]] == rpl[1].list[curr->ref_idx[1]]) {
+        } else if (neigh_rpl[L1].refs[neigh->ref_idx[L1]].poc == rpl[L0].refs[curr->ref_idx[L0]].poc &&
+                   neigh_rpl[L0].refs[neigh->ref_idx[L0]].poc == rpl[L1].refs[curr->ref_idx[L1]].poc) {
             if (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 8 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 8 ||
                 FFABS(neigh->mv[0].x - curr->mv[1].x) >= 8 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 8)
                 return 1;
@@ -354,18 +354,18 @@ static int boundary_strength(const VVCLocalContext *lc, const MvField *curr, con
 
         if (curr->pred_flag & 1) {
             A     = curr->mv[0];
-            ref_A = rpl[0].list[curr->ref_idx[0]];
+            ref_A = rpl[L0].refs[curr->ref_idx[L0]].poc;
         } else {
             A     = curr->mv[1];
-            ref_A = rpl[1].list[curr->ref_idx[1]];
+            ref_A = rpl[L1].refs[curr->ref_idx[L1]].poc;
         }
 
         if (neigh->pred_flag & 1) {
             B     = neigh->mv[0];
-            ref_B = neigh_rpl[0].list[neigh->ref_idx[0]];
+            ref_B = neigh_rpl[L0].refs[neigh->ref_idx[L0]].poc;
         } else {
             B     = neigh->mv[1];
-            ref_B = neigh_rpl[1].list[neigh->ref_idx[1]];
+            ref_B = neigh_rpl[L1].refs[neigh->ref_idx[L1]].poc;
         }
 
         if (ref_A == ref_B) {
diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 3bf06d6d53..cd96707c02 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -394,7 +394,7 @@ static int pred_get_refs(const VVCLocalContext *lc, VVCFrame *ref[2],  const MvF
     for (int mask = PF_L0; mask <= PF_L1; mask++) {
         if (mv->pred_flag & mask) {
             const int lx = mask - PF_L0;
-            ref[lx] = rpl[lx].ref[mv->ref_idx[lx]];
+            ref[lx] = rpl[lx].refs[mv->ref_idx[lx]].ref;
             if (!ref[lx])
                 return AVERROR_INVALIDDATA;
         }
@@ -450,7 +450,7 @@ static void pred_gpm_blk(VVCLocalContext *lc)
         for (int i = 0; i < 2; i++) {
             const MvField *mv = pu->gpm_mv + i;
             const int lx = mv->pred_flag - PF_L0;
-            VVCFrame *ref = lc->sc->rpl[lx].ref[mv->ref_idx[lx]];
+            VVCFrame *ref = lc->sc->rpl[lx].refs[mv->ref_idx[lx]].ref;
             if (!ref)
                 return;
             mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height, c_idx);
diff --git a/libavcodec/vvc/mvs.c b/libavcodec/vvc/mvs.c
index fe7d923460..9407fbfd8a 100644
--- a/libavcodec/vvc/mvs.c
+++ b/libavcodec/vvc/mvs.c
@@ -88,8 +88,8 @@ static int check_mvset(Mv *mvLXCol, Mv *mvCol,
                        const RefPicList *refPicList, int X, int refIdxLx,
                        const RefPicList *refPicList_col, int listCol, int refidxCol)
 {
-    int cur_lt = refPicList[X].isLongTerm[refIdxLx];
-    int col_lt = refPicList_col[listCol].isLongTerm[refidxCol];
+    int cur_lt = refPicList[X].refs[refIdxLx].is_lt;
+    int col_lt = refPicList_col[listCol].refs[refidxCol].is_lt;
     int col_poc_diff, cur_poc_diff;
 
     if (cur_lt != col_lt) {
@@ -98,8 +98,8 @@ static int check_mvset(Mv *mvLXCol, Mv *mvCol,
         return 0;
     }
 
-    col_poc_diff = colPic - refPicList_col[listCol].list[refidxCol];
-    cur_poc_diff = poc    - refPicList[X].list[refIdxLx];
+    col_poc_diff = colPic - refPicList_col[listCol].refs[refidxCol].poc;
+    cur_poc_diff = poc    - refPicList[X].refs[refIdxLx].poc;
 
     mv_compression(mvCol);
     if (cur_lt || col_poc_diff == cur_poc_diff) {
@@ -126,7 +126,7 @@ int ff_vvc_no_backward_pred_flag(const VVCLocalContext *lc)
 
     for (j = 0; j < 2; j++) {
         for (i = 0; i < lc->sc->sh.r->num_ref_idx_active[j]; i++) {
-            if (rpl[j].list[i] > lc->fc->ps.ph.poc) {
+            if (rpl[j].refs[i].poc > lc->fc->ps.ph.poc) {
                 check_diffpicount++;
                 break;
             }
@@ -1059,9 +1059,9 @@ static int sb_temporal_luma_motion_data(const VVCLocalContext *lc, const MvField
     colPic  = ref->poc;
 
     if (a1) {
-        if ((a1->pred_flag & PF_L0) && colPic == rpl[0].list[a1->ref_idx[0]])
+        if ((a1->pred_flag & PF_L0) && colPic == rpl[L0].refs[a1->ref_idx[L0]].poc)
             *temp_mv = a1->mv[0];
-        else if ((a1->pred_flag & PF_L1) && colPic == rpl[1].list[a1->ref_idx[1]])
+        else if ((a1->pred_flag & PF_L1) && colPic == rpl[L1].refs[a1->ref_idx[L1]].poc)
             *temp_mv = a1->mv[1];
         ff_vvc_round_mv(temp_mv, 0, 4);
     }
@@ -1418,16 +1418,16 @@ static int mvp_candidate(const VVCLocalContext *lc, const int x_cand, const int
     const MvField* tab_mvf          = fc->tab.mvf;
     const MvField *mvf              = &TAB_MVF(x_cand, y_cand);
     const PredFlag maskx = lx + 1;
-    const int poc = rpl[lx].list[ref_idx[lx]];
+    const int poc = rpl[lx].refs[ref_idx[lx]].poc;
     int available = 0;
 
-    if ((mvf->pred_flag & maskx) && rpl[lx].list[mvf->ref_idx[lx]] == poc) {
+    if ((mvf->pred_flag & maskx) && rpl[lx].refs[mvf->ref_idx[lx]].poc == poc) {
         available = 1;
         *mv = mvf->mv[lx];
     } else {
         const int ly = !lx;
         const PredFlag masky = ly + 1;
-        if ((mvf->pred_flag & masky) && rpl[ly].list[mvf->ref_idx[ly]] == poc) {
+        if ((mvf->pred_flag & masky) && rpl[ly].refs[mvf->ref_idx[ly]].poc == poc) {
             available = 1;
             *mv = mvf->mv[ly];
         }
@@ -1450,15 +1450,15 @@ static int affine_mvp_candidate(const VVCLocalContext *lc,
         const MvField *mvf = &TAB_MVF(x_nb, y_nb);
         RefPicList* rpl = lc->sc->rpl;
         const PredFlag maskx = lx + 1;
-        const int poc = rpl[lx].list[ref_idx[lx]];
+        const int poc = rpl[lx].refs[ref_idx[lx]].poc;
 
-        if ((mvf->pred_flag & maskx) && rpl[lx].list[mvf->ref_idx[lx]] == poc) {
+        if ((mvf->pred_flag & maskx) && rpl[lx].refs[mvf->ref_idx[lx]].poc == poc) {
             available = 1;
             affine_cps_from_nb(lc, x_nb, y_nb, nbw, nbh, lx, cps, num_cp);
         } else {
             const int ly = !lx;
             const PredFlag masky = ly + 1;
-            if ((mvf->pred_flag & masky) && rpl[ly].list[mvf->ref_idx[ly]] == poc) {
+            if ((mvf->pred_flag & masky) && rpl[ly].refs[mvf->ref_idx[ly]].poc == poc) {
                 available = 1;
                 affine_cps_from_nb(lc, x_nb, y_nb, nbw, nbh, ly, cps, num_cp);
             }
@@ -1550,7 +1550,7 @@ static int mvp_history_candidates(const VVCLocalContext *lc,
 {
     const EntryPoint* ep            = lc->ep;
     const RefPicList* rpl           = lc->sc->rpl;
-    const int poc                   = rpl[lx].list[ref_idx];
+    const int poc                   = rpl[lx].refs[ref_idx].poc;
 
     if (ep->num_hmvp == 0)
         return 0;
@@ -1559,7 +1559,7 @@ static int mvp_history_candidates(const VVCLocalContext *lc,
         for (int j = 0; j < 2; j++) {
             const int ly = (j ? !lx : lx);
             PredFlag mask = PF_L0 + ly;
-            if ((h->pred_flag & mask) && poc == rpl[ly].list[h->ref_idx[ly]]) {
+            if ((h->pred_flag & mask) && poc == rpl[ly].refs[h->ref_idx[ly]].poc) {
                 if (mvp_lx_flag == num_cands) {
                     *mv = h->mv[ly];
                     ff_vvc_round_mv(mv, amvr_shift, amvr_shift);
@@ -1725,14 +1725,14 @@ static int affine_mvp_constructed_cp(NeighbourContext *ctx,
         if (check_available(n, ctx->lc, 0)) {
             const PredFlag maskx = lx + 1;
             const MvField* mvf = &TAB_MVF(n->x, n->y);
-            const int poc = rpl[lx].list[ref_idx];
-            if ((mvf->pred_flag & maskx) && rpl[lx].list[mvf->ref_idx[lx]] == poc) {
+            const int poc = rpl[lx].refs[ref_idx].poc;
+            if ((mvf->pred_flag & maskx) && rpl[lx].refs[mvf->ref_idx[lx]].poc == poc) {
                 available = 1;
                 *cp = mvf->mv[lx];
             } else {
                 const int ly = !lx;
                 const PredFlag masky = ly + 1;
-                if ((mvf->pred_flag & masky) && rpl[ly].list[mvf->ref_idx[ly]] == poc) {
+                if ((mvf->pred_flag & masky) && rpl[ly].refs[mvf->ref_idx[ly]].poc == poc) {
                     available = 1;
                     *cp = mvf->mv[ly];
                 }
diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index 6694bc4c51..74c105b619 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -352,7 +352,8 @@ static VVCFrame *generate_missing_ref(VVCContext *s, VVCFrameContext *fc, int po
 static int add_candidate_ref(VVCContext *s, VVCFrameContext *fc, RefPicList *list,
                              int poc, int ref_flag, uint8_t use_msb)
 {
-    VVCFrame *ref = find_ref_idx(s, fc, poc, use_msb);
+    VVCFrame *ref   = find_ref_idx(s, fc, poc, use_msb);
+    VVCRefPic *refp = &list->refs[list->nb_refs];
 
     if (ref == fc->ref || list->nb_refs >= VVC_MAX_REF_ENTRIES)
         return AVERROR_INVALIDDATA;
@@ -363,9 +364,9 @@ static int add_candidate_ref(VVCContext *s, VVCFrameContext *fc, RefPicList *lis
             return AVERROR(ENOMEM);
     }
 
-    list->list[list->nb_refs] = poc;
-    list->ref[list->nb_refs]  = ref;
-    list->isLongTerm[list->nb_refs] = ref_flag & VVC_FRAME_FLAG_LONG_REF;
+    refp->poc = poc;
+    refp->ref = ref;
+    refp->is_lt = ref_flag & VVC_FRAME_FLAG_LONG_REF;
     list->nb_refs++;
 
     mark_ref(ref, ref_flag);
@@ -463,7 +464,7 @@ int ff_vvc_slice_rpl(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
         }
         if ((!rsh->sh_collocated_from_l0_flag) == lx &&
             rsh->sh_collocated_ref_idx < rpl->nb_refs)
-            fc->ref->collocated_ref = rpl->ref[rsh->sh_collocated_ref_idx];
+            fc->ref->collocated_ref = rpl->refs[rsh->sh_collocated_ref_idx].ref;
     }
     return 0;
 }
diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
index 3b27811db2..2654b40058 100644
--- a/libavcodec/vvc/thread.c
+++ b/libavcodec/vvc/thread.c
@@ -294,7 +294,7 @@ static void schedule_inter(VVCContext *s, VVCFrameContext *fc, const SliceContex
         for (int lx = 0; lx < 2; lx++) {
             for (int i = 0; i < sh->r->num_ref_idx_active[lx]; i++) {
                 const int y = ctu->max_y[lx][i];
-                VVCFrame *ref = sc->rpl[lx].ref[i];
+                VVCFrame *ref = sc->rpl[lx].refs[i].ref;
                 if (ref && y >= 0)
                     add_progress_listener(ref, &t->listener[lx][i], t, s, VVC_PROGRESS_PIXEL, y + LUMA_EXTRA_AFTER);
             }
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 08/18] avcodec/vvcdec: refact, pred_get_refs return VVCRefPic instead of VVCFrame
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (5 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 07/18] avcodec/vvcdec: refact out VVCRefPic from RefPicList Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 09/18] avcodec/vvcdec: add vvc inter filters for RPR Nuo Mi
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/inter.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index cd96707c02..23d9ac05e6 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -387,15 +387,15 @@ static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_
         fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
 }
 
-static int pred_get_refs(const VVCLocalContext *lc, VVCFrame *ref[2],  const MvField *mv)
+static int pred_get_refs(const VVCLocalContext *lc, VVCRefPic *refp[2], const MvField *mv)
 {
-    const RefPicList *rpl = lc->sc->rpl;
+    RefPicList *rpl = lc->sc->rpl;
 
     for (int mask = PF_L0; mask <= PF_L1; mask++) {
         if (mv->pred_flag & mask) {
             const int lx = mask - PF_L0;
-            ref[lx] = rpl[lx].refs[mv->ref_idx[lx]].ref;
-            if (!ref[lx])
+            refp[lx] = rpl[lx].refs + mv->ref_idx[lx];
+            if (!refp[lx]->ref)
                 return AVERROR_INVALIDDATA;
         }
     }
@@ -487,9 +487,9 @@ static void pred_regular(VVCLocalContext *lc, const MvField *mvf, const MvField
 {
     const VVCFrameContext *fc = lc->fc;
     const int c_end           = fc->ps.sps->r->sps_chroma_format_idc ? CR : LUMA;
-    VVCFrame *ref[2];
+    VVCRefPic *refp[2];
 
-    if (pred_get_refs(lc, ref, mvf) < 0)
+    if (pred_get_refs(lc, refp, mvf) < 0)
         return;
 
     for (int c_idx = c_start; c_idx <= c_end; c_idx++) {
@@ -511,10 +511,10 @@ static void pred_regular(VVCLocalContext *lc, const MvField *mvf, const MvField
 
         if (mvf->pred_flag != PF_BI) {
             const int lx = mvf->pred_flag - PF_L0;
-            mc_uni(lc, inter, inter_stride, ref[lx]->frame, mvf,
+            mc_uni(lc, inter, inter_stride, refp[lx]->ref->frame, mvf,
                 x, y, w, h, c_idx, hf_idx, vf_idx);
         } else {
-            mc_bi(lc, inter, inter_stride, ref[0]->frame, ref[1]->frame, mvf, orig_mvf,
+            mc_bi(lc, inter, inter_stride, refp[L0]->ref->frame, refp[L1]->ref->frame, mvf, orig_mvf,
                 x, y, w, h, c_idx, do_bdof, hf_idx, vf_idx);
         }
         if (do_ciip) {
@@ -660,10 +660,10 @@ static void derive_sb_mv(VVCLocalContext *lc, MvField *mv, MvField *orig_mv, int
     if (pu->bdof_flag)
         *sb_bdof_flag = 1;
     if (pu->dmvr_flag) {
-        VVCFrame* ref[2];
-        if (pred_get_refs(lc, ref, mv) < 0)
+        VVCRefPic *refp[2];
+        if (pred_get_refs(lc, refp, mv) < 0)
             return;
-        dmvr_mv_refine(lc, mv, orig_mv, sb_bdof_flag, ref[0]->frame, ref[1]->frame, x0, y0, sbw, sbh);
+        dmvr_mv_refine(lc, mv, orig_mv, sb_bdof_flag, refp[L0]->ref->frame, refp[L1]->ref->frame, x0, y0, sbw, sbh);
         set_dmvr_info(fc, x0, y0, sbw, sbh, mv);
     }
 }
@@ -734,18 +734,18 @@ static void pred_affine_blk(VVCLocalContext *lc)
 
             uint8_t *dst0 = POS(0, x, y);
             const MvField *mv = ff_vvc_get_mvf(fc, x, y);
-            VVCFrame *ref[2];
+            VVCRefPic *refp[2];
 
-            if (pred_get_refs(lc, ref, mv) < 0)
+            if (pred_get_refs(lc, refp, mv) < 0)
                 return;
 
             if (mi->pred_flag != PF_BI) {
                 const int lx = mi->pred_flag - PF_L0;
-                luma_prof_uni(lc, dst0, fc->frame->linesize[0], ref[lx]->frame,
+                luma_prof_uni(lc, dst0, fc->frame->linesize[LUMA], refp[lx]->ref->frame,
                     mv, x, y, sbw, sbh, pu->cb_prof_flag[lx],
                     pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
             } else {
-                luma_prof_bi(lc, dst0, fc->frame->linesize[0], ref[0]->frame, ref[1]->frame,
+                luma_prof_bi(lc, dst0, fc->frame->linesize[LUMA], refp[L0]->ref->frame, refp[L1]->ref->frame,
                     mv, x, y, sbw, sbh);
             }
             if (fc->ps.sps->r->sps_chroma_format_idc) {
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 09/18] avcodec/vvcdec: add vvc inter filters for RPR
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (6 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 08/18] avcodec/vvcdec: refact, pred_get_refs return VVCRefPic instead of VVCFrame Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 10/18] avcodec/vvcdec: emulated_edge, use reference frame's sps and pps Nuo Mi
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/data.c   | 83 ++++++++++++++++++++++++++++++++++++++++-
 libavcodec/vvc/data.h   | 10 +++--
 libavcodec/vvc/inter.c  |  8 ++--
 tests/checkasm/vvc_mc.c | 12 +++---
 4 files changed, 98 insertions(+), 15 deletions(-)

diff --git a/libavcodec/vvc/data.c b/libavcodec/vvc/data.c
index ace585b663..a91e20754e 100644
--- a/libavcodec/vvc/data.c
+++ b/libavcodec/vvc/data.c
@@ -1732,7 +1732,7 @@ const uint8_t ff_vvc_alf_aps_class_to_filt_map[25] = {
     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
 };
 
-const int8_t ff_vvc_inter_luma_filters[VVC_INTER_FILTER_TYPES][VVC_INTER_LUMA_FACTS][VVC_INTER_LUMA_TAPS] = {
+const int8_t ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPES][VVC_INTER_LUMA_FACTS][VVC_INTER_LUMA_TAPS] = {
     {
         //1x, hpelIfIdx == 0, Table 27
         {  0, 0,   0, 64,  0,   0,  0,  0 },
@@ -1773,6 +1773,46 @@ const int8_t ff_vvc_inter_luma_filters[VVC_INTER_FILTER_TYPES][VVC_INTER_LUMA_FA
         {  0, 1,  -2,  4, 63,  -3,  1,  0 },
     },
 
+    {
+        //1.5x, Table 28
+        { -1, -5, 17, 42, 17, -5, -1,  0 },
+        {  0, -5, 15, 41, 19, -5, -1,  0 },
+        {  0, -5, 13, 40, 21, -4, -1,  0 },
+        {  0, -5, 11, 39, 24, -4, -2,  1 },
+        {  0, -5,  9, 38, 26, -3, -2,  1 },
+        {  0, -5,  7, 38, 28, -2, -3,  1 },
+        {  1, -5,  5, 36, 30, -1, -3,  1 },
+        {  1, -4,  3, 35, 32,  0, -4,  1 },
+        {  1, -4,  2, 33, 33,  2, -4,  1 },
+        {  1, -4,  0, 32, 35,  3, -4,  1 },
+        {  1, -3, -1, 30, 36,  5, -5,  1 },
+        {  1, -3, -2, 28, 38,  7, -5,  0 },
+        {  1, -2, -3, 26, 38,  9, -5,  0 },
+        {  1, -2, -4, 24, 39, 11, -5,  0 },
+        {  0, -1, -4, 21, 40, 13, -5,  0 },
+        {  0, -1, -5, 19, 41, 15, -5,  0 },
+    },
+
+    {
+        //2x, Table 29
+        { -4,  2, 20, 28, 20,  2, -4,  0 },
+        { -4,  0, 19, 29, 21,  5, -4, -2 },
+        { -4, -1, 18, 29, 22,  6, -4, -2 },
+        { -4, -1, 16, 29, 23,  7, -4, -2 },
+        { -4, -1, 16, 28, 24,  7, -4, -2 },
+        { -4, -1, 14, 28, 25,  8, -4, -2 },
+        { -3, -3, 14, 27, 26,  9, -3, -3 },
+        { -3, -1, 12, 28, 25, 10, -4, -3 },
+        { -3, -3, 11, 27, 27, 11, -3, -3 },
+        { -3, -4, 10, 25, 28, 12, -1, -3 },
+        { -3, -3,  9, 26, 27, 14, -3, -3 },
+        { -2, -4,  8, 25, 28, 14, -1, -4 },
+        { -2, -4,  7, 24, 28, 16, -1, -4 },
+        { -2, -4,  7, 23, 29, 16, -1, -4 },
+        { -2, -4,  6, 22, 29, 18, -1, -4 },
+        { -2, -4,  5, 21, 29, 19,  0, -4 },
+    },
+
     {
         //1x, affine, Table 30
         {  0, 0,   0, 64,  0,   0,  0,  0 },
@@ -1793,9 +1833,48 @@ const int8_t ff_vvc_inter_luma_filters[VVC_INTER_FILTER_TYPES][VVC_INTER_LUMA_FA
         {  0, 1,  -2,  4, 63,  -3,  1,  0 },
     },
 
+    {
+        //1.5x, affine, Table 31
+        {  0, -6, 17, 42, 17, -5, -1,  0 },
+        {  0, -5, 15, 41, 19, -5, -1,  0 },
+        {  0, -5, 13, 40, 21, -4, -1,  0 },
+        {  0, -5, 11, 39, 24, -4, -1,  0 },
+        {  0, -5,  9, 38, 26, -3, -1,  0 },
+        {  0, -5,  7, 38, 28, -2, -2,  0 },
+        {  0, -4,  5, 36, 30, -1, -2,  0 },
+        {  0, -3,  3, 35, 32,  0, -3,  0 },
+        {  0, -3,  2, 33, 33,  2, -3,  0 },
+        {  0, -3,  0, 32, 35,  3, -3,  0 },
+        {  0, -2, -1, 30, 36,  5, -4,  0 },
+        {  0, -2, -2, 28, 38,  7, -5,  0 },
+        {  0, -1, -3, 26, 38,  9, -5,  0 },
+        {  0, -1, -4, 24, 39, 11, -5,  0 },
+        {  0, -1, -4, 21, 40, 13, -5,  0 },
+        {  0, -1, -5, 19, 41, 15, -5,  0 },
+    },
+
+    {
+        //2x, affine, Table 32
+        {  0, -2, 20, 28, 20,  2, -4,  0 },
+        {  0, -4, 19, 29, 21,  5, -6,  0 },
+        {  0, -5, 18, 29, 22,  6, -6,  0 },
+        {  0, -5, 16, 29, 23,  7, -6,  0 },
+        {  0, -5, 16, 28, 24,  7, -6,  0 },
+        {  0, -5, 14, 28, 25,  8, -6,  0 },
+        {  0, -6, 14, 27, 26,  9, -6,  0 },
+        {  0, -4, 12, 28, 25, 10, -7,  0 },
+        {  0, -6, 11, 27, 27, 11, -6,  0 },
+        {  0, -7, 10, 25, 28, 12, -4,  0 },
+        {  0, -6,  9, 26, 27, 14, -6,  0 },
+        {  0, -6,  8, 25, 28, 14, -5,  0 },
+        {  0, -6,  7, 24, 28, 16, -5,  0 },
+        {  0, -6,  7, 23, 29, 16, -5,  0 },
+        {  0, -6,  6, 22, 29, 18, -5,  0 },
+        {  0, -6,  5, 21, 29, 19, -4,  0 },
+    }
 };
 
-const int8_t ff_vvc_inter_chroma_filters[VVC_INTER_FILTER_TYPES][VVC_INTER_CHROMA_FACTS][VVC_INTER_CHROMA_TAPS] = {
+const int8_t ff_vvc_inter_chroma_filters[VVC_INTER_CHROMA_FILTER_TYPES][VVC_INTER_CHROMA_FACTS][VVC_INTER_CHROMA_TAPS] = {
     {
         //1x, Table 33
         {  0, 64,  0,  0 },
diff --git a/libavcodec/vvc/data.h b/libavcodec/vvc/data.h
index e493b9e0e6..a0512e626b 100644
--- a/libavcodec/vvc/data.h
+++ b/libavcodec/vvc/data.h
@@ -43,15 +43,19 @@ extern const int8_t ff_vvc_lfnst_8x8[4][2][16][48];
 extern const uint8_t ff_vvc_lfnst_tr_set_index[95];
 extern uint8_t ff_vvc_default_scale_m[64 * 64];
 
-#define VVC_INTER_FILTER_TYPES       3
+#define VVC_INTER_LUMA_FILTER_TYPE_AFFINE   4
+
+#define VVC_INTER_LUMA_FILTER_TYPES         7
+#define VVC_INTER_CHROMA_FILTER_TYPES       3
+
 #define VVC_INTER_LUMA_FACTS        16
 #define VVC_INTER_LUMA_TAPS          8
 #define VVC_INTER_CHROMA_FACTS      32
 #define VVC_INTER_CHROMA_TAPS        4
 #define VVC_INTER_LUMA_DMVR_FACTS   16
 #define VVC_INTER_LUMA_DMVR_TAPS     2
-extern const int8_t ff_vvc_inter_luma_filters[VVC_INTER_FILTER_TYPES][VVC_INTER_LUMA_FACTS][VVC_INTER_LUMA_TAPS];
-extern const int8_t ff_vvc_inter_chroma_filters[VVC_INTER_FILTER_TYPES][VVC_INTER_CHROMA_FACTS][VVC_INTER_CHROMA_TAPS];
+extern const int8_t ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPES][VVC_INTER_LUMA_FACTS][VVC_INTER_LUMA_TAPS];
+extern const int8_t ff_vvc_inter_chroma_filters[VVC_INTER_CHROMA_FILTER_TYPES][VVC_INTER_CHROMA_FACTS][VVC_INTER_CHROMA_TAPS];
 extern const int8_t ff_vvc_inter_luma_dmvr_filters[VVC_INTER_LUMA_DMVR_FACTS][VVC_INTER_LUMA_DMVR_TAPS];
 
 #define VVC_INTRA_LUMA_TYPES         2
diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 23d9ac05e6..31c6f43916 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -320,8 +320,8 @@ static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst
     const Mv *mv                = mvf->mv + lx;
     const int mx                = mv->x & 0xf;
     const int my                = mv->y & 0xf;
-    const int8_t *hf            = ff_vvc_inter_luma_filters[2][mx];
-    const int8_t *vf            = ff_vvc_inter_luma_filters[2][my];
+    const int8_t *hf            = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
+    const int8_t *vf            = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
     int denom, wx, ox;
     const int weight_flag       = derive_weight_uni(&denom, &wx, &ox, lc, mvf, LUMA);
     const int is_chroma         = 0;
@@ -368,8 +368,8 @@ static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_
         const int oy            = y_off + (mv->y >> 4);
         ptrdiff_t src_stride    = ref[i]->linesize[0];
         const uint8_t *src      = ref[i]->data[0] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
-        const int8_t *hf        = ff_vvc_inter_luma_filters[2][mx];
-        const int8_t *vf        = ff_vvc_inter_luma_filters[2][my];
+        const int8_t *hf        = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
+        const int8_t *vf        = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
 
         MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
         if (!pu->cb_prof_flag[i]) {
diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c
index 71087dc3dd..a5ec7b7869 100644
--- a/tests/checkasm/vvc_mc.c
+++ b/tests/checkasm/vvc_mc.c
@@ -134,8 +134,8 @@ static void check_put_vvc_luma_uni(void)
                         const int idx       = av_log2(w) - 1;
                         const int mx        = rnd() % VVC_INTER_LUMA_FACTS;
                         const int my        = rnd() % VVC_INTER_LUMA_FACTS;
-                        const int8_t *hf    = ff_vvc_inter_luma_filters[rnd() % VVC_INTER_FILTER_TYPES][mx];
-                        const int8_t *vf    = ff_vvc_inter_luma_filters[rnd() % VVC_INTER_FILTER_TYPES][my];
+                        const int8_t *hf    = ff_vvc_inter_luma_filters[rnd() % VVC_INTER_LUMA_FILTER_TYPES][mx];
+                        const int8_t *vf    = ff_vvc_inter_luma_filters[rnd() % VVC_INTER_LUMA_FILTER_TYPES][my];
                         const char *type;
 
                         switch ((j << 1) | i) {
@@ -184,8 +184,8 @@ static void check_put_vvc_chroma(void)
                         const int idx       = av_log2(w) - 1;
                         const int mx        = rnd() % VVC_INTER_CHROMA_FACTS;
                         const int my        = rnd() % VVC_INTER_CHROMA_FACTS;
-                        const int8_t *hf    = ff_vvc_inter_chroma_filters[rnd() % VVC_INTER_FILTER_TYPES][mx];
-                        const int8_t *vf    = ff_vvc_inter_chroma_filters[rnd() % VVC_INTER_FILTER_TYPES][my];
+                        const int8_t *hf    = ff_vvc_inter_chroma_filters[rnd() % VVC_INTER_CHROMA_FILTER_TYPES][mx];
+                        const int8_t *vf    = ff_vvc_inter_chroma_filters[rnd() % VVC_INTER_CHROMA_FILTER_TYPES][my];
                         const char *type;
                         switch ((j << 1) | i) {
                             case 0: type = "put_chroma_pixels"; break; // 0 0
@@ -233,8 +233,8 @@ static void check_put_vvc_chroma_uni(void)
                         const int idx       = av_log2(w) - 1;
                         const int mx        = rnd() % VVC_INTER_CHROMA_FACTS;
                         const int my        = rnd() % VVC_INTER_CHROMA_FACTS;
-                        const int8_t *hf    = ff_vvc_inter_chroma_filters[rnd() % VVC_INTER_FILTER_TYPES][mx];
-                        const int8_t *vf    = ff_vvc_inter_chroma_filters[rnd() % VVC_INTER_FILTER_TYPES][my];
+                        const int8_t *hf    = ff_vvc_inter_chroma_filters[rnd() % VVC_INTER_CHROMA_FILTER_TYPES][mx];
+                        const int8_t *vf    = ff_vvc_inter_chroma_filters[rnd() % VVC_INTER_CHROMA_FILTER_TYPES][my];
                         const char *type;
 
                         switch ((j << 1) | i) {
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 10/18] avcodec/vvcdec: emulated_edge, use reference frame's sps and pps
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (7 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 09/18] avcodec/vvcdec: add vvc inter filters for RPR Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 11/18] avcodec/vvcdec: add RPR dsp Nuo Mi
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

a preparation for Reference Picture Resampling
---
 libavcodec/vvc/dec.c   |  3 +++
 libavcodec/vvc/dec.h   |  2 ++
 libavcodec/vvc/inter.c | 54 ++++++++++++++++++++++--------------------
 libavcodec/vvc/refs.c  |  5 ++++
 4 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index b4c35330eb..3325133efb 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -560,6 +560,9 @@ static int ref_frame(VVCFrame *dst, const VVCFrame *src)
     if (ret < 0)
         return ret;
 
+    ff_refstruct_replace(&dst->sps, src->sps);
+    ff_refstruct_replace(&dst->pps, src->pps);
+
     ff_refstruct_replace(&dst->progress, src->progress);
 
     ff_refstruct_replace(&dst->tab_dmvr_mvf, src->tab_dmvr_mvf);
diff --git a/libavcodec/vvc/dec.h b/libavcodec/vvc/dec.h
index 205427f681..6f14cc1860 100644
--- a/libavcodec/vvc/dec.h
+++ b/libavcodec/vvc/dec.h
@@ -60,6 +60,8 @@ typedef struct RefPicListTab {
 typedef struct VVCFrame {
     struct AVFrame *frame;
 
+    const VVCSPS *sps;                          ///< RefStruct reference
+    const VVCPPS *pps;                          ///< RefStruct reference
     struct MvField *tab_dmvr_mvf;               ///< RefStruct reference
     RefPicListTab **rpl_tab;                    ///< RefStruct reference
     RefPicListTab  *rpl;                        ///< RefStruct reference
diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 31c6f43916..f432a2dc3c 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -44,12 +44,12 @@ static void subpic_width_height(int *pic_width, int *pic_height,
     *pic_height = pps->subpic_height[subpic_idx] >> sps->vshift[is_chroma];
 }
 
-static int emulated_edge(const VVCLocalContext *lc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride,
+static int emulated_edge(const VVCLocalContext *lc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
     int x_off, int y_off, const int block_w, const int block_h, const int is_chroma)
 {
     const VVCFrameContext *fc = lc->fc;
-    const VVCSPS *sps         = fc->ps.sps;
-    const VVCPPS *pps         = fc->ps.pps;
+    const VVCSPS *sps         = src_frame->sps;
+    const VVCPPS *pps         = src_frame->pps;
     const int subpic_idx      = lc->sc->sh.r->curr_subpic_idx;
     const int extra_before    = is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE;
     const int extra_after     = is_chroma ? CHROMA_EXTRA_AFTER : LUMA_EXTRA_AFTER;
@@ -143,7 +143,7 @@ static void emulated_edge_bilinear(const VVCLocalContext *lc, uint8_t *dst, cons
 }
 
 #define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off)                                                \
-    emulated_edge(lc, dst, src, src_stride, x_off, y_off, block_w, block_h, is_chroma)
+    emulated_edge(lc, dst, src, src_stride, ref, x_off, y_off, block_w, block_h, is_chroma)
 
 #define MC_EMULATED_EDGE_DMVR(dst, src, src_stride, x_sb, y_sb, x_off, y_off)                               \
     emulated_edge_dmvr(lc, dst, src, src_stride, x_sb, y_sb, x_off, y_off, block_w, block_h, is_chroma)
@@ -204,12 +204,12 @@ static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1,
 
 #define INTER_FILTER(t, frac)  (is_chroma ? ff_vvc_inter_chroma_filters[t][frac] : ff_vvc_inter_luma_filters[t][frac])
 
-static void mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,
+static void mc(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref, const Mv *mv,
     int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
 {
     const VVCFrameContext *fc   = lc->fc;
-    const uint8_t *src          = ref->data[c_idx];
-    ptrdiff_t src_stride        = ref->linesize[c_idx];
+    const uint8_t *src          = ref->frame->data[c_idx];
+    ptrdiff_t src_stride        = ref->frame->linesize[c_idx];
     const int is_chroma         = !!c_idx;
     const int hs                = fc->ps.sps->hshift[c_idx];
     const int vs                = fc->ps.sps->vshift[c_idx];
@@ -228,12 +228,12 @@ static void mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *
 }
 
 static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
-    const AVFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
+    const VVCFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
     const int c_idx, const int hf_idx, const int vf_idx)
 {
     const VVCFrameContext *fc   = lc->fc;
-    const uint8_t *src          = ref->data[c_idx];
-    ptrdiff_t src_stride        = ref->linesize[c_idx];
+    const uint8_t *src          = ref->frame->data[c_idx];
+    ptrdiff_t src_stride        = ref->frame->linesize[c_idx];
     const int lx                = mvf->pred_flag - PF_L0;
     const int hs                = fc->ps.sps->hshift[c_idx];
     const int vs                = fc->ps.sps->vshift[c_idx];
@@ -261,7 +261,7 @@ static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride
 }
 
 static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
-    const AVFrame *ref0, const AVFrame *ref1, const MvField *mvf, const MvField *orig_mv,
+    const VVCFrame *ref0, const VVCFrame *ref1, const MvField *mvf, const MvField *orig_mv,
     const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx,
     const int sb_bdof_flag, const int hf_idx, const int vf_idx)
 {
@@ -270,7 +270,7 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
     const int hs                = fc->ps.sps->hshift[c_idx];
     const int vs                = fc->ps.sps->vshift[c_idx];
     const int idx               = av_log2(block_w) - 1;
-    const AVFrame *ref[]        = { ref0, ref1 };
+    const VVCFrame *refs[]      = { ref0, ref1 };
     int16_t *tmp[]              = { lc->tmp + sb_bdof_flag * PROF_TEMP_OFFSET, lc->tmp1 + sb_bdof_flag * PROF_TEMP_OFFSET };
     int denom, w0, w1, o0, o1;
     const int weight_flag       = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, pu->dmvr_flag);
@@ -282,8 +282,9 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
         const int my            = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - vs);
         const int ox            = x_off + (mv->x >> (4 + hs));
         const int oy            = y_off + (mv->y >> (4 + vs));
-        ptrdiff_t src_stride    = ref[i]->linesize[c_idx];
-        const uint8_t *src      = ref[i]->data[c_idx] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
+        const VVCFrame *ref     = refs[i];
+        ptrdiff_t src_stride    = ref->frame->linesize[c_idx];
+        const uint8_t *src      = ref->frame->data[c_idx] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
         const int8_t *hf        = INTER_FILTER(hf_idx, mx);
         const int8_t *vf        = INTER_FILTER(vf_idx, my);
 
@@ -308,12 +309,12 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
 }
 
 static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
-    const AVFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
+    const VVCFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
     const int cb_prof_flag, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
 {
     const VVCFrameContext *fc   = lc->fc;
-    const uint8_t *src          = ref->data[0];
-    ptrdiff_t src_stride        = ref->linesize[0];
+    const uint8_t *src          = ref->frame->data[LUMA];
+    ptrdiff_t src_stride        = ref->frame->linesize[LUMA];
     uint16_t *prof_tmp          = lc->tmp + PROF_TEMP_OFFSET;
     const int idx               = av_log2(block_w) - 1;
     const int lx                = mvf->pred_flag - PF_L0;
@@ -347,12 +348,12 @@ static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst
 }
 
 static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
-    const AVFrame *ref0, const AVFrame *ref1, const MvField *mvf, const int x_off, const int y_off,
+    const VVCFrame *ref0, const VVCFrame *ref1, const MvField *mvf, const int x_off, const int y_off,
     const int block_w, const int block_h)
 {
     const VVCFrameContext *fc   = lc->fc;
     const PredictionUnit *pu    = &lc->cu->pu;
-    const AVFrame *ref[]        = { ref0, ref1 };
+    const VVCFrame *refs[]      = { ref0, ref1 };
     int16_t *tmp[]              = { lc->tmp, lc->tmp1 };
     uint16_t *prof_tmp          = lc->tmp2 + PROF_TEMP_OFFSET;
     const int idx               = av_log2(block_w) - 1;
@@ -366,8 +367,9 @@ static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_
         const int my            = mv->y & 0xf;
         const int ox            = x_off + (mv->x >> 4);
         const int oy            = y_off + (mv->y >> 4);
-        ptrdiff_t src_stride    = ref[i]->linesize[0];
-        const uint8_t *src      = ref[i]->data[0] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
+        const VVCFrame *ref     = refs[i];
+        ptrdiff_t src_stride    = ref->frame->linesize[LUMA];
+        const uint8_t *src      = ref->frame->data[LUMA] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
         const int8_t *hf        = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
         const int8_t *vf        = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
 
@@ -453,7 +455,7 @@ static void pred_gpm_blk(VVCLocalContext *lc)
             VVCFrame *ref = lc->sc->rpl[lx].refs[mv->ref_idx[lx]].ref;
             if (!ref)
                 return;
-            mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height, c_idx);
+            mc(lc, tmp[i], ref, mv->mv + lx, x, y, width, height, c_idx);
         }
         fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y);
     }
@@ -511,10 +513,10 @@ static void pred_regular(VVCLocalContext *lc, const MvField *mvf, const MvField
 
         if (mvf->pred_flag != PF_BI) {
             const int lx = mvf->pred_flag - PF_L0;
-            mc_uni(lc, inter, inter_stride, refp[lx]->ref->frame, mvf,
+            mc_uni(lc, inter, inter_stride, refp[lx]->ref, mvf,
                 x, y, w, h, c_idx, hf_idx, vf_idx);
         } else {
-            mc_bi(lc, inter, inter_stride, refp[L0]->ref->frame, refp[L1]->ref->frame, mvf, orig_mvf,
+            mc_bi(lc, inter, inter_stride, refp[L0]->ref, refp[L1]->ref, mvf, orig_mvf,
                 x, y, w, h, c_idx, do_bdof, hf_idx, vf_idx);
         }
         if (do_ciip) {
@@ -741,11 +743,11 @@ static void pred_affine_blk(VVCLocalContext *lc)
 
             if (mi->pred_flag != PF_BI) {
                 const int lx = mi->pred_flag - PF_L0;
-                luma_prof_uni(lc, dst0, fc->frame->linesize[LUMA], refp[lx]->ref->frame,
+                luma_prof_uni(lc, dst0, fc->frame->linesize[LUMA], refp[lx]->ref,
                     mv, x, y, sbw, sbh, pu->cb_prof_flag[lx],
                     pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
             } else {
-                luma_prof_bi(lc, dst0, fc->frame->linesize[LUMA], refp[L0]->ref->frame, refp[L1]->ref->frame,
+                luma_prof_bi(lc, dst0, fc->frame->linesize[LUMA], refp[L0]->ref, refp[L1]->ref,
                     mv, x, y, sbw, sbh);
             }
             if (fc->ps.sps->r->sps_chroma_format_idc) {
diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index 74c105b619..954db4a8c8 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -52,6 +52,8 @@ void ff_vvc_unref_frame(VVCFrameContext *fc, VVCFrame *frame, int flags)
     frame->flags &= ~flags;
     if (!frame->flags) {
         av_frame_unref(frame->frame);
+        ff_refstruct_unref(&frame->sps);
+        ff_refstruct_unref(&frame->pps);
         ff_refstruct_unref(&frame->progress);
 
         ff_refstruct_unref(&frame->tab_dmvr_mvf);
@@ -119,6 +121,9 @@ static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc)
         if (frame->frame->buf[0])
             continue;
 
+        frame->sps = ff_refstruct_ref_c(fc->ps.sps);
+        frame->pps = ff_refstruct_ref_c(fc->ps.pps);
+
         ret = ff_thread_get_buffer(s->avctx, frame->frame, AV_GET_BUFFER_FLAG_REF);
         if (ret < 0)
             return NULL;
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 11/18] avcodec/vvcdec: add RPR dsp
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (8 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 10/18] avcodec/vvcdec: emulated_edge, use reference frame's sps and pps Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 12/18] avcodec/vvcdec: inter, wait reference with a diffrent resolution Nuo Mi
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/ctu.h            |   2 +
 libavcodec/vvc/dsp.h            |  13 +++
 libavcodec/vvc/inter_template.c | 168 ++++++++++++++++++++++++++++++++
 3 files changed, 183 insertions(+)

diff --git a/libavcodec/vvc/ctu.h b/libavcodec/vvc/ctu.h
index 337d0e7c28..50109154aa 100644
--- a/libavcodec/vvc/ctu.h
+++ b/libavcodec/vvc/ctu.h
@@ -58,6 +58,8 @@
 #define BILINEAR_EXTRA_AFTER    1
 #define BILINEAR_EXTRA          1
 
+#define SCALED_INT(pos) ((pos) >> 10)
+
 #define MAX_CONTROL_POINTS      3
 
 #define AFFINE_MIN_BLOCK_SIZE   4
diff --git a/libavcodec/vvc/dsp.h b/libavcodec/vvc/dsp.h
index 9810ac314c..1f14096c41 100644
--- a/libavcodec/vvc/dsp.h
+++ b/libavcodec/vvc/dsp.h
@@ -57,6 +57,19 @@ typedef struct VVCInterDSPContext {
         uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int height,
         int denom, int wx, int ox, const int8_t *hf, const int8_t *vf, int width);
 
+    void (*put_scaled[2 /* luma, chroma */][7 /* log2(width) - 1 */])(
+        int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, int src_height,
+        int x, int y, int dx, int dy, int height, const int8_t *hf, const int8_t *vf, int width);
+
+    void (*put_uni_scaled[2 /* luma, chroma */][7 /* log2(width) - 1 */])(
+        uint8_t *dst, const ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int src_height,
+        int x, int y, int dx, int dy, int height, const int8_t *hf, const int8_t *vf, int width);
+
+    void (*put_uni_w_scaled[2 /* luma, chroma */][7 /* log2(width) - 1 */])(
+        uint8_t *dst, const ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int src_height,
+        int x, int y, int dx, int dy, int height, int denom, int wx, int ox, const int8_t *hf, const int8_t *vf,
+        int width);
+
     void (*avg)(uint8_t *dst, ptrdiff_t dst_stride,
         const int16_t *src0, const int16_t *src1, int width, int height);
 
diff --git a/libavcodec/vvc/inter_template.c b/libavcodec/vvc/inter_template.c
index e2fbfd4fc0..a8068f4ba8 100644
--- a/libavcodec/vvc/inter_template.c
+++ b/libavcodec/vvc/inter_template.c
@@ -22,6 +22,165 @@
 
 #include "libavcodec/h26x/h2656_inter_template.c"
 
+#define TMP_STRIDE EDGE_EMU_BUFFER_STRIDE
+static void av_always_inline FUNC(put_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *const _src, ptrdiff_t _src_stride, const int src_height,
+    const int _x, const int _y, const int dx, const int dy,
+    const int height, const int8_t *hf, const int8_t *vf, const int width, const int is_uni, const int is_chroma)
+{
+    int16_t tmp_array[TMP_STRIDE * MAX_PB_SIZE];
+    int16_t *tmp                 = tmp_array;
+    pixel *dst                   = (pixel*)_dst;
+    int16_t *dst16               = (int16_t*)_dst;
+    const ptrdiff_t dst_stride   = _dst_stride / sizeof(pixel);
+    const ptrdiff_t src_stride   = _src_stride / sizeof(pixel);
+    const int shift              = FFMAX(2, 14 - BIT_DEPTH);
+    const int offset             = 1 << (shift - 1);
+    const int taps               = is_chroma ? VVC_INTER_CHROMA_TAPS : VVC_INTER_LUMA_TAPS;
+    const int extra              = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA;
+    const int extra_before       = is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE;
+    const int shift1             = 6 - is_chroma;
+    const int shift2             = 4 + is_chroma;
+    const int x0                 = SCALED_INT(_x);
+    const int y0                 = SCALED_INT(_y);
+
+    for (int i = 0; i < width; i++) {
+        const int tx         = _x + dx * i;
+        const int x          = SCALED_INT(tx) - x0;
+        const int mx         = av_mod_uintp2(tx >> shift1, shift2);
+        const int8_t *filter = hf + mx * taps;
+        const pixel *src     = (pixel*)_src - extra_before * src_stride;
+
+        for (int j = 0; j < src_height + extra; j++) {
+            tmp[j] = (is_chroma ? CHROMA_FILTER(src, 1) : LUMA_FILTER(src, 1)) >> (BIT_DEPTH - 8);
+            src += src_stride;
+        }
+        tmp += TMP_STRIDE;
+    }
+
+    for (int i = 0; i < height; i++) {
+        const int ty         = _y + dy * i;
+        const int x          = SCALED_INT(ty) - y0;
+        const int mx         = av_mod_uintp2(ty >> shift1, shift2);
+        const int8_t *filter = vf + mx * taps;
+
+        tmp = tmp_array + extra_before;
+        for (int j = 0; j < width; j++) {
+            const int val = (is_chroma ? CHROMA_FILTER(tmp, 1) : LUMA_FILTER(tmp, 1)) >> 6;
+            if (is_uni)
+                dst[j] = av_clip_pixel((val  + offset) >> shift);
+            else
+                dst16[j] = val;
+            tmp += TMP_STRIDE;
+        }
+        if (is_uni)
+            dst += dst_stride;
+        else
+            dst16 += dst_stride;
+    }
+}
+
+static void FUNC(put_luma_scaled)(int16_t *_dst,
+    const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
+    const int x, const int y, const int dx, const int dy,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    FUNC(put_scaled)((uint8_t *)_dst, MAX_PB_SIZE * sizeof(pixel), _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 0, 0);
+}
+
+static void FUNC(put_chroma_scaled)(int16_t *_dst,
+    const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
+    const int x, const int y, const int dx, const int dy,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    FUNC(put_scaled)((uint8_t *)_dst, MAX_PB_SIZE * sizeof(pixel), _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 0, 1);
+}
+
+static void FUNC(put_uni_luma_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
+    const int x, const int y, const int dx, const int dy,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    FUNC(put_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 1, 0);
+}
+
+static void FUNC(put_uni_chroma_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
+    const int x, const int y, const int dx, const int dy,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    FUNC(put_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 1, 1);
+}
+
+static void av_always_inline FUNC(put_uni_w_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *const _src, ptrdiff_t _src_stride, const int src_height,
+    const int _x, const int _y, const int dx, const int dy, const int denom, const int wx, const int _ox,
+    const int height, const int8_t *hf, const int8_t *vf, const int width, const int is_chroma)
+{
+    int16_t tmp_array[TMP_STRIDE * MAX_PB_SIZE];
+    int16_t *tmp                 = tmp_array;
+    pixel *dst                   = (pixel*)_dst;
+    const ptrdiff_t dst_stride   = _dst_stride / sizeof(pixel);
+    const ptrdiff_t src_stride   = _src_stride / sizeof(pixel);
+    const int shift              = FFMAX(2, 14 - BIT_DEPTH);
+    const int offset             = 1 << (shift - 1);
+    const int ox                 = _ox * (1 << (BIT_DEPTH - 8));
+    const int taps               = is_chroma ? VVC_INTER_CHROMA_TAPS : VVC_INTER_LUMA_TAPS;
+    const int extra              = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA;
+    const int extra_before       = is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE;
+    const int shift1             = 6 - is_chroma;
+    const int shift2             = 4 + is_chroma;
+    const int x0                 = SCALED_INT(_x);
+    const int y0                 = SCALED_INT(_y);
+
+    for (int i = 0; i < width; i++) {
+        const int tx         = _x + dx * i;
+        const int x          = SCALED_INT(tx) - x0;
+        const int mx         = av_mod_uintp2(tx >> shift1, shift2);
+        const int8_t *filter = hf + mx * taps;
+        const pixel *src     = (pixel*)_src - extra_before * src_stride;
+
+        for (int j = 0; j < src_height + extra; j++) {
+            tmp[j] = (is_chroma ? CHROMA_FILTER(src, 1) : LUMA_FILTER(src, 1)) >> (BIT_DEPTH - 8);
+            src += src_stride;
+        }
+        tmp += TMP_STRIDE;
+    }
+
+    for (int i = 0; i < height; i++) {
+        const int ty         = _y + dy * i;
+        const int x          = SCALED_INT(ty) - y0;
+        const int mx         = av_mod_uintp2(ty >> shift1, shift2);
+        const int8_t *filter = vf + mx * taps;
+
+        tmp = tmp_array + extra_before;
+        for (int j = 0; j < width; j++) {
+            const int val = (is_chroma ? CHROMA_FILTER(tmp, 1) : LUMA_FILTER(tmp, 1)) >> 6;
+            dst[j] = av_clip_pixel(((wx * val  + offset) >> shift) + ox);
+            tmp += TMP_STRIDE;
+        }
+        dst += dst_stride;
+    }
+}
+
+static void FUNC(put_uni_luma_w_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
+    const int x, const int y, const int dx, const int dy, const int denom, const int wx, const int ox,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    FUNC(put_uni_w_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, denom, wx, ox, height, hf, vf, width, 0);
+}
+
+static void FUNC(put_uni_chroma_w_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
+    const int x, const int y, const int dx, const int dy, const int denom, const int wx, const int ox,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    FUNC(put_uni_w_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy,  denom, wx, ox, height, hf, vf, width, 1);
+}
+
+#undef TMP_STRIDE
+
 static void FUNC(avg)(uint8_t *_dst, const ptrdiff_t _dst_stride,
     const int16_t *src0, const int16_t *src1, const int width, const int height)
 {
@@ -440,6 +599,15 @@ static void FUNC(ff_vvc_inter_dsp_init)(VVCInterDSPContext *const inter)
     FUNCS(LUMA, luma);
     FUNCS(CHROMA, chroma);
 
+    for (int i = 0; i < FF_ARRAY_ELEMS(inter->put_scaled[LUMA]); i++) {
+        inter->put_scaled[LUMA][i]         = FUNC(put_luma_scaled);
+        inter->put_scaled[CHROMA][i]       = FUNC(put_chroma_scaled);
+        inter->put_uni_scaled[LUMA][i]     = FUNC(put_uni_luma_scaled);
+        inter->put_uni_scaled[CHROMA][i]   = FUNC(put_uni_chroma_scaled);
+        inter->put_uni_w_scaled[LUMA][i]   = FUNC(put_uni_luma_w_scaled);
+        inter->put_uni_w_scaled[CHROMA][i] = FUNC(put_uni_chroma_w_scaled);
+    }
+
     inter->avg                  = FUNC(avg);
     inter->w_avg                = FUNC(w_avg);
 
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 12/18] avcodec/vvcdec: inter, wait reference with a diffrent resolution
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (9 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 11/18] avcodec/vvcdec: add RPR dsp Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 15:20   ` Jean-Baptiste Kempf
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 13/18] avcodec/vvcdec: fix dmvr, bdof, cb_prof for RPR Nuo Mi
                   ` (5 subsequent siblings)
  16 siblings, 1 reply; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

For RPR, the current frame may reference a frame with a different resolution.
Therefore, we need to consider frame scaling when we wait for reference pixels.
---
 libavcodec/vvc/dec.c    |  5 +++++
 libavcodec/vvc/dec.h    | 17 +++++++++++++++++
 libavcodec/vvc/refs.c   | 39 +++++++++++++++++++++++++++++++++++++++
 libavcodec/vvc/thread.c | 10 +++++++---
 4 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 3325133efb..584c7b219f 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -573,6 +573,11 @@ static int ref_frame(VVCFrame *dst, const VVCFrame *src)
 
     dst->poc = src->poc;
     dst->ctb_count = src->ctb_count;
+
+    dst->scaling_win = src->scaling_win;
+    dst->ref_width   = src->ref_width;
+    dst->ref_height  = src->ref_height;
+
     dst->flags = src->flags;
     dst->sequence = src->sequence;
 
diff --git a/libavcodec/vvc/dec.h b/libavcodec/vvc/dec.h
index 6f14cc1860..1e0b76f283 100644
--- a/libavcodec/vvc/dec.h
+++ b/libavcodec/vvc/dec.h
@@ -46,6 +46,10 @@ typedef struct VVCRefPic {
     struct VVCFrame *ref;
     int poc;
     int is_lt;                  // is long term reference
+
+    // for RPR
+    int is_scaled;              ///< RprConstraintsActiveFlag
+    int scale[2];               ///< RefPicScale[]
 } VVCRefPic;
 
 typedef struct RefPicList {
@@ -57,6 +61,13 @@ typedef struct RefPicListTab {
     RefPicList refPicList[2];
 } RefPicListTab;
 
+typedef struct VVCWindow {
+    int16_t left_offset;
+    int16_t right_offset;
+    int16_t top_offset;
+    int16_t bottom_offset;
+} VVCWindow;
+
 typedef struct VVCFrame {
     struct AVFrame *frame;
 
@@ -71,6 +82,12 @@ typedef struct VVCFrame {
 
     int poc;
 
+    //for RPR
+    VVCWindow scaling_win;                      ///< pps_scaling_win_left_offset * SubWithC,  pps_scaling_win_right_offset  * SubWithC,
+                                                ///< pps_scaling_win_top_offset  * SubHeigtC, pps_scaling_win_bottom_offset * SubHiehgtC
+    int ref_width;                              ///< CurrPicScalWinWidthL
+    int ref_height;                             ///< CurrPicScalWinHeightL
+
     struct VVCFrame *collocated_ref;
 
     struct FrameProgress *progress;             ///< RefStruct reference
diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index 954db4a8c8..fb42963034 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -114,10 +114,12 @@ static FrameProgress *alloc_progress(void)
 
 static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc)
 {
+    const VVCSPS *sps = fc->ps.sps;
     const VVCPPS *pps = fc->ps.pps;
     for (int i = 0; i < FF_ARRAY_ELEMS(fc->DPB); i++) {
         int ret;
         VVCFrame *frame = &fc->DPB[i];
+        VVCWindow *win = &frame->scaling_win;
         if (frame->frame->buf[0])
             continue;
 
@@ -144,6 +146,13 @@ static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc)
         for (int j = 0; j < frame->ctb_count; j++)
             frame->rpl_tab[j] = frame->rpl;
 
+        win->left_offset   = pps->r->pps_scaling_win_left_offset   << sps->hshift[CHROMA];
+        win->right_offset  = pps->r->pps_scaling_win_right_offset  << sps->hshift[CHROMA];
+        win->top_offset    = pps->r->pps_scaling_win_top_offset    << sps->vshift[CHROMA];
+        win->bottom_offset = pps->r->pps_scaling_win_bottom_offset << sps->vshift[CHROMA];
+        frame->ref_width   = pps->r->pps_pic_width_in_luma_samples  - win->left_offset   - win->right_offset;
+        frame->ref_height  = pps->r->pps_pic_height_in_luma_samples - win->bottom_offset - win->top_offset;
+
         frame->progress = alloc_progress();
         if (!frame->progress)
             goto fail;
@@ -353,6 +362,24 @@ static VVCFrame *generate_missing_ref(VVCContext *s, VVCFrameContext *fc, int po
     return frame;
 }
 
+#define CHECK_MAX(d) (frame->ref_##d * frame->sps->r->sps_pic_##d##_max_in_luma_samples >= ref->ref_##d * (frame->pps->r->pps_pic_##d##_in_luma_samples - max))
+#define CHECK_SAMPLES(d) (frame->pps->r->pps_pic_##d##_in_luma_samples == ref->pps->r->pps_pic_##d##_in_luma_samples)
+static int check_candidate_ref(const VVCFrame *frame, const VVCRefPic *refp)
+{
+    const VVCFrame *ref = refp->ref;
+
+    if (refp->is_scaled) {
+        const int max = FFMAX(8, frame->sps->min_cb_size_y);
+        return frame->ref_width * 2 >= ref->ref_width &&
+            frame->ref_height * 2 >= ref->ref_height &&
+            frame->ref_width <= ref->ref_width * 8 &&
+            frame->ref_height <= ref->ref_height * 8 &&
+            CHECK_MAX(width) && CHECK_MAX(height);
+    }
+    return CHECK_SAMPLES(width) && CHECK_SAMPLES(height);
+}
+
+#define RPR_SCALE(f) (((ref->f << 14) + (fc->ref->f >> 1)) / fc->ref->f)
 /* add a reference with the given poc to the list and mark it as used in DPB */
 static int add_candidate_ref(VVCContext *s, VVCFrameContext *fc, RefPicList *list,
                              int poc, int ref_flag, uint8_t use_msb)
@@ -372,6 +399,18 @@ static int add_candidate_ref(VVCContext *s, VVCFrameContext *fc, RefPicList *lis
     refp->poc = poc;
     refp->ref = ref;
     refp->is_lt = ref_flag & VVC_FRAME_FLAG_LONG_REF;
+    refp->is_scaled = ref->sps->r->sps_num_subpics_minus1 != fc->ref->sps->r->sps_num_subpics_minus1||
+        memcmp(&ref->scaling_win, &fc->ref->scaling_win, sizeof(ref->scaling_win)) ||
+        ref->pps->r->pps_pic_width_in_luma_samples != fc->ref->pps->r->pps_pic_width_in_luma_samples ||
+        ref->pps->r->pps_pic_height_in_luma_samples != fc->ref->pps->r->pps_pic_height_in_luma_samples;
+
+    if (!check_candidate_ref(fc->ref, refp))
+        return AVERROR_INVALIDDATA;
+
+    if (refp->is_scaled) {
+        refp->scale[0] = RPR_SCALE(ref_width);
+        refp->scale[1] = RPR_SCALE(ref_height);
+    }
     list->nb_refs++;
 
     mark_ref(ref, ref_flag);
diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
index 2654b40058..8777d380bf 100644
--- a/libavcodec/vvc/thread.c
+++ b/libavcodec/vvc/thread.c
@@ -293,10 +293,14 @@ static void schedule_inter(VVCContext *s, VVCFrameContext *fc, const SliceContex
         CTU *ctu = fc->tab.ctus + rs;
         for (int lx = 0; lx < 2; lx++) {
             for (int i = 0; i < sh->r->num_ref_idx_active[lx]; i++) {
-                const int y = ctu->max_y[lx][i];
-                VVCFrame *ref = sc->rpl[lx].refs[i].ref;
-                if (ref && y >= 0)
+                int y = ctu->max_y[lx][i];
+                VVCRefPic *refp = sc->rpl[lx].refs + i;
+                VVCFrame *ref   = refp->ref;
+                if (ref && y >= 0) {
+                    if (refp->is_scaled)
+                        y = y * refp->scale[1] >> 14;
                     add_progress_listener(ref, &t->listener[lx][i], t, s, VVC_PROGRESS_PIXEL, y + LUMA_EXTRA_AFTER);
+                }
             }
         }
     }
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 13/18] avcodec/vvcdec: fix dmvr, bdof, cb_prof for RPR
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (10 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 12/18] avcodec/vvcdec: inter, wait reference with a diffrent resolution Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 14/18] avcodec/vvcdec: refact out luma_prof from luma_prof_bi Nuo Mi
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/ctu.c | 18 +++++++++---------
 libavcodec/vvc/mvs.c |  3 ++-
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
index 242caa58f7..809510b93d 100644
--- a/libavcodec/vvc/ctu.c
+++ b/libavcodec/vvc/ctu.c
@@ -1689,25 +1689,25 @@ static void derive_dmvr_bdof_flag(const VVCLocalContext *lc, PredictionUnit *pu)
     const VVCPH *ph             = &fc->ps.ph;
     const VVCSH *sh             = &lc->sc->sh;
     const int poc               = ph->poc;
-    const RefPicList *rpl0      = lc->sc->rpl + L0;
-    const RefPicList *rpl1      = lc->sc->rpl + L1;
-    const int8_t *ref_idx       = pu->mi.ref_idx;
     const MotionInfo *mi        = &pu->mi;
+    const int8_t *ref_idx       = mi->ref_idx;
+    const VVCRefPic *rp0        = &lc->sc->rpl[L0].refs[ref_idx[L0]];
+    const VVCRefPic *rp1        = &lc->sc->rpl[L1].refs[ref_idx[L1]];
     const CodingUnit *cu        = lc->cu;
     const PredWeightTable *w    = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt;
 
     pu->bdof_flag = 0;
 
     if (mi->pred_flag == PF_BI &&
-        (poc - rpl0->refs[ref_idx[L0]].poc == rpl1->refs[ref_idx[L1]].poc - poc) &&
-        !rpl0->refs[ref_idx[L0]].is_lt && !rpl1->refs[ref_idx[L1]].is_lt &&
+        (poc - rp0->poc == rp1->poc - poc) &&
+        !rp0->is_lt && !rp1->is_lt &&
         !cu->ciip_flag &&
         !mi->bcw_idx &&
-        !w->weight_flag[L0][LUMA][mi->ref_idx[L0]] && !w->weight_flag[L1][LUMA][mi->ref_idx[L1]] &&
-        !w->weight_flag[L0][CHROMA][mi->ref_idx[L0]] && !w->weight_flag[L1][CHROMA][mi->ref_idx[L1]] &&
+        !w->weight_flag[L0][LUMA][ref_idx[L0]] && !w->weight_flag[L1][LUMA][ref_idx[L1]] &&
+        !w->weight_flag[L0][CHROMA][ref_idx[L0]] && !w->weight_flag[L1][CHROMA][ref_idx[L1]] &&
         cu->cb_width >= 8 && cu->cb_height >= 8 &&
-        (cu->cb_width * cu->cb_height >= 128)) {
-        // fixme: for RprConstraintsActiveFlag
+        (cu->cb_width * cu->cb_height >= 128) &&
+        !rp0->is_scaled && !rp1->is_scaled) {
         if (!ph->r->ph_bdof_disabled_flag &&
             mi->motion_model_idc == MOTION_TRANSLATION &&
             !pu->merge_subblock_flag &&
diff --git a/libavcodec/vvc/mvs.c b/libavcodec/vvc/mvs.c
index 9407fbfd8a..e78a9b4694 100644
--- a/libavcodec/vvc/mvs.c
+++ b/libavcodec/vvc/mvs.c
@@ -297,7 +297,8 @@ static int derive_cb_prof_flag_lx(const VVCLocalContext *lc, const PredictionUni
         if (IS_SAME_MV(cp_mv, cp_mv + 1) && IS_SAME_MV(cp_mv, cp_mv + 2))
             return 0;
     }
-    //fixme: RprConstraintsActiveFlag
+    if (lc->sc->rpl[lx].refs[mi->ref_idx[lx]].is_scaled)
+        return 0;
     return 1;
 }
 
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 14/18] avcodec/vvcdec: refact out luma_prof from luma_prof_bi
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (11 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 13/18] avcodec/vvcdec: fix dmvr, bdof, cb_prof for RPR Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 15/18] avcodec/vvcdec: refact, remove hf_idx and vf_idx from mc_xxx's param list Nuo Mi
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/inter.c | 52 ++++++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 22 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index f432a2dc3c..23b9a8af6b 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -347,40 +347,48 @@ static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst
     }
 }
 
+static void luma_prof(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref,
+    const Mv *mv , const int x_off, const int y_off, const int block_w, const int block_h, const int lx)
+{
+    const VVCFrameContext *fc = lc->fc;
+    const PredictionUnit *pu  = &lc->cu->pu;
+    const int mx              = mv->x & 0xf;
+    const int my              = mv->y & 0xf;
+    const int ox              = x_off + (mv->x >> 4);
+    const int oy              = y_off + (mv->y >> 4);
+    const int idx             = av_log2(block_w) - 1;
+    const int is_chroma       = 0;
+    uint16_t *prof_tmp        = lc->tmp2 + PROF_TEMP_OFFSET;
+    ptrdiff_t src_stride      = ref->frame->linesize[0];
+    const uint8_t *src        = ref->frame->data[0] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
+    const int8_t *hf          = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
+    const int8_t *vf          = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
+
+    MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
+    if (!pu->cb_prof_flag[lx]) {
+        fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
+    } else {
+        fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
+        fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
+        fc->vvcdsp.inter.apply_prof(dst, prof_tmp, pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
+    }
+}
+
 static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
     const VVCFrame *ref0, const VVCFrame *ref1, const MvField *mvf, const int x_off, const int y_off,
     const int block_w, const int block_h)
 {
     const VVCFrameContext *fc   = lc->fc;
-    const PredictionUnit *pu    = &lc->cu->pu;
     const VVCFrame *refs[]      = { ref0, ref1 };
     int16_t *tmp[]              = { lc->tmp, lc->tmp1 };
-    uint16_t *prof_tmp          = lc->tmp2 + PROF_TEMP_OFFSET;
-    const int idx               = av_log2(block_w) - 1;
     int denom, w0, w1, o0, o1;
     const int weight_flag       = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, LUMA, 0);
-    const int is_chroma         = 0;
 
     for (int i = L0; i <= L1; i++) {
-        const Mv *mv            = mvf->mv + i;
-        const int mx            = mv->x & 0xf;
-        const int my            = mv->y & 0xf;
-        const int ox            = x_off + (mv->x >> 4);
-        const int oy            = y_off + (mv->y >> 4);
         const VVCFrame *ref     = refs[i];
-        ptrdiff_t src_stride    = ref->frame->linesize[LUMA];
-        const uint8_t *src      = ref->frame->data[LUMA] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
-        const int8_t *hf        = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
-        const int8_t *vf        = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
-
-        MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
-        if (!pu->cb_prof_flag[i]) {
-            fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](tmp[i], src, src_stride, block_h, hf, vf, block_w);
-        } else {
-            fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
-            fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
-            fc->vvcdsp.inter.apply_prof(tmp[i], prof_tmp, pu->diff_mv_x[i], pu->diff_mv_y[i]);
-        }
+        const Mv *mv            = mvf->mv + i;
+
+        luma_prof(lc, tmp[i], ref, mv, x_off, y_off, block_w, block_h, i);
     }
 
     if (weight_flag)
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 15/18] avcodec/vvcdec: refact, remove hf_idx and vf_idx from mc_xxx's param list
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (12 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 14/18] avcodec/vvcdec: refact out luma_prof from luma_prof_bi Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 16/18] avcodec/vvcdec: increase edge_emu_buffer for RPR Nuo Mi
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/inter.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 23b9a8af6b..5d553708d9 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -208,6 +208,7 @@ static void mc(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref, const Mv
     int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
 {
     const VVCFrameContext *fc   = lc->fc;
+    const PredictionUnit *pu    = &lc->cu->pu;
     const uint8_t *src          = ref->frame->data[c_idx];
     ptrdiff_t src_stride        = ref->frame->linesize[c_idx];
     const int is_chroma         = !!c_idx;
@@ -216,8 +217,9 @@ static void mc(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref, const Mv
     const int idx               = av_log2(block_w) - 1;
     const intptr_t mx           = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - hs);
     const intptr_t my           = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - vs);
-    const int8_t *hf            = INTER_FILTER(0, mx);
-    const int8_t *vf            = INTER_FILTER(0, my);
+    const int hpel_if_idx       = (is_chroma || pu->merge_gpm_flag) ? 0 : pu->mi.hpel_if_idx;
+    const int8_t *hf            = INTER_FILTER(hpel_if_idx, mx);
+    const int8_t *vf            = INTER_FILTER(hpel_if_idx, my);
 
     x_off += mv->x >> (4 + hs);
     y_off += mv->y >> (4 + vs);
@@ -229,9 +231,10 @@ static void mc(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref, const Mv
 
 static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
     const VVCFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
-    const int c_idx, const int hf_idx, const int vf_idx)
+    const int c_idx)
 {
     const VVCFrameContext *fc   = lc->fc;
+    const PredictionUnit *pu    = &lc->cu->pu;
     const uint8_t *src          = ref->frame->data[c_idx];
     ptrdiff_t src_stride        = ref->frame->linesize[c_idx];
     const int lx                = mvf->pred_flag - PF_L0;
@@ -242,8 +245,9 @@ static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride
     const int is_chroma         = !!c_idx;
     const intptr_t mx           = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - hs);
     const intptr_t my           = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - vs);
-    const int8_t *hf            = INTER_FILTER(hf_idx, mx);
-    const int8_t *vf            = INTER_FILTER(vf_idx, my);
+    const int hpel_if_idx       = is_chroma ? 0 : pu->mi.hpel_if_idx;
+    const int8_t *hf            = INTER_FILTER(hpel_if_idx, mx);
+    const int8_t *vf            = INTER_FILTER(hpel_if_idx, my);
     int denom, wx, ox;
 
     x_off += mv->x >> (4 + hs);
@@ -263,7 +267,7 @@ static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride
 static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
     const VVCFrame *ref0, const VVCFrame *ref1, const MvField *mvf, const MvField *orig_mv,
     const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx,
-    const int sb_bdof_flag, const int hf_idx, const int vf_idx)
+    const int sb_bdof_flag)
 {
     const VVCFrameContext *fc   = lc->fc;
     const PredictionUnit *pu    = &lc->cu->pu;
@@ -275,6 +279,7 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
     int denom, w0, w1, o0, o1;
     const int weight_flag       = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, pu->dmvr_flag);
     const int is_chroma         = !!c_idx;
+    const int hpel_if_idx       = is_chroma ? 0 : pu->mi.hpel_if_idx;
 
     for (int i = L0; i <= L1; i++) {
         const Mv *mv            = mvf->mv + i;
@@ -285,8 +290,8 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
         const VVCFrame *ref     = refs[i];
         ptrdiff_t src_stride    = ref->frame->linesize[c_idx];
         const uint8_t *src      = ref->frame->data[c_idx] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
-        const int8_t *hf        = INTER_FILTER(hf_idx, mx);
-        const int8_t *vf        = INTER_FILTER(vf_idx, my);
+        const int8_t *hf        = INTER_FILTER(hpel_if_idx, mx);
+        const int8_t *vf        = INTER_FILTER(hpel_if_idx, my);
 
         if (pu->dmvr_flag) {
             const int x_sb = x_off + (orig_mv->mv[i].x >> (4 + hs));
@@ -515,17 +520,15 @@ static void pred_regular(VVCLocalContext *lc, const MvField *mvf, const MvField
         const int do_ciip            = lc->cu->ciip_flag && (is_luma || (w > 2));
         uint8_t *inter               = do_ciip ? (uint8_t *)lc->ciip_tmp : dst;
         const ptrdiff_t inter_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst_stride;
-        const int hf_idx             = is_luma ? lc->cu->pu.mi.hpel_if_idx : 0;
-        const int vf_idx             = is_luma ? lc->cu->pu.mi.hpel_if_idx : 0;
         const int do_bdof            = is_luma && sb_bdof_flag;
 
         if (mvf->pred_flag != PF_BI) {
             const int lx = mvf->pred_flag - PF_L0;
             mc_uni(lc, inter, inter_stride, refp[lx]->ref, mvf,
-                x, y, w, h, c_idx, hf_idx, vf_idx);
+                x, y, w, h, c_idx);
         } else {
             mc_bi(lc, inter, inter_stride, refp[L0]->ref, refp[L1]->ref, mvf, orig_mvf,
-                x, y, w, h, c_idx, do_bdof, hf_idx, vf_idx);
+                x, y, w, h, c_idx, do_bdof);
         }
         if (do_ciip) {
             const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 16/18] avcodec/vvcdec: increase edge_emu_buffer for RPR
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (13 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 15/18] avcodec/vvcdec: refact, remove hf_idx and vf_idx from mc_xxx's param list Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 17/18] avcodec/vvcdec: support Reference Picture Resampling Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 18/18] Changelog: add DVB compatible information for VVC decoder Nuo Mi
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

---
 libavcodec/vvc/ctu.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vvc/ctu.h b/libavcodec/vvc/ctu.h
index 50109154aa..a987328d81 100644
--- a/libavcodec/vvc/ctu.h
+++ b/libavcodec/vvc/ctu.h
@@ -46,7 +46,8 @@
 #define MAX_QP                  63
 
 #define MAX_PB_SIZE             128
-#define EDGE_EMU_BUFFER_STRIDE  (MAX_PB_SIZE + 32)
+#define MAX_SCALING_RATIO       8
+#define EDGE_EMU_BUFFER_STRIDE  ((MAX_PB_SIZE + 32) * MAX_SCALING_RATIO)
 
 #define CHROMA_EXTRA_BEFORE     1
 #define CHROMA_EXTRA_AFTER      2
@@ -375,10 +376,8 @@ typedef struct VVCLocalContext {
     int     end_of_tiles_x;
     int     end_of_tiles_y;
 
-    /* +7 is for subpixel interpolation, *2 for high bit depths */
-    DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2];
-    /* The extended size between the new edge emu buffer is abused by SAO */
-    DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer2)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2];
+    /* *2 for high bit depths */
+    DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[EDGE_EMU_BUFFER_STRIDE * EDGE_EMU_BUFFER_STRIDE * 2];
     DECLARE_ALIGNED(32, int16_t, tmp)[MAX_PB_SIZE * MAX_PB_SIZE];
     DECLARE_ALIGNED(32, int16_t, tmp1)[MAX_PB_SIZE * MAX_PB_SIZE];
     DECLARE_ALIGNED(32, int16_t, tmp2)[MAX_PB_SIZE * MAX_PB_SIZE];
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 17/18] avcodec/vvcdec: support Reference Picture Resampling
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (14 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 16/18] avcodec/vvcdec: increase edge_emu_buffer for RPR Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 18/18] Changelog: add DVB compatible information for VVC decoder Nuo Mi
  16 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

passed clips:
    RPR_A_Alibaba_4.bit
    RPR_B_Alibaba_3.bit
    RPR_C_Alibaba_3.bit
    RPR_D_Qualcomm_1.bit
    VVC_HDR_UHDTV1_OpenGOP_Max3840x2160_50fps_HLG10_res_change_with_RPR.ts
---
 libavcodec/vvc/inter.c | 190 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 173 insertions(+), 17 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 5d553708d9..e1011b4fa1 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -313,6 +313,141 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
         fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
 }
 
+static const int8_t* inter_filter_scaled(const int scale, const int is_chroma, const int is_affine)
+{
+#define SCALE_THRESHOLD_1 20480
+#define SCALE_THRESHOLD_2 28672
+
+    const int i = (scale > SCALE_THRESHOLD_2) + (scale > SCALE_THRESHOLD_1);
+
+    if (!is_chroma) {
+        if (!is_affine)
+            return &ff_vvc_inter_luma_filters[i + !!i][0][0];   //hpel 1 is not needed for scaled
+        return &ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE + i][0][0];
+    }
+
+    return &ff_vvc_inter_chroma_filters[i][0][0];
+}
+#define INTER_FILTER_SCALED(scale) inter_filter_scaled(scale, is_chroma, is_affine)
+
+#define SCALED_CHROMA_ADDIN(scale, collocated_flag) (is_chroma ? (collocated_flag ? 0 : 8 * (scale - (1 << 14))) : 0)
+#define SCALED_REF_SB(off, scaling_off, ref_mv, scale, add, shift) ((((off - (scaling_off << shift)) << (4 + shift)) + ref_mv) * scale + add)
+#define SCALED_REF(ref_sb, offset, shift) (FFSIGN(ref_sb) * ((FFABS(ref_sb) + (128 << is_chroma)) >> (8 + is_chroma)) + (offset << (10 - shift)) + (32 >> is_chroma))
+#define SCALED_STEP(scale) ((scale + 8) >> 4)
+
+static void scaled_ref_pos_and_step(const VVCLocalContext *lc, const VVCRefPic *refp, const Mv *mv, const int x_off, const int y_off, const int c_idx,
+    int *x, int *y, int *dx, int *dy)
+{
+    const VVCFrameContext *fc = lc->fc;
+    const VVCSPS *sps         = fc->ps.sps;
+    const int is_chroma       = !!c_idx;
+    const int hs              = sps->hshift[c_idx];
+    const int vs              = sps->vshift[c_idx];
+    const int left_offset     = fc->ref->scaling_win.left_offset;
+    const int top_offset      = fc->ref->scaling_win.top_offset;
+    const int addx            = SCALED_CHROMA_ADDIN(refp->scale[0], sps->r->sps_chroma_horizontal_collocated_flag);
+    const int addy            = SCALED_CHROMA_ADDIN(refp->scale[1], sps->r->sps_chroma_vertical_collocated_flag);
+    const int refx_sb         = SCALED_REF_SB(x_off, left_offset, mv->x, refp->scale[0], addx, hs);
+    const int refy_sb         = SCALED_REF_SB(y_off, top_offset,  mv->y, refp->scale[1], addy, vs);
+
+    *x  = SCALED_REF(refx_sb, left_offset, hs);
+    *y  = SCALED_REF(refy_sb, top_offset, vs);
+    *dx = SCALED_STEP(refp->scale[0]);
+    *dy = SCALED_STEP(refp->scale[1]);
+}
+
+static void emulated_edge_scaled(VVCLocalContext *lc, const uint8_t **src, ptrdiff_t *src_stride, int *src_height,
+    const VVCFrame *ref, const int x, const int y, const int dx, const int dy,
+    const int block_w, const int block_h, const int is_chroma)
+{
+    const VVCFrameContext *fc = lc->fc;
+    const int x0              = SCALED_INT(x);
+    const int y0              = SCALED_INT(y);
+    const int x_end           = SCALED_INT(x + block_w * dx);
+    const int y_end           = SCALED_INT(y + block_h * dy);
+    const int x_last          = SCALED_INT(x + (block_w - 1) * dx);
+    const int y_last          = SCALED_INT(y + (block_h - 1) * dy);
+    const int src_width       = x_end - x0 + (x_end == x_last);
+
+    *src_height = y_end - y0 + (y_end == y_last);
+
+    *src  += y0 * *src_stride + (x0 * (1 << fc->ps.sps->pixel_shift));
+
+    emulated_edge(lc, lc->edge_emu_buffer, src, src_stride, ref, x0, y0, src_width, *src_height, is_chroma);
+}
+
+static void mc_scaled(VVCLocalContext *lc, int16_t *dst, const VVCRefPic *refp, const Mv *mv,
+    int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
+{
+    const VVCFrameContext *fc = lc->fc;
+    const PredictionUnit *pu  = &lc->cu->pu;
+    const uint8_t *src        = refp->ref->frame->data[c_idx];
+    ptrdiff_t src_stride      = refp->ref->frame->linesize[c_idx];
+    const int is_affine       = pu->inter_affine_flag;
+    const int is_chroma       = !!c_idx;
+    const int idx             = av_log2(block_w) - 1;
+    const int8_t *hf          = INTER_FILTER_SCALED(refp->scale[0]);
+    const int8_t *vf          = INTER_FILTER_SCALED(refp->scale[1]);
+    int x, y, dx, dy, src_height;
+
+    scaled_ref_pos_and_step(lc, refp, mv, x_off, y_off, c_idx, &x, &y, &dx, &dy);
+    emulated_edge_scaled(lc, &src, &src_stride, &src_height, refp->ref, x, y, dx, dy, block_w, block_h, is_chroma);
+    fc->vvcdsp.inter.put_scaled[is_chroma][idx](dst, src, src_stride, src_height, x, y, dx, dy, block_h, hf, vf, block_w);
+}
+
+static void mc_uni_scaled(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const VVCRefPic *refp,
+    const MvField *mvf, const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx)
+{
+    const VVCFrameContext *fc = lc->fc;
+    const PredictionUnit *pu  = &lc->cu->pu;
+    const uint8_t *src        = refp->ref->frame->data[c_idx];
+    ptrdiff_t src_stride      = refp->ref->frame->linesize[c_idx];
+    const int lx              = mvf->pred_flag - PF_L0;
+    const Mv *mv              = &mvf->mv[lx];
+    const int is_affine       = pu->inter_affine_flag;
+    const int is_chroma       = !!c_idx;
+    const int idx             = av_log2(block_w) - 1;
+    const int8_t *hf          = INTER_FILTER_SCALED(refp->scale[0]);
+    const int8_t *vf          = INTER_FILTER_SCALED(refp->scale[1]);
+    int denom, wx, ox, x, y, dx, dy, src_height;
+
+    scaled_ref_pos_and_step(lc, refp, mv, x_off, y_off, c_idx, &x, &y, &dx, &dy);
+    emulated_edge_scaled(lc, &src, &src_stride, &src_height, refp->ref, x, y, dx, dy, block_w, block_h, is_chroma);
+
+    if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, c_idx)) {
+        fc->vvcdsp.inter.put_uni_w_scaled[is_chroma][idx](dst, dst_stride, src, src_stride, src_height,
+            x, y, dx, dy, block_h, denom, wx, ox, hf, vf, block_w);
+    } else {
+        fc->vvcdsp.inter.put_uni_scaled[is_chroma][idx](dst, dst_stride, src, src_stride, src_height,
+            x, y, dx, dy, block_h, hf, vf, block_w);
+    }
+}
+
+static void mc_bi_scaled(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
+   const VVCRefPic *refp0, const VVCRefPic *refp1, const MvField *mvf,
+   const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx)
+{
+    int denom, w0, w1, o0, o1;
+    const VVCFrameContext *fc = lc->fc;
+    const int weight_flag     = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, lc->cu->pu.dmvr_flag);
+    const VVCRefPic *refps[]  = { refp0, refp1 };
+    int16_t *tmp[]            = { lc->tmp, lc->tmp1 };
+
+    for (int i = L0; i <= L1; i++) {
+        const Mv *mv          = mvf->mv + i;
+        const VVCRefPic *refp = refps[i];
+
+        if (refp->is_scaled)
+            mc_scaled(lc, tmp[i], refp, mv, x_off, y_off, block_w, block_h, c_idx);
+        else
+            mc(lc, tmp[i], refp->ref, mv, x_off, y_off, block_w, block_h, c_idx);
+    }
+    if (weight_flag)
+        fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1);
+    else
+        fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
+}
+
 static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
     const VVCFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
     const int cb_prof_flag, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
@@ -380,20 +515,23 @@ static void luma_prof(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref,
 }
 
 static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
-    const VVCFrame *ref0, const VVCFrame *ref1, const MvField *mvf, const int x_off, const int y_off,
+    const VVCRefPic *ref0, const VVCRefPic *ref1, const MvField *mvf, const int x_off, const int y_off,
     const int block_w, const int block_h)
 {
     const VVCFrameContext *fc   = lc->fc;
-    const VVCFrame *refs[]      = { ref0, ref1 };
+    const VVCRefPic *refps[]    = { ref0, ref1 };
     int16_t *tmp[]              = { lc->tmp, lc->tmp1 };
     int denom, w0, w1, o0, o1;
     const int weight_flag       = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, LUMA, 0);
 
     for (int i = L0; i <= L1; i++) {
-        const VVCFrame *ref     = refs[i];
-        const Mv *mv            = mvf->mv + i;
+        const VVCRefPic *refp = refps[i];
+        const Mv *mv          = mvf->mv + i;
 
-        luma_prof(lc, tmp[i], ref, mv, x_off, y_off, block_w, block_h, i);
+        if (refp->is_scaled)
+            mc_scaled(lc, tmp[i], refp, mv, x_off, y_off, block_w, block_h, LUMA);
+        else
+            luma_prof(lc, tmp[i], refp->ref, mv, x_off, y_off, block_w, block_h, i);
     }
 
     if (weight_flag)
@@ -465,10 +603,13 @@ static void pred_gpm_blk(VVCLocalContext *lc)
         for (int i = 0; i < 2; i++) {
             const MvField *mv = pu->gpm_mv + i;
             const int lx = mv->pred_flag - PF_L0;
-            VVCFrame *ref = lc->sc->rpl[lx].refs[mv->ref_idx[lx]].ref;
-            if (!ref)
+            VVCRefPic *refp = lc->sc->rpl[lx].refs + mv->ref_idx[lx];
+            if (!refp->ref)
                 return;
-            mc(lc, tmp[i], ref, mv->mv + lx, x, y, width, height, c_idx);
+            if (refp->is_scaled)
+                mc_scaled(lc, tmp[i], refp, mv->mv + lx, x, y, width, height, c_idx);
+            else
+                mc(lc, tmp[i], refp->ref, mv->mv + lx, x, y, width, height, c_idx);
         }
         fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y);
     }
@@ -524,11 +665,22 @@ static void pred_regular(VVCLocalContext *lc, const MvField *mvf, const MvField
 
         if (mvf->pred_flag != PF_BI) {
             const int lx = mvf->pred_flag - PF_L0;
-            mc_uni(lc, inter, inter_stride, refp[lx]->ref, mvf,
-                x, y, w, h, c_idx);
+
+            if (refp[lx]->is_scaled) {
+                mc_uni_scaled(lc, inter, inter_stride, refp[lx], mvf,
+                    x, y, w, h, c_idx);
+            } else {
+                mc_uni(lc, inter, inter_stride, refp[lx]->ref, mvf,
+                    x, y, w, h, c_idx);
+            }
         } else {
-            mc_bi(lc, inter, inter_stride, refp[L0]->ref, refp[L1]->ref, mvf, orig_mvf,
-                x, y, w, h, c_idx, do_bdof);
+            if (refp[L0]->is_scaled || refp[L1]->is_scaled) {
+                mc_bi_scaled(lc, inter, inter_stride, refp[L0], refp[L1], mvf,
+                    x, y, w, h, c_idx);
+            } else {
+                mc_bi(lc, inter, inter_stride, refp[L0]->ref, refp[L1]->ref, mvf, orig_mvf,
+                    x, y, w, h, c_idx, do_bdof);
+            }
         }
         if (do_ciip) {
             const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
@@ -739,6 +891,7 @@ static void pred_affine_blk(VVCLocalContext *lc)
     const int sbh  = cu->cb_height / mi->num_sb_y;
     const int hs = fc->ps.sps->hshift[1];
     const int vs = fc->ps.sps->vshift[1];
+    const int dst_stride = fc->frame->linesize[LUMA];
 
     for (int sby = 0; sby < mi->num_sb_y; sby++) {
         for (int sbx = 0; sbx < mi->num_sb_x; sbx++) {
@@ -754,12 +907,15 @@ static void pred_affine_blk(VVCLocalContext *lc)
 
             if (mi->pred_flag != PF_BI) {
                 const int lx = mi->pred_flag - PF_L0;
-                luma_prof_uni(lc, dst0, fc->frame->linesize[LUMA], refp[lx]->ref,
-                    mv, x, y, sbw, sbh, pu->cb_prof_flag[lx],
-                    pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
+                if (refp[lx]->is_scaled) {
+                    mc_uni_scaled(lc, dst0, dst_stride, refp[lx], mv, x, y, sbw, sbh, LUMA);
+                } else {
+                    luma_prof_uni(lc, dst0, dst_stride, refp[lx]->ref,
+                        mv, x, y, sbw, sbh, pu->cb_prof_flag[lx],
+                        pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
+                }
             } else {
-                luma_prof_bi(lc, dst0, fc->frame->linesize[LUMA], refp[L0]->ref, refp[L1]->ref,
-                    mv, x, y, sbw, sbh);
+                luma_prof_bi(lc, dst0, dst_stride, refp[L0], refp[L1], mv, x, y, sbw, sbh);
             }
             if (fc->ps.sps->r->sps_chroma_format_idc) {
                 if (!av_mod_uintp2(sby, vs) && !av_mod_uintp2(sbx, hs)) {
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH 18/18] Changelog: add DVB compatible information for VVC decoder
       [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
                   ` (15 preceding siblings ...)
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 17/18] avcodec/vvcdec: support Reference Picture Resampling Nuo Mi
@ 2024-05-19 13:27 ` Nuo Mi
  2024-05-21 12:32   ` Nuo Mi
  16 siblings, 1 reply; 20+ messages in thread
From: Nuo Mi @ 2024-05-19 13:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nuo Mi

see https://dvb.org/specifications/verification-validation/vvc-test-content/
---
 Changelog | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Changelog b/Changelog
index dd25715d6b..12770e4296 100644
--- a/Changelog
+++ b/Changelog
@@ -10,6 +10,7 @@ version <next>:
 - vf_scale supports secondary ref input and framesync options
 - vf_scale2ref deprecated
 - qsv_params option added for QSV encoders
+- VVC decoder compatible with DVB test content
 
 
 version 7.0:
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH 12/18] avcodec/vvcdec: inter, wait reference with a diffrent resolution
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 12/18] avcodec/vvcdec: inter, wait reference with a diffrent resolution Nuo Mi
@ 2024-05-19 15:20   ` Jean-Baptiste Kempf
  2024-05-20 13:25     ` Nuo Mi
  0 siblings, 1 reply; 20+ messages in thread
From: Jean-Baptiste Kempf @ 2024-05-19 15:20 UTC (permalink / raw)
  To: ffmpeg-devel

Careful about the typo on "different" on the title of the patch.

On Sun, 19 May 2024, at 13:27, Nuo Mi wrote:
> For RPR, the current frame may reference a frame with a different resolution.
> Therefore, we need to consider frame scaling when we wait for reference pixels.
> ---
>  libavcodec/vvc/dec.c    |  5 +++++
>  libavcodec/vvc/dec.h    | 17 +++++++++++++++++
>  libavcodec/vvc/refs.c   | 39 +++++++++++++++++++++++++++++++++++++++
>  libavcodec/vvc/thread.c | 10 +++++++---
>  4 files changed, 68 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
> index 3325133efb..584c7b219f 100644
> --- a/libavcodec/vvc/dec.c
> +++ b/libavcodec/vvc/dec.c
> @@ -573,6 +573,11 @@ static int ref_frame(VVCFrame *dst, const VVCFrame *src)
> 
>      dst->poc = src->poc;
>      dst->ctb_count = src->ctb_count;
> +
> +    dst->scaling_win = src->scaling_win;
> +    dst->ref_width   = src->ref_width;
> +    dst->ref_height  = src->ref_height;
> +
>      dst->flags = src->flags;
>      dst->sequence = src->sequence;
> 
> diff --git a/libavcodec/vvc/dec.h b/libavcodec/vvc/dec.h
> index 6f14cc1860..1e0b76f283 100644
> --- a/libavcodec/vvc/dec.h
> +++ b/libavcodec/vvc/dec.h
> @@ -46,6 +46,10 @@ typedef struct VVCRefPic {
>      struct VVCFrame *ref;
>      int poc;
>      int is_lt;                  // is long term reference
> +
> +    // for RPR
> +    int is_scaled;              ///< RprConstraintsActiveFlag
> +    int scale[2];               ///< RefPicScale[]
>  } VVCRefPic;
> 
>  typedef struct RefPicList {
> @@ -57,6 +61,13 @@ typedef struct RefPicListTab {
>      RefPicList refPicList[2];
>  } RefPicListTab;
> 
> +typedef struct VVCWindow {
> +    int16_t left_offset;
> +    int16_t right_offset;
> +    int16_t top_offset;
> +    int16_t bottom_offset;
> +} VVCWindow;
> +
>  typedef struct VVCFrame {
>      struct AVFrame *frame;
> 
> @@ -71,6 +82,12 @@ typedef struct VVCFrame {
> 
>      int poc;
> 
> +    //for RPR
> +    VVCWindow scaling_win;                      ///< 
> pps_scaling_win_left_offset * SubWithC,  pps_scaling_win_right_offset  
> * SubWithC,
> +                                                ///< 
> pps_scaling_win_top_offset  * SubHeigtC, pps_scaling_win_bottom_offset 
> * SubHiehgtC
> +    int ref_width;                              ///< 
> CurrPicScalWinWidthL
> +    int ref_height;                             ///< 
> CurrPicScalWinHeightL
> +
>      struct VVCFrame *collocated_ref;
> 
>      struct FrameProgress *progress;             ///< RefStruct reference
> diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
> index 954db4a8c8..fb42963034 100644
> --- a/libavcodec/vvc/refs.c
> +++ b/libavcodec/vvc/refs.c
> @@ -114,10 +114,12 @@ static FrameProgress *alloc_progress(void)
> 
>  static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc)
>  {
> +    const VVCSPS *sps = fc->ps.sps;
>      const VVCPPS *pps = fc->ps.pps;
>      for (int i = 0; i < FF_ARRAY_ELEMS(fc->DPB); i++) {
>          int ret;
>          VVCFrame *frame = &fc->DPB[i];
> +        VVCWindow *win = &frame->scaling_win;
>          if (frame->frame->buf[0])
>              continue;
> 
> @@ -144,6 +146,13 @@ static VVCFrame *alloc_frame(VVCContext *s, 
> VVCFrameContext *fc)
>          for (int j = 0; j < frame->ctb_count; j++)
>              frame->rpl_tab[j] = frame->rpl;
> 
> +        win->left_offset   = pps->r->pps_scaling_win_left_offset   << 
> sps->hshift[CHROMA];
> +        win->right_offset  = pps->r->pps_scaling_win_right_offset  << 
> sps->hshift[CHROMA];
> +        win->top_offset    = pps->r->pps_scaling_win_top_offset    << 
> sps->vshift[CHROMA];
> +        win->bottom_offset = pps->r->pps_scaling_win_bottom_offset << 
> sps->vshift[CHROMA];
> +        frame->ref_width   = pps->r->pps_pic_width_in_luma_samples  - 
> win->left_offset   - win->right_offset;
> +        frame->ref_height  = pps->r->pps_pic_height_in_luma_samples - 
> win->bottom_offset - win->top_offset;
> +
>          frame->progress = alloc_progress();
>          if (!frame->progress)
>              goto fail;
> @@ -353,6 +362,24 @@ static VVCFrame *generate_missing_ref(VVCContext 
> *s, VVCFrameContext *fc, int po
>      return frame;
>  }
> 
> +#define CHECK_MAX(d) (frame->ref_##d * 
> frame->sps->r->sps_pic_##d##_max_in_luma_samples >= ref->ref_##d * 
> (frame->pps->r->pps_pic_##d##_in_luma_samples - max))
> +#define CHECK_SAMPLES(d) (frame->pps->r->pps_pic_##d##_in_luma_samples 
> == ref->pps->r->pps_pic_##d##_in_luma_samples)
> +static int check_candidate_ref(const VVCFrame *frame, const VVCRefPic 
> *refp)
> +{
> +    const VVCFrame *ref = refp->ref;
> +
> +    if (refp->is_scaled) {
> +        const int max = FFMAX(8, frame->sps->min_cb_size_y);
> +        return frame->ref_width * 2 >= ref->ref_width &&
> +            frame->ref_height * 2 >= ref->ref_height &&
> +            frame->ref_width <= ref->ref_width * 8 &&
> +            frame->ref_height <= ref->ref_height * 8 &&
> +            CHECK_MAX(width) && CHECK_MAX(height);
> +    }
> +    return CHECK_SAMPLES(width) && CHECK_SAMPLES(height);
> +}
> +
> +#define RPR_SCALE(f) (((ref->f << 14) + (fc->ref->f >> 1)) / 
> fc->ref->f)
>  /* add a reference with the given poc to the list and mark it as used 
> in DPB */
>  static int add_candidate_ref(VVCContext *s, VVCFrameContext *fc, 
> RefPicList *list,
>                               int poc, int ref_flag, uint8_t use_msb)
> @@ -372,6 +399,18 @@ static int add_candidate_ref(VVCContext *s, 
> VVCFrameContext *fc, RefPicList *lis
>      refp->poc = poc;
>      refp->ref = ref;
>      refp->is_lt = ref_flag & VVC_FRAME_FLAG_LONG_REF;
> +    refp->is_scaled = ref->sps->r->sps_num_subpics_minus1 != 
> fc->ref->sps->r->sps_num_subpics_minus1||
> +        memcmp(&ref->scaling_win, &fc->ref->scaling_win, 
> sizeof(ref->scaling_win)) ||
> +        ref->pps->r->pps_pic_width_in_luma_samples != 
> fc->ref->pps->r->pps_pic_width_in_luma_samples ||
> +        ref->pps->r->pps_pic_height_in_luma_samples != 
> fc->ref->pps->r->pps_pic_height_in_luma_samples;
> +
> +    if (!check_candidate_ref(fc->ref, refp))
> +        return AVERROR_INVALIDDATA;
> +
> +    if (refp->is_scaled) {
> +        refp->scale[0] = RPR_SCALE(ref_width);
> +        refp->scale[1] = RPR_SCALE(ref_height);
> +    }
>      list->nb_refs++;
> 
>      mark_ref(ref, ref_flag);
> diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
> index 2654b40058..8777d380bf 100644
> --- a/libavcodec/vvc/thread.c
> +++ b/libavcodec/vvc/thread.c
> @@ -293,10 +293,14 @@ static void schedule_inter(VVCContext *s, 
> VVCFrameContext *fc, const SliceContex
>          CTU *ctu = fc->tab.ctus + rs;
>          for (int lx = 0; lx < 2; lx++) {
>              for (int i = 0; i < sh->r->num_ref_idx_active[lx]; i++) {
> -                const int y = ctu->max_y[lx][i];
> -                VVCFrame *ref = sc->rpl[lx].refs[i].ref;
> -                if (ref && y >= 0)
> +                int y = ctu->max_y[lx][i];
> +                VVCRefPic *refp = sc->rpl[lx].refs + i;
> +                VVCFrame *ref   = refp->ref;
> +                if (ref && y >= 0) {
> +                    if (refp->is_scaled)
> +                        y = y * refp->scale[1] >> 14;
>                      add_progress_listener(ref, &t->listener[lx][i], t, 
> s, VVC_PROGRESS_PIXEL, y + LUMA_EXTRA_AFTER);
> +                }
>              }
>          }
>      }
> -- 
> 2.34.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
https://jbkempf.com/
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH 12/18] avcodec/vvcdec: inter, wait reference with a diffrent resolution
  2024-05-19 15:20   ` Jean-Baptiste Kempf
@ 2024-05-20 13:25     ` Nuo Mi
  0 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-20 13:25 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sun, May 19, 2024 at 11:21 PM Jean-Baptiste Kempf <jb@videolan.org>
wrote:

> Careful about the typo on "different" on the title of the patch.
>
Changed locally.
Thank you, jb

>
> On Sun, 19 May 2024, at 13:27, Nuo Mi wrote:
> > For RPR, the current frame may reference a frame with a different
> resolution.
> > Therefore, we need to consider frame scaling when we wait for reference
> pixels.
> > ---
> >  libavcodec/vvc/dec.c    |  5 +++++
> >  libavcodec/vvc/dec.h    | 17 +++++++++++++++++
> >  libavcodec/vvc/refs.c   | 39 +++++++++++++++++++++++++++++++++++++++
> >  libavcodec/vvc/thread.c | 10 +++++++---
> >  4 files changed, 68 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
> > index 3325133efb..584c7b219f 100644
> > --- a/libavcodec/vvc/dec.c
> > +++ b/libavcodec/vvc/dec.c
> > @@ -573,6 +573,11 @@ static int ref_frame(VVCFrame *dst, const VVCFrame
> *src)
> >
> >      dst->poc = src->poc;
> >      dst->ctb_count = src->ctb_count;
> > +
> > +    dst->scaling_win = src->scaling_win;
> > +    dst->ref_width   = src->ref_width;
> > +    dst->ref_height  = src->ref_height;
> > +
> >      dst->flags = src->flags;
> >      dst->sequence = src->sequence;
> >
> > diff --git a/libavcodec/vvc/dec.h b/libavcodec/vvc/dec.h
> > index 6f14cc1860..1e0b76f283 100644
> > --- a/libavcodec/vvc/dec.h
> > +++ b/libavcodec/vvc/dec.h
> > @@ -46,6 +46,10 @@ typedef struct VVCRefPic {
> >      struct VVCFrame *ref;
> >      int poc;
> >      int is_lt;                  // is long term reference
> > +
> > +    // for RPR
> > +    int is_scaled;              ///< RprConstraintsActiveFlag
> > +    int scale[2];               ///< RefPicScale[]
> >  } VVCRefPic;
> >
> >  typedef struct RefPicList {
> > @@ -57,6 +61,13 @@ typedef struct RefPicListTab {
> >      RefPicList refPicList[2];
> >  } RefPicListTab;
> >
> > +typedef struct VVCWindow {
> > +    int16_t left_offset;
> > +    int16_t right_offset;
> > +    int16_t top_offset;
> > +    int16_t bottom_offset;
> > +} VVCWindow;
> > +
> >  typedef struct VVCFrame {
> >      struct AVFrame *frame;
> >
> > @@ -71,6 +82,12 @@ typedef struct VVCFrame {
> >
> >      int poc;
> >
> > +    //for RPR
> > +    VVCWindow scaling_win;                      ///<
> > pps_scaling_win_left_offset * SubWithC,  pps_scaling_win_right_offset
> > * SubWithC,
> > +                                                ///<
> > pps_scaling_win_top_offset  * SubHeigtC, pps_scaling_win_bottom_offset
> > * SubHiehgtC
> > +    int ref_width;                              ///<
> > CurrPicScalWinWidthL
> > +    int ref_height;                             ///<
> > CurrPicScalWinHeightL
> > +
> >      struct VVCFrame *collocated_ref;
> >
> >      struct FrameProgress *progress;             ///< RefStruct reference
> > diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
> > index 954db4a8c8..fb42963034 100644
> > --- a/libavcodec/vvc/refs.c
> > +++ b/libavcodec/vvc/refs.c
> > @@ -114,10 +114,12 @@ static FrameProgress *alloc_progress(void)
> >
> >  static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc)
> >  {
> > +    const VVCSPS *sps = fc->ps.sps;
> >      const VVCPPS *pps = fc->ps.pps;
> >      for (int i = 0; i < FF_ARRAY_ELEMS(fc->DPB); i++) {
> >          int ret;
> >          VVCFrame *frame = &fc->DPB[i];
> > +        VVCWindow *win = &frame->scaling_win;
> >          if (frame->frame->buf[0])
> >              continue;
> >
> > @@ -144,6 +146,13 @@ static VVCFrame *alloc_frame(VVCContext *s,
> > VVCFrameContext *fc)
> >          for (int j = 0; j < frame->ctb_count; j++)
> >              frame->rpl_tab[j] = frame->rpl;
> >
> > +        win->left_offset   = pps->r->pps_scaling_win_left_offset   <<
> > sps->hshift[CHROMA];
> > +        win->right_offset  = pps->r->pps_scaling_win_right_offset  <<
> > sps->hshift[CHROMA];
> > +        win->top_offset    = pps->r->pps_scaling_win_top_offset    <<
> > sps->vshift[CHROMA];
> > +        win->bottom_offset = pps->r->pps_scaling_win_bottom_offset <<
> > sps->vshift[CHROMA];
> > +        frame->ref_width   = pps->r->pps_pic_width_in_luma_samples  -
> > win->left_offset   - win->right_offset;
> > +        frame->ref_height  = pps->r->pps_pic_height_in_luma_samples -
> > win->bottom_offset - win->top_offset;
> > +
> >          frame->progress = alloc_progress();
> >          if (!frame->progress)
> >              goto fail;
> > @@ -353,6 +362,24 @@ static VVCFrame *generate_missing_ref(VVCContext
> > *s, VVCFrameContext *fc, int po
> >      return frame;
> >  }
> >
> > +#define CHECK_MAX(d) (frame->ref_##d *
> > frame->sps->r->sps_pic_##d##_max_in_luma_samples >= ref->ref_##d *
> > (frame->pps->r->pps_pic_##d##_in_luma_samples - max))
> > +#define CHECK_SAMPLES(d) (frame->pps->r->pps_pic_##d##_in_luma_samples
> > == ref->pps->r->pps_pic_##d##_in_luma_samples)
> > +static int check_candidate_ref(const VVCFrame *frame, const VVCRefPic
> > *refp)
> > +{
> > +    const VVCFrame *ref = refp->ref;
> > +
> > +    if (refp->is_scaled) {
> > +        const int max = FFMAX(8, frame->sps->min_cb_size_y);
> > +        return frame->ref_width * 2 >= ref->ref_width &&
> > +            frame->ref_height * 2 >= ref->ref_height &&
> > +            frame->ref_width <= ref->ref_width * 8 &&
> > +            frame->ref_height <= ref->ref_height * 8 &&
> > +            CHECK_MAX(width) && CHECK_MAX(height);
> > +    }
> > +    return CHECK_SAMPLES(width) && CHECK_SAMPLES(height);
> > +}
> > +
> > +#define RPR_SCALE(f) (((ref->f << 14) + (fc->ref->f >> 1)) /
> > fc->ref->f)
> >  /* add a reference with the given poc to the list and mark it as used
> > in DPB */
> >  static int add_candidate_ref(VVCContext *s, VVCFrameContext *fc,
> > RefPicList *list,
> >                               int poc, int ref_flag, uint8_t use_msb)
> > @@ -372,6 +399,18 @@ static int add_candidate_ref(VVCContext *s,
> > VVCFrameContext *fc, RefPicList *lis
> >      refp->poc = poc;
> >      refp->ref = ref;
> >      refp->is_lt = ref_flag & VVC_FRAME_FLAG_LONG_REF;
> > +    refp->is_scaled = ref->sps->r->sps_num_subpics_minus1 !=
> > fc->ref->sps->r->sps_num_subpics_minus1||
> > +        memcmp(&ref->scaling_win, &fc->ref->scaling_win,
> > sizeof(ref->scaling_win)) ||
> > +        ref->pps->r->pps_pic_width_in_luma_samples !=
> > fc->ref->pps->r->pps_pic_width_in_luma_samples ||
> > +        ref->pps->r->pps_pic_height_in_luma_samples !=
> > fc->ref->pps->r->pps_pic_height_in_luma_samples;
> > +
> > +    if (!check_candidate_ref(fc->ref, refp))
> > +        return AVERROR_INVALIDDATA;
> > +
> > +    if (refp->is_scaled) {
> > +        refp->scale[0] = RPR_SCALE(ref_width);
> > +        refp->scale[1] = RPR_SCALE(ref_height);
> > +    }
> >      list->nb_refs++;
> >
> >      mark_ref(ref, ref_flag);
> > diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
> > index 2654b40058..8777d380bf 100644
> > --- a/libavcodec/vvc/thread.c
> > +++ b/libavcodec/vvc/thread.c
> > @@ -293,10 +293,14 @@ static void schedule_inter(VVCContext *s,
> > VVCFrameContext *fc, const SliceContex
> >          CTU *ctu = fc->tab.ctus + rs;
> >          for (int lx = 0; lx < 2; lx++) {
> >              for (int i = 0; i < sh->r->num_ref_idx_active[lx]; i++) {
> > -                const int y = ctu->max_y[lx][i];
> > -                VVCFrame *ref = sc->rpl[lx].refs[i].ref;
> > -                if (ref && y >= 0)
> > +                int y = ctu->max_y[lx][i];
> > +                VVCRefPic *refp = sc->rpl[lx].refs + i;
> > +                VVCFrame *ref   = refp->ref;
> > +                if (ref && y >= 0) {
> > +                    if (refp->is_scaled)
> > +                        y = y * refp->scale[1] >> 14;
> >                      add_progress_listener(ref, &t->listener[lx][i], t,
> > s, VVC_PROGRESS_PIXEL, y + LUMA_EXTRA_AFTER);
> > +                }
> >              }
> >          }
> >      }
> > --
> > 2.34.1
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
> --
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> https://jbkempf.com/
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH 18/18] Changelog: add DVB compatible information for VVC decoder
  2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 18/18] Changelog: add DVB compatible information for VVC decoder Nuo Mi
@ 2024-05-21 12:32   ` Nuo Mi
  0 siblings, 0 replies; 20+ messages in thread
From: Nuo Mi @ 2024-05-21 12:32 UTC (permalink / raw)
  To: ffmpeg-devel

On Sun, May 19, 2024 at 9:39 PM Nuo Mi <nuomi2021@gmail.com> wrote:

> see
> https://dvb.org/specifications/verification-validation/vvc-test-content/
> ---
>  Changelog | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/Changelog b/Changelog
> index dd25715d6b..12770e4296 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -10,6 +10,7 @@ version <next>:
>  - vf_scale supports secondary ref input and framesync options
>  - vf_scale2ref deprecated
>  - qsv_params option added for QSV encoders
> +- VVC decoder compatible with DVB test content
>
Applied.
Thank you.

>
>
>  version 7.0:
> --
> 2.34.1
>
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-05-21 12:32 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20240519132749.790832-1-nuomi2021@gmail.com>
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 02/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc to mc Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 03/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc_uni to mc_uni Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 04/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc_bi to mc_bi Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 05/18] avcodec/vvcdec: misc, remove unused EMULATED_EDGE_{LUMA, CHROMA}, EMULATED_EDGE_DMVR_{LUAM, CHROMA} Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 06/18] avcodec/vvcdec: refact, unify pred_regular_{luma, chroma} to pred_regular Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 07/18] avcodec/vvcdec: refact out VVCRefPic from RefPicList Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 08/18] avcodec/vvcdec: refact, pred_get_refs return VVCRefPic instead of VVCFrame Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 09/18] avcodec/vvcdec: add vvc inter filters for RPR Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 10/18] avcodec/vvcdec: emulated_edge, use reference frame's sps and pps Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 11/18] avcodec/vvcdec: add RPR dsp Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 12/18] avcodec/vvcdec: inter, wait reference with a diffrent resolution Nuo Mi
2024-05-19 15:20   ` Jean-Baptiste Kempf
2024-05-20 13:25     ` Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 13/18] avcodec/vvcdec: fix dmvr, bdof, cb_prof for RPR Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 14/18] avcodec/vvcdec: refact out luma_prof from luma_prof_bi Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 15/18] avcodec/vvcdec: refact, remove hf_idx and vf_idx from mc_xxx's param list Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 16/18] avcodec/vvcdec: increase edge_emu_buffer for RPR Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 17/18] avcodec/vvcdec: support Reference Picture Resampling Nuo Mi
2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 18/18] Changelog: add DVB compatible information for VVC decoder Nuo Mi
2024-05-21 12:32   ` Nuo Mi

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git