[ffmpeg] branch master updated. 0bd5a7d371 avfilter/vf_colordetect: only report detected properties on EOF
The branch, master has been updated via 0bd5a7d3719456f049f4d29abb313968ccacb28c (commit) from 843920d5d6bdcecbfd4eeac66cd175348bf99496 (commit) - Log ----------------------------------------------------------------- commit 0bd5a7d3719456f049f4d29abb313968ccacb28c Author: Niklas Haas <git@haasn.dev> AuthorDate: Sun Sep 21 13:28:58 2025 +0200 Commit: Niklas Haas <git@haasn.dev> CommitDate: Sun Sep 21 13:28:58 2025 +0200 avfilter/vf_colordetect: only report detected properties on EOF Instead of reporting them also when the filtergraph is suddenly destroyed mid-stream, e.g. during the `ffmpeg` tool's early init. 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, }; ----------------------------------------------------------------------- Summary of changes: libavfilter/vf_colordetect.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) hooks/post-receive --
participants (1)
-
ffmpeg-git@ffmpeg.org