Commit a8bff80d75 for ffmpeg
commit a8bff80d75ae4a38a26baaebc41731ead1e98960
Author: Wu Jianhua <toqsxw@outlook.com>
Date: Sun Aug 16 03:45:16 2026 +0800
avcodec/vvc/ps: fix chroma QP table OOB for 16-bit
ChromaQpTable is indexed by qPi in [-QpBdOffset, 63]. For 16-bit,
QpBdOffset is 48, so the stored table needs 112 entries. Enlarge
chroma_qp_table and qp_in/qp_out accordingly.
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
diff --git a/libavcodec/vvc.h b/libavcodec/vvc.h
index 5490ddb4c8..d21f615e6f 100644
--- a/libavcodec/vvc.h
+++ b/libavcodec/vvc.h
@@ -118,6 +118,9 @@ enum {
//and sps_qp_table_start_minus26[i] in range [−26 − QpBdOffset, 36].
//so sps_num_points_in_qp_table_minus1[i] should in range [0, 62 + QpBdOffset]
//since 16 bits QpBdOffset is 48, sps_num_points_in_qp_table_minus1[i] should range [0, 110]
+ //ChromaQpTable is indexed by qPi + QpBdOffset for qPi in [-QpBdOffset, 63],
+ //so the table size is 64 + QpBdOffset = 112 (VVC_MAX_POINTS_IN_QP_TABLE + 1).
+ //qp_in/qp_out store the start point plus up to VVC_MAX_POINTS_IN_QP_TABLE deltas.
VVC_MAX_POINTS_IN_QP_TABLE = 111,
// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c
index 84adaf191d..8d6bb74533 100644
--- a/libavcodec/vvc/ps.c
+++ b/libavcodec/vvc/ps.c
@@ -97,7 +97,7 @@ static int sps_chroma_qp_table(VVCSPS *sps)
for (int i = 0; i < num_qp_tables; i++) {
int num_points_in_qp_table;
- int8_t qp_in[VVC_MAX_POINTS_IN_QP_TABLE], qp_out[VVC_MAX_POINTS_IN_QP_TABLE];
+ int8_t qp_in[VVC_MAX_POINTS_IN_QP_TABLE + 1], qp_out[VVC_MAX_POINTS_IN_QP_TABLE + 1];
unsigned int delta_qp_in[VVC_MAX_POINTS_IN_QP_TABLE];
int off = sps->qp_bd_offset;
diff --git a/libavcodec/vvc/ps.h b/libavcodec/vvc/ps.h
index add8e22367..95ee1d7f96 100644
--- a/libavcodec/vvc/ps.h
+++ b/libavcodec/vvc/ps.h
@@ -81,7 +81,7 @@ typedef struct VVCSPS {
uint32_t ladf_interval_lower_bound[LADF_MAX_INTERVAL]; ///< SpsLadfIntervalLowerBound[]
uint8_t log2_parallel_merge_level; ///< sps_log2_parallel_merge_level_minus2 + 2;
uint8_t log2_transform_range; ///< Log2TransformRange
- int8_t chroma_qp_table[3][VVC_MAX_POINTS_IN_QP_TABLE]; ///< ChromaQpTable
+ int8_t chroma_qp_table[3][VVC_MAX_POINTS_IN_QP_TABLE + 1]; ///< ChromaQpTable
} VVCSPS;
typedef struct DBParams {