History

avcodec/vvcdec: refact out deblock_is_boundary

Nuo Mi committed 2 years ago

Commit 0d12e9c1 parent 4020e681 file · +26 −40Browse files

Unified · Split

libavcodec/vvc/vvc_filter.c+26−40
@@ -528,6 +528,26 @@ static av_always_inline int deblock_bs(const VVCLocalContext *lc, · 527 unmodified lines
528528 return boundary_strength(lc, mvf_q, mvf_p, rpl_p);
529529 }
530530
531+static int deblock_is_boundary(const VVCLocalContext *lc, const int boundary,
532+ const int pos, const int vertical)
533+{
534+ const VVCFrameContext *fc = lc->fc;
535+ const H266RawPPS *rpps = fc->ps.pps->r;
536+ int flag;
537+ if (boundary && (pos % fc->ps.sps->ctb_size_y) == 0) {
538+ flag = vertical ? BOUNDARY_LEFT_SLICE : BOUNDARY_UPPER_SLICE;
539+ if (lc->boundary_flags & flag &&
540+ !rpps->pps_loop_filter_across_slices_enabled_flag)
541+ return 0;
542+
543+ flag = vertical ? BOUNDARY_LEFT_TILE : BOUNDARY_UPPER_TILE;
544+ if (lc->boundary_flags & flag &&
545+ !rpps->pps_loop_filter_across_tiles_enabled_flag)
546+ return 0;
547+ }
548+ return boundary;
549+}
550+
531551 static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc,
532552 const int x0, const int y0, const int width, const int height)
533553 {
@@ -554,15 +574,7 @@ static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc, · 20 unmodified lines
554574 }
555575
556576 // bs for vertical TU boundaries
557− boundary_left = x0 > 0 && !(x0 & 3);
558− if (boundary_left &&
559− ((!fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag &&
560− lc->boundary_flags & BOUNDARY_LEFT_SLICE &&
561− (x0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0) ||
562− (!fc->ps.pps->r->pps_loop_filter_across_tiles_enabled_flag &&
563− lc->boundary_flags & BOUNDARY_LEFT_TILE &&
564− (x0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0)))
565− boundary_left = 0;
577+ boundary_left = deblock_is_boundary(lc, x0 > 0 && !(x0 & 3), x0, 1);
566578
567579 if (boundary_left) {
568580 const RefPicList *rpl_left =
@@ -610,15 +622,7 @@ static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc, · 41 unmodified lines
610622 has_horizontal_sb = cb_height > 8;
611623 }
612624
613− boundary_upper = y0 > 0 && !(y0 & 3);
614− if (boundary_upper &&
615− ((!fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag &&
616− lc->boundary_flags & BOUNDARY_UPPER_SLICE &&
617− (y0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0) ||
618− (!fc->ps.pps->r->pps_loop_filter_across_tiles_enabled_flag &&
619− lc->boundary_flags & BOUNDARY_UPPER_TILE &&
620− (y0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0)))
621− boundary_upper = 0;
625+ boundary_upper = deblock_is_boundary(lc, y0 > 0 && !(y0 & 3), y0, 0);
622626
623627 if (boundary_upper) {
624628 const RefPicList *rpl_top =
@@ -646,18 +650,9 @@ static void vvc_deblock_bs_chroma_vertical(const VVCLocalContext *lc, · 21 unmodified lines
646650 const int x0, const int y0, const int width, const int height)
647651 {
648652 const VVCFrameContext *fc = lc->fc;
649− int boundary_left;
650−
651653 // bs for vertical TU boundaries
652− boundary_left = x0 > 0 && !(x0 & ((CHROMA_GRID << fc->ps.sps->hshift[1]) - 1));
653− if (boundary_left &&
654− ((!fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag &&
655− lc->boundary_flags & BOUNDARY_LEFT_SLICE &&
656− (x0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0) ||
657− (!fc->ps.pps->r->pps_loop_filter_across_tiles_enabled_flag &&
658− lc->boundary_flags & BOUNDARY_LEFT_TILE &&
659− (x0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0)))
660− boundary_left = 0;
654+ const int boundary_left = deblock_is_boundary(lc,
655+ x0 > 0 && !(x0 & ((CHROMA_GRID << fc->ps.sps->hshift[CHROMA]) - 1)), x0, 1);
661656
662657 if (boundary_left) {
663658 for (int i = 0; i < height; i += 2) {
@@ -674,17 +669,8 @@ static void vvc_deblock_bs_chroma_horizontal(const VVCLocalContext *lc, · 10 unmodified lines
674669 const int x0, const int y0, const int width, const int height)
675670 {
676671 const VVCFrameContext *fc = lc->fc;
677− int boundary_upper;
678−
679− boundary_upper = y0 > 0 && !(y0 & ((CHROMA_GRID << fc->ps.sps->vshift[1]) - 1));
680− if (boundary_upper &&
681− ((!fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag &&
682− lc->boundary_flags & BOUNDARY_UPPER_SLICE &&
683− (y0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0) ||
684− (!fc->ps.pps->r->pps_loop_filter_across_tiles_enabled_flag &&
685− lc->boundary_flags & BOUNDARY_UPPER_TILE &&
686− (y0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0)))
687− boundary_upper = 0;
672+ const int boundary_upper = deblock_is_boundary(lc,
673+ y0 > 0 && !(y0 & ((CHROMA_GRID << fc->ps.sps->vshift[CHROMA]) - 1)), y0, 0);
688674
689675 if (boundary_upper) {
690676 for (int i = 0; i < width; i += 2) {

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