From patchwork Thu Feb 11 18:18:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 25577 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 5815344A462 for ; Thu, 11 Feb 2021 20:23:54 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 280C568AAC1; Thu, 11 Feb 2021 20:23:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 98A2D68A99E for ; Thu, 11 Feb 2021 20:23:47 +0200 (EET) Received: by mail-lj1-f179.google.com with SMTP id a22so8494528ljp.10 for ; Thu, 11 Feb 2021 10:23:47 -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:mime-version :content-transfer-encoding; bh=YnbX5LakcKuMeZk4tTq7GUCxW1KJy9PefWuifjE89CY=; b=L1BFS6y1q+EWBLHiK7MoC7STcEvG9pHYynfeB2xhzuk5Ifk9KlrMAHhNOxzxbYVCYh RuuYlppuq7f0I6yQzdqcFGPnDYEyCNqZGWB6/eGKUC3DzAHM8wcQuL3MzZJjJEa19IBC X2DD6e7L8WLUUxySEeRzds3h2RdZiktYbweNqIZbD1RnxjH9kysSbIshOiz58EYfVBRY GZdLkIpwjp2gq3AqhbqxlQs93TNGzP/vy8mehkvzOKXvs6MXTKyeqq+OhHImG/1RcBjz NqwF1mURqb0u2NkaWRiOpDBx5giudYNenJIM+uyvp3C9pAFeAd4NCF1PJkxla2U0PC43 lk/Q== 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:mime-version:content-transfer-encoding; bh=YnbX5LakcKuMeZk4tTq7GUCxW1KJy9PefWuifjE89CY=; b=IZNI00OwxWUk0eMwT8iMrhS2WonJj6E3nUJP3xYkxZFSctIoCPN3Oip6teBmEU4r8s deAMLUJ8VAkkgzFe1oZPOlZOafNVhD65bZKq0HYY8+dtWDBeoSDqu2FgiUOiQdlI7P6w 9I+e2N2Nie3nw5CzS4IP7oGpRMEf3atsNtqCGzNOrLU4d+G0HMp/Pkzx3lcHFLkTBpzW k+CeaifqtOJjll0f6hQJ1+mqCv5FeUDPgQLMJwL8bRIJgao3Hw/RQneksDVVZdvv9kme 1njlzANMElux9efZZvSfmnhIHtQ+oUzJlQg/rnC7ER3aApEc1rpbQYv66n9+1MU7QOA/ fPJw== X-Gm-Message-State: AOAM531xlP48d+jhf7ZdxOVNg6WBTe6ysbqsdKTLO/k6eJwfrpo6Pm88 aV30JD2GdbFw6EZqrVkZuvk9RyO1c1g= X-Google-Smtp-Source: ABdhPJwSedUtqBGYV36ObO1/9+LwQ58qn1PBEkl5kXupLfig/0aYYs/gZWhS8Tf1LDmVDScny1TRuA== X-Received: by 2002:a2e:8743:: with SMTP id q3mr5726041ljj.12.1613067500852; Thu, 11 Feb 2021 10:18:20 -0800 (PST) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id f13sm996970ljo.39.2021.02.11.10.18.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 10:18:20 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Feb 2021 20:18:17 +0200 Message-Id: <20210211181817.49454-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210209210754.7618-1-jeebjp@gmail.com> References: <20210209210754.7618-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avfilter/vf_zscale: add support for setting scaling filter parameters 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" param_a/b are utilized for this. --- Changes from v1: * Documentation was added. * The author of the zimg library noted that the bicubic parameters technically can go negative. Thus the range is -DBL_MAX to DBL_MAX. --- doc/filters.texi | 7 +++++++ libavfilter/vf_zscale.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 50aa0eb305..152e806fdd 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -22393,6 +22393,13 @@ Possible values are: @item npl Set the nominal peak luminance. + +@item param_a +Parameter A for scaling filters. Parameter "b" for bicubic, and the number of +filter taps for lanczos. + +@item param_b +Parameter B for scaling filters. Parameter "c" for bicubic. @end table The values of the @option{w} and @option{h} options are expressions diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c index 57199a0878..c18a161ab4 100644 --- a/libavfilter/vf_zscale.c +++ b/libavfilter/vf_zscale.c @@ -101,6 +101,8 @@ typedef struct ZScaleContext { char *size_str; double nominal_peak_luminance; int approximate_gamma; + double param_a; + double param_b; char *w_expr; ///< width expression string char *h_expr; ///< height expression string @@ -601,6 +603,8 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) s->params.resample_filter_uv = s->filter; s->params.nominal_peak_luminance = s->nominal_peak_luminance; s->params.allow_approximate_gamma = s->approximate_gamma; + s->params.filter_param_a = s->params.filter_param_a_uv = s->param_a; + s->params.filter_param_b = s->params.filter_param_b_uv = s->param_b; format_init(&s->src_format, in, desc, s->colorspace_in, s->primaries_in, s->trc_in, s->range_in, s->chromal_in); @@ -897,6 +901,9 @@ static const AVOption zscale_options[] = { { "cin", "set input chroma location", OFFSET(chromal_in), AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_CHROMA_BOTTOM, FLAGS, "chroma" }, { "npl", "set nominal peak luminance", OFFSET(nominal_peak_luminance), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, 0, DBL_MAX, FLAGS }, { "agamma", "allow approximate gamma", OFFSET(approximate_gamma), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS }, + { "param_a", "parameter A, which is parameter \"b\" for bicubic, " + "and the number of filter taps for lanczos", OFFSET(param_a), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, -DBL_MAX, DBL_MAX, FLAGS }, + { "param_b", "parameter B, which is parameter \"c\" for bicubic", OFFSET(param_b), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, -DBL_MAX, DBL_MAX, FLAGS }, { NULL } };