summaryrefslogtreecommitdiff
path: root/libavfilter/vf_find_rect.c
diff options
context:
space:
mode:
authorGyan Doshi <ffmpeg@gyani.pro>2021-04-01 18:22:03 +0530
committerGyan Doshi <ffmpeg@gyani.pro>2021-04-04 10:47:09 +0530
commitabdafca9ad26b020b13b76d538a98d135d127fcb (patch)
tree9218ce15de440eba5fe39c907cc4d9625a64525a /libavfilter/vf_find_rect.c
parentaff23c3474f93d7f08422755a55da4ba3ce1e800 (diff)
avfilter/find_rect: add option to discard non-matching frames
Default is disabled.
Diffstat (limited to 'libavfilter/vf_find_rect.c')
-rw-r--r--libavfilter/vf_find_rect.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
index ea3b7aeee5..f9129cc140 100644
--- a/libavfilter/vf_find_rect.c
+++ b/libavfilter/vf_find_rect.c
@@ -40,6 +40,7 @@ typedef struct FOCContext {
AVFrame *obj_frame;
AVFrame *needle_frame[MAX_MIPMAPS];
AVFrame *haystack_frame[MAX_MIPMAPS];
+ int discard;
} FOCContext;
#define OFFSET(x) offsetof(FOCContext, x)
@@ -52,6 +53,7 @@ static const AVOption find_rect_options[] = {
{ "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 },
+ { "discard", "", OFFSET(discard), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
{ NULL }
};
@@ -206,7 +208,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
}
if (best_score > foc->threshold) {
- return ff_filter_frame(ctx->outputs[0], in);
+ if (foc->discard) {
+ av_frame_free(&in);
+ return 0;
+ } else {
+ return ff_filter_frame(ctx->outputs[0], in);
+ }
}
av_log(ctx, AV_LOG_INFO, "Found at n=%lld pts_time=%f x=%d y=%d with score=%f\n",