mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
lavfi/avfilter: export AVFilter initialization state
This will allow the AVOption code to detect setting non-runtime options after the filter has been initialized.
This commit is contained in:
parent
0548ab2e42
commit
262e6f8430
@ -159,7 +159,8 @@ 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 (!fffilterctx(src)->initialized || !fffilterctx(dst)->initialized) {
|
if (!(fffilterctx(src)->state_flags & AV_CLASS_STATE_INITIALIZED) ||
|
||||||
|
!(fffilterctx(dst)->state_flags & AV_CLASS_STATE_INITIALIZED)) {
|
||||||
av_log(src, AV_LOG_ERROR, "Filters must be initialized before linking.\n");
|
av_log(src, AV_LOG_ERROR, "Filters must be initialized before linking.\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
@ -676,6 +677,7 @@ static const AVClass avfilter_class = {
|
|||||||
.child_next = filter_child_next,
|
.child_next = filter_child_next,
|
||||||
.child_class_iterate = filter_child_class_iterate,
|
.child_class_iterate = filter_child_class_iterate,
|
||||||
.option = avfilter_options,
|
.option = avfilter_options,
|
||||||
|
.state_flags_offset = offsetof(FFFilterContext, state_flags),
|
||||||
};
|
};
|
||||||
|
|
||||||
static int default_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg,
|
static int default_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg,
|
||||||
@ -909,7 +911,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
|
|||||||
FFFilterContext *ctxi = fffilterctx(ctx);
|
FFFilterContext *ctxi = fffilterctx(ctx);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctxi->initialized) {
|
if (ctxi->state_flags & AV_CLASS_STATE_INITIALIZED) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Filter already initialized\n");
|
av_log(ctx, AV_LOG_ERROR, "Filter already initialized\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
@ -940,7 +942,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxi->initialized = 1;
|
ctxi->state_flags |= AV_CLASS_STATE_INITIALIZED;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -100,9 +100,8 @@ typedef struct FFFilterContext {
|
|||||||
|
|
||||||
avfilter_execute_func *execute;
|
avfilter_execute_func *execute;
|
||||||
|
|
||||||
// 1 when avfilter_init_*() was successfully called on this filter
|
// AV_CLASS_STATE_FLAG_*
|
||||||
// 0 otherwise
|
unsigned state_flags;
|
||||||
int initialized;
|
|
||||||
} FFFilterContext;
|
} FFFilterContext;
|
||||||
|
|
||||||
static inline FFFilterContext *fffilterctx(AVFilterContext *ctx)
|
static inline FFFilterContext *fffilterctx(AVFilterContext *ctx)
|
||||||
|
@ -627,7 +627,8 @@ int avfilter_graph_segment_init(AVFilterGraphSegment *seg, int flags)
|
|||||||
|
|
||||||
if (p->filter_name)
|
if (p->filter_name)
|
||||||
return fail_creation_pending(seg, p->filter_name, __func__);
|
return fail_creation_pending(seg, p->filter_name, __func__);
|
||||||
if (!p->filter || fffilterctx(p->filter)->initialized)
|
if (!p->filter ||
|
||||||
|
(fffilterctx(p->filter)->state_flags & AV_CLASS_STATE_INITIALIZED))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret = avfilter_init_dict(p->filter, NULL);
|
ret = avfilter_init_dict(p->filter, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user