History

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

Nuo Mi committed 2 years ago

Commit 0a5bbcf1 parent cb6538e1 file · +36 −72Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/vvc/filter.c+36−72
@@ -538,100 +538,64 @@ static int deblock_is_boundary(const VVCLocalContext *lc, const int boundary, · 537 unmodified lines
538 return boundary;538 return boundary;
539}539}
540 540
541static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc,541static void vvc_deblock_bs_luma(const VVCLocalContext *lc,
542 const int x0, const int y0, const int width, const int height, const int rs)542 const int x0, const int y0, const int width, const int height, const int rs, const int vertical)
543{543{
544 const VVCFrameContext *fc = lc->fc;544 const VVCFrameContext *fc = lc->fc;
545 const MvField *tab_mvf = fc->tab.mvf;545 const MvField *tab_mvf = fc->tab.mvf;
546 const int mask = LUMA_GRID - 1;
546 const int log2_min_pu_size = MIN_PU_LOG2;547 const int log2_min_pu_size = MIN_PU_LOG2;
547 const int min_pu_width = fc->ps.pps->min_pu_width;548 const int min_pu_width = fc->ps.pps->min_pu_width;
548 const int min_cb_log2 = fc->ps.sps->min_cb_log2_size_y;549 const int min_cb_log2 = fc->ps.sps->min_cb_log2_size_y;
549 const int min_cb_width = fc->ps.pps->min_cb_width;550 const int min_cb_width = fc->ps.pps->min_cb_width;
550 const int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +551 const int pos = vertical ? x0 : y0;
551 (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
552 int boundary_left;
553 int has_vertical_sb = 0;
554
555 const int off_q = (y0 >> min_cb_log2) * min_cb_width + (x0 >> min_cb_log2);552 const int off_q = (y0 >> min_cb_log2) * min_cb_width + (x0 >> min_cb_log2);
556 const int cb_x = fc->tab.cb_pos_x[LUMA][off_q];553 const int cb = (vertical ? fc->tab.cb_pos_x : fc->tab.cb_pos_y )[LUMA][off_q];
557 const int cb_width = fc->tab.cb_width[LUMA][off_q];554 const int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
558 const int off_x = cb_x - x0;555 (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
559 556
560 if (!is_intra) {557 if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) {
561 if (fc->tab.msf[off_q] || fc->tab.iaf[off_q])558 const int size = vertical ? height : width;
562 has_vertical_sb = cb_width > 8;559 const int off = cb - pos;
563 }560 const int cb_size = (vertical ? fc->tab.cb_width : fc->tab.cb_height)[LUMA][off_q];
564 561 const int has_sb = !is_intra && (fc->tab.msf[off_q] || fc->tab.iaf[off_q]) && cb_size > 8;
565 // bs for vertical TU boundaries562 const int flag = vertical ? BOUNDARY_LEFT_SLICE : BOUNDARY_UPPER_SLICE;
566 boundary_left = deblock_is_boundary(lc, x0 > 0 && !(x0 & 3), x0, rs, 1);563 const RefPicList *rpl_p =
567 564 (lc->boundary_flags & flag) ? ff_vvc_get_ref_list(fc, fc->ref, x0 - vertical, y0 - !vertical) : lc->sc->rpl;
568 if (boundary_left) {565 uint8_t *tab_bs = vertical ? fc->tab.vertical_bs[LUMA] : fc->tab.horizontal_bs[LUMA];
569 const RefPicList *rpl_left =566 uint8_t *tab_max_len_p = vertical ? fc->tab.vertical_p : fc->tab.horizontal_p;
570 (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ? ff_vvc_get_ref_list(fc, fc->ref, x0 - 1, y0) : lc->sc->rpl;567 uint8_t *tab_max_len_q = vertical ? fc->tab.vertical_q : fc->tab.horizontal_q;
571 for (int i = 0; i < height; i += 4) {568
569 for (int i = 0; i < size; i += 4) {
570 const int x = x0 + i * !vertical;
571 const int y = y0 + i * vertical;
572 uint8_t max_len_p, max_len_q;572 uint8_t max_len_p, max_len_q;
573 const int bs = deblock_bs(lc, x0 - 1, y0 + i, x0, y0 + i, rpl_left, 0, off_x, has_vertical_sb);573 const int bs = deblock_bs(lc, x - vertical, y - !vertical, x, y, rpl_p, LUMA, off, has_sb);
574 574
575 TAB_BS(fc->tab.vertical_bs[LUMA], x0, (y0 + i)) = bs;575 TAB_BS(tab_bs, x, y) = bs;
576 576
577 derive_max_filter_length_luma(fc, x0, y0 + i, is_intra, has_vertical_sb, 1, &max_len_p, &max_len_q);577 derive_max_filter_length_luma(fc, x, y, is_intra, has_sb, vertical, &max_len_p, &max_len_q);
578 TAB_MAX_LEN(fc->tab.vertical_p, x0, y0 + i) = max_len_p;578 TAB_MAX_LEN(tab_max_len_p, x, y) = max_len_p;
579 TAB_MAX_LEN(fc->tab.vertical_q, x0, y0 + i) = max_len_q;579 TAB_MAX_LEN(tab_max_len_q, x, y) = max_len_q;
580 }580 }
581 }581 }
582 582
583 if (!is_intra) {583 if (!is_intra) {
584 if (fc->tab.msf[off_q] || fc->tab.iaf[off_q])584 if (fc->tab.msf[off_q] || fc->tab.iaf[off_q])
585 vvc_deblock_subblock_bs(lc, cb_x, x0, y0, width, height, 1);585 vvc_deblock_subblock_bs(lc, cb, x0, y0, width, height, vertical);
586 }586 }
587}587}
588 588
589static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc,589static void vvc_deblock_bs_luma_vertical(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)
591{591{
592 const VVCFrameContext *fc = lc->fc;592 vvc_deblock_bs_luma(lc, x0, y0, width, height, rs, 1);
593 const MvField *tab_mvf = fc->tab.mvf;593}
594 const int log2_min_pu_size = MIN_PU_LOG2;
595 const int min_pu_width = fc->ps.pps->min_pu_width;
596 const int min_cb_log2 = fc->ps.sps->min_cb_log2_size_y;
597 const int min_cb_width = fc->ps.pps->min_cb_width;
598 const int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
599 (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
600 int boundary_upper;
601 int has_horizontal_sb = 0;
602
603 const int off_q = (y0 >> min_cb_log2) * min_cb_width + (x0 >> min_cb_log2);
604 const int cb_y = fc->tab.cb_pos_y[LUMA][off_q];
605 const int cb_height = fc->tab.cb_height[LUMA][off_q];
606 const int off_y = y0 - cb_y;
607
608 if (!is_intra) {
609 if (fc->tab.msf[off_q] || fc->tab.iaf[off_q])
610 has_horizontal_sb = cb_height > 8;
611 }
612
613 boundary_upper = deblock_is_boundary(lc, y0 > 0 && !(y0 & 3), y0, rs, 0);
614
615 if (boundary_upper) {
616 const RefPicList *rpl_top =
617 (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ? ff_vvc_get_ref_list(fc, fc->ref, x0, y0 - 1) : lc->sc->rpl;
618
619 for (int i = 0; i < width; i += 4) {
620 uint8_t max_len_p, max_len_q;
621 const int bs = deblock_bs(lc, x0 + i, y0 - 1, x0 + i, y0, rpl_top, 0, off_y, has_horizontal_sb);
622
623 TAB_BS(fc->tab.horizontal_bs[LUMA], x0 + i, y0) = bs;
624
625 derive_max_filter_length_luma(fc, x0 + i, y0, is_intra, has_horizontal_sb, 0, &max_len_p, &max_len_q);
626 TAB_MAX_LEN(fc->tab.horizontal_p, x0 + i, y0) = max_len_p;
627 TAB_MAX_LEN(fc->tab.horizontal_q, x0 + i, y0) = max_len_q;
628 }
629 }
630 594
631 if (!is_intra) {595static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc,
632 if (fc->tab.msf[off_q] || fc->tab.iaf[off_q])596 const int x0, const int y0, const int width, const int height, const int rs)
633 vvc_deblock_subblock_bs(lc, cb_y, x0, y0, width, height, 0);597{
634 }598 vvc_deblock_bs_luma(lc, x0, y0, width, height, rs, 0);
635}599}
636 600
637static void vvc_deblock_bs_chroma_vertical(const VVCLocalContext *lc,601static void vvc_deblock_bs_chroma_vertical(const 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