diff mbox series

[FFmpeg-devel,v2] avfilter/vf_zscale: add support for setting scaling filter parameters

Message ID 20210211181817.49454-1-jeebjp@gmail.com
State Accepted
Commit 58e59396f5fe93f0606dc458d84c609b5d23ea1c
Headers show
Series [FFmpeg-devel,v2] avfilter/vf_zscale: add support for setting scaling filter parameters
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Jan Ekström Feb. 11, 2021, 6:18 p.m. UTC
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(+)

Comments

Paul B Mahol Feb. 11, 2021, 6:30 p.m. UTC | #1
lgtm
Jan Ekström Feb. 11, 2021, 6:47 p.m. UTC | #2
On Thu, Feb 11, 2021 at 8:31 PM Paul B Mahol <onemda@gmail.com> wrote:
>
> lgtm

Thanks, applied as 58e59396f5fe93f0606dc458d84c609b5d23ea1c .

Jan
diff mbox series

Patch

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 }
 };