diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-09-28 16:19:06 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-10-01 09:57:58 +0200 |
commit | 262e6f8430a821effb63af67e8f0bbbea9c3a754 (patch) | |
tree | b369c0d000f732306aceee15c7c88467f16a8d35 /libavfilter/avfilter.c | |
parent | 0548ab2e4257f9c6e7a7a57138504533a6ca5507 (diff) | |
download | ffmpeg-262e6f8430a821effb63af67e8f0bbbea9c3a754.tar.gz |
lavfi/avfilter: export AVFilter initialization state
This will allow the AVOption code to detect setting non-runtime options
after the filter has been initialized.
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r-- | libavfilter/avfilter.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 8a2a9e0593..dc06ebab4d 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -159,7 +159,8 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, src->outputs[srcpad] || dst->inputs[dstpad]) 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"); return AVERROR(EINVAL); } @@ -676,6 +677,7 @@ static const AVClass avfilter_class = { .child_next = filter_child_next, .child_class_iterate = filter_child_class_iterate, .option = avfilter_options, + .state_flags_offset = offsetof(FFFilterContext, state_flags), }; 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); int ret = 0; - if (ctxi->initialized) { + if (ctxi->state_flags & AV_CLASS_STATE_INITIALIZED) { av_log(ctx, AV_LOG_ERROR, "Filter already initialized\n"); return AVERROR(EINVAL); } @@ -940,7 +942,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) return ret; } - ctxi->initialized = 1; + ctxi->state_flags |= AV_CLASS_STATE_INITIALIZED; return 0; } |