From patchwork Thu Feb 22 07:13:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 46439 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:26a3:b0:19e:cdac:8cce with SMTP id h35csp184451pze; Wed, 21 Feb 2024 23:47:31 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUwN5Xsq0NOSTHnNWSqR+8NoNfKIoD8txUgyvnFOwZJY6vMwcTUmfaOjTR85Qk5mYXiB2Zm0m+crjqbsksfXMk4ouJ3tYmja77gmQ== X-Google-Smtp-Source: AGHT+IHoov/8V3Vh3Ed1Bgf2fx9MJtTWmouM7T91ZK1xP/q9v42XDx6BNPcuECFmcXA/rbOGSdQ9 X-Received: by 2002:a50:9513:0:b0:563:8a71:eb77 with SMTP id u19-20020a509513000000b005638a71eb77mr12973075eda.4.1708588051280; Wed, 21 Feb 2024 23:47:31 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s19-20020a50d493000000b005642ea0a7besi4692788edi.164.2024.02.21.23.47.30; Wed, 21 Feb 2024 23:47:31 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=A0hdGwb6; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 91EAC68D1FD; Thu, 22 Feb 2024 09:47:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01olkn2065.outbound.protection.outlook.com [40.92.53.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 15A0468D1CC for ; Thu, 22 Feb 2024 09:47:21 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZDNcaU0gfoAfv4Egl8an8m7ITruwtwgt3HKAFHsEBuPxhPSBFUVDjbDJPo1qsPpbEEFyPUvHxwIIWFbKtTV9jYDCHoRDLyP8ToOtBl2hfBYzL3w+FedwYoAVc9a6vKxsues4PKrWNCwfHyewO9VAmjwvQ0ZcNWmhI82AlFZVT2sKWZfTJgwb8Ru7UDewMi30zSHgW9II9ZqtZ4Qg6db5r/mn4m10lvYGEXvXFiwIsGcRhrEMWnHwVEILRD3Mo+nXhUhDkUY+YnK2rvYjI9E/ZZVzjKkkwcEY9FJuOip26OFug2kFG542fglOqY9tXB/LRFePxwrBasoP/UVCEkP7wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qleb8xdIFcvBkT4cl9DmxFlroDN5G8DK1C75dXmUihc=; b=hphFCS4XyM4vweYU10cgyeG3+zazrQ6Yn/xYMvv4iTpQE2as/9YRQxGUnvRHFZjMdMlIxQ8iWOHomzRFMmhcq3vk5droDOohE33JGQXGRgyiMNXkVPUUCv/m3ClHadBu1hcWlj4Msa4T2TI5CdULXCTA0Y4ye1AXG8Au7O/0w/a2HwjDQGbrSMIfNXRvrNP+6lNga7tpe1fg7ODJ7Z7aRYi8eRRuxImH2t8LQGcQRJ/aRda2ZCBl6QG5PMeGDr0P8TrrxWrugbUnmUuM4woQMpAs6V5IEX26ojeh7EV1WH8OXjAVoUHo0mjPS2j0Rnaha2WtDMcq0iAQ+wcCWj/Zlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qleb8xdIFcvBkT4cl9DmxFlroDN5G8DK1C75dXmUihc=; b=A0hdGwb6bu0wPzPdFLMa0+t/9PHt/Znm0eQFTao3GJMZ/mSwEDXiRbzwegGG/v1fMxGWcp4q46HfNPJtHQibQN+6/i9bGr87uWUWU6HcAqU81NlYfvDbyn6L84ChHi/vgNK7wWRYAIH6jQ0QUqB9lY/To049HaBfI4puM1ypHjXjDlU74fcRQlK/ES3w/VyjF1XHLY/k/CT5pRRiEqVHYd/KP00wF4p4xFNnLRMMS9V3fG73LqfHULWBVtpuIcoO0W8BzqQJ0+3rEP9xekMdl5zwZZVieiiEdl8n+4qiR5YW1scEqlTWa0CBIW4wl1wPDG4D2UNMbDHeqBbngvZ/ew== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by TYUPR06MB6241.apcprd06.prod.outlook.com (2603:1096:400:358::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.38; Thu, 22 Feb 2024 07:14:46 +0000 Received: from TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::e139:fd7a:1b66:a3f7]) by TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::e139:fd7a:1b66:a3f7%7]) with mapi id 15.20.7292.036; Thu, 22 Feb 2024 07:14:46 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Feb 2024 15:13:56 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240222071406.5714-1-nuomi2021@gmail.com> References: <20240222071406.5714-1-nuomi2021@gmail.com> X-TMN: [ewpEOt41sek8LNtDYuGa9OSEFBYUPH1M] X-ClientProxiedBy: TYCP286CA0049.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b5::7) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20240222071406.5714-2-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|TYUPR06MB6241:EE_ X-MS-Office365-Filtering-Correlation-Id: 22ab87b5-597f-4ec1-c6f4-08dc3375f2f6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ba0UIguNa87V4elASLAc3MoKPTXcNAb6rpCqSBPY2APrFu2awTQRs9sErkPdW9r76orFbe7qwC7D+nN6UfTjsXtRLE3CJoGV6sY/I5zR4dEUhTpbBVARkZi3XBFSmApuPbXYB7gYWoN+3qmyYlC0/ZfD9x/G0iFgrinIf++xGT6+N7AXCYhpAELzhHJgzK+S10wvJqeNjT3F8ocyaPXyEhLxAh2TtK6GO8fsWzxZ25MxiFKAFa35YWULia1dhefOTmzl4mSPRpqwmGNccf5klY8+2ozk0iftomvaCP75Gcp8Fon/ApzMVReheT9MLYOjDT7llDeOaSFqZq5npylI9DKlTCOMEgw+v0UcGPcAwD0fr+vd5MoS6+Z/W1WKojoxJIulON+AyBHuEBzxccjsSCQwt1KKCBLAaZeTIEONf3c8xb/YVxzXvxwc0G/XKX1tiexIpKvmCwSUthbPdLJhHUgYKifAsDODdEqQeJB0x6kdy9zuvAjKM4rhXlvwelW7WASCVLcYjG5HHnXhPu7hkBNTOUMbh65b0CHoSFXKymk0edvXwSVLfeXAIhumun+m7gsZTAAQ2WDDGgjl42hvssrkuPIt1Vn2IFg31UNh+eQ= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rhJOuLfZgB3DCKQ+SUd5v+Pz7YC4mt/FB2vS8ooDotJzdHtSF7fDCKlZLmrzE9hGDZ6aE9U0MsS6/OpuI6lFWKt3un0iRJpIQXRjsdAxdeV03DV067+uC1h0yhCvDH3bRzZoGcDaGXtS8K3IexoL5FlirJxVWMyybIm06mDsJsbQWl1GxTF3QlbYM53cxpFz1yRZDz2wcP6rIAskDs7nvbAWOZ7nkTFdE8ccdKJwyOTQGdFIkNihxk5iXREuGTAtUz4z22r/tLTGc4bFpRbpRj2ZL8eNUxPoK4fPjr0xA5IXAmmHm+adatVwY9ThWFlGw43GwksuhOABQXmXUO74IZcdLFbY4FXu4zCpcKS4Cyyo7uq9N3ca4ui8vCPCQ+RUfyTqrHdocSETYUmITnIfNCgBPxLSLwnuHk2FjshCxbNtnLBxcbmhyZfpxtUEXUz+C4m1pUFmU/LI8hJJqf8bGgjTmLxKqJpRtIWcvFU0z6m6mwcY5bHxAjtMIo4VHpgeoe653N50Jf1ib0uWLw86s+aIGRbxW7QzFs6CVfmB7EClkBuJ8/gWzPc98qd5jZcC8mdKoxTZM/PKBT02SJpw+2Zhi6pF/3wBS9R9bUTVlBai/qbbv+n29DQmvvf8rAJKbTZrwXKQ2RMoMx35vFn+r/wbpMBTw00+5KLUH6P6qzD8FvQqPHkgQsiMX4pN1ApBeNJWevMGzwFvWcpVZUsyZCUM/fwfI0LzOWtxoXPGq6BKOWBfgqK6ZRcbYoNQhSx8uQOMug3CMbzImkX7z0FRl6OeWWDJipw7e3t33UUvihhyRbZyW0IjLwhz4tSv0fNhm6hmjDIygeckvb6lvBqjjH03wrqB8Xpu1DdGz0m8ufU+wiPA0vTnoMOHJDB1HIXNw/XplvxksR2Si09mtKkrHKcIO0nctmqRRQkxH2RPU/mtqJWNALchdFSTjYqX/vJi00tnWuaHAAeYnhog+I25UVnVlKaSemG6jmyZaTvnjF/jXt9pMD6iTdx9zz8D0uUXC/Rai3QWfeJT8RnqKjr+WRiNDzwdBAquyXvVZHVKClMKDQ/oPRxCJa+1gV81y9LhjkM4AKFcVQnTUf7hHArmHMS+XDYC7uTxoMk8ntlQ1LaADFY/rq5oYHSvuqUDjk0Z9LTySFXDihFW6NfxTsNWEZfy6Ht0ACx254HV9orIA05rqcI4i5w9Cn4r+84m+SXPYoGhU/TDom1r0ujndbquUIYnUaiDFKqwicuwoOlcI5TGH9mJX4QBeSWFVndN5T+ZlNDkmcVr4dLwwdmWCLAenQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22ab87b5-597f-4ec1-c6f4-08dc3375f2f6 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2024 07:14:46.3038 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYUPR06MB6241 Subject: [FFmpeg-devel] [PATCH 01/11] avcodec/vvcdec: refact out deblock_bs to reduce duplicate code X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Nuo Mi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: F19H9VKsJSBK --- libavcodec/vvc/vvc_filter.c | 176 +++++++++++------------------------- 1 file changed, 55 insertions(+), 121 deletions(-) diff --git a/libavcodec/vvc/vvc_filter.c b/libavcodec/vvc/vvc_filter.c index 5fa711c9e0..ca541fd997 100644 --- a/libavcodec/vvc/vvc_filter.c +++ b/libavcodec/vvc/vvc_filter.c @@ -474,8 +474,9 @@ static void vvc_deblock_subblock_bs_horizontal(const VVCLocalContext *lc, } } -static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc, - const int x0, const int y0, const int width, const int height) +static av_always_inline int deblock_bs(const VVCLocalContext *lc, + const int x_p, const int y_p, const int x_q, const int y_q, + const RefPicList *rpl_p, const int c_idx, const int off_to_cb, const uint8_t has_sub_block) { const VVCFrameContext *fc = lc->fc; const MvField *tab_mvf = fc->tab.mvf; @@ -483,6 +484,44 @@ static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc, const int log2_min_tu_size = MIN_TU_LOG2; const int min_pu_width = fc->ps.pps->min_pu_width; const int min_tu_width = fc->ps.pps->min_tu_width; + const int pu_p = (y_p >> log2_min_pu_size) * min_pu_width + (x_p >> log2_min_pu_size); + const int pu_q = (y_q >> log2_min_pu_size) * min_pu_width + (x_q >> log2_min_pu_size); + const MvField *mvf_p = &tab_mvf[pu_p]; + const MvField *mvf_q = &tab_mvf[pu_q]; + const uint8_t chroma = !!c_idx; + const int tu_p = (y_p >> log2_min_tu_size) * min_tu_width + (x_p >> log2_min_tu_size); + const int tu_q = (y_q >> log2_min_tu_size) * min_tu_width + (x_q >> log2_min_tu_size); + const uint8_t pcmf = fc->tab.pcmf[chroma][tu_p] && fc->tab.pcmf[chroma][tu_q]; + + if (pcmf) + return 0; + + if (mvf_p->pred_flag == PF_INTRA || mvf_q->pred_flag == PF_INTRA || mvf_p->ciip_flag || mvf_q->ciip_flag) + return 2; + + if (chroma) { + return fc->tab.tu_coded_flag[c_idx][tu_p] || + fc->tab.tu_coded_flag[c_idx][tu_q] || + fc->tab.tu_joint_cbcr_residual_flag[tu_p] || + fc->tab.tu_joint_cbcr_residual_flag[tu_q]; + } + + if (fc->tab.tu_coded_flag[LUMA][tu_p] || fc->tab.tu_coded_flag[LUMA][tu_q]) + return 1; + + if ((off_to_cb && ((off_to_cb % 8) || !has_sub_block))) + return 0; // inside a cu, not aligned to 8 or with no subblocks + + return boundary_strength(lc, mvf_q, mvf_p, rpl_p); +} + +static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc, + const int x0, const int y0, const int width, const int height) +{ + const VVCFrameContext *fc = lc->fc; + const MvField *tab_mvf = fc->tab.mvf; + const int log2_min_pu_size = MIN_PU_LOG2; + const int min_pu_width = fc->ps.pps->min_pu_width; const int min_cb_log2 = fc->ps.sps->min_cb_log2_size_y; const int min_cb_width = fc->ps.pps->min_cb_width; const int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width + @@ -494,6 +533,7 @@ static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc, const int cb_x = fc->tab.cb_pos_x[LUMA][off_q]; const int cb_y = fc->tab.cb_pos_y[LUMA][off_q]; const int cb_width = fc->tab.cb_width[LUMA][off_q]; + const int off_x = cb_x - x0; if (!is_intra) { if (fc->tab.msf[off_q] || fc->tab.iaf[off_q]) @@ -514,34 +554,9 @@ static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc, if (boundary_left) { const RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ? ff_vvc_get_ref_list(fc, fc->ref, x0 - 1, y0) : lc->sc->rpl; - const int xp_pu = (x0 - 1) >> log2_min_pu_size; - const int xq_pu = x0 >> log2_min_pu_size; - const int xp_tu = (x0 - 1) >> log2_min_tu_size; - const int xq_tu = x0 >> log2_min_tu_size; - for (int i = 0; i < height; i += 4) { - const int off_x = cb_x - x0; - const int y_pu = (y0 + i) >> log2_min_pu_size; - const int y_tu = (y0 + i) >> log2_min_tu_size; - const MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; - const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; - const uint8_t left_cbf_luma = fc->tab.tu_coded_flag[LUMA][y_tu * min_tu_width + xp_tu]; - const uint8_t curr_cbf_luma = fc->tab.tu_coded_flag[LUMA][y_tu * min_tu_width + xq_tu]; - const uint8_t pcmf = fc->tab.pcmf[LUMA][y_tu * min_tu_width + xp_tu] && - fc->tab.pcmf[LUMA][y_tu * min_tu_width + xq_tu]; uint8_t max_len_p, max_len_q; - int bs; - - if (pcmf) - bs = 0; - else if (curr->pred_flag == PF_INTRA || left->pred_flag == PF_INTRA || curr->ciip_flag || left->ciip_flag) - bs = 2; - else if (curr_cbf_luma || left_cbf_luma) - bs = 1; - else if (off_x && ((off_x % 8) || !has_vertical_sb)) - bs = 0; ////inside a cu, not aligned to 8 or with no subblocks - else - bs = boundary_strength(lc, curr, left, rpl_left); + const int bs = deblock_bs(lc, x0 - 1, y0 + i, x0, y0 + i, rpl_left, 0, off_x, has_vertical_sb); TAB_BS(fc->tab.vertical_bs[LUMA], x0, (y0 + i)) = bs; @@ -561,11 +576,9 @@ static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc, const int x0, const int y0, const int width, const int height) { const VVCFrameContext *fc = lc->fc; - const MvField *tab_mvf = fc->tab.mvf; + const MvField *tab_mvf = fc->tab.mvf; const int log2_min_pu_size = MIN_PU_LOG2; - const int log2_min_tu_size = MIN_TU_LOG2; const int min_pu_width = fc->ps.pps->min_pu_width; - const int min_tu_width = fc->ps.pps->min_tu_width; const int min_cb_log2 = fc->ps.sps->min_cb_log2_size_y; const int min_cb_width = fc->ps.pps->min_cb_width; const int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width + @@ -577,6 +590,7 @@ static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc, const int cb_x = fc->tab.cb_pos_x[LUMA][off_q]; const int cb_y = fc->tab.cb_pos_y[LUMA][off_q]; const int cb_height = fc->tab.cb_height[LUMA][off_q]; + const int off_y = y0 - cb_y; if (!is_intra) { if (fc->tab.msf[off_q] || fc->tab.iaf[off_q]) @@ -596,34 +610,10 @@ static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc, if (boundary_upper) { const RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ? ff_vvc_get_ref_list(fc, fc->ref, x0, y0 - 1) : lc->sc->rpl; - int yp_pu = (y0 - 1) >> log2_min_pu_size; - int yq_pu = y0 >> log2_min_pu_size; - int yp_tu = (y0 - 1) >> log2_min_tu_size; - int yq_tu = y0 >> log2_min_tu_size; for (int i = 0; i < width; i += 4) { - const int off_y = y0 - cb_y; - const int x_pu = (x0 + i) >> log2_min_pu_size; - const int x_tu = (x0 + i) >> log2_min_tu_size; - const MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; - const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; - const uint8_t top_cbf_luma = fc->tab.tu_coded_flag[LUMA][yp_tu * min_tu_width + x_tu]; - const uint8_t curr_cbf_luma = fc->tab.tu_coded_flag[LUMA][yq_tu * min_tu_width + x_tu]; - const uint8_t pcmf = fc->tab.pcmf[LUMA][yp_tu * min_tu_width + x_tu] && - fc->tab.pcmf[LUMA][yq_tu * min_tu_width + x_tu]; uint8_t max_len_p, max_len_q; - int bs; - - if (pcmf) - bs = 0; - else if (curr->pred_flag == PF_INTRA || top->pred_flag == PF_INTRA || curr->ciip_flag || top->ciip_flag) - bs = 2; - else if (curr_cbf_luma || top_cbf_luma) - bs = 1; - else if (off_y && ((off_y % 8) || !has_horizontal_sb)) - bs = 0; //inside a cu, not aligned to 8 or with no subblocks - else - bs = boundary_strength(lc, curr, top, rpl_top); + const int bs = deblock_bs(lc, x0 + i, y0 - 1, x0 + i, y0, rpl_top, 0, off_y, has_horizontal_sb); TAB_BS(fc->tab.horizontal_bs[LUMA], x0 + i, y0) = bs; @@ -642,12 +632,7 @@ static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc, static void vvc_deblock_bs_chroma_vertical(const VVCLocalContext *lc, const int x0, const int y0, const int width, const int height) { - const VVCFrameContext *fc = lc->fc; - const MvField *tab_mvf = fc->tab.mvf; - const int log2_min_pu_size = MIN_PU_LOG2; - const int log2_min_tu_size = MIN_PU_LOG2; - const int min_pu_width = fc->ps.pps->min_pu_width; - const int min_tu_width = fc->ps.pps->min_tu_width; + const VVCFrameContext *fc = lc->fc; int boundary_left; // bs for vertical TU boundaries @@ -662,34 +647,11 @@ static void vvc_deblock_bs_chroma_vertical(const VVCLocalContext *lc, boundary_left = 0; if (boundary_left) { - const int xp_pu = (x0 - 1) >> log2_min_pu_size; - const int xq_pu = x0 >> log2_min_pu_size; - const int xp_tu = (x0 - 1) >> log2_min_tu_size; - const int xq_tu = x0 >> log2_min_tu_size; - for (int i = 0; i < height; i += 2) { - const int y_pu = (y0 + i) >> log2_min_pu_size; - const int y_tu = (y0 + i) >> log2_min_tu_size; - const MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; - const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; - const int left_tu = y_tu * min_tu_width + xp_tu; - const int curr_tu = y_tu * min_tu_width + xq_tu; - const uint8_t pcmf = fc->tab.pcmf[CHROMA][left_tu] && fc->tab.pcmf[CHROMA][curr_tu]; - - for (int c = CB; c <= CR; c++) { - uint8_t cbf = fc->tab.tu_coded_flag[c][left_tu] | - fc->tab.tu_coded_flag[c][curr_tu] | - fc->tab.tu_joint_cbcr_residual_flag[left_tu] | - fc->tab.tu_joint_cbcr_residual_flag[curr_tu]; - int bs = 0; - - if (pcmf) - bs = 0; - else if (curr->pred_flag == PF_INTRA || left->pred_flag == PF_INTRA || curr->ciip_flag || left->ciip_flag) - bs = 2; - else if (cbf) - bs = 1; - TAB_BS(fc->tab.vertical_bs[c], x0, (y0 + i)) = bs; + for (int c_idx = CB; c_idx <= CR; c_idx++) { + const int bs = deblock_bs(lc, x0 - 1, y0 + i, x0, y0 + i, NULL, c_idx, 0, 0); + + TAB_BS(fc->tab.vertical_bs[c_idx], x0, (y0 + i)) = bs; } } } @@ -699,11 +661,6 @@ static void vvc_deblock_bs_chroma_horizontal(const VVCLocalContext *lc, const int x0, const int y0, const int width, const int height) { const VVCFrameContext *fc = lc->fc; - MvField *tab_mvf = fc->tab.mvf; - const int log2_min_pu_size = MIN_PU_LOG2; - const int log2_min_tu_size = MIN_PU_LOG2; - const int min_pu_width = fc->ps.pps->min_pu_width; - const int min_tu_width = fc->ps.pps->min_tu_width; int boundary_upper; boundary_upper = y0 > 0 && !(y0 & ((CHROMA_GRID << fc->ps.sps->vshift[1]) - 1)); @@ -717,34 +674,11 @@ static void vvc_deblock_bs_chroma_horizontal(const VVCLocalContext *lc, boundary_upper = 0; if (boundary_upper) { - int yp_pu = (y0 - 1) >> log2_min_pu_size; - int yq_pu = y0 >> log2_min_pu_size; - int yp_tu = (y0 - 1) >> log2_min_tu_size; - int yq_tu = y0 >> log2_min_tu_size; - for (int i = 0; i < width; i += 2) { - const int x_pu = (x0 + i) >> log2_min_pu_size; - const int x_tu = (x0 + i) >> log2_min_tu_size; - const MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; - const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; - const int top_tu = yp_tu * min_tu_width + x_tu; - const int curr_tu = yq_tu * min_tu_width + x_tu; - const uint8_t pcmf = fc->tab.pcmf[CHROMA][top_tu] && fc->tab.pcmf[CHROMA][curr_tu]; - - for (int c = CB; c <= CR; c++) { - uint8_t cbf = fc->tab.tu_coded_flag[c][top_tu] | - fc->tab.tu_coded_flag[c][curr_tu] | - fc->tab.tu_joint_cbcr_residual_flag[top_tu] | - fc->tab.tu_joint_cbcr_residual_flag[curr_tu]; - int bs = 0; - - if (pcmf) - bs = 0; - else if (curr->pred_flag == PF_INTRA || top->pred_flag == PF_INTRA || curr->ciip_flag || top->ciip_flag) - bs = 2; - else if (cbf) - bs = 1; - TAB_BS(fc->tab.horizontal_bs[c], x0 + i, y0) = bs; + for (int c_idx = CB; c_idx <= CR; c_idx++) { + const int bs = deblock_bs(lc, x0 + i, y0 - 1, x0 + i, y0, NULL, c_idx, 0, 0); + + TAB_BS(fc->tab.horizontal_bs[c_idx], x0 + i, y0) = bs; } } }