You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-23 21:54:53 +02:00
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.
This commit is contained in:
@@ -207,7 +207,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
return ff_filter_frame(inlink->dst->outputs[0], 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;
|
ColorDetectContext *s = ctx->priv;
|
||||||
if (!s->mode)
|
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[] = {
|
static const AVFilterPad colordetect_inputs[] = {
|
||||||
{
|
{
|
||||||
.name = "default",
|
.name = "default",
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.config_props = config_input,
|
.config_props = config_input,
|
||||||
.filter_frame = filter_frame,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -251,5 +282,5 @@ const FFFilter ff_vf_colordetect = {
|
|||||||
FILTER_INPUTS(colordetect_inputs),
|
FILTER_INPUTS(colordetect_inputs),
|
||||||
FILTER_OUTPUTS(ff_video_default_filterpad),
|
FILTER_OUTPUTS(ff_video_default_filterpad),
|
||||||
FILTER_QUERY_FUNC2(query_format),
|
FILTER_QUERY_FUNC2(query_format),
|
||||||
.uninit = uninit,
|
.activate = activate,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user