Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PR] vfilter/vf_find_rect: Clamp x/y min/max to valid values (PR #21457)
@ 2026-01-14  1:22 michaelni via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: michaelni via ffmpeg-devel @ 2026-01-14  1:22 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: michaelni

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 <michael@niedermayer.cc>


>From 237cf3eaa83b17312cd3ee77f931fec2138c2956 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael@niedermayer.cc>
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 <michael@niedermayer.cc>
---
 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 -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-01-14  1:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-14  1:22 [FFmpeg-devel] [PR] vfilter/vf_find_rect: Clamp x/y min/max to valid values (PR #21457) michaelni via ffmpeg-devel

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git