From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 6/6] fftools, avfilter, avformat: Simplify check for "is dictionary empty?" Date: Fri, 17 May 2024 17:25:40 +0200 Message-ID: <AS8P250MB07441DA402AA9682708B417D8FEE2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <AS8P250MB0744CC67273864DA864725B98FEE2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- fftools/ffmpeg.c | 4 ++-- fftools/ffplay.c | 4 ++-- fftools/ffprobe.c | 2 +- libavfilter/avfilter.c | 4 ++-- libavformat/aacdec.c | 2 +- libavformat/http.c | 8 ++++---- libavformat/mpc.c | 2 +- libavformat/oggenc.c | 2 +- libavformat/wvdec.c | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 1f50ed6805..c86fd5065e 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -484,8 +484,8 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b) int check_avoptions(AVDictionary *m) { - const AVDictionaryEntry *t; - if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + const AVDictionaryEntry *t = av_dict_iterate(m, NULL); + if (t) { av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key); return AVERROR_OPTION_NOT_FOUND; } diff --git a/fftools/ffplay.c b/fftools/ffplay.c index b9d11eecee..5a66bfa38d 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2694,7 +2694,7 @@ static int stream_component_open(VideoState *is, int stream_index) if ((ret = avcodec_open2(avctx, codec, &opts)) < 0) { goto fail; } - if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + if ((t = av_dict_iterate(opts, NULL))) { av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); ret = AVERROR_OPTION_NOT_FOUND; goto fail; @@ -2862,7 +2862,7 @@ static int read_thread(void *arg) if (scan_all_pmts_set) av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE); - if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + if ((t = av_dict_iterate(format_opts, NULL))) { av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); ret = AVERROR_OPTION_NOT_FOUND; goto fail; diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 5b40dad527..2d38e5dfdc 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3951,7 +3951,7 @@ static int open_input_file(InputFile *ifile, const char *filename, exit(1); } - if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + if ((t = av_dict_iterate(opts, NULL))) { av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not found\n", t->key, stream->index); return AVERROR_OPTION_NOT_FOUND; diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 049e4f62ca..2dc8820184 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -941,7 +941,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) int avfilter_init_str(AVFilterContext *filter, const char *args) { AVDictionary *options = NULL; - AVDictionaryEntry *e; + const AVDictionaryEntry *e; int ret = 0; if (args && *args) { @@ -954,7 +954,7 @@ int avfilter_init_str(AVFilterContext *filter, const char *args) if (ret < 0) goto fail; - if ((e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + if ((e = av_dict_iterate(options, NULL))) { av_log(filter, AV_LOG_ERROR, "No such option: %s.\n", e->key); ret = AVERROR_OPTION_NOT_FOUND; goto fail; diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index e267886e1a..a8be251815 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -119,7 +119,7 @@ static int adts_aac_read_header(AVFormatContext *s) ff_id3v1_read(s); if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && - !av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) { + !av_dict_count(s->metadata)) { int64_t cur = avio_tell(s->pb); ff_ape_parse_tag(s); avio_seek(s->pb, cur, SEEK_SET); diff --git a/libavformat/http.c b/libavformat/http.c index 1a67068a44..ec60bc0b17 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -990,7 +990,7 @@ static int parse_set_cookie(const char *set_cookie, AVDictionary **dict) static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies) { AVDictionary *new_params = NULL; - AVDictionaryEntry *e, *cookie_entry; + const AVDictionaryEntry *e, *cookie_entry; char *eql, *name; // ensure the cookie is parsable @@ -998,7 +998,7 @@ static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies) return -1; // if there is no cookie value there is nothing to parse - cookie_entry = av_dict_get(new_params, "", NULL, AV_DICT_IGNORE_SUFFIX); + cookie_entry = av_dict_iterate(new_params, NULL); if (!cookie_entry || !cookie_entry->value) { av_dict_free(&new_params); return -1; @@ -1300,7 +1300,7 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path, *cookies = NULL; while ((cookie = av_strtok(next, "\n", &saveptr)) && !ret) { AVDictionary *cookie_params = NULL; - AVDictionaryEntry *cookie_entry, *e; + const AVDictionaryEntry *cookie_entry, *e; next = NULL; // store the cookie in a dict in case it is updated in the response @@ -1312,7 +1312,7 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path, goto skip_cookie; // if the cookie has no value, skip it - cookie_entry = av_dict_get(cookie_params, "", NULL, AV_DICT_IGNORE_SUFFIX); + cookie_entry = av_dict_iterate(cookie_params, NULL); if (!cookie_entry || !cookie_entry->value) goto skip_cookie; diff --git a/libavformat/mpc.c b/libavformat/mpc.c index 60cb768ab6..1e0e170c7d 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -112,7 +112,7 @@ static int mpc_read_header(AVFormatContext *s) if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { int64_t pos = avio_tell(s->pb); ff_ape_parse_tag(s); - if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) + if (av_dict_count(s->metadata) == 0) ff_id3v1_read(s); avio_seek(s->pb, pos, SEEK_SET); } diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index f5782cb583..224519a4da 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -432,7 +432,7 @@ static int ogg_build_vp8_headers(AVFormatContext *s, AVStream *st, bytestream_put_be32(&p, st->time_base.num); /* optional second packet: VorbisComment */ - if (av_dict_get(st->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) { + if (av_dict_count(st->metadata)) { p = ogg_write_vorbiscomment(7, bitexact, &oggstream->header_len[1], &st->metadata, 0, NULL, 0); if (!p) return AVERROR(ENOMEM); diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c index b25c1eee83..e2a79957f7 100644 --- a/libavformat/wvdec.c +++ b/libavformat/wvdec.c @@ -268,7 +268,7 @@ static int wv_read_header(AVFormatContext *s) if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { int64_t cur = avio_tell(s->pb); wc->apetag_start = ff_ape_parse_tag(s); - if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) + if (av_dict_count(s->metadata) == 0) ff_id3v1_read(s); avio_seek(s->pb, cur, SEEK_SET); } -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-05-17 15:26 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-17 15:23 [FFmpeg-devel] [PATCH 1/6] avformat/utils: Use static mutexes instead of ff_lock_avformat() Andreas Rheinhardt 2024-05-17 15:25 ` [FFmpeg-devel] [PATCH 2/6] avformat/tls_openssl: #if ff_openssl_init/deinit() away if possible Andreas Rheinhardt 2024-05-17 15:25 ` [FFmpeg-devel] [PATCH 3/6] avformat/tee: Constify AVDictionaryEntry* pointee where possible Andreas Rheinhardt 2024-05-17 15:42 ` epirat07 2024-05-17 16:17 ` Andreas Rheinhardt 2024-05-17 15:25 ` [FFmpeg-devel] [PATCH 4/6] avformat/tee: Use smaller scope for variables Andreas Rheinhardt 2024-05-17 15:25 ` [FFmpeg-devel] [PATCH 5/6] avcodec/lib*, avformat/tee: Simplify iterating over AVDictionary Andreas Rheinhardt 2024-05-17 15:41 ` epirat07 2024-05-17 15:44 ` Andreas Rheinhardt 2024-05-17 15:48 ` epirat07 2024-05-17 15:25 ` Andreas Rheinhardt [this message] 2024-05-17 15:39 ` [FFmpeg-devel] [PATCH 6/6] fftools, avfilter, avformat: Simplify check for "is dictionary empty?" epirat07 2024-05-19 9:57 ` [FFmpeg-devel] [PATCH 1/6] avformat/utils: Use static mutexes instead of ff_lock_avformat() Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AS8P250MB07441DA402AA9682708B417D8FEE2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git