This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch release/4.4 in repository ffmpeg.
commit cfe3dad4459cd04ca168fd3e4938b6ce18c5ade7 Author: Michael Niedermayer <[email protected]> AuthorDate: Wed Jan 14 02:13:14 2026 +0100 Commit: Michael Niedermayer <[email protected]> CommitDate: Tue May 5 18:54:58 2026 +0200 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]> (cherry picked from commit 12321e5eba32bd07f4c313c7e1eeb84ac2af7953) 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 fc5eafb149..d55df8da6b 100644 --- a/libavfilter/vf_find_rect.c +++ b/libavfilter/vf_find_rect.c @@ -50,8 +50,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 }, { NULL } }; @@ -157,19 +157,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; @@ -204,19 +191,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) int best_x, best_y; int i; + 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++) { @@ -294,7 +286,6 @@ static const AVFilterPad foc_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .config_props = config_input, .filter_frame = filter_frame, }, { NULL } _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
