diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-04-09 12:56:46 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-07-03 11:38:52 +0200 |
commit | f1664aabb18b2d726c3c0c0b7fa8202f3b52b8da (patch) | |
tree | bcbff7ba11217d943ce7992c6fe47ce8ebe67622 /fftools/cmdutils.c | |
parent | fc446eea05b9bc7de9a3c6b56dae8255bb5c5b5d (diff) | |
download | ffmpeg-f1664aabb18b2d726c3c0c0b7fa8202f3b52b8da.tar.gz |
fftools/ffmpeg: rewrite checking whether codec AVOptions have been used
Share the code between encoding and decoding. Instead of checking every
stream's options dictionary (which is also used for other purposes),
track all used options in a dedicated dictionary.
Diffstat (limited to 'fftools/cmdutils.c')
-rw-r--r-- | fftools/cmdutils.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index a504acb3e4..9b18cf5e4d 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -986,7 +986,7 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec, - AVDictionary **dst) + AVDictionary **dst, AVDictionary **opts_used) { AVDictionary *ret = NULL; const AVDictionaryEntry *t = NULL; @@ -1013,6 +1013,7 @@ int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, while (t = av_dict_iterate(opts, t)) { const AVClass *priv_class; char *p = strchr(t->key, ':'); + int used = 0; /* check stream specification in opt name */ if (p) { @@ -1030,15 +1031,21 @@ int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, !codec || ((priv_class = codec->priv_class) && av_opt_find(&priv_class, t->key, NULL, flags, - AV_OPT_SEARCH_FAKE_OBJ))) + AV_OPT_SEARCH_FAKE_OBJ))) { av_dict_set(&ret, t->key, t->value, 0); - else if (t->key[0] == prefix && + used = 1; + } else if (t->key[0] == prefix && av_opt_find(&cc, t->key + 1, NULL, flags, - AV_OPT_SEARCH_FAKE_OBJ)) + AV_OPT_SEARCH_FAKE_OBJ)) { av_dict_set(&ret, t->key + 1, t->value, 0); + used = 1; + } if (p) *p = ':'; + + if (used && opts_used) + av_dict_set(opts_used, t->key, "", 0); } *dst = ret; @@ -1063,7 +1070,7 @@ int setup_find_stream_info_opts(AVFormatContext *s, for (int i = 0; i < s->nb_streams; i++) { ret = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id, - s, s->streams[i], NULL, &opts[i]); + s, s->streams[i], NULL, &opts[i], NULL); if (ret < 0) goto fail; } |