PR #23377 opened by frankplow
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23377
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23377.patch

Context:
1. In the case sps_subpic_info_present=0, there is a single subpicture
   which includes the entire picture.
2. When sps_subpic_info_present=0, we might be using Reference Picture
   Resampling (RPR), in which picture sizes might differ in the PPS,
   rather than in the SPS.

Because of 2., we can't rely on the sequence-level variables
sps_subpic_width_minus1 and sps_subpic_height_minus1 to derive the
picture-level variable num_entry_points, as the picture might have a
different size to the picture used when deriving those sequence-level
variables.

Supersedes #23273


>From 068073d34759050f516599e1a44dfb7e1aa857df Mon Sep 17 00:00:00 2001
From: Frank Plowman <[email protected]>
Date: Sat, 6 Jun 2026 10:13:23 +0100
Subject: [PATCH] lavc/vvc: Fix num_entry_points derivation when using RPR

Context:
1. In the case sps_subpic_info_present=0, there is a single subpicture
   which includes the entire picture.
2. When sps_subpic_info_present=0, we might be using Reference Picture
   Resampling (RPR), in which picture sizes might differ in the PPS,
   rather than in the SPS.

Because of 2., we can't rely on the sequence-level variables
sps_subpic_width_minus1 and sps_subpic_height_minus1 to derive the
picture-level variable num_entry_points, as the picture might have a
different size to the picture used when deriving those sequence-level
variables.
---
 libavcodec/cbs_h266_syntax_template.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavcodec/cbs_h266_syntax_template.c 
b/libavcodec/cbs_h266_syntax_template.c
index 6016644eb8..eda724bcaa 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -3457,7 +3457,17 @@ static int FUNC(slice_header) (CodedBitstreamContext 
*ctx, RWContext *rw,
             }
 
             if (pps->pps_single_slice_per_subpic_flag) {
-                const int width_in_ctus = 
sps->sps_subpic_width_minus1[slice_idx] + 1;
+                int width_in_ctus, height_in_ctus;
+                if (sps->sps_subpic_info_present_flag) {
+                    width_in_ctus = sps->sps_subpic_width_minus1[slice_idx] + 
1;
+                    height_in_ctus = sps->sps_subpic_height_minus1[slice_idx] 
+ 1;
+                } else {
+                    const int log2_ctb_size = sps->sps_log2_ctu_size_minus5 + 
5;
+                    const int ctb_size = 1 << log2_ctb_size;
+                    width_in_ctus = (pps->pps_pic_width_in_luma_samples + 
ctb_size - 1) >> log2_ctb_size;
+                    height_in_ctus = (pps->pps_pic_height_in_luma_samples + 
ctb_size - 1) >> log2_ctb_size;
+                }
+
                 const int subpic_l = sps->sps_subpic_ctu_top_left_x[slice_idx];
                 const int subpic_r = subpic_l + width_in_ctus;
 
@@ -3472,9 +3482,8 @@ static int FUNC(slice_header) (CodedBitstreamContext 
*ctx, RWContext *rw,
                 }
 
                 if (entropy_sync) {
-                    height = sps->sps_subpic_height_minus1[slice_idx] + 1;
+                    height = height_in_ctus;
                 } else {
-                    const int height_in_ctus = 
sps->sps_subpic_height_minus1[slice_idx] + 1;
                     const int subpic_t = 
sps->sps_subpic_ctu_top_left_y[slice_idx];
                     const int subpic_b = subpic_t + height_in_ctus;
 
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to