From patchwork Thu Nov 21 14:53:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 16365 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 6265B44AE11 for ; Thu, 21 Nov 2019 17:00:33 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3A4F868A607; Thu, 21 Nov 2019 17:00:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 50F4D6899BB for ; Thu, 21 Nov 2019 17:00:27 +0200 (EET) Received: by mail-wm1-f67.google.com with SMTP id l17so4087996wmh.0 for ; Thu, 21 Nov 2019 07:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=SO8aA0VfCrLHvhg7lz3IY2Jttvmit4bT0i1kk17DfUk=; b=Tjm/bPRIezRgGM8FtY5gWYzu8l/QD+/jHUDbv3Znv2oh+CE8qtDRgFrNYw6bb9nu8E 8ht7B3o6fKKYNBnDP3+/mq7hwfblu/cczdLtO31usl6Qq7xlukQvG1L4MaNR5S61uA+F cH02xcihQM0eBqMgFfJANv73zYveT2i+5Ppah5sPIW5y6moaNF+ccqV7xE2md+yPmeSX /H6wHRvv2DFK6HPAmRyQiJQ9XjwP5H+VnRe1Sot952hjONhnE3/H0UfBg4qBpkSygSXy j1UTyKtjWZ6n+QrlyErCjjtLbtePXcKXLqIHBjLdcsn5hHfxO54q0H+m6NiwmJ1c5hgO YXaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=SO8aA0VfCrLHvhg7lz3IY2Jttvmit4bT0i1kk17DfUk=; b=LS3ngrTBRWWXeR/h3JAE4427rNYKiASaW4tubENvN+/Q4LV9jb7aoGZzkZpsagzzaK D437qAmO8/s0tohCsN90dRu6U8qCWGWaOkv8fWu8OdV5W4gMdHGC0YORpzQWGlT855X8 kEPFPnliYM0oQqCo8vGvMuruRtVtN/8f5rIHBSvQPvkpz2eAZWc27agXtiS9IYncKssS SgSbu08UvMYaUsLxncfI/bXHPYhtLATAP4e8EsQkDqiWxY8XWOadYMwKZErLgVsvO9gA nD2u/DnPf4JTC0sORJITPsEa17vPPaXpQr/9u4T8WZtizCXFS25z6XMOEoGjO7u44qHD ddOQ== X-Gm-Message-State: APjAAAXuXEsHQDRFzR5la1F+iEWVnibKGcwPRUQxX1fMIa571CYrNehx SbnZlAaFMcpe3Z0vfXG6pGFabKwW X-Google-Smtp-Source: APXvYqzqkKsDHS5o+DCQZ16A0PgvAeqdeituwuMVZY99+6R84nypHBJKxAJHMM8CgWdLfzlOsqtlrA== X-Received: by 2002:a05:600c:3cd:: with SMTP id z13mr10448332wmd.105.1574348016490; Thu, 21 Nov 2019 06:53:36 -0800 (PST) Received: from localhost.localdomain ([94.250.173.190]) by smtp.gmail.com with ESMTPSA id b196sm3359337wmd.24.2019.11.21.06.53.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 06:53:35 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Thu, 21 Nov 2019 15:53:25 +0100 Message-Id: <20191121145325.8168-2-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191121145325.8168-1-onemda@gmail.com> References: <20191121145325.8168-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_hqdn3d: add support for commands 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- doc/filters.texi | 7 +++++++ libavfilter/vf_hqdn3d.c | 40 +++++++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index cc192d634f..c88544408f 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -11679,6 +11679,13 @@ A floating point number which specifies chroma temporal strength. It defaults to @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}. @end table +@subsection Commands +This filter supports same @ref{commands} as options. +The command accepts the same syntax of the corresponding option. + +If the specified expression is not valid, it is kept at its current +value. + @anchor{hwdownload} @section hwdownload diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c index eac10bf261..803f90c28c 100644 --- a/libavfilter/vf_hqdn3d.c +++ b/libavfilter/vf_hqdn3d.c @@ -172,13 +172,10 @@ static int denoise_depth(HQDN3DContext *s, } \ } while (0) -static int16_t *precalc_coefs(double dist25, int depth) +static void precalc_coefs(double dist25, int depth, int16_t *ct) { int i; double gamma, simil, C; - int16_t *ct = av_malloc((512<priv; + + for (int i = 0; i < 4; i++) + precalc_coefs(s->strength[i], s->depth, s->coefs[i]); +} + static int config_input(AVFilterLink *inlink) { + AVFilterContext *ctx = inlink->dst; HQDN3DContext *s = inlink->dst->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); - int i; + int i, depth; uninit(inlink->dst); s->hsub = desc->log2_chroma_w; s->vsub = desc->log2_chroma_h; - s->depth = desc->comp[0].depth; + s->depth = depth = desc->comp[0].depth; for (i = 0; i < 3; i++) { s->line[i] = av_malloc_array(inlink->w, sizeof(*s->line[i])); @@ -273,11 +278,13 @@ static int config_input(AVFilterLink *inlink) } for (i = 0; i < 4; i++) { - s->coefs[i] = precalc_coefs(s->strength[i], s->depth); + s->coefs[i] = av_malloc((512<coefs[i]) return AVERROR(ENOMEM); } + calc_coefs(ctx); + if (ARCH_X86) ff_hqdn3d_init_x86(s); @@ -346,8 +353,22 @@ 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) +{ + int ret; + + ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags); + if (ret < 0) + return ret; + + calc_coefs(ctx); + + return 0; +} + #define OFFSET(x) offsetof(HQDN3DContext, 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 hqdn3d_options[] = { { "luma_spatial", "spatial luma strength", OFFSET(strength[LUMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS }, { "chroma_spatial", "spatial chroma strength", OFFSET(strength[CHROMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS }, @@ -388,4 +409,5 @@ AVFilter ff_vf_hqdn3d = { .inputs = avfilter_vf_hqdn3d_inputs, .outputs = avfilter_vf_hqdn3d_outputs, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS, + .process_command = process_command, };