From: Thilo Borgmann <thilo.borgmann@mail.de> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH v2 1/4] fftools: Add support for dictionary options Date: Mon, 15 Aug 2022 21:58:54 +0200 Message-ID: <b4fb59b6-de3a-c011-8ea2-5595fca39568@mail.de> (raw) [-- Attachment #1: Type: text/plain, Size: 334 bytes --] Hi, this is an updated and cleaned-up version of Jan's patchset discussed in [1], therefore v2... Comments from the previous thread are in and left-overs from the several options version removed. I'd especially appreciate any comments on 2/4, ffmpeg_opt.c:112ff which is pretty ugly as-is. Should fix #8329 and #6370. Thanks, Thilo [-- Attachment #2: v2-0001-fftools-Add-support-for-dictionary-options.patch --] [-- Type: text/plain, Size: 3631 bytes --] From 47e7d37e742344f8ae618b180cf8cb77abb33626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= <jeebjp@gmail.com> Date: Mon, 15 Aug 2022 20:44:16 +0200 Subject: [PATCH v2 1/4] fftools: Add support for dictionary options --- fftools/cmdutils.c | 18 ++++++++++++++++++ fftools/cmdutils.h | 2 ++ fftools/ffmpeg_opt.c | 11 +++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 18e768b386..22ba654bb0 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -131,6 +131,22 @@ int64_t parse_time_or_die(const char *context, const char *timestr, return us; } +static AVDictionary *parse_dict_or_die(const char *context, + const char *dict_str) +{ + AVDictionary *dict = NULL; + int ret = av_dict_parse_string(&dict, dict_str, "=", ",", 0); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Failed to create a dictionary from '%s': %s!\n", + dict_str, av_err2str(ret)); + exit_program(1); + } + + + return dict; +} + void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags) { @@ -288,6 +304,8 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); } else if (po->flags & OPT_DOUBLE) { *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); + } else if (po->flags & OPT_DICT) { + *(AVDictionary **)dst = parse_dict_or_die(opt, arg); } else if (po->u.func_arg) { int ret = po->u.func_arg(optctx, opt, arg); if (ret < 0) { diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index d87e162ccd..6a519c6546 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -129,6 +129,7 @@ typedef struct SpecifierOpt { uint64_t ui64; float f; double dbl; + AVDictionary *dict; } u; } SpecifierOpt; @@ -157,6 +158,7 @@ typedef struct OptionDef { #define OPT_DOUBLE 0x20000 #define OPT_INPUT 0x40000 #define OPT_OUTPUT 0x80000 +#define OPT_DICT 0x100000 union { void *dst_ptr; int (*func_arg)(void *, const char *, const char *); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 97f14b2a5b..cc038aae6b 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -62,6 +62,7 @@ #define SPECIFIER_OPT_FMT_ui64 "%"PRIu64 #define SPECIFIER_OPT_FMT_f "%f" #define SPECIFIER_OPT_FMT_dbl "%lf" +#define SPECIFIER_OPT_FMT_dict "%p" static const char *const opt_name_codec_names[] = {"c", "codec", "acodec", "vcodec", "scodec", "dcodec", NULL}; static const char *const opt_name_audio_channels[] = {"ac", NULL}; @@ -208,11 +209,17 @@ static void uninit_options(OptionsContext *o) av_freep(&(*so)[i].specifier); if (po->flags & OPT_STRING) av_freep(&(*so)[i].u.str); + else if (po->flags & OPT_DICT) + av_dict_free(&(*so)[i].u.dict); } av_freep(so); *count = 0; - } else if (po->flags & OPT_OFFSET && po->flags & OPT_STRING) - av_freep(dst); + } else if (po->flags & OPT_OFFSET) { + if (po->flags & OPT_STRING) + av_freep(dst); + else if (po->flags & OPT_DICT) + av_dict_free((AVDictionary **)&dst); + } po++; } -- 2.20.1 (Apple Git-117) [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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 reply other threads:[~2022-08-15 19:59 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-15 19:58 Thilo Borgmann [this message] 2022-08-15 20:02 ` [FFmpeg-devel] [PATCH v2 2/4] ffmpeg: Add display_matrix option Thilo Borgmann 2022-08-16 4:03 ` Gyan Doshi 2022-08-16 14:10 ` Anton Khirnov 2022-08-16 18:48 ` Thilo Borgmann 2022-08-17 8:18 ` Anton Khirnov 2022-08-17 8:50 ` Gyan Doshi 2022-08-17 8:59 ` Nicolas George 2022-08-17 9:05 ` Anton Khirnov 2022-08-17 10:53 ` Gyan Doshi 2022-08-17 12:25 ` Anton Khirnov 2022-08-18 10:58 ` Gyan Doshi 2022-08-20 13:32 ` Thilo Borgmann 2022-08-20 13:39 ` Nicolas George 2022-08-20 13:48 ` Thilo Borgmann 2022-08-22 12:30 ` Nicolas George 2022-09-07 16:05 ` Thilo Borgmann 2022-08-18 7:11 ` Anton Khirnov 2022-08-17 6:26 ` Marton Balint 2022-08-15 20:02 ` [FFmpeg-devel] [PATCH v2 3/4] ffmpeg: Deprecate display rotation override with a metadata key Thilo Borgmann 2022-08-15 20:02 ` [FFmpeg-devel] [PATCH v2 4/4] ffmpeg: Allow printing of option arguments in help output Thilo Borgmann
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=b4fb59b6-de3a-c011-8ea2-5595fca39568@mail.de \ --to=thilo.borgmann@mail.de \ --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