Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Nuo Mi <nuomi2021@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Nuo Mi <nuomi2021@gmail.com>
Subject: [FFmpeg-devel] [PATCH 15/18] avcodec/vvcdec: ps, derive virtual boundaries
Date: Sat, 22 Jun 2024 14:24:02 +0800
Message-ID: <TYSPR06MB6433AF9750D03AEEB2DE0F00AACA2@TYSPR06MB6433.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <20240622062405.285359-1-nuomi2021@gmail.com>

---
 libavcodec/vvc/ps.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/vvc/ps.h |  6 ++++++
 2 files changed, 51 insertions(+)

diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c
index 92368eafc2..58496c9fba 100644
--- a/libavcodec/vvc/ps.c
+++ b/libavcodec/vvc/ps.c
@@ -796,8 +796,49 @@ static int ph_max_num_subblock_merge_cand(const H266RawSPS *sps, const H266RawPi
     return sps->sps_sbtmvp_enabled_flag && ph->ph_temporal_mvp_enabled_flag;
 }
 
+static int ph_vb_pos(uint16_t *vbs, uint8_t *num_vbs, const uint16_t *pos_minus_1, const uint8_t num_pos, uint16_t max, const int ctb_size_y)
+{
+    max = FF_CEIL_RSHIFT(max, 3) - 2;
+    for (int i = 0; i < num_pos; i++) {
+        if (pos_minus_1[i] > max)
+            return AVERROR_INVALIDDATA;
+
+        vbs[i] = (pos_minus_1[i] + 1) << 3;
+
+        // The distance between any two vertical virtual boundaries shall be greater than or equal to CtbSizeY luma samples
+        if (i && vbs[i] < vbs[i - 1] + ctb_size_y)
+            return AVERROR_INVALIDDATA;
+    }
+    *num_vbs = num_pos;
+
+    return 0;
+}
+
+#define VBF(f) (sps->sps_virtual_boundaries_present_flag ? sps->sps_##f : ph->r->ph_##f)
+#define VBFS(c, d) VBF(virtual_boundary_pos_##c##_minus1), VBF(num_##d##_virtual_boundaries)
+
+static int ph_vb(VVCPH *ph, const H266RawSPS *sps, const H266RawPPS *pps)
+{
+    const int ctb_size_y = 1 << (sps->sps_log2_ctu_size_minus5 + 5);
+    int ret;
+
+    if (!sps->sps_virtual_boundaries_enabled_flag)
+        return 0;
+
+    ret = ph_vb_pos(ph->vb_pos_x, &ph->num_ver_vbs, VBFS(x, ver), pps->pps_pic_width_in_luma_samples, ctb_size_y);
+    if (ret < 0)
+        return ret;
+
+    ret = ph_vb_pos(ph->vb_pos_y, &ph->num_hor_vbs, VBFS(y, hor), pps->pps_pic_height_in_luma_samples, ctb_size_y);
+    if (ret < 0)
+        return ret;
+
+    return 0;
+}
+
 static int ph_derive(VVCPH *ph, const H266RawSPS *sps, const H266RawPPS *pps, const int poc_tid0, const int is_clvss)
 {
+    int ret;
     ph->max_num_subblock_merge_cand = ph_max_num_subblock_merge_cand(sps, ph->r);
 
     ph->poc = ph_compute_poc(ph->r, sps, poc_tid0, is_clvss);
@@ -805,6 +846,10 @@ static int ph_derive(VVCPH *ph, const H266RawSPS *sps, const H266RawPPS *pps, co
     if (pps->pps_wp_info_in_ph_flag)
         pred_weight_table(&ph->pwt, &ph->r->ph_pred_weight_table);
 
+    ret = ph_vb(ph, sps, pps);
+    if (ret < 0)
+        return ret;
+
     return 0;
 }
 
diff --git a/libavcodec/vvc/ps.h b/libavcodec/vvc/ps.h
index 6656a06320..9203e2c57f 100644
--- a/libavcodec/vvc/ps.h
+++ b/libavcodec/vvc/ps.h
@@ -151,6 +151,12 @@ typedef struct VVCPH {
     //derived values
     uint32_t max_num_subblock_merge_cand;           ///< MaxNumSubblockMergeCand
     int32_t  poc;                                   ///< PicOrderCntVal
+
+    uint8_t  num_ver_vbs;                           ///< NumVerVirtualBoundaries
+    uint16_t vb_pos_x[VVC_MAX_VBS];                 ///< VirtualBoundaryPosX
+    uint8_t  num_hor_vbs;                           ///< NumHorVirtualBoundaries
+    uint16_t vb_pos_y[VVC_MAX_VBS];                 ///< VirtualBoundaryPosY
+
     PredWeightTable pwt;
 } VVCPH;
 
-- 
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".

  parent reply	other threads:[~2024-06-22  6:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240622062405.285359-1-nuomi2021@gmail.com>
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 02/18] avcodec/vvcdec: refact, unify vvc_deblock_bs_luma_{horizontal, vertical} Nuo Mi
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 03/18] avcodec/vvcdec: refact, unify vvc_deblock_bs_chroma_{horizontal, vertical} Nuo Mi
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 04/18] avcodec/vvcdec: refact, unify {horizontal, vertical}_bs, {horizontal, vertical}_p, {horizontal, vertical}_q Nuo Mi
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 05/18] avcodec/vvcdec: misc, use POS to simplify filter code Nuo Mi
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 06/18] avcodec/vvcdec: refact, unify ff_vvc_deblock_{horizontal, vertical} Nuo Mi
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 07/18] avcodec/vvcdec: refact out sao_get_edges Nuo Mi
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 08/18] avcodec/vvcdec: refact out sao_extends_edges Nuo Mi
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 09/18] avcodec/vvcdec: refact, fix naming convention of x0, y0 for sao Nuo Mi
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 10/18] avcodec/vvcdec: misc, reformat ff_vvc_sao_filter Nuo Mi
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 11/18] avcodec/vvcdec: refact out alf_get_edges Nuo Mi
2024-06-22  6:23 ` [FFmpeg-devel] [PATCH 12/18] avcodec/vvcdec: misc, remove unused ALFParams.applied Nuo Mi
2024-06-22  6:24 ` [FFmpeg-devel] [PATCH 13/18] avcodec/vvcdec: misc, constify ALFParams Nuo Mi
2024-06-22  6:24 ` [FFmpeg-devel] [PATCH 14/18] cbs_h266: add VVC_MAX_VBS for max num of virtual boundaries Nuo Mi
2024-06-22  6:24 ` Nuo Mi [this message]
2024-06-22  6:24 ` [FFmpeg-devel] [PATCH 16/18] avcodec/vvcdec: deblock, support " Nuo Mi
2024-06-22  6:24 ` [FFmpeg-devel] [PATCH 17/18] avcodec/vvcdec: sao, " Nuo Mi
2024-06-22  6:24 ` [FFmpeg-devel] [PATCH 18/18] avcodec/vvcdec: alf, " Nuo Mi
2024-06-25 11:53   ` Nuo Mi
2024-06-25 12:48     ` James Almer
2024-06-25 14:29       ` Nuo Mi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=TYSPR06MB6433AF9750D03AEEB2DE0F00AACA2@TYSPR06MB6433.apcprd06.prod.outlook.com \
    --to=nuomi2021@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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