diff mbox series

[FFmpeg-devel,04/14] avcodec/vvcdec: derive subpic postion for PPS

Message ID TYSPR06MB64333C48FE97948A39946BB3AA2D2@TYSPR06MB6433.apcprd06.prod.outlook.com
State New
Headers show
Series avcodec/vvcdec: support subpicture | expand

Checks

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

Commit Message

Nuo Mi March 18, 2024, 2:16 p.m. UTC
---
 libavcodec/vvc/vvc_ps.c | 19 +++++++++++++++++++
 libavcodec/vvc/vvc_ps.h |  4 ++++
 2 files changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/vvc/vvc_ps.c b/libavcodec/vvc/vvc_ps.c
index bb13b04a5d..bbd666307f 100644
--- a/libavcodec/vvc/vvc_ps.c
+++ b/libavcodec/vvc/vvc_ps.c
@@ -511,6 +511,24 @@  static void pps_ref_wraparound_offset(VVCPPS *pps, const VVCSPS *sps)
         pps->ref_wraparound_offset = (pps->width / sps->min_cb_size_y) - r->pps_pic_width_minus_wraparound_offset;
 }
 
+static void pps_subpic(VVCPPS *pps, const VVCSPS *sps)
+{
+    const H266RawSPS *rsps = sps->r;
+    for (int i = 0; i < rsps->sps_num_subpics_minus1 + 1; i++) {
+        if (rsps->sps_subpic_treated_as_pic_flag[i]) {
+            pps->subpic_x[i]      = rsps->sps_subpic_ctu_top_left_x[i] << sps->ctb_log2_size_y;
+            pps->subpic_y[i]      = rsps->sps_subpic_ctu_top_left_y[i] << sps->ctb_log2_size_y;
+            pps->subpic_width[i]  = FFMIN(pps->width  - pps->subpic_x[i], (rsps->sps_subpic_width_minus1[i]  + 1) << sps->ctb_log2_size_y);
+            pps->subpic_height[i] = FFMIN(pps->height - pps->subpic_y[i], (rsps->sps_subpic_height_minus1[i] + 1) << sps->ctb_log2_size_y);
+        } else {
+            pps->subpic_x[i]      = 0;
+            pps->subpic_y[i]      = 0;
+            pps->subpic_width[i]  = pps->width;
+            pps->subpic_height[i] = pps->height;
+        }
+    }
+}
+
 static int pps_derive(VVCPPS *pps, const VVCSPS *sps)
 {
     int ret;
@@ -527,6 +545,7 @@  static int pps_derive(VVCPPS *pps, const VVCSPS *sps)
         return ret;
 
     pps_ref_wraparound_offset(pps, sps);
+    pps_subpic(pps, sps);
 
     return 0;
 }
diff --git a/libavcodec/vvc/vvc_ps.h b/libavcodec/vvc/vvc_ps.h
index 1164d0eab6..35b46e234b 100644
--- a/libavcodec/vvc/vvc_ps.h
+++ b/libavcodec/vvc/vvc_ps.h
@@ -127,6 +127,10 @@  typedef struct VVCPPS {
 
     uint16_t ref_wraparound_offset;         ///< PpsRefWraparoundOffset
 
+    uint16_t subpic_x[VVC_MAX_SLICES];      ///< SubpicLeftBoundaryPos
+    uint16_t subpic_y[VVC_MAX_SLICES];      ///< SubpicTopBoundaryPos
+    uint16_t subpic_width[VVC_MAX_SLICES];
+    uint16_t subpic_height[VVC_MAX_SLICES];
 } VVCPPS;
 
 #define MAX_WEIGHTS 15