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

Git pushed a commit to branch master
in repository ffmpeg.

commit 12321e5eba32bd07f4c313c7e1eeb84ac2af7953
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Wed Jan 14 02:13:14 2026 +0100
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Thu Feb 5 17:08:30 2026 +0100

    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 | 33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
index b0be1a6f11..d3df9c0c45 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 }
 };
@@ -150,19 +150,6 @@ static float compare(const AVFrame *haystack, const 
AVFrame *obj, int offx, int
     return 1 - fabs(c);
 }
 
-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;
-
-    return 0;
-}
-
 static float search(FOCContext *foc, int pass, int maxpass, int xmin, int 
xmax, int ymin, int ymax, int *best_x, int *best_y, float best_score)
 {
     int x, y;
@@ -199,19 +186,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     int i;
     char buf[32];
 
+    int xmin = FFMAX(foc->xmin, 0);
+    int ymin = FFMAX(foc->ymin, 0);
+    int xmax = FFMIN(foc->xmax, inlink->w - foc->obj_frame->width );
+    int ymax = FFMIN(foc->ymax, inlink->h - foc->obj_frame->height);
+
     foc->haystack_frame[0] = av_frame_clone(in);
     for (i=1; i<foc->mipmaps; i++) {
         foc->haystack_frame[i] = downscale(foc->haystack_frame[i-1]);
     }
 
     best_score = search(foc, 0, 0,
-                        FFMAX(foc->xmin, foc->last_x - 8),
-                        FFMIN(foc->xmax, foc->last_x + 8),
-                        FFMAX(foc->ymin, foc->last_y - 8),
-                        FFMIN(foc->ymax, foc->last_y + 8),
+                        FFMAX(xmin, foc->last_x - 8),
+                        FFMIN(xmax, foc->last_x + 8),
+                        FFMAX(ymin, foc->last_y - 8),
+                        FFMIN(ymax, foc->last_y + 8),
                         &best_x, &best_y, 2.0);
 
-    best_score = search(foc, 0, foc->mipmaps - 1, foc->xmin, foc->xmax, 
foc->ymin, foc->ymax,
+    best_score = search(foc, 0, foc->mipmaps - 1, xmin, xmax, ymin, ymax,
                         &best_x, &best_y, best_score);
 
     for (i=0; i<MAX_MIPMAPS; i++) {
@@ -297,7 +289,6 @@ static const AVFilterPad foc_inputs[] = {
     {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
-        .config_props = config_input,
         .filter_frame = filter_frame,
     },
 };

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

Reply via email to