From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH 07/31] avutil: use av_dict_iterate Date: Sun, 27 Nov 2022 10:59:14 -0300 Message-ID: <7f99f440-74c4-e14c-544e-6008e88edbbd@gmail.com> (raw) In-Reply-To: <4741D7B7-1FD9-401F-81FD-C5E5AB05EDBF@gmail.com> On 11/26/2022 11:42 AM, Marvin Scholz wrote: > > > On 25 Nov 2022, at 13:50, Andreas Rheinhardt wrote: > >> Marvin Scholz: >>> --- >>> libavutil/opt.c | 12 ++++++------ >>> libavutil/tests/dict.c | 10 +++++----- >>> 2 files changed, 11 insertions(+), 11 deletions(-) >>> >>> diff --git a/libavutil/opt.c b/libavutil/opt.c >>> index a3940f47fb..0a909a8b22 100644 >>> --- a/libavutil/opt.c >>> +++ b/libavutil/opt.c >>> @@ -1742,14 +1742,14 @@ void av_opt_free(void *obj) >>> >>> int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags) >>> { >>> - AVDictionaryEntry *t = NULL; >>> + const AVDictionaryEntry *t = NULL; >>> AVDictionary *tmp = NULL; >>> int ret; >>> >>> if (!options) >>> return 0; >>> >>> - while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) { >>> + while ((t = av_dict_iterate(*options, t))) { >>> ret = av_opt_set(obj, t->key, t->value, search_flags); >>> if (ret == AVERROR_OPTION_NOT_FOUND) >>> ret = av_dict_set(&tmp, t->key, t->value, 0); >>> @@ -2137,16 +2137,16 @@ FF_ENABLE_DEPRECATION_WARNINGS >>> case AV_OPT_TYPE_DICT: { >>> AVDictionary *dict1 = NULL; >>> AVDictionary *dict2 = *(AVDictionary **)dst; >>> - AVDictionaryEntry *en1 = NULL; >>> - AVDictionaryEntry *en2 = NULL; >>> + const AVDictionaryEntry *en1 = NULL; >>> + const AVDictionaryEntry *en2 = NULL; >>> ret = av_dict_parse_string(&dict1, o->default_val.str, "=", ":", 0); >>> if (ret < 0) { >>> av_dict_free(&dict1); >>> return ret; >>> } >>> do { >>> - en1 = av_dict_get(dict1, "", en1, AV_DICT_IGNORE_SUFFIX); >>> - en2 = av_dict_get(dict2, "", en2, AV_DICT_IGNORE_SUFFIX); >>> + en1 = av_dict_iterate(dict1, en1); >>> + en2 = av_dict_iterate(dict2, en2); >>> } while (en1 && en2 && !strcmp(en1->key, en2->key) && !strcmp(en1->value, en2->value)); >>> av_dict_free(&dict1); >>> return (!en1 && !en2); >>> diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c >>> index d053545f4d..8c05752ea7 100644 >>> --- a/libavutil/tests/dict.c >>> +++ b/libavutil/tests/dict.c >>> @@ -22,8 +22,8 @@ >>> >>> static void print_dict(const AVDictionary *m) >>> { >>> - AVDictionaryEntry *t = NULL; >>> - while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) >>> + const AVDictionaryEntry *t = NULL; >>> + while ((t = av_dict_iterate(m, t))) >>> printf("%s %s ", t->key, t->value); >>> printf("\n"); >>> } >>> @@ -94,7 +94,7 @@ int main(void) >>> if (av_dict_get(dict, NULL, NULL, 0)) >>> printf("av_dict_get() does not correctly handle NULL key.\n"); >>> e = NULL; >>> - while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))) >>> + while ((e = av_dict_iterate(dict, e))) >>> printf("%s %s\n", e->key, e->value); >>> av_dict_free(&dict); >>> >>> @@ -106,7 +106,7 @@ int main(void) >>> printf("av_dict_set does not correctly handle NULL key\n"); >>> >>> e = NULL; >>> - while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))) >>> + while ((e = av_dict_iterate(dict, e))) >>> printf("'%s' '%s'\n", e->key, e->value); >>> av_dict_free(&dict); >>> >>> @@ -122,7 +122,7 @@ int main(void) >>> av_dict_set_int(&dict, "12", 1, 0); >>> av_dict_set_int(&dict, "12", 2, AV_DICT_APPEND); >>> e = NULL; >>> - while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))) >>> + while ((e = av_dict_iterate(dict, e))) >>> printf("%s %s\n", e->key, e->value); >>> av_dict_free(&dict); >>> >> >> This stops testing the old iterating pattern; instead it should >> explicitly test that both patterns coincide. >> > > Ok, I've removed this change for now from the pachset > as adding tests is not really what this patchset is about. > > Additionally I do not fully understand how the testing works yet > so I don't know how I could write such a test. This specific test just prints some hardcoded lines plus the output of av_dict_get() to stderr, and compares it with the reference in tests/ref/fate/dict. What could be done is to either print both the output of the av_dict_get() and av_dict_iterate() iterations, or to compare the returned AVDictionaryEntry on each iteration and if they differ, print a line about it. I can send a patch for that later. > >> - Andreas >> >> _______________________________________________ >> 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". > _______________________________________________ > 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". _______________________________________________ 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:[~2022-11-27 13:58 UTC|newest] Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-25 1:30 [FFmpeg-devel] [PATCH 00/31] Use av_dict_iterate where approproate Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 01/31] fftools: use av_dict_iterate Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 02/31] fftools: use av_dict_get_string Marvin Scholz 2022-11-25 12:48 ` Andreas Rheinhardt 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 03/31] avcodec/librav1e: use av_dict_iterate Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 04/31] avcodec/librav1e: remove unnecessary variable Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 05/31] avcodec/libvpxenc: use av_dict_iterate Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 06/31] avformat/smjpegenc: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 07/31] avutil: " Marvin Scholz 2022-11-25 12:50 ` Andreas Rheinhardt 2022-11-26 14:42 ` Marvin Scholz 2022-11-27 13:59 ` James Almer [this message] 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 08/31] avfilter/vf_scale: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 09/31] avfilter/vf_coreimage: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 10/31] avcodec/libxavs2: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 11/31] avcodec/avpacket: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 12/31] avformat/vorbiscomment: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 13/31] avfilter/vf_libvmaf: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 14/31] avfilter/f_metadata: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 15/31] avformat/cafenc: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 16/31] doc/examples/metadata: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 17/31] avformat/movenc: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 18/31] avformat/metadata: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 19/31] avformat/flvenc: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 20/31] avformat/hls: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 21/31] avformat/lrcenc: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 22/31] avformat/dump: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 23/31] avformat/wtvenc: " Marvin Scholz 2022-11-25 12:53 ` Andreas Rheinhardt 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 24/31] avformat/ffmetaenc: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 25/31] avformat/id3v2enc: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 26/31] avformat/nutenc: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 27/31] avformat/apetag: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 28/31] avformat/asfenc: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 29/31] avformat/http: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 30/31] avformat/matroskaenc: " Marvin Scholz 2022-11-25 1:30 ` [FFmpeg-devel] [PATCH 31/31] avformat/fifo: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 00/31] Use av_dict_iterate where approproate Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 01/31] fftools: use av_dict_iterate Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 02/31] fftools: use av_dict_get_string Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 03/31] avcodec/librav1e: use av_dict_iterate Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 04/31] avcodec/librav1e: remove unnecessary variable Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 05/31] avcodec/libvpxenc: use av_dict_iterate Marvin Scholz 2022-11-30 20:18 ` James Zern 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 06/31] avformat/smjpegenc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 07/31] avutil: " Marvin Scholz 2022-11-27 15:06 ` James Almer 2022-11-30 22:06 ` Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 08/31] avfilter/vf_scale: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 09/31] avfilter/vf_coreimage: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 10/31] avcodec/libxavs2: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 11/31] avcodec/avpacket: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 12/31] avformat/vorbiscomment: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 13/31] avfilter/vf_libvmaf: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 14/31] avfilter/f_metadata: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 15/31] avformat/cafenc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 16/31] doc/examples/metadata: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 17/31] avformat/movenc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 18/31] avformat/metadata: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 19/31] avformat/flvenc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 20/31] avformat/hls: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 21/31] avformat/lrcenc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 22/31] avformat/dump: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 23/31] avformat/wtvenc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 24/31] avformat/ffmetaenc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 25/31] avformat/id3v2enc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 26/31] avformat/nutenc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 27/31] avformat/apetag: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 28/31] avformat/asfenc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 29/31] avformat/http: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 30/31] avformat/matroskaenc: " Marvin Scholz 2022-11-26 14:46 ` [FFmpeg-devel] [PATCH v2 31/31] avformat/fifo: " Marvin Scholz
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=7f99f440-74c4-e14c-544e-6008e88edbbd@gmail.com \ --to=jamrial@gmail.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