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: Frank Plowman <post@frankplowman.com>, Nuo Mi <nuomi2021@gmail.com>
Subject: [FFmpeg-devel] [PATCH 03/14] avcodec/vvcdec: support rectangular single-slice subpics
Date: Mon, 18 Mar 2024 22:16:15 +0800
Message-ID: <TYSPR06MB6433035C09F62A3DBF36D2B5AA2D2@TYSPR06MB6433.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <20240318141626.3375-1-nuomi2021@gmail.com>

From: Frank Plowman <post@frankplowman.com>

Co-authored-by: Nuo Mi <nuomi2021@gmail.com>
---
 libavcodec/cbs_h266_syntax_template.c |  5 +-
 libavcodec/vvc/vvc_ps.c               | 93 +++++++++++++++++++++++++--
 2 files changed, 91 insertions(+), 7 deletions(-)

diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c
index 15368502d7..9fa7e0eec8 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -2118,9 +2118,12 @@ static int FUNC(pps) (CodedBitstreamContext *ctx, RWContext *rw,
         } else {
             if (current->pps_no_pic_partition_flag)
                 infer(pps_num_slices_in_pic_minus1, 0);
-            else if (current->pps_single_slice_per_subpic_flag)
+            else if (current->pps_single_slice_per_subpic_flag) {
+                for (i = 0; i <= sps->sps_num_subpics_minus1; i++)
+                    current->num_slices_in_subpic[i] = 1;
                 infer(pps_num_slices_in_pic_minus1,
                       sps->sps_num_subpics_minus1);
+            }
             // else?
         }
         if (!current->pps_rect_slice_flag ||
diff --git a/libavcodec/vvc/vvc_ps.c b/libavcodec/vvc/vvc_ps.c
index 7972803da6..bb13b04a5d 100644
--- a/libavcodec/vvc/vvc_ps.c
+++ b/libavcodec/vvc/vvc_ps.c
@@ -343,6 +343,83 @@ static int pps_add_ctus(VVCPPS *pps, int *off, const int ctu_x, const int ctu_y,
     return *off - start;
 }
 
+static void pps_single_slice_picture(VVCPPS *pps, int *off)
+{
+    for (int j = 0; j < pps->r->num_tile_rows; j++) {
+        for (int i = 0; i < pps->r->num_tile_columns; i++) {
+            pps->num_ctus_in_slice[0] = pps_add_ctus(pps, off,
+                pps->col_bd[i], pps->row_bd[j],
+                pps->r->col_width_val[i], pps->r->row_height_val[j]);
+        }
+    }
+}
+
+static void subpic_tiles(int *tile_x, int *tile_y, int *tile_x_end, int *tile_y_end,
+    const VVCSPS *sps, const VVCPPS *pps,  const int i)
+{
+    const int rx = sps->r->sps_subpic_ctu_top_left_x[i];
+    const int ry = sps->r->sps_subpic_ctu_top_left_y[i];
+
+    *tile_x = *tile_y = 0;
+
+    while (pps->col_bd[*tile_x] != rx)
+        (*tile_x)++;
+
+    while (pps->row_bd[*tile_y] != ry)
+        (*tile_y)++;
+
+    *tile_x_end = (*tile_x);
+    *tile_y_end = (*tile_y);
+
+    while (pps->col_bd[*tile_x_end] < rx + sps->r->sps_subpic_width_minus1[i] + 1)
+        (*tile_x_end)++;
+
+    while (pps->row_bd[*tile_y_end] < ry + sps->r->sps_subpic_height_minus1[i] + 1)
+        (*tile_y_end)++;
+}
+
+static void pps_subpic_less_than_one_tile_slice(VVCPPS *pps, const VVCSPS *sps, const int i, const int tx, const int ty, int *off)
+{
+    pps->num_ctus_in_slice[i] = pps_add_ctus(pps, off,
+        pps->col_bd[tx], pps->row_bd[ty],
+        pps->r->col_width_val[tx], sps->r->sps_subpic_height_minus1[i] + 1);
+}
+
+static void pps_subpic_multi_tiles_slice(VVCPPS *pps, const int tile_x, const int tile_y, const int x_end, const int y_end, const int i, int *off)
+{
+    for (int ty = tile_y; ty < y_end; ty++) {
+        for (int tx = tile_x; tx < x_end; tx++) {
+            pps->num_ctus_in_slice[i] += pps_add_ctus(pps, off,
+                pps->col_bd[tx], pps->row_bd[ty],
+                pps->r->col_width_val[tx], pps->r->row_height_val[ty]);
+        }
+    }
+}
+
+static void pps_subpic_slice(VVCPPS *pps, const VVCSPS *sps, const int i, int *off)
+{
+    int tx, ty, x_end, y_end;
+
+    pps->slice_start_offset[i] = *off;
+    pps->num_ctus_in_slice[i] = 0;
+
+    subpic_tiles(&tx, &ty, &x_end, &y_end, sps, pps, i);
+    if (ty + 1 == y_end && sps->r->sps_subpic_height_minus1[i] + 1 < pps->r->row_height_val[ty])
+        pps_subpic_less_than_one_tile_slice(pps, sps, i, tx, ty, off);
+    else
+        pps_subpic_multi_tiles_slice(pps, tx, ty, x_end, y_end, i, off);
+}
+
+static void pps_single_slice_per_subpic(VVCPPS *pps, const VVCSPS *sps, int *off)
+{
+    if (!sps->r->sps_subpic_info_present_flag) {
+        pps_single_slice_picture(pps, off);
+    } else {
+        for (int i = 0; i < pps->r->pps_num_slices_in_pic_minus1 + 1; i++)
+            pps_subpic_slice(pps, sps, i, off);
+    }
+}
+
 static int pps_one_tile_slices(VVCPPS *pps, const int tile_idx, int i, int *off)
 {
     const H266RawPPS *r = pps->r;
@@ -378,18 +455,22 @@ static void pps_multi_tiles_slice(VVCPPS *pps, const int tile_idx, const int i,
     }
 }
 
-static void pps_rect_slice(VVCPPS* pps)
+static void pps_rect_slice(VVCPPS *pps, const VVCSPS *sps)
 {
-    const H266RawPPS* r = pps->r;
+    const H266RawPPS *r = pps->r;
     int tile_idx = 0, off = 0;
 
+    if (r->pps_single_slice_per_subpic_flag) {
+        pps_single_slice_per_subpic(pps, sps, &off);
+        return;
+    }
+
     for (int i = 0; i < r->pps_num_slices_in_pic_minus1 + 1; i++) {
         if (!r->pps_slice_width_in_tiles_minus1[i] &&
             !r->pps_slice_height_in_tiles_minus1[i]) {
             i = pps_one_tile_slices(pps, tile_idx, i, &off);
         } else {
             pps_multi_tiles_slice(pps, tile_idx, i, &off);
-
         }
         tile_idx = next_tile_idx(tile_idx, i, r);
     }
@@ -408,14 +489,14 @@ static void pps_no_rect_slice(VVCPPS* pps)
     }
 }
 
-static int pps_slice_map(VVCPPS *pps)
+static int pps_slice_map(VVCPPS *pps, const VVCSPS *sps)
 {
     pps->ctb_addr_in_slice = av_calloc(pps->ctb_count, sizeof(*pps->ctb_addr_in_slice));
     if (!pps->ctb_addr_in_slice)
         return AVERROR(ENOMEM);
 
     if (pps->r->pps_rect_slice_flag)
-        pps_rect_slice(pps);
+        pps_rect_slice(pps, sps);
     else
         pps_no_rect_slice(pps);
 
@@ -441,7 +522,7 @@ static int pps_derive(VVCPPS *pps, const VVCSPS *sps)
     if (ret < 0)
         return ret;
 
-    ret = pps_slice_map(pps);
+    ret = pps_slice_map(pps, sps);
     if (ret < 0)
         return ret;
 
-- 
2.25.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-03-18 14:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240318141626.3375-1-nuomi2021@gmail.com>
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 01/14] avcodec/vvcdec: NoBackwardPredFlag, only check active pictures Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 02/14] avcodec/cbs_h266: fix sh_collocated_from_l0_flag and sh_collocated_ref_idx infer Nuo Mi
2024-03-18 14:16 ` Nuo Mi [this message]
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 04/14] avcodec/vvcdec: derive subpic postion for PPS Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 05/14] avcodec/vvcdec: ff_vvc_decode_neighbour, support subpicture Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 06/14] avcodec/vvcdec: misc, rename x_ctb, y_ctb, ctu_x, ctu_y to rx, ry to avoid misleading Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 07/14] avcodec/vvcdec: refact out deblock_is_boundary Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 08/14] avcodec/vvcdec: deblock, support subpicture Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 09/14] avcodec/vvcdec: refact, movie the lc->sc assignment to task_run_stage to simplify the code Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 10/14] avcodec/vvcdec: sao, refact out tile_edge arrays Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 11/14] avcodec/vvcdec: sao, support subpicture Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 12/14] avcodec/vvcdec: alf, " Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 13/14] avcodec/vvcdec: mvs, " Nuo Mi
2024-03-18 14:16 ` [FFmpeg-devel] [PATCH 14/14] avcodec/vvcdec: inter prediction, " 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=TYSPR06MB6433035C09F62A3DBF36D2B5AA2D2@TYSPR06MB6433.apcprd06.prod.outlook.com \
    --to=nuomi2021@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=post@frankplowman.com \
    /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