This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 26ebd5a180f5bed3063c8ddbb64d8bb3ae289299
Author:     Niklas Haas <[email protected]>
AuthorDate: Sun Nov 8 02:54:37 2026 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Tue Nov 10 14:57:29 2026 +0000

    swscale/filters: calculate true filter size
    
    Instead of estimating based on a worst-case scenario, calculate the
    number of taps each row needs (which depends on the phase), and take
    the maximum of these values as the overall filter size.
    
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/filters.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/libswscale/filters.c b/libswscale/filters.c
index 006cad5f83..5544116961 100644
--- a/libswscale/filters.c
+++ b/libswscale/filters.c
@@ -267,11 +267,22 @@ int ff_sws_filter_generate(void *log, const 
SwsFilterParams *params,
     }
     radius *= stretch;
 
-    int filter_size = ceil(radius * 2.0);
-    filter_size = FFMIN(filter_size, params->src_size);
-    av_assert0(filter_size >= 1);
-    if (filter_size > SWS_FILTER_SIZE_MAX)
-        return AVERROR(ENOTSUP);
+    /* Compute filter size by checking the number of taps in each row */
+    int filter_size = 0;
+    for (int i = 0; i < params->dst_size; i++) {
+        /* Matches the indexing in compute_row() */
+        const double src_pos = get_src_pos(i, ratio_inv, params->offset);
+        const int start = floor(src_pos - radius) + 1;
+        const int stop  = ceil (src_pos + radius) - 1;
+        const int taps  = av_clip(stop - start + 1, 1, params->src_size);
+        if (taps > SWS_FILTER_SIZE_MAX) {
+            return AVERROR(ENOTSUP);
+        } else if (taps > filter_size) {
+            filter_size = taps;
+            if (taps == params->src_size)
+                break; /* can't get any bigger */
+        }
+    }
 
     SwsFilterWeights *filter;
     filter = av_refstruct_alloc_ext(sizeof(*filter), 0, NULL, sws_filter_free);

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to