From patchwork Mon Mar 18 14:16:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 47171 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp1042437pzb; Mon, 18 Mar 2024 07:18:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVDKTeCUQ19l+pxeF98+2M2+BnOlAw4MBajqs37azxDEYkbl7RpPaXmagKwBXx/IYfsZvtdaEbhuW0Pa8RsxOAmXvVB9dkEvg/44A== X-Google-Smtp-Source: AGHT+IFZ9ZHUoQhCQ8X4fPu1NvhbT06DkHcszElcq+jOZSqk6EkHiQBZ61xKRQFwdpQf8wvk0i3A X-Received: by 2002:aa7:d3ce:0:b0:568:b393:ade0 with SMTP id o14-20020aa7d3ce000000b00568b393ade0mr5304805edr.1.1710771513532; Mon, 18 Mar 2024 07:18:33 -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 fj12-20020a0564022b8c00b005689f106b7fsi4688359edb.313.2024.03.18.07.18.33; Mon, 18 Mar 2024 07:18:33 -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=gNW+muQN; 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 43FD568D29B; Mon, 18 Mar 2024 16:17:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01olkn2037.outbound.protection.outlook.com [40.92.107.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E114A68D28F for ; Mon, 18 Mar 2024 16:17:18 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LaMsiFWhZvS/7c94GPmASOItmybQdCWoEDBQmM6Ajr19eUO5SqJJ7HHLbc+CnAGZb4bKfZSUUWZ4XjLFQp7hCCX/ohh6rvAHJtKl7QgbKqVxvbcDcGb7ViX9nPwkiNkNBdzkzxggrMSXUYqRcA2JGznTJUjuzvP6lDrZe1fNKuxwtB/ihmzmT1o6lwRCnct28Tslk+CTAQLVBjdT76jvO3EO9n3ETEB9u/dmaTNjxQtk3i/ZjzRA5LndEY5/QkCfvUBE0LEAoyE4amDg2nBLKVBdnHmU9N3U814RwDH1FuLDEZJHIbjPHimqzGyRQ2zW6+MTiLjjWKgSozy5UyRB1Q== 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=/2JtCP0x9zUOKSmAixxljMReLCurMfDvm5V0WW9MHNA=; b=YobLNo2vdt1wnqRUNP+o4V0/3rnENPGAe5oTXzDtYapTi1H9fRlQDxaHCe6+vnBwLqkde6jJ7eG4SL55lJsxGhWpvj1cpJNr/MobsAmzRm03r5Pio7cnqfLAPmli8ZB4/aU0XRVIee0/KuwlO5mHb85WtShlxxVcY3Tqyt0o1/M+aUEfQZ/PlIk3g/Y5RcJBAU3529jYa5wldt3oz978psLN+GEV3vrNHzFPtLkx/VYMJ0Wt6BUHcANTXaP7jvkZJcpKOgt0hnVlSfeuGIT5clSO9dFFZYZC9o8JAY0KKcBUl7KfhPgpxlLNj/YolqWHPk2swDyfnnw+VPRWrjwmzg== 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=/2JtCP0x9zUOKSmAixxljMReLCurMfDvm5V0WW9MHNA=; b=gNW+muQNX2NYmQQEzOygzX42PHpPWG/6H0nd795K+WGNbVoCgB1itznJLLb764psXf5XaZhA8PUOk6ivl5vE0k9+S3pkd5M4oxjYIAJ9JnsalOKS1Aofc8C/a0ymG6WrAgOyoFK/Ljux45BfEX45v7/3JbQoCd4YaRQuM0je2mm8AIaAO7rfYALYsBsSIC0GnjvrlY7qgcHLMgJF0ob7QoEAejhl8G0SfKR43gvLvBI8I8cnXJIF+9RwbSbuNdTj1i1yaFoVBz0Lg0a1xhpqVFHQITM8N6lRdJ0pXqETNjjUk08sdRKixeOjpQuigvbiZCjeWNvW6fdc0n9Cjsq9kg== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by JH0PR06MB6604.apcprd06.prod.outlook.com (2603:1096:990:3f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 14:17:03 +0000 Received: from TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::d001:da90:518b:ec1c]) by TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::d001:da90:518b:ec1c%3]) with mapi id 15.20.7386.025; Mon, 18 Mar 2024 14:17:03 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Mon, 18 Mar 2024 22:16:19 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240318141626.3375-1-nuomi2021@gmail.com> References: <20240318141626.3375-1-nuomi2021@gmail.com> X-TMN: [VEiqxie9X/no2Twm7L71hrh98gLgPrfY] X-ClientProxiedBy: TYAPR01CA0085.jpnprd01.prod.outlook.com (2603:1096:404:2c::25) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20240318141626.3375-8-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|JH0PR06MB6604:EE_ X-MS-Office365-Filtering-Correlation-Id: b39ba707-a3a1-444c-ab41-08dc47561567 X-MS-Exchange-SLBlob-MailProps: znQPCv1HvwVyACnTOSFL5RJO0O1WevBv3nTXuDteMAMHWwWx2K5B/8b468zDt3yRi8xeG+YztGA8x5C53rsPyyrGSWKPxqkOfzcMw+9prArX0Of+LKGxb4W9xYcGSqsz//SXdV59Uq0uV73Ms0B821FyaZSzl0tlYdv9dyh4UsmLDm46ARzlDDfYSlrBdEJjrRagDr9tNPz3oFWJnXSG3M8JUZMfFj7RmNbbE5EwI40BxryU1BJtF9NjyCJy3i81RU+N5gh6aqn0yimgi3UF7NiuiMG0xa85qgqADLEB/4w2aVELGbekdrgqX/yyd63QekC2F41Szb4GoDWLmybnaGrGsRlsXk3WitRFTKG20OsZPy8Yer4+TIEF3X4vZ52f0FkSFplSzgSMofMPVWKetZFvP1WbihCk0aFJ6V4pzZlRkOREqFoViRfuFaVBziKVo10ahpDOnTM9nQ9RTReHZGXKBI4HRAnUwdaS0D1TinoTl47yOWfyJugSiJvBTZi5C4smAP6J+03s+GbCdgVz2ZgxaesiTvLOMmJMfr4ZtkcO4R+1/FscTZ/ba8uXlHr0/7UbdMmjVBtgpL3WbOi2T97QVSIH5fKvslfexz2TAe+HRW7/w+ZEIpr2jxDvO4KFeACDsaCmXBBL95yIEKnPN0/QhHqIvYW5oBS1L1VbbGD5a5egS9P6CJK33ReojaBYbVPmZmiIEJoFh/xrGtBMpRjy01hlbBycXTwe77Rrfr/zRdNNIiWYK8GdYjgehzu7w9e84wroBX0= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5o2PyAkCd4wnB/C0XCYFLuSrJxqTnBPI51MBi7Uj77bAE0SaCL38YBQwqp7hwzShIsAS8LfIFpNk8K5Nt1sKf9R7eZTyfIwGd8xZCz1oWrs0XWL/Wo8rncaLkfEWNqthqxaUFJ5yphg1NnYXad3szg3bWyPGpuSIeGcg7p6bjWbq/FolkI+mId1jywnk2gIE1VJNV1z/hVxG52m0/rOEjUaD6GosUxadX3BlJUDa1Gyih+EOD3ebViFy5dR2UXyp5HspCySEt7MeDRpdMiMN4zW1fbKap2xOKGCgb9TO8gn3qVaw6HDwhqr3ytvQ3SOmZDoYZMHXIF6I71Sn1+mf2JtzdwhkgQIUYUM8YxMHvjrKhEe7SQq5slBEzM3ybR0bvknc863P/Iy2RL2GLfwLpWPowfBH+4pAVjE7T/dgEerGNL6EUHvXY1ZelyoeZxigvQ2CApKvbUrlwwyvEZ93da1QmjGuRuHGKk7/sJzE3BdFA3JVlS4n3S3egkVlBbZ+MBQa4p09xEy8tKAzwLmHd6cJ1yAAgIV5hQZqJMZObcDkZrnIV7y6lTIMdUGnR/gE4yXsY2aldF8Rc4XQ1DEWOAHUqf+B92pt5NUnCa02t7yceQQlvBt5JyuEgbJp85CS X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JinamjZuyfWcdo6oiC0cyw8LnsqEtiAHMFB3jI1wZDDYOI2ZVBFf58JaY6eCkTfgbxGbbHdSYojXR2p+i5vurcLg0hEwSWTcpLN5IK6mh26nuJQ0FNdSXixraywqzY35xCZZUm6gUOc77g3zdh497TvI7iTZSDFBbUSGT2zeHCk8DJYDj1L+AgCmn9j9GQo4Bchztixa5GwzCD4OBY9WzkNvB1G/gG7wZLUsqc+An6xoFSsyBWdk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riginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b39ba707-a3a1-444c-ab41-08dc47561567 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2024 14:17:03.3990 (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: JH0PR06MB6604 Subject: [FFmpeg-devel] [PATCH 07/14] avcodec/vvcdec: refact out deblock_is_boundary 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: P4EdI/3YwZph --- libavcodec/vvc/vvc_filter.c | 66 +++++++++++++++---------------------- 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/libavcodec/vvc/vvc_filter.c b/libavcodec/vvc/vvc_filter.c index 10bd57e078..11972bde41 100644 --- a/libavcodec/vvc/vvc_filter.c +++ b/libavcodec/vvc/vvc_filter.c @@ -528,6 +528,26 @@ static av_always_inline int deblock_bs(const VVCLocalContext *lc, return boundary_strength(lc, mvf_q, mvf_p, rpl_p); } +static int deblock_is_boundary(const VVCLocalContext *lc, const int boundary, + const int pos, const int vertical) +{ + const VVCFrameContext *fc = lc->fc; + const H266RawPPS *rpps = fc->ps.pps->r; + int flag; + if (boundary && (pos % fc->ps.sps->ctb_size_y) == 0) { + flag = vertical ? BOUNDARY_LEFT_SLICE : BOUNDARY_UPPER_SLICE; + if (lc->boundary_flags & flag && + !rpps->pps_loop_filter_across_slices_enabled_flag) + return 0; + + flag = vertical ? BOUNDARY_LEFT_TILE : BOUNDARY_UPPER_TILE; + if (lc->boundary_flags & flag && + !rpps->pps_loop_filter_across_tiles_enabled_flag) + return 0; + } + return boundary; +} + static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc, const int x0, const int y0, const int width, const int height) { @@ -554,15 +574,7 @@ static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc, } // bs for vertical TU boundaries - boundary_left = x0 > 0 && !(x0 & 3); - if (boundary_left && - ((!fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag && - lc->boundary_flags & BOUNDARY_LEFT_SLICE && - (x0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0) || - (!fc->ps.pps->r->pps_loop_filter_across_tiles_enabled_flag && - lc->boundary_flags & BOUNDARY_LEFT_TILE && - (x0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0))) - boundary_left = 0; + boundary_left = deblock_is_boundary(lc, x0 > 0 && !(x0 & 3), x0, 1); if (boundary_left) { const RefPicList *rpl_left = @@ -610,15 +622,7 @@ static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc, has_horizontal_sb = cb_height > 8; } - boundary_upper = y0 > 0 && !(y0 & 3); - if (boundary_upper && - ((!fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag && - lc->boundary_flags & BOUNDARY_UPPER_SLICE && - (y0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0) || - (!fc->ps.pps->r->pps_loop_filter_across_tiles_enabled_flag && - lc->boundary_flags & BOUNDARY_UPPER_TILE && - (y0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0))) - boundary_upper = 0; + boundary_upper = deblock_is_boundary(lc, y0 > 0 && !(y0 & 3), y0, 0); if (boundary_upper) { const RefPicList *rpl_top = @@ -646,18 +650,9 @@ 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; - int boundary_left; - // bs for vertical TU boundaries - boundary_left = x0 > 0 && !(x0 & ((CHROMA_GRID << fc->ps.sps->hshift[1]) - 1)); - if (boundary_left && - ((!fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag && - lc->boundary_flags & BOUNDARY_LEFT_SLICE && - (x0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0) || - (!fc->ps.pps->r->pps_loop_filter_across_tiles_enabled_flag && - lc->boundary_flags & BOUNDARY_LEFT_TILE && - (x0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0))) - boundary_left = 0; + const int boundary_left = deblock_is_boundary(lc, + x0 > 0 && !(x0 & ((CHROMA_GRID << fc->ps.sps->hshift[CHROMA]) - 1)), x0, 1); if (boundary_left) { for (int i = 0; i < height; i += 2) { @@ -674,17 +669,8 @@ 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; - int boundary_upper; - - boundary_upper = y0 > 0 && !(y0 & ((CHROMA_GRID << fc->ps.sps->vshift[1]) - 1)); - if (boundary_upper && - ((!fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag && - lc->boundary_flags & BOUNDARY_UPPER_SLICE && - (y0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0) || - (!fc->ps.pps->r->pps_loop_filter_across_tiles_enabled_flag && - lc->boundary_flags & BOUNDARY_UPPER_TILE && - (y0 % (1 << fc->ps.sps->ctb_log2_size_y)) == 0))) - boundary_upper = 0; + const int boundary_upper = deblock_is_boundary(lc, + y0 > 0 && !(y0 & ((CHROMA_GRID << fc->ps.sps->vshift[CHROMA]) - 1)), y0, 0); if (boundary_upper) { for (int i = 0; i < width; i += 2) {