History

avcodec/vvc: add adaptive color transform support

passed files: ACT_A_Kwai_3.bit ACT_B_Kwai_3.bit

Wu Jianhua committed 1 year ago

Commit fd5d7541 parent 0e4c0db2 files · +13 −2Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/vvc/ctu.c +2 −0
  2. libavcodec/vvc/intra.c +11 −2
libavcodec/vvc/ctu.c+2−0
@@ -392,6 +392,8 @@ static int hls_transform_unit(VVCLocalContext *lc, int x0, int y0,int tu_width, · 391 unmodified lines
392 if (ret < 0)392 if (ret < 0)
393 return ret;393 return ret;
394 set_tb_tab(fc->tab.tu_coded_flag[tb->c_idx], tu->coded_flag[tb->c_idx], fc, tb);394 set_tb_tab(fc->tab.tu_coded_flag[tb->c_idx], tu->coded_flag[tb->c_idx], fc, tb);
395 } else if (cu->act_enabled_flag) {
396 memset(tb->coeffs, 0, tb->tb_width * tb->tb_height * sizeof(*tb->coeffs));
395 }397 }
396 if (tb->c_idx != CR)398 if (tb->c_idx != CR)
397 set_tb_size(fc, tb);399 set_tb_size(fc, tb);
libavcodec/vvc/intra.c+11−2
@@ -523,13 +523,14 @@ static void lmcs_scale_chroma(VVCLocalContext *lc, TransformUnit *tu, TransformB · 522 unmodified lines
523static void add_residual(const VVCLocalContext *lc, TransformUnit *tu, const int target_ch_type)523static void add_residual(const VVCLocalContext *lc, TransformUnit *tu, const int target_ch_type)
524{524{
525 const VVCFrameContext *fc = lc->fc;525 const VVCFrameContext *fc = lc->fc;
526 const CodingUnit *cu = lc->cu;
526 527
527 for (int i = 0; i < tu->nb_tbs; i++) {528 for (int i = 0; i < tu->nb_tbs; i++) {
528 TransformBlock *tb = tu->tbs + i;529 TransformBlock *tb = tu->tbs + i;
529 const int c_idx = tb->c_idx;530 const int c_idx = tb->c_idx;
530 const int ch_type = c_idx > 0;531 const int ch_type = c_idx > 0;
531 const ptrdiff_t stride = fc->frame->linesize[c_idx];532 const ptrdiff_t stride = fc->frame->linesize[c_idx];
532 const bool has_residual = tb->has_coeffs ||533 const bool has_residual = tb->has_coeffs || cu->act_enabled_flag ||
533 (c_idx && tu->joint_cbcr_residual_flag);534 (c_idx && tu->joint_cbcr_residual_flag);
534 uint8_t *dst = POS(c_idx, tb->x0, tb->y0);535 uint8_t *dst = POS(c_idx, tb->x0, tb->y0);
535 536
@@ -543,12 +544,13 @@ static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int target_ · 7 unmodified lines
543 const VVCFrameContext *fc = lc->fc;544 const VVCFrameContext *fc = lc->fc;
544 const CodingUnit *cu = lc->cu;545 const CodingUnit *cu = lc->cu;
545 TransformBlock *tbs = tu->tbs;546 TransformBlock *tbs = tu->tbs;
547 const bool is_act_luma = cu->act_enabled_flag && target_ch_type == LUMA;
546 548
547 for (int i = 0; i < tu->nb_tbs; i++) {549 for (int i = 0; i < tu->nb_tbs; i++) {
548 TransformBlock *tb = tbs + i;550 TransformBlock *tb = tbs + i;
549 const int c_idx = tb->c_idx;551 const int c_idx = tb->c_idx;
550 const int ch_type = c_idx > 0;552 const int ch_type = c_idx > 0;
551 const bool do_itx = ch_type == target_ch_type;553 const bool do_itx = is_act_luma || !cu->act_enabled_flag && ch_type == target_ch_type;
552 554
553 if (tb->has_coeffs && do_itx) {555 if (tb->has_coeffs && do_itx) {
554 if (cu->bdpcm_flag[tb->c_idx])556 if (cu->bdpcm_flag[tb->c_idx])
@@ -568,6 +570,13 @@ static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int target_ · 13 unmodified lines
568 lmcs_scale_chroma(lc, tu, tb, target_ch_type);570 lmcs_scale_chroma(lc, tu, tb, target_ch_type);
569 }571 }
570 }572 }
573
574 if (is_act_luma) {
575 fc->vvcdsp.itx.adaptive_color_transform(
576 tbs[LUMA].coeffs, tbs[CB].coeffs, tbs[CR].coeffs,
577 tbs[LUMA].tb_width, tbs[LUMA].tb_height);
578 }
579
571 add_residual(lc, tu, target_ch_type);580 add_residual(lc, tu, target_ch_type);
572}581}
573 582

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