From patchwork Thu Nov 14 03:51:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: leozhang X-Patchwork-Id: 16254 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 AA5FD449C82 for ; Thu, 14 Nov 2019 05:52:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9652368A7FD; Thu, 14 Nov 2019 05:52:00 +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 2AF1E68A641 for ; Thu, 14 Nov 2019 05:51:53 +0200 (EET) X-AuditID: ca6c0e64-24fff70000007a70-ee-5dcccf58cc9c Received: from mail.iqiyi.com (Unknown_Domain [10.11.69.97]) by smg-bj-02.qiyi.com (Qiyi mail Gateway) with SMTP id A1.96.31344.85FCCCD5; Thu, 14 Nov 2019 11:51:52 +0800 (HKT) From: leozhang To: Date: Thu, 14 Nov 2019 11:51:48 +0800 Message-ID: <1573703508-129041-1-git-send-email-leozhang@qiyi.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.13.40.213] X-ClientProxiedBy: BJ-CAS31.iqiyi.pps (10.11.50.86) To EXCH20.iqiyi.pps (10.16.148.50) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsXCxe2aqBtx/kyswf9Z6hbfPp1hdmD0+LNo M0sAYxS3TVJiSVlwZnqevl0Cd8b16YvYC97xV1x/e4u5gXE/TxcjJ4eEgInEldtPWLsYuTiE BDYySly+sZIFJMEmoCSxfsVUVhBbREBWYvW/KWwgtrBAtMSR5bPA4iwCqhITDx1jArF5BZwk Js//xwwxVEFiysP3zBBxQYmTM5+AzWQWkJA4+OIFWFxIQE7i6a9fLDD1D6dOYoewIyS+vFrJ OoGRdxaS9llI2hcwMq1iFCrOTddNytI1MNIrzKzM1EvOz93ECAyPUzl8KTsYD853PsQowMGo xMNroHsmVog1say4MvcQowQHs5IIL2fLkVgh3pTEyqrUovz4otKc1OJDjNIcLErivGXngKoF 0hNLUrNTUwtSi2CyTBycIN1cUiLFqXkpqUWJpSUZ8aDQjS8GBq9UA6PL5ufPn3tOWO2apSPJ /2ar6V4PwTcr+ySzJQJqLvN5+zwUquqJd35UzfRlf4pT1kOPMv9JLiL5q9aaJidb8lyRudlU XrQ51qfLr/qMiPxtWeMpx1NPpnM+FvwpsCGrN2vzX/M9pxlbN9SUJvdJSLG8M3t11DT0P0t7 iF/ets+KP7wnOgmJKbEUZyQaajEXFScCAHwB1rAmAgAA Subject: [FFmpeg-devel] [PATCH 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 Signed-off-by: leozhang --- libavfilter/vf_bilateral.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c index 36e53d2..ba3631c 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 (fabs(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, };