History

avcodec/vvcdec: refact, unify vvc_deblock_bs_chroma_{horizontal, vertical}

Nuo Mi committed 2 years ago

Commit cc898321 parent 0a5bbcf1 file · +19 −43Browse files

Unified · Split

libavcodec/vvc/filter.c+19−43
@@ -586,56 +586,33 @@ static void vvc_deblock_bs_luma(const VVCLocalContext *lc, · 585 unmodified lines
586 }586 }
587}587}
588 588
589static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc,589static void vvc_deblock_bs_chroma(const VVCLocalContext *lc,
590 const int x0, const int y0, const int width, const int height, const int rs)590 const int x0, const int y0, const int width, const int height, const int rs, const int vertical)
591{
592 vvc_deblock_bs_luma(lc, x0, y0, width, height, rs, 1);
593}
594
595static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc,
596 const int x0, const int y0, const int width, const int height, const int rs)
597{
598 vvc_deblock_bs_luma(lc, x0, y0, width, height, rs, 0);
599}
600
601static void vvc_deblock_bs_chroma_vertical(const VVCLocalContext *lc,
602 const int x0, const int y0, const int width, const int height, const int rs)
603{591{
604 const VVCFrameContext *fc = lc->fc;592 const VVCFrameContext *fc = lc->fc;
605 const int boundary_left = deblock_is_boundary(lc,593 const int shift = (vertical ? fc->ps.sps->hshift : fc->ps.sps->vshift)[CHROMA];
606 x0 > 0 && !(x0 & ((CHROMA_GRID << fc->ps.sps->hshift[CHROMA]) - 1)), x0, rs, 1);594 const int mask = (CHROMA_GRID << shift) - 1;
607 595 const int pos = vertical ? x0 : y0;
608 if (boundary_left) {
609 for (int i = 0; i < height; i += 2) {
610 for (int c_idx = CB; c_idx <= CR; c_idx++) {
611 const int bs = deblock_bs(lc, x0 - 1, y0 + i, x0, y0 + i, NULL, c_idx, 0, 0);
612 596
613 TAB_BS(fc->tab.vertical_bs[c_idx], x0, (y0 + i)) = bs;597 if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) {
614 }598 const int size = vertical ? height : width;
615 }
616 }
617}
618 599
619static void vvc_deblock_bs_chroma_horizontal(const VVCLocalContext *lc,600 for (int c_idx = CB; c_idx <= CR; c_idx++) {
620 const int x0, const int y0, const int width, const int height, const int rs)601 uint8_t *tab_bs = (vertical ? fc->tab.vertical_bs : fc->tab.horizontal_bs)[c_idx];
621{
622 const VVCFrameContext *fc = lc->fc;
623 const int boundary_upper = deblock_is_boundary(lc,
624 y0 > 0 && !(y0 & ((CHROMA_GRID << fc->ps.sps->vshift[CHROMA]) - 1)), y0, rs, 0);
625 602
626 if (boundary_upper) {603 for (int i = 0; i < size; i += 2) {
627 for (int i = 0; i < width; i += 2) {604 const int x = x0 + i * !vertical;
628 for (int c_idx = CB; c_idx <= CR; c_idx++) {605 const int y = y0 + i * vertical;
629 const int bs = deblock_bs(lc, x0 + i, y0 - 1, x0 + i, y0, NULL, c_idx, 0, 0);606 const int bs = deblock_bs(lc, x - vertical, y - !vertical, x, y, NULL, c_idx, 0, 0);
630 607
631 TAB_BS(fc->tab.horizontal_bs[c_idx], x0 + i, y0) = bs;608 TAB_BS(tab_bs, x, y) = bs;
632 }609 }
633 }610 }
634 }611 }
635}612}
636 613
637typedef void (*deblock_bs_fn)(const VVCLocalContext *lc, const int x0, const int y0,614typedef void (*deblock_bs_fn)(const VVCLocalContext *lc, const int x0, const int y0,
638 const int width, const int height, const int rs);615 const int width, const int height, const int rs, const int vertical);
639 616
640static void vvc_deblock_bs(const VVCLocalContext *lc, const int x0, const int y0, const int rs, const int vertical)617static void vvc_deblock_bs(const VVCLocalContext *lc, const int x0, const int y0, const int rs, const int vertical)
641{618{
@@ -645,9 +622,8 @@ static void vvc_deblock_bs(const VVCLocalContext *lc, const int x0, const int y0 · 3 unmodified lines
645 const int ctb_size = sps->ctb_size_y;622 const int ctb_size = sps->ctb_size_y;
646 const int x_end = FFMIN(x0 + ctb_size, pps->width) >> MIN_TU_LOG2;623 const int x_end = FFMIN(x0 + ctb_size, pps->width) >> MIN_TU_LOG2;
647 const int y_end = FFMIN(y0 + ctb_size, pps->height) >> MIN_TU_LOG2;624 const int y_end = FFMIN(y0 + ctb_size, pps->height) >> MIN_TU_LOG2;
648 deblock_bs_fn deblock_bs[2][2] = {625 deblock_bs_fn deblock_bs[] = {
649 { vvc_deblock_bs_luma_horizontal, vvc_deblock_bs_chroma_horizontal },626 vvc_deblock_bs_luma, vvc_deblock_bs_chroma
650 { vvc_deblock_bs_luma_vertical, vvc_deblock_bs_chroma_vertical }
651 };627 };
652 628
653 for (int is_chroma = 0; is_chroma <= 1; is_chroma++) {629 for (int is_chroma = 0; is_chroma <= 1; is_chroma++) {
@@ -657,8 +633,8 @@ static void vvc_deblock_bs(const VVCLocalContext *lc, const int x0, const int y0 · 3 unmodified lines
657 for (int x = x0 >> MIN_TU_LOG2; x < x_end; x++) {633 for (int x = x0 >> MIN_TU_LOG2; x < x_end; x++) {
658 const int off = y * fc->ps.pps->min_tu_width + x;634 const int off = y * fc->ps.pps->min_tu_width + x;
659 if ((fc->tab.tb_pos_x0[is_chroma][off] >> MIN_TU_LOG2) == x && (fc->tab.tb_pos_y0[is_chroma][off] >> MIN_TU_LOG2) == y) {635 if ((fc->tab.tb_pos_x0[is_chroma][off] >> MIN_TU_LOG2) == x && (fc->tab.tb_pos_y0[is_chroma][off] >> MIN_TU_LOG2) == y) {
660 deblock_bs[vertical][is_chroma](lc, x << MIN_TU_LOG2, y << MIN_TU_LOG2,636 deblock_bs[is_chroma](lc, x << MIN_TU_LOG2, y << MIN_TU_LOG2,
661 fc->tab.tb_width[is_chroma][off] << hs, fc->tab.tb_height[is_chroma][off] << vs, rs);637 fc->tab.tb_width[is_chroma][off] << hs, fc->tab.tb_height[is_chroma][off] << vs, rs, vertical);
662 }638 }
663 }639 }
664 }640 }

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