PR #25080 opened by romainhedouin URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25080 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25080.patch
The reference row was found by subtracting the image width from the distance one row at a time The distance can be about a million so for a very narrow image one reference could take a million steps Use a division and a remainder instead which gives the same result <!-- If this PR requires new FATE test samples, attach them to the PR and list their target paths below (relative to the fate-suite root). Attached filenames must match the sample's filename: ```fate-samples # e.g. vorbis/new-sample.ogg ``` --> >From 70ac6ca3973bc6bbd94e99b3e27b271b663e9b05 Mon Sep 17 00:00:00 2001 From: romainhedouin <[email protected]> Date: Wed, 14 Oct 2026 21:31:45 +0200 Subject: [PATCH] avcodec/webp: Find the reference row with a division The reference row was found by subtracting the image width from the distance one row at a time. The distance can be about a million, so for a very narrow image one reference could take a million steps. Use a division and a remainder instead, which gives the same result. Found with the help of an AI code review. --- libavcodec/webp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/webp.c b/libavcodec/webp.c index e4174f0828..7e96e6a587 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -698,10 +698,8 @@ static int decode_entropy_coded_image(WebPContext *s, enum ImageRole role, ref_x = 0; distance -= x; } - while (distance >= width) { - ref_y--; - distance -= width; - } + ref_y -= distance / width; + distance %= width; if (distance > 0) { ref_x = width - distance; ref_y--; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
