History

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

Andreas Rheinhardt committed 2 years ago

Commit f3d206d1 parent 482afe89 files · +15 −15Browse files

Unified · Split

9 files
  1. fftools/ffmpeg.c +2 −2
  2. fftools/ffplay.c +2 −2
  3. fftools/ffprobe.c +1 −1
  4. libavfilter/avfilter.c +2 −2
  5. libavformat/aacdec.c +1 −1
  6. libavformat/http.c +4 −4
  7. libavformat/mpc.c +1 −1
  8. libavformat/oggenc.c +1 −1
  9. libavformat/wvdec.c +1 −1
fftools/ffmpeg.c+2−2
@@ -484,8 +484,8 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b) · 483 unmodified lines
484 484
485int check_avoptions(AVDictionary *m)485int check_avoptions(AVDictionary *m)
486{486{
487 const AVDictionaryEntry *t;487 const AVDictionaryEntry *t = av_dict_iterate(m, NULL);
488 if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {488 if (t) {
489 av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);489 av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
490 return AVERROR_OPTION_NOT_FOUND;490 return AVERROR_OPTION_NOT_FOUND;
491 }491 }
fftools/ffplay.c+2−2
@@ -2694,7 +2694,7 @@ static int stream_component_open(VideoState *is, int stream_index) · 2693 unmodified lines
2694 if ((ret = avcodec_open2(avctx, codec, &opts)) < 0) {2694 if ((ret = avcodec_open2(avctx, codec, &opts)) < 0) {
2695 goto fail;2695 goto fail;
2696 }2696 }
2697 if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {2697 if ((t = av_dict_iterate(opts, NULL))) {
2698 av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);2698 av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
2699 ret = AVERROR_OPTION_NOT_FOUND;2699 ret = AVERROR_OPTION_NOT_FOUND;
2700 goto fail;2700 goto fail;
@@ -2862,7 +2862,7 @@ static int read_thread(void *arg) · 161 unmodified lines
2862 if (scan_all_pmts_set)2862 if (scan_all_pmts_set)
2863 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);2863 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
2864 2864
2865 if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {2865 if ((t = av_dict_iterate(format_opts, NULL))) {
2866 av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);2866 av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
2867 ret = AVERROR_OPTION_NOT_FOUND;2867 ret = AVERROR_OPTION_NOT_FOUND;
2868 goto fail;2868 goto fail;
fftools/ffprobe.c+1−1
@@ -3951,7 +3951,7 @@ static int open_input_file(InputFile *ifile, const char *filename, · 3950 unmodified lines
3951 exit(1);3951 exit(1);
3952 }3952 }
3953 3953
3954 if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {3954 if ((t = av_dict_iterate(opts, NULL))) {
3955 av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not found\n",3955 av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not found\n",
3956 t->key, stream->index);3956 t->key, stream->index);
3957 return AVERROR_OPTION_NOT_FOUND;3957 return AVERROR_OPTION_NOT_FOUND;
libavfilter/avfilter.c+2−2
@@ -941,7 +941,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) · 940 unmodified lines
941int avfilter_init_str(AVFilterContext *filter, const char *args)941int avfilter_init_str(AVFilterContext *filter, const char *args)
942{942{
943 AVDictionary *options = NULL;943 AVDictionary *options = NULL;
944 AVDictionaryEntry *e;944 const AVDictionaryEntry *e;
945 int ret = 0;945 int ret = 0;
946 946
947 if (args && *args) {947 if (args && *args) {
@@ -954,7 +954,7 @@ int avfilter_init_str(AVFilterContext *filter, const char *args) · 6 unmodified lines
954 if (ret < 0)954 if (ret < 0)
955 goto fail;955 goto fail;
956 956
957 if ((e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX))) {957 if ((e = av_dict_iterate(options, NULL))) {
958 av_log(filter, AV_LOG_ERROR, "No such option: %s.\n", e->key);958 av_log(filter, AV_LOG_ERROR, "No such option: %s.\n", e->key);
959 ret = AVERROR_OPTION_NOT_FOUND;959 ret = AVERROR_OPTION_NOT_FOUND;
960 goto fail;960 goto fail;
libavformat/aacdec.c+1−1
@@ -119,7 +119,7 @@ static int adts_aac_read_header(AVFormatContext *s) · 118 unmodified lines
119 119
120 ff_id3v1_read(s);120 ff_id3v1_read(s);
121 if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&121 if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
122 !av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) {122 !av_dict_count(s->metadata)) {
123 int64_t cur = avio_tell(s->pb);123 int64_t cur = avio_tell(s->pb);
124 ff_ape_parse_tag(s);124 ff_ape_parse_tag(s);
125 avio_seek(s->pb, cur, SEEK_SET);125 avio_seek(s->pb, cur, SEEK_SET);
libavformat/http.c+4−4
@@ -990,7 +990,7 @@ static int parse_set_cookie(const char *set_cookie, AVDictionary **dict) · 989 unmodified lines
990static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies)990static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies)
991{991{
992 AVDictionary *new_params = NULL;992 AVDictionary *new_params = NULL;
993 AVDictionaryEntry *e, *cookie_entry;993 const AVDictionaryEntry *e, *cookie_entry;
994 char *eql, *name;994 char *eql, *name;
995 995
996 // ensure the cookie is parsable996 // ensure the cookie is parsable
@@ -998,7 +998,7 @@ static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies) · 1 unmodified line
998 return -1;998 return -1;
999 999
1000 // if there is no cookie value there is nothing to parse1000 // if there is no cookie value there is nothing to parse
1001 cookie_entry = av_dict_get(new_params, "", NULL, AV_DICT_IGNORE_SUFFIX);1001 cookie_entry = av_dict_iterate(new_params, NULL);
1002 if (!cookie_entry || !cookie_entry->value) {1002 if (!cookie_entry || !cookie_entry->value) {
1003 av_dict_free(&new_params);1003 av_dict_free(&new_params);
1004 return -1;1004 return -1;
@@ -1300,7 +1300,7 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path, · 295 unmodified lines
1300 *cookies = NULL;1300 *cookies = NULL;
1301 while ((cookie = av_strtok(next, "\n", &saveptr)) && !ret) {1301 while ((cookie = av_strtok(next, "\n", &saveptr)) && !ret) {
1302 AVDictionary *cookie_params = NULL;1302 AVDictionary *cookie_params = NULL;
1303 AVDictionaryEntry *cookie_entry, *e;1303 const AVDictionaryEntry *cookie_entry, *e;
1304 1304
1305 next = NULL;1305 next = NULL;
1306 // store the cookie in a dict in case it is updated in the response1306 // 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, · 5 unmodified lines
1312 goto skip_cookie;1312 goto skip_cookie;
1313 1313
1314 // if the cookie has no value, skip it1314 // if the cookie has no value, skip it
1315 cookie_entry = av_dict_get(cookie_params, "", NULL, AV_DICT_IGNORE_SUFFIX);1315 cookie_entry = av_dict_iterate(cookie_params, NULL);
1316 if (!cookie_entry || !cookie_entry->value)1316 if (!cookie_entry || !cookie_entry->value)
1317 goto skip_cookie;1317 goto skip_cookie;
1318 1318
libavformat/mpc.c+1−1
@@ -112,7 +112,7 @@ static int mpc_read_header(AVFormatContext *s) · 111 unmodified lines
112 if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {112 if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
113 int64_t pos = avio_tell(s->pb);113 int64_t pos = avio_tell(s->pb);
114 ff_ape_parse_tag(s);114 ff_ape_parse_tag(s);
115 if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))115 if (av_dict_count(s->metadata) == 0)
116 ff_id3v1_read(s);116 ff_id3v1_read(s);
117 avio_seek(s->pb, pos, SEEK_SET);117 avio_seek(s->pb, pos, SEEK_SET);
118 }118 }
libavformat/oggenc.c+1−1
@@ -432,7 +432,7 @@ static int ogg_build_vp8_headers(AVFormatContext *s, AVStream *st, · 431 unmodified lines
432 bytestream_put_be32(&p, st->time_base.num);432 bytestream_put_be32(&p, st->time_base.num);
433 433
434 /* optional second packet: VorbisComment */434 /* optional second packet: VorbisComment */
435 if (av_dict_get(st->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) {435 if (av_dict_count(st->metadata)) {
436 p = ogg_write_vorbiscomment(7, bitexact, &oggstream->header_len[1], &st->metadata, 0, NULL, 0);436 p = ogg_write_vorbiscomment(7, bitexact, &oggstream->header_len[1], &st->metadata, 0, NULL, 0);
437 if (!p)437 if (!p)
438 return AVERROR(ENOMEM);438 return AVERROR(ENOMEM);
libavformat/wvdec.c+1−1
@@ -268,7 +268,7 @@ static int wv_read_header(AVFormatContext *s) · 267 unmodified lines
268 if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {268 if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
269 int64_t cur = avio_tell(s->pb);269 int64_t cur = avio_tell(s->pb);
270 wc->apetag_start = ff_ape_parse_tag(s);270 wc->apetag_start = ff_ape_parse_tag(s);
271 if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))271 if (av_dict_count(s->metadata) == 0)
272 ff_id3v1_read(s);272 ff_id3v1_read(s);
273 avio_seek(s->pb, cur, SEEK_SET);273 avio_seek(s->pb, cur, SEEK_SET);
274 }274 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t