mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-17 20:17:55 +02:00
lavfi/avfilter: track whether a filter has been initialized
Refuse to link uninitialized filters or initialize a filter twice.
This commit is contained in:
parent
80cf509e73
commit
4310b66b98
@ -158,6 +158,11 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
|
|||||||
src->outputs[srcpad] || dst->inputs[dstpad])
|
src->outputs[srcpad] || dst->inputs[dstpad])
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
|
|
||||||
|
if (!src->internal->initialized || !dst->internal->initialized) {
|
||||||
|
av_log(src, AV_LOG_ERROR, "Filters must be initialized before linking.\n");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (src->output_pads[srcpad].type != dst->input_pads[dstpad].type) {
|
if (src->output_pads[srcpad].type != dst->input_pads[dstpad].type) {
|
||||||
av_log(src, AV_LOG_ERROR,
|
av_log(src, AV_LOG_ERROR,
|
||||||
"Media type mismatch between the '%s' filter output pad %d (%s) and the '%s' filter input pad %d (%s)\n",
|
"Media type mismatch between the '%s' filter output pad %d (%s) and the '%s' filter input pad %d (%s)\n",
|
||||||
@ -851,6 +856,11 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
if (ctx->internal->initialized) {
|
||||||
|
av_log(ctx, AV_LOG_ERROR, "Filter already initialized\n");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
ret = av_opt_set_dict2(ctx, options, AV_OPT_SEARCH_CHILDREN);
|
ret = av_opt_set_dict2(ctx, options, AV_OPT_SEARCH_CHILDREN);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Error applying generic filter options.\n");
|
av_log(ctx, AV_LOG_ERROR, "Error applying generic filter options.\n");
|
||||||
@ -877,6 +887,8 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->internal->initialized = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +137,10 @@ struct AVFilterGraphInternal {
|
|||||||
|
|
||||||
struct AVFilterInternal {
|
struct AVFilterInternal {
|
||||||
avfilter_execute_func *execute;
|
avfilter_execute_func *execute;
|
||||||
|
|
||||||
|
// 1 when avfilter_init_*() was successfully called on this filter
|
||||||
|
// 0 otherwise
|
||||||
|
int initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func,
|
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user