aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu Jianhua <toqsxw@outlook.com>2025-06-04 01:07:17 +0800
committerTimo Rothenpieler <timo@rothenpieler.org>2025-08-08 16:55:12 +0000
commit77b9b9420b8a9b74db9934f32bdb3fd077e7a66d (patch)
treedab3b775ccc8d7d29ba243b6ba42a7626417a7c4
parent35ea45835484b90490e7d1704ef99ccb7b775578 (diff)
downloadffmpeg-77b9b9420b8a9b74db9934f32bdb3fd077e7a66d.tar.gz
avcodec/vvc/ctu: should use the width and height of the start component
This commit fixed decoding the DUAL_TREE_CHROMA palette coding unit Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
-rw-r--r--libavcodec/vvc/ctu.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
index fd7d07f438..18cbe0fe0f 100644
--- a/libavcodec/vvc/ctu.c
+++ b/libavcodec/vvc/ctu.c
@@ -1966,7 +1966,7 @@ static void palette_qp(VVCLocalContext *lc, VVCTreeType tree_type, const bool es
u16[off] = pix; \
} while (0)
-#define PALETTE_INDEX(x, y) index[(y) * cu->cb_width + (x)]
+#define PALETTE_INDEX(x, y) index[(y) * width + (x)]
// 6.5.3 Horizontal and vertical traverse scan order array initialization process
// The hTravScan and vTravScan tables require approximately 576 KB of memory.
@@ -1984,12 +1984,15 @@ static int palette_subblock_data(VVCLocalContext *lc,
const CodingUnit *cu = lc->cu;
TransformUnit *tu = cu->tus.head;
const VVCSPS *sps = lc->fc->ps.sps;
+ const int width = tu->tbs[0].tb_width;
+ const int height = tu->tbs[0].tb_height;
const int min_pos = subset_id << 4;
- const int max_pos = FFMIN(min_pos + 16, cu->cb_width * cu->cb_height);
- const int wmask = cu->cb_width - 1;
- const int hmask = cu->cb_height - 1;
- const int wlog2 = av_log2(cu->cb_width);
- const int hlog2 = av_log2(cu->cb_height);
+ const int max_pos = FFMIN(min_pos + 16, width * height);
+ const int wmask = width - 1;
+ const int hmask = height - 1;
+ const int wlog2 = av_log2(width);
+ const int hlog2 = av_log2(height);
+ const int start_idx = tu->tbs[0].c_idx;
const uint8_t esc = cu->plt[tu->tbs[0].c_idx].size;
uint8_t run_copy[16] = { 0 };
@@ -2040,10 +2043,11 @@ static int palette_subblock_data(VVCLocalContext *lc,
for (int c = 0; c < tu->nb_tbs; c++) {
TransformBlock *tb = &tu->tbs[c];
- const Palette *plt = cu->plt + tb->c_idx;
+ const int c_idx = tb->c_idx;
+ const Palette *plt = &cu->plt[c_idx];
const int scale = ff_vvc_palette_derive_scale(lc, tu, tb);
- const int hs = sps->hshift[c];
- const int vs = sps->vshift[c];
+ const int hs = sps->hshift[c_idx] - sps->hshift[start_idx];
+ const int vs = sps->vshift[c_idx] - sps->vshift[start_idx];
uint8_t *u8 = (uint8_t *)tb->coeffs;
uint16_t *u16 = (uint16_t *)tb->coeffs;
@@ -2089,9 +2093,12 @@ static int hls_palette_coding(VVCLocalContext *lc, const VVCTreeType tree_type)
uint8_t run_type[MAX_PALETTE_CU_SIZE * MAX_PALETTE_CU_SIZE];
uint8_t index[MAX_PALETTE_CU_SIZE * MAX_PALETTE_CU_SIZE];
+ TransformUnit *tu;
+
ff_vvc_channel_range(&start, &end, tree_type, sps->r->sps_chroma_format_idc);
- if (!palette_add_tu(lc, start, end, tree_type))
+ tu = palette_add_tu(lc, start, end, tree_type);
+ if (!tu)
return AVERROR(ENOMEM);
predictor_size = pp[start].size;
@@ -2119,7 +2126,7 @@ static int hls_palette_coding(VVCLocalContext *lc, const VVCTreeType tree_type)
palette_qp(lc, tree_type, escape_present);
index[0] = 0;
- for (int i = 0; i <= (cu->cb_width * cu->cb_height - 1) >> 4; i++) {
+ for (int i = 0; i <= (tu->tbs[0].tb_width * tu->tbs[0].tb_height - 1) >> 4; i++) {
ret = palette_subblock_data(lc, max_index, i, transpose,
run_type, index, &prev_run_pos, &adjust);
if (ret < 0)