[FFmpeg-cvslog] fftools, avfilter, avformat: Simplify check for "is dictionary empty?"

Andreas Rheinhardt git at videolan.org
Mon May 20 15:05:12 EEST 2024


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri May 17 17:04:50 2024 +0200| [f3d206d25ffdb02ba30b9bf37720f94819f9be3e] | committer: Andreas Rheinhardt

fftools, avfilter, avformat: Simplify check for "is dictionary empty?"

Reviewed-by: epirat07 at gmail.com
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f3d206d25ffdb02ba30b9bf37720f94819f9be3e
---

 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 d5324df4d5..0b4bd69dd2 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);
     }



More information about the ffmpeg-cvslog mailing list