summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <[email protected]>2025-09-21 13:28:58 +0200
committerNiklas Haas <[email protected]>2025-09-21 13:28:58 +0200
commit0bd5a7d3719456f049f4d29abb313968ccacb28c (patch)
treeb9c348b102c15b85ca04bb695a73cd0850def082
parent843920d5d6bdcecbfd4eeac66cd175348bf99496 (diff)
avfilter/vf_colordetect: only report detected properties on EOFHEADmaster
Instead of reporting them also when the filtergraph is suddenly destroyed mid-stream, e.g. during the `ffmpeg` tool's early init.
-rw-r--r--libavfilter/vf_colordetect.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/libavfilter/vf_colordetect.c b/libavfilter/vf_colordetect.c
index 14b75b72ce..cfe7753ca3 100644
--- a/libavfilter/vf_colordetect.c
+++ b/libavfilter/vf_colordetect.c
@@ -207,7 +207,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return ff_filter_frame(inlink->dst->outputs[0], in);
}
-static av_cold void uninit(AVFilterContext *ctx)
+static av_cold void report_detected_props(AVFilterContext *ctx)
{
ColorDetectContext *s = ctx->priv;
if (!s->mode)
@@ -233,12 +233,43 @@ static av_cold void uninit(AVFilterContext *ctx)
}
}
+static int activate(AVFilterContext *ctx)
+{
+ AVFilterLink *inlink = ctx->inputs[0];
+ AVFilterLink *outlink = ctx->outputs[0];
+ AVFrame *frame;
+ int64_t pts;
+ int ret;
+
+ ret = ff_outlink_get_status(outlink);
+ if (ret) {
+ ff_inlink_set_status(inlink, ret);
+ report_detected_props(ctx);
+ return 0;
+ }
+
+ ret = ff_inlink_consume_frame(inlink, &frame);
+ if (ret < 0) {
+ return ret;
+ } else if (ret) {
+ return filter_frame(inlink, frame);
+ }
+
+ if (ff_inlink_acknowledge_status(inlink, &ret, &pts)) {
+ ff_outlink_set_status(outlink, ret, pts);
+ report_detected_props(ctx);
+ return 0;
+ }
+
+ FF_FILTER_FORWARD_WANTED(outlink, inlink);
+ return FFERROR_NOT_READY;
+}
+
static const AVFilterPad colordetect_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = config_input,
- .filter_frame = filter_frame,
},
};
@@ -251,5 +282,5 @@ const FFFilter ff_vf_colordetect = {
FILTER_INPUTS(colordetect_inputs),
FILTER_OUTPUTS(ff_video_default_filterpad),
FILTER_QUERY_FUNC2(query_format),
- .uninit = uninit,
+ .activate = activate,
};