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

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
538538 return boundary;
539539 }
540540
541−static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc,
542− const int x0, const int y0, const int width, const int height, const int rs)
541+static void vvc_deblock_bs_luma(const VVCLocalContext *lc,
542+ const int x0, const int y0, const int width, const int height, const int rs, const int vertical)
543543 {
544544 const VVCFrameContext *fc = lc->fc;
545545 const MvField *tab_mvf = fc->tab.mvf;
546+ const int mask = LUMA_GRID - 1;
546547 const int log2_min_pu_size = MIN_PU_LOG2;
547548 const int min_pu_width = fc->ps.pps->min_pu_width;
548549 const int min_cb_log2 = fc->ps.sps->min_cb_log2_size_y;
549550 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− (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
552− int boundary_left;
553− int has_vertical_sb = 0;
554−
551+ const int pos = vertical ? x0 : y0;
555552 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];
557− const int cb_width = fc->tab.cb_width[LUMA][off_q];
558− const int off_x = cb_x - x0;
559−
560− if (!is_intra) {
561− if (fc->tab.msf[off_q] || fc->tab.iaf[off_q])
562− has_vertical_sb = cb_width > 8;
563− }
564−
565− // bs for vertical TU boundaries
566− boundary_left = deblock_is_boundary(lc, x0 > 0 && !(x0 & 3), x0, rs, 1);
567−
568− if (boundary_left) {
569− const RefPicList *rpl_left =
570− (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ? ff_vvc_get_ref_list(fc, fc->ref, x0 - 1, y0) : lc->sc->rpl;
571− for (int i = 0; i < height; i += 4) {
553+ const int cb = (vertical ? fc->tab.cb_pos_x : fc->tab.cb_pos_y )[LUMA][off_q];
554+ const int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
555+ (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
556+
557+ if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) {
558+ const int size = vertical ? height : width;
559+ const int off = cb - pos;
560+ const int cb_size = (vertical ? fc->tab.cb_width : fc->tab.cb_height)[LUMA][off_q];
561+ const int has_sb = !is_intra && (fc->tab.msf[off_q] || fc->tab.iaf[off_q]) && cb_size > 8;
562+ const int flag = vertical ? BOUNDARY_LEFT_SLICE : BOUNDARY_UPPER_SLICE;
563+ const RefPicList *rpl_p =
564+ (lc->boundary_flags & flag) ? ff_vvc_get_ref_list(fc, fc->ref, x0 - vertical, y0 - !vertical) : lc->sc->rpl;
565+ uint8_t *tab_bs = vertical ? fc->tab.vertical_bs[LUMA] : fc->tab.horizontal_bs[LUMA];
566+ uint8_t *tab_max_len_p = vertical ? fc->tab.vertical_p : fc->tab.horizontal_p;
567+ uint8_t *tab_max_len_q = vertical ? fc->tab.vertical_q : fc->tab.horizontal_q;
568+
569+ for (int i = 0; i < size; i += 4) {
570+ const int x = x0 + i * !vertical;
571+ const int y = y0 + i * vertical;
572572 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);
574574
575− TAB_BS(fc->tab.vertical_bs[LUMA], x0, (y0 + i)) = bs;
575+ TAB_BS(tab_bs, x, y) = bs;
576576
577− derive_max_filter_length_luma(fc, x0, y0 + i, is_intra, has_vertical_sb, 1, &max_len_p, &max_len_q);
578− TAB_MAX_LEN(fc->tab.vertical_p, x0, y0 + i) = max_len_p;
579− TAB_MAX_LEN(fc->tab.vertical_q, x0, y0 + i) = 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(tab_max_len_p, x, y) = max_len_p;
579+ TAB_MAX_LEN(tab_max_len_q, x, y) = max_len_q;
580580 }
581581 }
582582
583583 if (!is_intra) {
584584 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);
586586 }
587587 }
588588
589−static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc,
589+static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc,
590590 const int x0, const int y0, const int width, const int height, const int rs)
591591 {
592− const VVCFrameContext *fc = lc->fc;
593− const MvField *tab_mvf = fc->tab.mvf;
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− }
592+ vvc_deblock_bs_luma(lc, x0, y0, width, height, rs, 1);
593+}
630594
631− if (!is_intra) {
632− if (fc->tab.msf[off_q] || fc->tab.iaf[off_q])
633− vvc_deblock_subblock_bs(lc, cb_y, x0, y0, width, height, 0);
634− }
595+static 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);
635599 }
636600
637601 static 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