From patchwork Wed Jan 3 15:32:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 45459 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6623:b0:194:e134:edd4 with SMTP id n35csp7327905pzh; Wed, 3 Jan 2024 07:33:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9jBQ+qKN8yQLJeDEX1XqWvZpiNVJZKneg7UbuvJCqxfnWgccuF6sb5BkMaPqyptkThSSo X-Received: by 2002:a17:906:1d0:b0:a23:6462:4d66 with SMTP id 16-20020a17090601d000b00a2364624d66mr9465765ejj.85.1704296028127; Wed, 03 Jan 2024 07:33:48 -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 pv18-20020a170907209200b00a27fb1e91desi2568599ejb.213.2024.01.03.07.33.47; Wed, 03 Jan 2024 07:33:48 -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=NVqLLteA; 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 1FBC068CC8A; Wed, 3 Jan 2024 17:33:29 +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-tyzapc01olkn2033.outbound.protection.outlook.com [40.92.107.33]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AC94968CC5B for ; Wed, 3 Jan 2024 17:33:21 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SjRjdA5AD0Swd+JtC/mBT1/wlyvbafXOhYeBdWqX/Ib+YPPOhBPOEIFk0/PrbrgDh/a+9vbTDakKN3a4QY/oKX77wwylFi6vHryVP9J2B12uQT8lS/jUhe5LbxDXGMRMhhl5mVnso0iSf6dwbvK4iGtLJJcdRB5ku34QYpnFUa4Bis7hnWtwm6G21Okics7YkkP7hy9/PlJhUwpo1uKGqz4mryVvnZTA3XfQJYVtxG4h2u+dWrWbuh+hRYaaF1CvT3A6AShKhWPWv/HZof8iOXsckuIs3lEhEuJAO75p/LurZAjh4mJZMYQ48ZeucSsnyJGDfdgVeW1V6DBoG2hPwQ== 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=v3M7s2fmvsvIA1rY9839pSJpt3HsQEI/anmh+EE6Li0=; b=lH7S5U91ejwODYcdOHuRbMukXzDsh0/dHuiilRs2NVRQFsBg4c9Snb6I+Ao5UYEGHD/ZPavesVtfXuVQ6vZVBKAjH2jSfgf36CUhHGNq799LfK7YBYeeMMQ7q93/NKlqp0vEPiySMsKcgG9y13Obpu9BZt6e1jx2qJsMfRy/K9AlzjzwNDvxIsUoTu+NthLAz5Frqx9X1XZLjksZgb3Q11E0VhFNGjE7UD6juW55G9Y8HCzuo9kRoBPlkVR0K0qDQKwMOYDhxDfXOS2lwBdnrU8WgA26izUjYQjZvSbimjfEjMSLEzL+UtxGm4Rwk0KxzwCqdJ8dczH+dWbfL7J8Iw== 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=v3M7s2fmvsvIA1rY9839pSJpt3HsQEI/anmh+EE6Li0=; b=NVqLLteAbsGNcDx8S9CUeanJgoR+/6vsfOairnrNd8x1ZO6KTbyVri4wffZ+9OUAz72q3gvYW4kIAyf7ldh5uxkAF87ApoCZM/D3X5NlJwKD+P1ukSAglVy5ZjRtCtrVlj9EaJDEuQ4OUmKJ9l5zfVM+arhn1Fm/polM138nnAZWmmgef426FzGixvBqg9UFIJBjMgN5anZVHIhC0b55PmtzoyVC9vHdJ0kmk9pfetaPJGhNgmcpK8qrBCd0aUDn5CfTxIS6JTX/Tqj2lihQiOZR78Ml4Grpo4kBpW2NBlpGmyp9zX2q3FatHFxQrUbm2FslWyR7l+DWOiMbNeQZhQ== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by SEYPR06MB5085.apcprd06.prod.outlook.com (2603:1096:101:55::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.13; Wed, 3 Jan 2024 15:33:03 +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.7159.013; Wed, 3 Jan 2024 15:33:02 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Wed, 3 Jan 2024 23:32:37 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240103153238.18678-1-nuomi2021@gmail.com> References: <20240103153238.18678-1-nuomi2021@gmail.com> X-TMN: [saPlrVKIxazLgUlaPZiIa3l+Pg0ddXI2] X-ClientProxiedBy: SI1PR02CA0008.apcprd02.prod.outlook.com (2603:1096:4:1f7::14) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20240103153238.18678-4-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|SEYPR06MB5085:EE_ X-MS-Office365-Filtering-Correlation-Id: 7687ddd5-77ce-4125-5ee2-08dc0c71460e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fcUzZI/Ws03EspUhods0ZPJxlaRXCQrPPOibyWeeAxGWFxLTnrUuSXYAITfn4xy2A3BrR7qkqp3R0GLpqkE9YrvNMokKbEwGFBnNSwS24DYzDU8GS4DcV8bTQO069G5z5/XUJLJ71KkqXypXywjclzfbOPKVpc4/l5jSXLR9IwUtZqPmxjprvoIbJOb2nX7POAzYcMMXEM7YGvsgzfLXT9yfE2x0RY/2RpLKwK2j3EFJkzkh39uf1qXRKiRpDeFtsJ7ailWvvX4+kFGpe3yIGFOgKEjVMREZ/rAVecmiZa2/em5jH8XmVrvI5q5rQM30DCcyS6MhlRPRqbt+WWFEDA/ZYFJXcvRIhVoXAmpdjXYbuX9deZl6i5adyd839p3Jn9gSdpzc/Qe3UDdv6Z88vzP6qre7AAZ9rvKvhNvGiCh6jeimPlAzcOyCTmlSHQwhP38uHVqW/tV+4N7Xai07sLbUZjASc9lfF8H6zvUobf279Y14Ifqcd+xg8B8OJr4FJsuRjv4MZuijFba485GwYugl/KQ+dbkD+pOYaPsD37aa3OOWMY6rXkNN2W18TAIAZXegb7utEWK0epPRdLJmLEYCemyr0xQQ8CYv3qbgvB+uexcNHVaijZEvftSEEa6J X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tnC47XSW0LilgBKxcAxSO5ua37PcJpE1oVji6Cq0b16Odn37KKw2MN/jhFPlTsfsAVpPuiXo/e3rsiopZyDmvG4wedXGbUJif6qGBhoALRvgPk2tZyc2+5Zu1iJUuuEjpjy75wieXYh4UrunxzbHatSuWGjvOhT/AeU4+dFCqOgRIPwI1/d+bjPM6camxAo4QM+DSEPVe+wP/y+M9O5aIXOcYm3rhBPDiVFCdJ7XphCvmlqoeqYcCBgCA8lQTzPO2ZmZRLkQIR2yac/gTmxjUX/xPiaKYvlwbGw5UZWRdzKkHEUmmhyGTH+4JsVT42nrSTPcr1ZVYCF7xpeyNgbj+MGbDqvuCCuweMfadtj59ML48u4xUxctvgzYUgBr8pB2gARGIn1KglxLMc/wGBQwNHK0DL1CAhxTBk6FBLBEgKdUMCOk/x61pD3cNu3oqOjm4khWzvsEEzbaVrhBM/KgGIYVz/69L7kfSGHwRrPHvP9rf8hJ2VDwWRCyeaDH0xJ0w8QtO4uRykd5gU8nD+CprKFftwBdPTwPkyPsASxcEdO6lGCqSdn8JeEm9SjIHIhjB0oJdzW4sV9VPfx7E43LZp/P3/M2O27YN4zuIXVP+AT35z9JwR+G9w/XEmAyiDFQAUR5XfgBcQBXFJUPH9xZO7XgmWzT7ChbHMMSD4Alt7/R6iuFo8J4YT4ESwvg/EHtTguZUJnjZMsZrf8oU8sS9GLLv+fz1qcP5C1x5bEX2v9K9umeEvv9TN/ygGWsYPhe0T/tqXg6yw7GkcTx8cd5rr3m6fVNvOLfHHakghgNxCNkejDcmZWyghAhibFXBOwLhY5N+tnb6qGu2n5Fb6eWuQ7e4dqHw8DW6M/Ff88j/X03umZ4DHpUAPcQZc+7For1hqREYe5DM6Eae7qVMFhGoUMJUGWGmKT7vb+yykFqOOag+QAY9HRmxnm3dSTG/IVXV4UVZV3i01aX5AoNOiT14HqcSyekUiaxjNHbzOY/mSCLLY0BHaKgH8tssD5ZPAtKDUP+CxHRGwHE0VC4WJO5XGsYeQ6FqXSRhjtwHNXtiHGksRFFMw8k2O84z20aHBfzAiNVhlZsbmZGKGdtLICn6gzGUo//fgIM+p5VC/hJxP+dotLMoFNkPStZxDtYUiQ5/uOCe/T+sKL47HNm8Y3FmaHpQCIEjPiSa1rmyM1XBxSsywkE9wNLQ8VnyLialrBDLV7wByB//xeMgVf9/OgSDeRU6M+uOgOMLA0pgUdSOfETL2W8kdS8RMankfFNL/iR X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7687ddd5-77ce-4125-5ee2-08dc0c71460e X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2024 15:33:02.9347 (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: SEYPR06MB5085 Subject: [FFmpeg-devel] [PATCH 3/4] hevcdec: move deblock template to xvc_deblock_template.c 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: l1v55+yypz3R --- libavcodec/hevcdsp_template.c | 96 ++++++------------------------ libavcodec/xvc_deblock_template.c | 99 +++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 79 deletions(-) create mode 100644 libavcodec/xvc_deblock_template.c diff --git a/libavcodec/hevcdsp_template.c b/libavcodec/hevcdsp_template.c index 00786bb2f8..fb7d2ebb60 100644 --- a/libavcodec/hevcdsp_template.c +++ b/libavcodec/hevcdsp_template.c @@ -1319,19 +1319,20 @@ static void FUNC(put_hevc_epel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, #define TQ2 pix[2 * xstride + 3 * ystride] #define TQ3 pix[3 * xstride + 3 * ystride] +#include "xvc_deblock_template.c" + static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix, ptrdiff_t _xstride, ptrdiff_t _ystride, int beta, const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q) { - int d, j; - pixel *pix = (pixel *)_pix; ptrdiff_t xstride = _xstride / sizeof(pixel); ptrdiff_t ystride = _ystride / sizeof(pixel); beta <<= BIT_DEPTH - 8; - for (j = 0; j < 2; j++) { + for (int j = 0; j < 2; j++) { + pixel* pix = (pixel*)_pix + j * 4 * ystride; const int dp0 = abs(P2 - 2 * P1 + P0); const int dq0 = abs(Q2 - 2 * Q1 + Q0); const int dp3 = abs(TP2 - 2 * TP1 + TP0); @@ -1342,10 +1343,7 @@ static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix, const int no_p = _no_p[j]; const int no_q = _no_q[j]; - if (d0 + d3 >= beta) { - pix += 4 * ystride; - continue; - } else { + if (d0 + d3 < beta) { const int beta_3 = beta >> 3; const int beta_2 = beta >> 2; const int tc25 = ((tc * 5 + 1) >> 1); @@ -1353,63 +1351,16 @@ static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix, if (abs(P3 - P0) + abs(Q3 - Q0) < beta_3 && abs(P0 - Q0) < tc25 && abs(TP3 - TP0) + abs(TQ3 - TQ0) < beta_3 && abs(TP0 - TQ0) < tc25 && (d0 << 1) < beta_2 && (d3 << 1) < beta_2) { - // strong filtering const int tc2 = tc << 1; - for (d = 0; d < 4; d++) { - const int p3 = P3; - const int p2 = P2; - const int p1 = P1; - const int p0 = P0; - const int q0 = Q0; - const int q1 = Q1; - const int q2 = Q2; - const int q3 = Q3; - if (!no_p) { - P0 = p0 + av_clip(((p2 + 2 * p1 + 2 * p0 + 2 * q0 + q1 + 4) >> 3) - p0, -tc2, tc2); - P1 = p1 + av_clip(((p2 + p1 + p0 + q0 + 2) >> 2) - p1, -tc2, tc2); - P2 = p2 + av_clip(((2 * p3 + 3 * p2 + p1 + p0 + q0 + 4) >> 3) - p2, -tc2, tc2); - } - if (!no_q) { - Q0 = q0 + av_clip(((p1 + 2 * p0 + 2 * q0 + 2 * q1 + q2 + 4) >> 3) - q0, -tc2, tc2); - Q1 = q1 + av_clip(((p0 + q0 + q1 + q2 + 2) >> 2) - q1, -tc2, tc2); - Q2 = q2 + av_clip(((2 * q3 + 3 * q2 + q1 + q0 + p0 + 4) >> 3) - q2, -tc2, tc2); - } - pix += ystride; - } - } else { // normal filtering + FUNC(loop_filter_luma_strong)(pix, xstride, ystride, tc2, tc2, tc2, no_p, no_q); + } else { int nd_p = 1; int nd_q = 1; - const int tc_2 = tc >> 1; if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3)) nd_p = 2; if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3)) nd_q = 2; - - for (d = 0; d < 4; d++) { - const int p2 = P2; - const int p1 = P1; - const int p0 = P0; - const int q0 = Q0; - const int q1 = Q1; - const int q2 = Q2; - int delta0 = (9 * (q0 - p0) - 3 * (q1 - p1) + 8) >> 4; - if (abs(delta0) < 10 * tc) { - delta0 = av_clip(delta0, -tc, tc); - if (!no_p) - P0 = av_clip_pixel(p0 + delta0); - if (!no_q) - Q0 = av_clip_pixel(q0 - delta0); - if (!no_p && nd_p > 1) { - const int deltap1 = av_clip((((p2 + p0 + 1) >> 1) - p1 + delta0) >> 1, -tc_2, tc_2); - P1 = av_clip_pixel(p1 + deltap1); - } - if (!no_q && nd_q > 1) { - const int deltaq1 = av_clip((((q2 + q0 + 1) >> 1) - q1 - delta0) >> 1, -tc_2, tc_2); - Q1 = av_clip_pixel(q1 + deltaq1); - } - } - pix += ystride; - } + FUNC(loop_filter_luma_weak)(pix, xstride, ystride, tc, beta, no_p, no_q, nd_p, nd_q); } } } @@ -1419,32 +1370,19 @@ static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride, ptrdiff_t _ystride, const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q) { - int d, j, no_p, no_q; - pixel *pix = (pixel *)_pix; + int no_p, no_q; ptrdiff_t xstride = _xstride / sizeof(pixel); ptrdiff_t ystride = _ystride / sizeof(pixel); + const int size = 4; - for (j = 0; j < 2; j++) { + for (int j = 0; j < 2; j++) { + pixel *pix = (pixel *)_pix + j * size * ystride; const int tc = _tc[j] << (BIT_DEPTH - 8); - if (tc <= 0) { - pix += 4 * ystride; - continue; - } - no_p = _no_p[j]; - no_q = _no_q[j]; - - for (d = 0; d < 4; d++) { - int delta0; - const int p1 = P1; - const int p0 = P0; - const int q0 = Q0; - const int q1 = Q1; - delta0 = av_clip((((q0 - p0) * 4) + p1 - q1 + 4) >> 3, -tc, tc); - if (!no_p) - P0 = av_clip_pixel(p0 + delta0); - if (!no_q) - Q0 = av_clip_pixel(q0 - delta0); - pix += ystride; + if (tc > 0) { + no_p = _no_p[j]; + no_q = _no_q[j]; + + FUNC(loop_filter_chroma_weak)(pix, xstride, ystride, size, tc, no_p, no_q); } } } diff --git a/libavcodec/xvc_deblock_template.c b/libavcodec/xvc_deblock_template.c new file mode 100644 index 0000000000..8ed95e754d --- /dev/null +++ b/libavcodec/xvc_deblock_template.c @@ -0,0 +1,99 @@ + +/* + * HEVC/VVC deblocking dsp template + * + * Copyright (C) 2024 Nuo Mi + * Copyright (C) 2012 - 2013 Guillaume Martres + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static void FUNC(loop_filter_luma_strong)(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, + const int32_t tc, const int32_t tc2, const int tc3, + const uint8_t no_p, const uint8_t no_q) +{ + for (int d = 0; d < 4; d++) { + const int p3 = P3; + const int p2 = P2; + const int p1 = P1; + const int p0 = P0; + const int q0 = Q0; + const int q1 = Q1; + const int q2 = Q2; + const int q3 = Q3; + if (!no_p) { + P0 = p0 + av_clip(((p2 + 2 * p1 + 2 * p0 + 2 * q0 + q1 + 4) >> 3) - p0, -tc3, tc3); + P1 = p1 + av_clip(((p2 + p1 + p0 + q0 + 2) >> 2) - p1, -tc2, tc2); + P2 = p2 + av_clip(((2 * p3 + 3 * p2 + p1 + p0 + q0 + 4) >> 3) - p2, -tc, tc); + } + if (!no_q) { + Q0 = q0 + av_clip(((p1 + 2 * p0 + 2 * q0 + 2 * q1 + q2 + 4) >> 3) - q0, -tc3, tc3); + Q1 = q1 + av_clip(((p0 + q0 + q1 + q2 + 2) >> 2) - q1, -tc2, tc2); + Q2 = q2 + av_clip(((2 * q3 + 3 * q2 + q1 + q0 + p0 + 4) >> 3) - q2, -tc, tc); + } + pix += ystride; + } +} + +static void FUNC(loop_filter_luma_weak)(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, + const int32_t tc, const int32_t beta, const uint8_t no_p, const uint8_t no_q, const int nd_p, const int nd_q) +{ + const int tc_2 = tc >> 1; + for (int d = 0; d < 4; d++) { + const int p2 = P2; + const int p1 = P1; + const int p0 = P0; + const int q0 = Q0; + const int q1 = Q1; + const int q2 = Q2; + int delta0 = (9 * (q0 - p0) - 3 * (q1 - p1) + 8) >> 4; + if (abs(delta0) < 10 * tc) { + delta0 = av_clip(delta0, -tc, tc); + if (!no_p) + P0 = av_clip_pixel(p0 + delta0); + if (!no_q) + Q0 = av_clip_pixel(q0 - delta0); + if (!no_p && nd_p > 1) { + const int deltap1 = av_clip((((p2 + p0 + 1) >> 1) - p1 + delta0) >> 1, -tc_2, tc_2); + P1 = av_clip_pixel(p1 + deltap1); + } + if (!no_q && nd_q > 1) { + const int deltaq1 = av_clip((((q2 + q0 + 1) >> 1) - q1 - delta0) >> 1, -tc_2, tc_2); + Q1 = av_clip_pixel(q1 + deltaq1); + } + } + pix += ystride; + } +} + +static void FUNC(loop_filter_chroma_weak)(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, + const int size, const int32_t tc, const uint8_t no_p, const uint8_t no_q) +{ + for (int d = 0; d < size; d++) { + int delta0; + const int p1 = P1; + const int p0 = P0; + const int q0 = Q0; + const int q1 = Q1; + delta0 = av_clip((((q0 - p0) * 4) + p1 - q1 + 4) >> 3, -tc, tc); + if (!no_p) + P0 = av_clip_pixel(p0 + delta0); + if (!no_q) + Q0 = av_clip_pixel(q0 - delta0); + pix += ystride; + } +}