From: Niklas Haas via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: Niklas Haas <code@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] avfilter/vf_colordetect: only report detected properties on EOF (PR #20503) Date: Fri, 12 Sep 2025 11:19:59 -0000 Message-ID: <175767600084.25.6282037680849514793@463a07221176> (raw) PR #20503 opened by Niklas Haas (haasn) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20503 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20503.patch Instead of reporting them also when the filtergraph is suddenly destroyed mid-stream, e.g. during the `ffmpeg` tool's early init. >From 113878b880bf0d25a0c683acd9e3c0dc91bc2a34 Mon Sep 17 00:00:00 2001 From: Niklas Haas <git@haasn.dev> Date: Fri, 12 Sep 2025 13:18:07 +0200 Subject: [PATCH] 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. --- libavfilter/vf_colordetect.c | 37 +++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_colordetect.c b/libavfilter/vf_colordetect.c index ef7fb25130..5fd61a302c 100644 --- a/libavfilter/vf_colordetect.c +++ b/libavfilter/vf_colordetect.c @@ -204,7 +204,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) @@ -226,6 +226,38 @@ 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; +} + av_cold void ff_color_detect_dsp_init(FFColorDetectDSPContext *dsp, int depth, enum AVColorRange color_range) { @@ -248,7 +280,6 @@ static const AVFilterPad colordetect_inputs[] = { .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_input, - .filter_frame = filter_frame, }, }; @@ -261,5 +292,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, }; -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-09-12 11:20 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=175767600084.25.6282037680849514793@463a07221176 \ --to=ffmpeg-devel@ffmpeg.org \ --cc=code@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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