From patchwork Sat Jun 22 06:24:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 50063 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:ae71:0:b0:482:c625:d099 with SMTP id w17csp937573vqz; Fri, 21 Jun 2024 23:32:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2MEVeAxqvaJSi9dlCHgKw5BC/afdNbA6eefHSLSFPRIJhk5fKXDPETkilA5s4u2IRMP0VwZ6/MHStmkSjMIjMr5a4PkCbvJa2gA== X-Google-Smtp-Source: AGHT+IExlfN4FSZWieLc3857mGjbLfbghrHPymhmvL6+JgfZbk8LSEvUDsjjiDiGmxaJz+SMIPCj X-Received: by 2002:ac2:4433:0:b0:52c:df55:e112 with SMTP id 2adb3069b0e04-52cdf55e20amr200067e87.6.1719037972278; Fri, 21 Jun 2024 23:32:52 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-52cd63b45f3si861637e87.60.2024.06.21.23.32.51; Fri, 21 Jun 2024 23:32:52 -0700 (PDT) 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=aHWjcWlr; 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 57B0B68D901; Sat, 22 Jun 2024 09:24:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01olkn2034.outbound.protection.outlook.com [40.92.53.34]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 689CE68D870 for ; Sat, 22 Jun 2024 09:24:41 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MxWMNXJJtZ/fkjXZBuOChQDawEjRVQUsvhCq2NtvlrMXR7leJGB9sh5hwibRWpFl3arCnuCU7+Xaky8J/cQIZQgGTExMnI+SssbNUEPJ55qPstrwkKMFUY2tgsIdnD5O0DXIPrzKeX9xI/ZvQ+hKtcsUPREcwYsR0FtJcTzoc4121OlVBjzFoL28IjerKb9gnW1nP6e7kNAwbxZxIwf5AAA63KogPeeA2z7ppIs/s3ExUcKLsSu0XRMRnGPOjwS01c0LmLKRnR56BoNyOP/4fBfeahtsaSkdK7xjXDdok+0wEXRAlmp/pyCD1pSb/JmsgmgOGsfrcIJfaPBIfqVWTg== 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=QVvX/Ic6ZLvs9IsJo+Tus8PxyXmmP3Vw+5bfpMTqAwQ=; b=mAzqoc4g3U1mhGA8SvOoqSlBKquptZXwN3La2OJ8z4k4spi4uGm54hxyB1VLHV7Lolhs9WNlWMjwZg0MuUwnNiHvlafF22kAIvlZrBtfevyJN6mywbkc54U5K7lby5FVtyCZCWAVtjPtiXODYZypul1ZCugILQCTbGjEbNeDyy2wsSAaFolahkZo/FuJKTSDumcgKE5Quy/iwS4x7whBqBlXSSxe55zq731pcUklEPY/rgbJRi706Nd0536snRya4uES3Y/UDQM4GAiw9gfOr9jtWWL1aFUcbw2CcJkjzyiKrcnISzD6N+Mv+QhqduQ/cYpSlkl5GA+kLYH5aT0Ccw== 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=QVvX/Ic6ZLvs9IsJo+Tus8PxyXmmP3Vw+5bfpMTqAwQ=; b=aHWjcWlrsTh896I6RyIiImkUqC1yP/06L8Y5ZlajFoefCc14fWOkFeLrAU3yzdUXF6+LqH83baIjQ6erD9OjgbNzLZ8FeLqMazg7/5Isha1cDQ+m+FSMVzVcJqYhm4Klr4uPBg5rAIQCpQSzbmRiCLiOmq58UsCJJWfetf+ocWRasNGJyxtXpUbKHVKofVozvMGKfUgV7yvCRQhg7LnDMwFoDA5AI6rUs3a1wvHKbViS8WeN1IzuzdXFV3gSRMLKMzpjvfqN1x6zA966xJNMzAAV/0RHmAScPRNbzhUpf/aeBRsiDIx/zFvVKsscIChX+Uq0qjTm+kAC9lhDMD6b2Q== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by KL1PR06MB6258.apcprd06.prod.outlook.com (2603:1096:820:d8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.25; Sat, 22 Jun 2024 06:24:25 +0000 Received: from TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::81f7:9125:583a:1cca]) by TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::81f7:9125:583a:1cca%3]) with mapi id 15.20.7698.017; Sat, 22 Jun 2024 06:24:25 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Sat, 22 Jun 2024 14:24:03 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240622062405.285359-1-nuomi2021@gmail.com> References: <20240622062405.285359-1-nuomi2021@gmail.com> X-TMN: [+5o9aMMZd6aPRu/umDRqLkbgRM8Rlo8k] X-ClientProxiedBy: TY2PR04CA0023.apcprd04.prod.outlook.com (2603:1096:404:f6::35) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20240622062405.285359-16-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|KL1PR06MB6258:EE_ X-MS-Office365-Filtering-Correlation-Id: e61321fb-04e5-41c2-e78e-08dc9283f64f X-Microsoft-Antispam: BCL:0; ARA:14566002|461199025|440099025|3412199022|1710799023; X-Microsoft-Antispam-Message-Info: Nogj1GbtvpnEUke4Fq7tH7W6PGcQPfBbyGDSOiUUc5lgz73H+3jXcUPyZAT27XZnCemwdkg0WXaatK0PYt1RmY20mD0I6wZaxtGbH9qEEuxk54N/PQwqXiS/TRQgf3ofq1HItHXjmooQfjzgbKQWCy5CxCi8EDmQADHkt40vX9/fCCNGQPGBpFDswUyLOPphO5vwp4iAFKin+3a88am8KGDLhljxNffH2klT73wnyxU6wJrKv6+NxAXPR+cLgbPUCtstsantbEh76dDVukyHuLSsZVwupUpdjtbcNONq5FNYC00ZFO/jq7FDohEu5wimlQSyKiOEHf3PeUXnSk25tct1LUiIgRuIhUgUSxqLl2Shr5OEds2cIcBTbZJSkCVhOCx6eI+d2R4Xtb1i0nC6V9c1tMlYGGODWrj1zqEOd+KfNBPCt9alG1DRWxhoBIH5hHUxSQcs3/CiHvwwTcrBO/cnO2nA6jEwSMMrmKLJDbLkzOsYgo9O+H+3mtKSbjU2YP1cI1vbm/JgsSjmkLq5a/oWLMKT7oK1d4ATlOP2DfhhgKKs6JyXjOZpQYBaYmPB60dzPYPL+RInwLaiv806hcDazMWtI1THyWiEPCWqIWI= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-M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ZeqrvGKXcodvThcquLJCvW/vp7vwDAoCvKNg9NVlaLE+m5wlqpgXdxj4goqU1GXRoWQ59LXgC3k9iYwR6pbfE1Qb5ERrQCwZiFl2q6WFfGkeAx09052xInyTZqTy+TPzA7ZDWedsODemt6Mnq3MuckbSP3cJdeDxpJxo4yUFnC3t09eO3LEKltEClVIa71ubjquOWsrhzpmPsF2Hf4qHa2bmC7zylS7g48xW3Gv2cGbcmuYdxMaYer2Yh1KBdqog== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e61321fb-04e5-41c2-e78e-08dc9283f64f X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2024 06:24:25.2340 (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: KL1PR06MB6258 Subject: [FFmpeg-devel] [PATCH 16/18] avcodec/vvcdec: deblock, support virtual boundaries 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: KqGhgEMEOjnX --- libavcodec/vvc/filter.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c index a5635c60df..69d67cb7f6 100644 --- a/libavcodec/vvc/filter.c +++ b/libavcodec/vvc/filter.c @@ -55,6 +55,29 @@ static const uint8_t betatable[64] = { 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, }; +static int get_virtual_boundary(const VVCFrameContext *fc, const int ctu_pos, const int vertical) +{ + const VVCSPS *sps = fc->ps.sps; + const VVCPH *ph = &fc->ps.ph; + const uint16_t *vbs = vertical ? ph->vb_pos_x : ph->vb_pos_y; + const uint8_t nb_vbs = vertical ? ph->num_ver_vbs : ph->num_hor_vbs; + const int pos = ctu_pos << sps->ctb_log2_size_y; + + if (sps->r->sps_virtual_boundaries_enabled_flag) { + for (int i = 0; i < nb_vbs; i++) { + const int o = vbs[i] - pos; + if (o >= 0 && o < sps->ctb_size_y) + return vbs[i]; + } + } + return 0; +} + +static int is_virtual_boundary(const VVCFrameContext *fc, const int pos, const int vertical) +{ + return get_virtual_boundary(fc, pos >> fc->ps.sps->ctb_log2_size_y, vertical) == pos; +} + static int get_qPc(const VVCFrameContext *fc, const int x0, const int y0, const int chroma) { const int x = x0 >> MIN_TU_LOG2; @@ -429,6 +452,7 @@ static void vvc_deblock_subblock_bs(const VVCLocalContext *lc, // bs for TU internal vertical PU boundaries for (int i = 8 - ((x0 - cb) % 8); i < width; i += 8) { + const int is_vb = is_virtual_boundary(fc, x0 + i, vertical); const int xp_pu = (x0 + i - 1) >> log2_min_pu_size; const int xq_pu = (x0 + i) >> log2_min_pu_size; @@ -436,7 +460,7 @@ static void vvc_deblock_subblock_bs(const VVCLocalContext *lc, const int y_pu = (y0 + j) >> log2_min_pu_size; const MvField *mvf_p = &tab_mvf[y_pu * stridea + xp_pu * strideb]; const MvField *mvf_q = &tab_mvf[y_pu * stridea + xq_pu * strideb]; - const int bs = boundary_strength(lc, mvf_q, mvf_p, rpl); + const int bs = is_vb ? 0 : boundary_strength(lc, mvf_q, mvf_p, rpl); int x = x0 + i; int y = y0 + j; uint8_t max_len_p = 0, max_len_q = 0; @@ -557,6 +581,7 @@ static void vvc_deblock_bs_luma(const VVCLocalContext *lc, (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA; if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) { + const int is_vb = is_virtual_boundary(fc, pos, vertical); const int size = vertical ? height : width; const int off = cb - pos; const int cb_size = (vertical ? fc->tab.cb_width : fc->tab.cb_height)[LUMA][off_q]; @@ -569,7 +594,7 @@ static void vvc_deblock_bs_luma(const VVCLocalContext *lc, const int x = x0 + i * !vertical; const int y = y0 + i * vertical; uint8_t max_len_p, max_len_q; - const int bs = deblock_bs(lc, x - vertical, y - !vertical, x, y, rpl_p, LUMA, off, has_sb); + const int bs = is_vb ? 0 : deblock_bs(lc, x - vertical, y - !vertical, x, y, rpl_p, LUMA, off, has_sb); TAB_BS(fc->tab.bs[vertical][LUMA], x, y) = bs; @@ -594,13 +619,14 @@ static void vvc_deblock_bs_chroma(const VVCLocalContext *lc, const int pos = vertical ? x0 : y0; if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) { - const int size = vertical ? height : width; + const int is_vb = is_virtual_boundary(fc, pos, vertical); + const int size = vertical ? height : width; for (int c_idx = CB; c_idx <= CR; c_idx++) { for (int i = 0; i < size; i += 2) { const int x = x0 + i * !vertical; const int y = y0 + i * vertical; - const int bs = deblock_bs(lc, x - vertical, y - !vertical, x, y, NULL, c_idx, 0, 0); + const int bs = is_vb ? 0 : deblock_bs(lc, x - vertical, y - !vertical, x, y, NULL, c_idx, 0, 0); TAB_BS(fc->tab.bs[vertical][c_idx], x, y) = bs; }