PR #25725 opened by Kilian (lusoris) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25725 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25725.patch
For an odd input width, `downscale()` built the rightmost output pixel from the half-width column instead of the input's right edge. The fix samples the right edge, as the bottom edge already does. Measured on a 65x49 `testsrc` frame with a 9x9 object at its right edge (x=56, y=10): with `mipmaps=2` or `3`, the current code reports x=55, y=7 with score 0.088824, and the fixed code reports x=56, y=10 with score 0.000000. With `mipmaps=1`, and for 17x17 and 15x11 objects at the right edge, both versions find the object. >From e3cd9bd9e472e0f425ad57bad416f31ffc7f735a Mon Sep 17 00:00:00 2001 From: lusoris <[email protected]> Date: Tue, 3 Nov 2026 16:22:54 +0100 Subject: [PATCH] avfilter/vf_find_rect: replicate the right edge when downscaling The downscale tail sampled the half-width column for the second pixel of an odd-width input's rightmost output pixel. Sample the input's right edge instead, matching the existing bottom-edge replication. Pyramid output changes for odd input widths. Signed-off-by: lusoris <[email protected]> --- libavfilter/vf_find_rect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c index 88dfecbe222..834110e29e9 100644 --- a/libavfilter/vf_find_rect.c +++ b/libavfilter/vf_find_rect.c @@ -99,9 +99,9 @@ static AVFrame *downscale(AVFrame *in) x = yd ? w2 : 0; for(; x < frame->width; x++) { dst[x] = ( src[2*x+0] - + src[FFMIN(2*x+1, w2)] + + src[FFMIN(2*x+1, in->width - 1)] + src[2*x+0 + yd] - + src[FFMIN(2*x+1, w2) + yd] + + src[FFMIN(2*x+1, in->width - 1) + yd] + 2) >> 2; } src += 2*in->linesize[0]; -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
