[PR] avfilter/vf_xpsnr: avoid a zero block size on small frames (PR #23908)
michaelni via ffmpeg-devel <[email protected]> Sat, 25 Jul 2026 10:41:09 -0000
| Newsgroups | gmane.comp.video.ffmpeg.devel |
|---|---|
| Message-ID | <178497606980.59.10228629547656429609@29965ddac10e> |
PR #23908 opened by michaelni URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23908 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23908.patch Fixes: division by zero Fixes: SUcVEyk7r3Gc Found-by: Kenan Alghythee <[email protected]> >From 1daa28b33b5e68e35c496867e4b95da1de473e34 Mon Sep 17 00:00:00 2001 From: Kenan Alghythee <[email protected]> Date: Sat, 11 Jul 2026 16:53:41 +0200 Subject: [PATCH] avfilter/vf_xpsnr: avoid a zero block size on small frames Fixes: division by zero Fixes: SUcVEyk7r3Gc Found-by: Kenan Alghythee <[email protected]> --- libavfilter/vf_xpsnr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_xpsnr.c b/libavfilter/vf_xpsnr.c index 34c875456e..89f4f279ba 100644 --- a/libavfilter/vf_xpsnr.c +++ b/libavfilter/vf_xpsnr.c @@ -273,7 +273,7 @@ static int get_wsse(AVFilterContext *ctx, int16_t **org, int16_t *org_m1, const uint32_t w = s->plane_width [0]; /* luma image width in pixels */ const uint32_t h = s->plane_height[0];/* luma image height in pixels */ const double r = (double)(w * h) / (3840.0 * 2160.0); /* UHD ratio */ - const uint32_t b = FFMAX(0, 4 * (int32_t) (32.0 * sqrt(r) + + const uint32_t b = FFMAX(1, 4 * (int32_t) (32.0 * sqrt(r) + 0.5)); /* block size, integer multiple of 4 for SIMD */ const uint32_t w_blk = (w + b - 1) / b; /* luma width in units of blocks */ const double avg_act = sqrt(16.0 * (double) (1 << (2 * s->depth - 9)) / sqrt(FFMAX(0.00001, @@ -399,7 +399,7 @@ static int do_xpsnr(FFFrameSync *fs) XPSNRContext *const s = ctx->priv; const uint32_t w = s->plane_width [0]; /* luma image width in pixels */ const uint32_t h = s->plane_height[0]; /* luma image height in pixels */ - const uint32_t b = FFMAX(0, 4 * (int32_t) (32.0 * sqrt((double) (w * h) / (3840.0 * 2160.0)) + 0.5)); /* block size */ + const uint32_t b = FFMAX(1, 4 * (int32_t) (32.0 * sqrt((double) (w * h) / (3840.0 * 2160.0)) + 0.5)); /* block size */ const uint32_t w_blk = (w + b - 1) / b; /* luma width in units of blocks */ const uint32_t h_blk = (h + b - 1) / b; /* luma height in units of blocks */ AVFrame *master, *ref = NULL; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]