This is an automated email from the git hooks/post-receive script.
Git pushed a commit to branch master
in repository ffmpeg.
The following commit(s) were added to refs/heads/master by this push:
new c1ff2c24b5 swscale/filters: hard-code radius for trivial kernels
c1ff2c24b5 is described below
commit c1ff2c24b560f8e0176a1fc0d3af94ab9e76652f
Author: Niklas Haas <[email protected]>
AuthorDate: Wed Apr 22 17:07:15 2026 +0200
Commit: Niklas Haas <[email protected]>
CommitDate: Mon May 11 19:59:39 2026 +0200
swscale/filters: hard-code radius for trivial kernels
box() and triangle() have well-defined, trivially verifiable numerical
inverses.
We could actually pre-compute and hard-code the numerical inverse of all
non-parametric kernels, but I'm a bit reluctant to do this as I have plans
to
adjust the value of SWS_MAX_REDUCE_CUTOFF based on the desired bit depth of
the
output, which makes a hard-coding approach unfeasible.
(It would also be a brittle solution that may break whenever we extend the
scaler configuration API, as well as making it harder to add new filters)
Signed-off-by: Niklas Haas <[email protected]>
---
libswscale/filters.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/libswscale/filters.c b/libswscale/filters.c
index a57d81fef3..7e8865659e 100644
--- a/libswscale/filters.c
+++ b/libswscale/filters.c
@@ -154,7 +154,11 @@ static bool validate_params(const SwsFilterFunction *fun,
SwsScaler scaler)
}
}
-static double filter_radius(const SwsFilterFunction *fun)
+/**
+ * Numerically estimate the last intersection between the function value
+ * and the cutoff domain [-SWS_MAX_REDUCE_CUTOFF, SWS_MAX_REDUCE_CUTOFF].
+ */
+static double est_filter_radius(const SwsFilterFunction *fun)
{
const double bound = fun->radius;
const double step = 1e-2;
@@ -225,7 +229,21 @@ int ff_sws_filter_generate(void *log, const
SwsFilterParams *params,
if (fun.radius < 0.0) /* tunable width kernels like lanczos */
fun.radius = fun.params[0];
- const double radius = filter_radius(&fun) * stretch;
+ double radius;
+ switch (scaler) {
+ case SWS_SCALE_POINT:
+ radius = 0.5;
+ break;
+ case SWS_SCALE_BILINEAR:
+ radius = 1.0 - SWS_MAX_REDUCE_CUTOFF;
+ break;
+ default:
+ /* Numerically estimate radius of nontrivial or parametric kernels */
+ radius = est_filter_radius(&fun);
+ break;
+ }
+ radius *= stretch;
+
int filter_size = ceil(radius * 2.0);
filter_size = FFMIN(filter_size, params->src_size);
av_assert0(filter_size >= 1);
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]