From patchwork Mon Jan 4 00:28:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24776 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 0AF9E44907C for ; Mon, 4 Jan 2021 02:29:05 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E7F3D68AA98; Mon, 4 Jan 2021 02:29:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 73F6468A943 for ; Mon, 4 Jan 2021 02:28:58 +0200 (EET) Received: by mail-wm1-f41.google.com with SMTP id q75so17568237wme.2 for ; Sun, 03 Jan 2021 16:28:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=4fRTdEvow8ONQwpYan4B65Bvb4AFcs9SG9SXDjqYF8g=; b=G9E5H5PYPyLDtTpTucxDiCWY13WrUXyXZFapgQ18FlE6PgXuEPxMSJG/ZQnSWaB7MS Yjc9EPXS2ySzXPt8bQD8gM1Un88vMooia9G/WhaIj+MVlU6bHav/W3YpQbukm4qO4eeV FzW0gbxm6ndEqrfLMputrzTzDfG+GrbQ9yPM0ZboSrA/0DYsWQ+fMrQq6h2GJnUCDaBp SwnIt8CLeB2RUY3qgqFFcxyxCUjc5eWXor8xW1KsDFk1x6nNL6XOBiima8CWsa/+jusD 0YhYfaB6cQSzQLkRTxBMfTEcZOHwXYd4pXNu+fyiPZXODNXJk30z+JbwPZg1VpEPFrrX pIWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=4fRTdEvow8ONQwpYan4B65Bvb4AFcs9SG9SXDjqYF8g=; b=laOZEVHsONRpPmLPSexBBMqY8ng5XQPYc0dC2t+/Hn4lDLa7CLl0zJIbRmlA8DXiBD q3+xsOf7f67LzhSL4ZBu7Jxgf8tcEFP6b9vMOrSzpdXAz01NgYaKqSm4S0MVtHy9pk1q 9AYBedfow3VSLHebVvYr9mIAFaK0qVyFHri+fRPK84OdWrmNAIL2h+mfX8B5uGy8Vrr1 ifK+z0Wtq5Q7+PHCpMB8xUomrn9vz4glT06hNVjsTu2Zqb+X7DOMHs8FqxMOO9DkAKyh CmtvnNIF9uqurKXn2I9yfVHdJIxEwja1BZVv1QQ5UIJViuC7a92rRZlXcEk4hzFcphic mO+A== X-Gm-Message-State: AOAM530jXTLVbj2gHvf12TGCE1laCeoiEay9cZnz8uvMjSv/NRpoJpkX 0zsnZ1/wQccVQKzA28GM9522se2nrhw= X-Google-Smtp-Source: ABdhPJxQ+cb8YeR5mqw7x3GNqBk/LqBc8OrZ6NAZFvFNBVN5wlPrBY2qbgAJTW26RPUcEBapVyTrdA== X-Received: by 2002:a7b:ce0f:: with SMTP id m15mr24296515wmc.56.1609720137649; Sun, 03 Jan 2021 16:28:57 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id u26sm30032046wmm.24.2021.01.03.16.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jan 2021 16:28:57 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Jan 2021 01:28:11 +0100 Message-Id: <20210104002816.2321974-11-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210104002816.2321974-1-andreas.rheinhardt@gmail.com> References: <20210104002816.2321974-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/16] avfilter/vf_neighbor: Deduplicate options X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_neighbor.c | 42 ++++++++++++--------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/libavfilter/vf_neighbor.c b/libavfilter/vf_neighbor.c index 17a9b88265..9cd9001320 100644 --- a/libavfilter/vf_neighbor.c +++ b/libavfilter/vf_neighbor.c @@ -371,60 +371,44 @@ AVFilter ff_vf_##name_ = { \ .process_command = ff_filter_process_command, \ } -#if CONFIG_EROSION_FILTER - -static const AVOption erosion_options[] = { +/* The following options are shared between all filters here; + * the de/inflate filters only use the threshold* options. */ +#define DEINFLATE_OPTIONS_OFFSET (CONFIG_EROSION_FILTER || CONFIG_DILATION_FILTER) +static const AVOption options[] = { +#if CONFIG_EROSION_FILTER || CONFIG_DILATION_FILTER + { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS }, +#endif { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS }, { NULL } }; +#if CONFIG_EROSION_FILTER + +#define erosion_options options DEFINE_NEIGHBOR_FILTER(erosion, "Apply erosion effect."); #endif /* CONFIG_EROSION_FILTER */ #if CONFIG_DILATION_FILTER -static const AVOption dilation_options[] = { - { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS }, - { NULL } -}; - +#define dilation_options options DEFINE_NEIGHBOR_FILTER(dilation, "Apply dilation effect."); #endif /* CONFIG_DILATION_FILTER */ #if CONFIG_DEFLATE_FILTER -static const AVOption deflate_options[] = { - { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { NULL } -}; - +#define deflate_options &options[DEINFLATE_OPTIONS_OFFSET] DEFINE_NEIGHBOR_FILTER(deflate, "Apply deflate effect."); #endif /* CONFIG_DEFLATE_FILTER */ #if CONFIG_INFLATE_FILTER -static const AVOption inflate_options[] = { - { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, - { NULL } -}; - +#define inflate_options &options[DEINFLATE_OPTIONS_OFFSET] DEFINE_NEIGHBOR_FILTER(inflate, "Apply inflate effect."); #endif /* CONFIG_INFLATE_FILTER */