From patchwork Fri Nov 22 02:19:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: leozhang X-Patchwork-Id: 16381 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 223CE44811D for ; Fri, 22 Nov 2019 04:20:11 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EEFC868AE4C; Fri, 22 Nov 2019 04:20:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smg-bj-02.qiyi.com (mx1.qiyi.com [202.108.14.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7828168ADAE for ; Fri, 22 Nov 2019 04:20:03 +0200 (EET) X-AuditID: ca6c0e64-7364e9e000007a70-8b-5dd745d09a56 Received: from mail.iqiyi.com (Unknown_Domain [10.11.69.96]) by smg-bj-02.qiyi.com (Qiyi mail Gateway) with SMTP id B1.D5.31344.0D547DD5; Fri, 22 Nov 2019 10:20:00 +0800 (HKT) From: leozhang To: Date: Fri, 22 Nov 2019 10:19:55 +0800 Message-ID: <1574389195-79049-1-git-send-email-leozhang@qiyi.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573806949-3806-1-git-send-email-leozhang@qiyi.com> References: <1573806949-3806-1-git-send-email-leozhang@qiyi.com> MIME-Version: 1.0 X-Originating-IP: [10.13.40.215] X-ClientProxiedBy: BJ-CAS32.iqiyi.pps (10.11.50.121) To EXCH20.iqiyi.pps (10.16.148.50) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJLMWRmVeSWpSXmKPExsXCxe2aoHvB9XqswaWt+hbfPp1hdmD0+LNo M0sAYxS3TVJiSVlwZnqevl0Cd8aRv1eZC54LVyy5vJWxgfEKfxcjJ4eEgInE93lrWLsYuTiE BDYyShxvf8sKkmATUJJYv2IqmC0iICux+t8UNhBbWCBOorfvLTuIzSKgKvHo3i4mEJtXwFFi +p9Z7BBDFSSmPHzPDGJzAsU3b/sDFhcScJA41vmbBaJeUOLkzCdgNrOAhMTBFy+YIWrkJJ7+ +gUU5wCb8+9hMIQZKbHmd/kERv5ZSJpnIWlewMi0ilGoODddNylL18BIrzCzMlMvOT93EyMw lE7l8KXsYDw43/kQowAHoxIP74y6a7FCrIllxZW5hxglOJiVRHg5W47ECvGmJFZWpRblxxeV 5qQWH2KU5mBREuddHAlULZCeWJKanZpakFoEk2Xi4ATp5pISKU7NS0ktSiwtyYgHhXl8MTDQ pRoYb55i9YtclSTyLC77EUfNPt71NScO2IbGCdhs/z61paww0vn6EsVEyU37FqdOv39k8Y8X WkmqZ+Uv2C8s/3dlznmjDsfZc9a5xK363HlfjPXGugzeS78zws/y6SU1My2xmrbU4ZaHlPEu 1jPae1u+fdy/NPadz/P8WbvXRf4/3etzaq/VIpabj5VYijMSDbWYi4oTARFZOBY8AgAA Subject: [FFmpeg-devel] [PATCH V3 2/2] avfilter/vf_bilateral: process command to set the parameter at runtime 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Reviewed-by: Paul B Mahol Reviewed-by: Jun Zhao Reviewed-by: Limin Wang Signed-off-by: leozhang --- doc/filters.texi | 4 ++++ libavfilter/vf_bilateral.c | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index e48f9c9..6b1a5cb 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6355,6 +6355,10 @@ Allowed range is 0 to 1. Default is 0.1. Set planes to filter. Default is first only. @end table +@subsection Commands + +This filter supports the all above options as @ref{commands}. + @section bitplanenoise Show and measure bit plane noise. diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c index 36e53d2..b2a3487 100644 --- a/libavfilter/vf_bilateral.c +++ b/libavfilter/vf_bilateral.c @@ -29,6 +29,8 @@ #include "internal.h" #include "video.h" +#include + typedef struct BilateralContext { const AVClass *class; @@ -54,7 +56,7 @@ typedef struct BilateralContext { } BilateralContext; #define OFFSET(x) offsetof(BilateralContext, x) -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM static const AVOption bilateral_options[] = { { "sigmaS", "set spatial sigma", OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 10, FLAGS }, @@ -333,6 +335,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) return ff_filter_frame(outlink, out); } +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, + char *res, int res_len, int flags) +{ + BilateralContext *s = ctx->priv; + int ret; + float old_sigmaR = s->sigmaR; + + if ((ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags)) < 0) { + return ret; + } + + if (fabsf(old_sigmaR - s->sigmaR) > FLT_EPSILON && (ret = init_lut(s)) < 0) { + s->sigmaR = old_sigmaR; + } + + return ret; +} + static av_cold void uninit(AVFilterContext *ctx) { BilateralContext *s = ctx->priv; @@ -375,4 +395,5 @@ AVFilter ff_vf_bilateral = { .inputs = bilateral_inputs, .outputs = bilateral_outputs, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, + .process_command = process_command, };