This commit fixed decoding the DUAL_TREE_CHROMA palette coding unit
Unified · Split
| @@ -1966,7 +1966,7 @@ static void palette_qp(VVCLocalContext *lc, VVCTreeType tree_type, const bool es · 1965 unmodified lines | ||
| 1966 | 1966 | u16[off] = pix; \ |
| 1967 | 1967 | } while (0) |
| 1968 | 1968 | |
| 1969 | −#define PALETTE_INDEX(x, y) index[(y) * cu->cb_width + (x)] | |
| 1969 | +#define PALETTE_INDEX(x, y) index[(y) * width + (x)] | |
| 1970 | 1970 | |
| 1971 | 1971 | // 6.5.3 Horizontal and vertical traverse scan order array initialization process |
| 1972 | 1972 | // 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 | ||
| 1984 | 1984 | const CodingUnit *cu = lc->cu; |
| 1985 | 1985 | TransformUnit *tu = cu->tus.head; |
| 1986 | 1986 | 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; | |
| 1987 | 1989 | 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; | |
| 1993 | 1996 | const uint8_t esc = cu->plt[tu->tbs[0].c_idx].size; |
| 1994 | 1997 | uint8_t run_copy[16] = { 0 }; |
| 1995 | 1998 | |
| @@ -2040,10 +2043,11 @@ static int palette_subblock_data(VVCLocalContext *lc, · 44 unmodified lines | ||
| 2040 | 2043 | |
| 2041 | 2044 | for (int c = 0; c < tu->nb_tbs; c++) { |
| 2042 | 2045 | 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]; | |
| 2044 | 2048 | 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]; | |
| 2047 | 2051 | uint8_t *u8 = (uint8_t *)tb->coeffs; |
| 2048 | 2052 | uint16_t *u16 = (uint16_t *)tb->coeffs; |
| 2049 | 2053 | |
| @@ -2089,9 +2093,12 @@ static int hls_palette_coding(VVCLocalContext *lc, const VVCTreeType tree_type) · 39 unmodified lines | ||
| 2089 | 2093 | uint8_t run_type[MAX_PALETTE_CU_SIZE * MAX_PALETTE_CU_SIZE]; |
| 2090 | 2094 | uint8_t index[MAX_PALETTE_CU_SIZE * MAX_PALETTE_CU_SIZE]; |
| 2091 | 2095 | |
| 2096 | + TransformUnit *tu; | |
| 2097 | + | |
| 2092 | 2098 | ff_vvc_channel_range(&start, &end, tree_type, sps->r->sps_chroma_format_idc); |
| 2093 | 2099 | |
| 2094 | − if (!palette_add_tu(lc, start, end, tree_type)) | |
| 2100 | + tu = palette_add_tu(lc, start, end, tree_type); | |
| 2101 | + if (!tu) | |
| 2095 | 2102 | return AVERROR(ENOMEM); |
| 2096 | 2103 | |
| 2097 | 2104 | predictor_size = pp[start].size; |
| @@ -2119,7 +2126,7 @@ static int hls_palette_coding(VVCLocalContext *lc, const VVCTreeType tree_type) · 21 unmodified lines | ||
| 2119 | 2126 | palette_qp(lc, tree_type, escape_present); |
| 2120 | 2127 | |
| 2121 | 2128 | 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++) { | |
| 2123 | 2130 | ret = palette_subblock_data(lc, max_index, i, transpose, |
| 2124 | 2131 | run_type, index, &prev_run_pos, &adjust); |
| 2125 | 2132 | if (ret < 0) |