From patchwork Tue May 3 06:37:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 35557 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp257690pzb; Mon, 2 May 2022 23:39:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ2a0/R7j5Pw5/vCxCH1OMNfFzGuZ2lO3Ba07VDx+xF67VIDEcHP5KBGwGehl3wc6pTwGa X-Received: by 2002:a05:6402:2291:b0:425:deb5:73be with SMTP id cw17-20020a056402229100b00425deb573bemr16567876edb.392.1651559989082; Mon, 02 May 2022 23:39:49 -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 kw2-20020a170907770200b006f41aaeb63dsi6880123ejc.353.2022.05.02.23.39.48; Mon, 02 May 2022 23:39:49 -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=fBBdc6Hx; 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 631AD68B3C1; Tue, 3 May 2022 09:39:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075031.outbound.protection.outlook.com [40.92.75.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7C78568B3A8 for ; Tue, 3 May 2022 09:39:27 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aAydP+zdAneqMNb5Qny1TNycwad/Jle3iVKARrRztRJWSBDNZPK9AsEC3ZwJlMv7fa9hhKUDx91LIb8NZeGY24/lIA+/uGvcYOGP/UEji8ZX07DXhkgKrq6qWHxQblntFjgZx+WBgqnxikIFQKUsh5XYJYOft44VRcxH+ZU89Swpdk+UlDPhDkziobyxRQ2d0uDkiGDCxuaMVnv5GHbKhJyhVR0jIFkHlvJViLJVZEzhxMAQZnkxLmK5LDDsdtqai80Nl7x4ofWj0pMbnWizd85pznUJOUbh5j+qgVFGVZjrRTG5FZVM55ZBRhZ3l0/WREfiz7Rwmhrq/6AiAR/YfQ== 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=I1PSqWy8Hc0ZLSsoYhxFzrCmCQwrJuoPER5SRo7Chz8=; b=TaD+4IezSPc4QAOm69Y4KusFwHVM/BHUyI5IQTNtmaHXiVypKa/buaYuTRWSYfs5lmJ8fNnP1DvtchOQLyFX/z8yjSatvST2r9yUObpNhFz1m0DoMwaRAfMLnPQcvsj9sfjsTpdqOUkhcHEv7bXHLl5rOd4ViKM4ZpIDRQH6zx4OEknyr+VqW8M6yJpsvWCibk9+1OYu9cN6d0FAhSq8tHOUt24Bu4nkb5WWsBHiQyTCie24SOdX9iZ1W6FqJLhymrIC4Lg9wVmmEPpAg19GnUEi8PN3iKVLeEgwRhUnceneDspcjUsHotYZEVhM7LzQ0U5hFqVVfd3A+m/3FILddA== 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=I1PSqWy8Hc0ZLSsoYhxFzrCmCQwrJuoPER5SRo7Chz8=; b=fBBdc6HxVhRiUDxN3FECsYvYJNaf9YIwVnfeyL9NuuE6zoXXh+ptWWsSuimYBjJUy4i9lxaY29VtaiX+9tqW8K9smbAmMRHQyyd2LAThccCJc73cEKnhOzDP1dYrNBD/Lg+hD6Zh7VzCbEYmdq/gEwIJsEmDtf9gbqjTg/XmElrJVNOCwK/tsVKawJicE8hJXipwgfPd6JDbK9/n+umtkvQ+TX0BCt/d+8R+HmGOob80Y1U/01Lov802DqUyxI+mOekTg5W0v1so/xyxSoSg9+wQk5yo5gJqp6E2GqJEOj5oKLSLlrXghxSr7jmpyTRa6HuxMQPIAaLLjZ/UdxxHLg== Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) by VI1PR0102MB3230.eurprd01.prod.exchangelabs.com (2603:10a6:803:8::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Tue, 3 May 2022 06:39:26 +0000 Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::1854:2c30:7ba1:c431]) by AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::1854:2c30:7ba1:c431%6]) with mapi id 15.20.5206.024; Tue, 3 May 2022 06:39:25 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 08:37:49 +0200 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [wF+zZf//PxeVU4f1SDo2YZZvDDM9l9vj] X-ClientProxiedBy: ZR0P278CA0014.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::24) To AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) X-Microsoft-Original-Message-ID: <20220503063751.2261222-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 34f87d67-a594-4c99-c066-08da2ccfa9d7 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNUfFs0p/ynZxoLjq6nuVP/rgtdGfCMrwqzTPUrXuZVDDKFvUctHMkQtfzhHCBPRs0aOWLqGaPxwHkaDPi56I0QheQ98AehVY3fHHhcm0kt44N8VAPdl4RO7w5JjCuuVN3s644++7coVTcbuyWo6uJxAg/z+QnrCLQwl6rIx3ClnI8MSYGZt3NuJdgtZPRat6C+rpDvDCkTd9V01jgmyzFGYb3+jSAsF4MjmX0Lqx8fcdY/Nrzx7b8wrSk9oy2+vSXRxj85svuxOY+DeEsd3ZER9G/ea3qSUCZwL8C3BFohGNHUchxm4sXRjxSdrWWGf84ANpHygb0H1Ex+rXOYcWrdbh1fQAIhaCdy0gF8QabU8wXYQq4yjxwktpyIYrBwYhLEFT28BdwECHvQnzSrI6ps1rwktlJAPzQWjw2M2Z7wzl6sKHrYXDlHjSkiqiu7Kn6EVqMSRyJmxNL5zvbqaNmSaLo0KXcohRXXexvwHDrFU7hUR0Rh9tASvwZUyLhfDFqJ1OSlNNzj2blxgaasHwlVeMtHKhUldm01f662c+TfJjs9dBhsr4gKK63m5gXlbZYhsJjZ7ybbjiPFvVzaQJ3lYEYjlccaA7K5gb0gsTpm1i45KYoyNN1dj3etc3l85jXVcVw1YTS4rA6fcHeGQDRVLwuqhTwBbxNGqnWNwYlJlmUnLO30lUqc9CeUTmU6aVgLp+g+VH2MmDiWT2+KsOKHzbJprl+lQcbE= X-MS-TrafficTypeDiagnostic: VI1PR0102MB3230:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dYOULmDJVMj2qeNhFcXF97IzS/uSChEdjGAQ+IZlK4bg7UR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id: 34f87d67-a594-4c99-c066-08da2ccfa9d7 X-MS-Exchange-CrossTenant-AuthSource: AS8PR01MB7944.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2022 06:39:25.4280 (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: VI1PR0102MB3230 Subject: [FFmpeg-devel] [PATCH 08/10] avfilter/vf_threshold: Move ff_threshold_init into a header 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +Wm1rhJExfq+ This removes a dependency of checkasm on lavfi/vf_threshold.o and also allows to inline ff_threshold_init() irrespectively of interposing. With this patch checkasm no longer pulls all of lavfi and lavf in. Signed-off-by: Andreas Rheinhardt --- libavfilter/threshold.h | 1 - libavfilter/vf_threshold.c | 66 +----------------------- libavfilter/vf_threshold_init.h | 91 +++++++++++++++++++++++++++++++++ tests/checkasm/vf_threshold.c | 2 +- 4 files changed, 93 insertions(+), 67 deletions(-) create mode 100644 libavfilter/vf_threshold_init.h diff --git a/libavfilter/threshold.h b/libavfilter/threshold.h index 775a9f9cae..8b55ad6ba1 100644 --- a/libavfilter/threshold.h +++ b/libavfilter/threshold.h @@ -46,7 +46,6 @@ typedef struct ThresholdContext { FFFrameSync fs; } ThresholdContext; -void ff_threshold_init(ThresholdContext *s); void ff_threshold_init_x86(ThresholdContext *s); #endif /* AVFILTER_THRESHOLD_H */ diff --git a/libavfilter/vf_threshold.c b/libavfilter/vf_threshold.c index 2a0add4a8f..dc73c277d3 100644 --- a/libavfilter/vf_threshold.c +++ b/libavfilter/vf_threshold.c @@ -32,6 +32,7 @@ #include "internal.h" #include "video.h" #include "threshold.h" +#include "vf_threshold_init.h" #define OFFSET(x) offsetof(ThresholdContext, x) #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM @@ -150,57 +151,6 @@ static int process_frame(FFFrameSync *fs) return ff_filter_frame(outlink, out); } -static void threshold8(const uint8_t *in, const uint8_t *threshold, - const uint8_t *min, const uint8_t *max, - uint8_t *out, - ptrdiff_t ilinesize, ptrdiff_t tlinesize, - ptrdiff_t flinesize, ptrdiff_t slinesize, - ptrdiff_t olinesize, - int w, int h) -{ - int x, y; - - for (y = 0; y < h; y++) { - for (x = 0; x < w; x++) { - out[x] = in[x] < threshold[x] ? min[x] : max[x]; - } - - in += ilinesize; - threshold += tlinesize; - min += flinesize; - max += slinesize; - out += olinesize; - } -} - -static void threshold16(const uint8_t *iin, const uint8_t *tthreshold, - const uint8_t *ffirst, const uint8_t *ssecond, - uint8_t *oout, - ptrdiff_t ilinesize, ptrdiff_t tlinesize, - ptrdiff_t flinesize, ptrdiff_t slinesize, - ptrdiff_t olinesize, - int w, int h) -{ - const uint16_t *in = (const uint16_t *)iin; - const uint16_t *threshold = (const uint16_t *)tthreshold; - const uint16_t *min = (const uint16_t *)ffirst; - const uint16_t *max = (const uint16_t *)ssecond; - uint16_t *out = (uint16_t *)oout; - int x, y; - - for (y = 0; y < h; y++) { - for (x = 0; x < w; x++) { - out[x] = in[x] < threshold[x] ? min[x] : max[x]; - } - - in += ilinesize / 2; - threshold += tlinesize / 2; - min += flinesize / 2; - max += slinesize / 2; - out += olinesize / 2; - } -} - static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; @@ -223,20 +173,6 @@ static int config_input(AVFilterLink *inlink) return 0; } -void ff_threshold_init(ThresholdContext *s) -{ - if (s->depth == 8) { - s->threshold = threshold8; - s->bpc = 1; - } else { - s->threshold = threshold16; - s->bpc = 2; - } - - if (ARCH_X86) - ff_threshold_init_x86(s); -} - static int config_output(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; diff --git a/libavfilter/vf_threshold_init.h b/libavfilter/vf_threshold_init.h new file mode 100644 index 0000000000..e79d2bb63d --- /dev/null +++ b/libavfilter/vf_threshold_init.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016 Paul B Mahol + * + * 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 + */ + +#ifndef AVFILTER_THRESHOLD_INIT_H +#define AVFILTER_THRESHOLD_INIT_H + +#include +#include + +#include "config.h" +#include "libavutil/attributes.h" +#include "threshold.h" + +static void threshold8(const uint8_t *in, const uint8_t *threshold, + const uint8_t *min, const uint8_t *max, + uint8_t *out, + ptrdiff_t ilinesize, ptrdiff_t tlinesize, + ptrdiff_t flinesize, ptrdiff_t slinesize, + ptrdiff_t olinesize, + int w, int h) +{ + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) + out[x] = in[x] < threshold[x] ? min[x] : max[x]; + + in += ilinesize; + threshold += tlinesize; + min += flinesize; + max += slinesize; + out += olinesize; + } +} + +static void threshold16(const uint8_t *iin, const uint8_t *tthreshold, + const uint8_t *ffirst, const uint8_t *ssecond, + uint8_t *oout, + ptrdiff_t ilinesize, ptrdiff_t tlinesize, + ptrdiff_t flinesize, ptrdiff_t slinesize, + ptrdiff_t olinesize, + int w, int h) +{ + const uint16_t *in = (const uint16_t *)iin; + const uint16_t *threshold = (const uint16_t *)tthreshold; + const uint16_t *min = (const uint16_t *)ffirst; + const uint16_t *max = (const uint16_t *)ssecond; + uint16_t *out = (uint16_t *)oout; + + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) + out[x] = in[x] < threshold[x] ? min[x] : max[x]; + + in += ilinesize / 2; + threshold += tlinesize / 2; + min += flinesize / 2; + max += slinesize / 2; + out += olinesize / 2; + } +} + +static av_unused void ff_threshold_init(ThresholdContext *s) +{ + if (s->depth == 8) { + s->threshold = threshold8; + s->bpc = 1; + } else { + s->threshold = threshold16; + s->bpc = 2; + } + + if (ARCH_X86) + ff_threshold_init_x86(s); +} + +#endif /* AVFILTER_THRESHOLD_INIT_H */ diff --git a/tests/checkasm/vf_threshold.c b/tests/checkasm/vf_threshold.c index 2c5cc807ee..e6a425edfe 100644 --- a/tests/checkasm/vf_threshold.c +++ b/tests/checkasm/vf_threshold.c @@ -18,7 +18,7 @@ #include #include "checkasm.h" -#include "libavfilter/threshold.h" +#include "libavfilter/vf_threshold_init.h" #include "libavutil/intreadwrite.h" #include "libavutil/mem_internal.h"