History

avcodec/vvc/ctu: should use the width and height of the start component

This commit fixed decoding the DUAL_TREE_CHROMA palette coding unit

Wu Jianhua committed 1 year ago

Commit 77b9b941 parent 35ea4581 file · +18 −11Browse files

Unified · Split

libavcodec/vvc/ctu.c+18−11
@@ -1966,7 +1966,7 @@ static void palette_qp(VVCLocalContext *lc, VVCTreeType tree_type, const bool es · 1965 unmodified lines
19661966 u16[off] = pix; \
19671967 } while (0)
19681968
1969−#define PALETTE_INDEX(x, y) index[(y) * cu->cb_width + (x)]
1969+#define PALETTE_INDEX(x, y) index[(y) * width + (x)]
19701970
19711971 // 6.5.3 Horizontal and vertical traverse scan order array initialization process
19721972 // The hTravScan and vTravScan tables require approximately 576 KB of memory.
@@ -1984,12 +1984,15 @@ static int palette_subblock_data(VVCLocalContext *lc, · 11 unmodified lines
19841984 const CodingUnit *cu = lc->cu;
19851985 TransformUnit *tu = cu->tus.head;
19861986 const VVCSPS *sps = lc->fc->ps.sps;
1987+ const int width = tu->tbs[0].tb_width;
1988+ const int height = tu->tbs[0].tb_height;
19871989 const int min_pos = subset_id << 4;
1988− const int max_pos = FFMIN(min_pos + 16, cu->cb_width * cu->cb_height);
1989− const int wmask = cu->cb_width - 1;
1990− const int hmask = cu->cb_height - 1;
1991− const int wlog2 = av_log2(cu->cb_width);
1992− const int hlog2 = av_log2(cu->cb_height);
1990+ const int max_pos = FFMIN(min_pos + 16, width * height);
1991+ const int wmask = width - 1;
1992+ const int hmask = height - 1;
1993+ const int wlog2 = av_log2(width);
1994+ const int hlog2 = av_log2(height);
1995+ const int start_idx = tu->tbs[0].c_idx;
19931996 const uint8_t esc = cu->plt[tu->tbs[0].c_idx].size;
19941997 uint8_t run_copy[16] = { 0 };
19951998
@@ -2040,10 +2043,11 @@ static int palette_subblock_data(VVCLocalContext *lc, · 44 unmodified lines
20402043
20412044 for (int c = 0; c < tu->nb_tbs; c++) {
20422045 TransformBlock *tb = &tu->tbs[c];
2043− const Palette *plt = cu->plt + tb->c_idx;
2046+ const int c_idx = tb->c_idx;
2047+ const Palette *plt = &cu->plt[c_idx];
20442048 const int scale = ff_vvc_palette_derive_scale(lc, tu, tb);
2045− const int hs = sps->hshift[c];
2046− const int vs = sps->vshift[c];
2049+ const int hs = sps->hshift[c_idx] - sps->hshift[start_idx];
2050+ const int vs = sps->vshift[c_idx] - sps->vshift[start_idx];
20472051 uint8_t *u8 = (uint8_t *)tb->coeffs;
20482052 uint16_t *u16 = (uint16_t *)tb->coeffs;
20492053
@@ -2089,9 +2093,12 @@ static int hls_palette_coding(VVCLocalContext *lc, const VVCTreeType tree_type) · 39 unmodified lines
20892093 uint8_t run_type[MAX_PALETTE_CU_SIZE * MAX_PALETTE_CU_SIZE];
20902094 uint8_t index[MAX_PALETTE_CU_SIZE * MAX_PALETTE_CU_SIZE];
20912095
2096+ TransformUnit *tu;
2097+
20922098 ff_vvc_channel_range(&start, &end, tree_type, sps->r->sps_chroma_format_idc);
20932099
2094− if (!palette_add_tu(lc, start, end, tree_type))
2100+ tu = palette_add_tu(lc, start, end, tree_type);
2101+ if (!tu)
20952102 return AVERROR(ENOMEM);
20962103
20972104 predictor_size = pp[start].size;
@@ -2119,7 +2126,7 @@ static int hls_palette_coding(VVCLocalContext *lc, const VVCTreeType tree_type) · 21 unmodified lines
21192126 palette_qp(lc, tree_type, escape_present);
21202127
21212128 index[0] = 0;
2122− for (int i = 0; i <= (cu->cb_width * cu->cb_height - 1) >> 4; i++) {
2129+ for (int i = 0; i <= (tu->tbs[0].tb_width * tu->tbs[0].tb_height - 1) >> 4; i++) {
21232130 ret = palette_subblock_data(lc, max_index, i, transpose,
21242131 run_type, index, &prev_run_pos, &adjust);
21252132 if (ret < 0)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t