PR #21457 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21457
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21457.patch

Fixes: #YWH-PGM40646-15
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <[email protected]>


>From 237cf3eaa83b17312cd3ee77f931fec2138c2956 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 14 Jan 2026 02:13:14 +0100
Subject: [PATCH] vfilter/vf_find_rect: Clamp x/y min/max to valid values

Fixes: #YWH-PGM40646-15
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavfilter/vf_find_rect.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
index b0be1a6f11..56ac9b3372 100644
--- a/libavfilter/vf_find_rect.c
+++ b/libavfilter/vf_find_rect.c
@@ -53,8 +53,8 @@ static const AVOption find_rect_options[] = {
     { "mipmaps", "set mipmaps", OFFSET(mipmaps), AV_OPT_TYPE_INT, {.i64 = 3}, 
1, MAX_MIPMAPS, FLAGS },
     { "xmin", "", OFFSET(xmin), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS 
},
     { "ymin", "", OFFSET(ymin), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS 
},
-    { "xmax", "", OFFSET(xmax), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS 
},
-    { "ymax", "", OFFSET(ymax), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS 
},
+    { "xmax", "", OFFSET(xmax), AV_OPT_TYPE_INT, {.i64 = INT_MAX}, 0, INT_MAX, 
FLAGS },
+    { "ymax", "", OFFSET(ymax), AV_OPT_TYPE_INT, {.i64 = INT_MAX}, 0, INT_MAX, 
FLAGS },
     { "discard", "", OFFSET(discard), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 
FLAGS },
     { NULL }
 };
@@ -155,10 +155,10 @@ static int config_input(AVFilterLink *inlink)
     AVFilterContext *ctx = inlink->dst;
     FOCContext *foc = ctx->priv;
 
-    if (foc->xmax <= 0)
-        foc->xmax = inlink->w - foc->obj_frame->width;
-    if (foc->ymax <= 0)
-        foc->ymax = inlink->h - foc->obj_frame->height;
+    foc->xmin = FFMAX(foc->xmin, 0);
+    foc->ymin = FFMAX(foc->ymin, 0);
+    foc->xmax = FFMIN(foc->xmax, inlink->w - foc->obj_frame->width );
+    foc->ymax = FFMIN(foc->ymax, inlink->h - foc->obj_frame->height);
 
     return 0;
 }
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to