History

avcodec/vvc/cabac: add palette support

Wu Jianhua committed 1 year ago

Commit 89ba1bb1 parent a7320ef2 files · +61 −0Browse files

Unified · Split

2 files
  1. libavcodec/vvc/cabac.c +52 −0
  2. libavcodec/vvc/cabac.h +9 −0
libavcodec/vvc/cabac.c+52−0
@@ -1377,6 +1377,58 @@ int ff_vvc_intra_chroma_pred_mode(VVCLocalContext *lc) · 1376 unmodified lines
13771377 return (get_cabac_bypass(&lc->ep->cc) << 1) | get_cabac_bypass(&lc->ep->cc);
13781378 }
13791379
1380+int ff_vvc_palette_predictor_run(VVCLocalContext *lc)
1381+{
1382+ return kth_order_egk_decode(&lc->ep->cc, 0);
1383+}
1384+
1385+int ff_vvc_num_signalled_palette_entries(VVCLocalContext *lc)
1386+{
1387+ return kth_order_egk_decode(&lc->ep->cc, 0);
1388+}
1389+
1390+int ff_vvc_new_palette_entries(VVCLocalContext *lc, const int bit_depth)
1391+{
1392+ return fixed_length_decode(&lc->ep->cc, bit_depth);
1393+}
1394+
1395+bool ff_vvc_palette_escape_val_present_flag(VVCLocalContext *lc)
1396+{
1397+ return get_cabac_bypass(&lc->ep->cc);
1398+}
1399+
1400+bool ff_vvc_palette_transpose_flag(VVCLocalContext *lc)
1401+{
1402+ return GET_CABAC(PALETTE_TRANSPOSE_FLAG);
1403+}
1404+
1405+bool ff_vvc_run_copy_flag(VVCLocalContext *lc, const int prev_run_type, const int prev_run_position, const int cur_pos)
1406+{
1407+ uint8_t run_left_lut[] = { 0, 1, 2, 3, 4 };
1408+ uint8_t run_top_lut[] = { 5, 6, 6, 7, 7 };
1409+
1410+ int bin_dist = cur_pos - prev_run_position - 1;
1411+ uint8_t *run_lut = prev_run_type == 1 ? run_top_lut : run_left_lut;
1412+ uint8_t ctx_inc = bin_dist <= 4 ? run_lut[bin_dist] : run_lut[4];
1413+
1414+ return GET_CABAC(RUN_COPY_FLAG + ctx_inc);
1415+}
1416+
1417+bool ff_vvc_copy_above_palette_indices_flag(VVCLocalContext *lc)
1418+{
1419+ return GET_CABAC(COPY_ABOVE_PALETTE_INDICES_FLAG);
1420+}
1421+
1422+int ff_vvc_palette_idx_idc(VVCLocalContext *lc, const int max_palette_index, const bool adjust)
1423+{
1424+ return truncated_binary_decode(lc, max_palette_index - adjust);
1425+}
1426+
1427+int ff_vvc_palette_escape_val(VVCLocalContext *lc)
1428+{
1429+ return kth_order_egk_decode(&lc->ep->cc, 5);
1430+}
1431+
13801432 int ff_vvc_general_merge_flag(VVCLocalContext *lc)
13811433 {
13821434 return GET_CABAC(GENERAL_MERGE_FLAG);
libavcodec/vvc/cabac.h+9−0
@@ -81,6 +81,15 @@ int ff_vvc_intra_luma_mpm_remainder(VVCLocalContext *lc); · 80 unmodified lines
8181 int ff_vvc_cclm_mode_flag(VVCLocalContext *lc);
8282 int ff_vvc_cclm_mode_idx(VVCLocalContext *lc);
8383 int ff_vvc_intra_chroma_pred_mode(VVCLocalContext *lc);
84+int ff_vvc_palette_predictor_run(VVCLocalContext *lc);
85+int ff_vvc_num_signalled_palette_entries(VVCLocalContext *lc);
86+int ff_vvc_new_palette_entries(VVCLocalContext *lc, int bit_dpeth);
87+bool ff_vvc_palette_escape_val_present_flag(VVCLocalContext *lc);
88+bool ff_vvc_palette_transpose_flag(VVCLocalContext *lc);
89+bool ff_vvc_run_copy_flag(VVCLocalContext *lc, int prev_run_type, int prev_run_position, int cur_pos);
90+bool ff_vvc_copy_above_palette_indices_flag(VVCLocalContext *lc);
91+int ff_vvc_palette_idx_idc(VVCLocalContext *lc, int max_palette_index, bool adjust);
92+int ff_vvc_palette_escape_val(VVCLocalContext *lc);
8493
8594 //inter
8695 int ff_vvc_general_merge_flag(VVCLocalContext *lc);

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