From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avformat: add a disposition field to AVStreamGroup Date: Sat, 10 Feb 2024 20:09:02 -0300 Message-ID: <20240210230903.64206-1-jamrial@gmail.com> (raw) The existing (and upcoming) available group types are meant to combine several streams for presentation, with the result being treated as if it was a stream itself. For example, a file could export two stream groups of the same type with one of them as the "default". Signed-off-by: James Almer <jamrial@gmail.com> --- libavformat/avformat.h | 8 +++++ libavformat/dump.c | 77 ++++++++++++++++++++++-------------------- libavformat/options.c | 45 ++++++++++++------------ 3 files changed, 73 insertions(+), 57 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 5d0fe82250..931c274879 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1093,6 +1093,14 @@ typedef struct AVStreamGroup { * Freed by libavformat in avformat_free_context(). */ AVStream **streams; + + /** + * Stream group disposition - a combination of AV_DISPOSITION_* flags. + * - demuxing: set by libavformat when creating the group or in + * avformat_find_stream_info(). + * - muxing: may be set by the caller before avformat_write_header(). + */ + int disposition; } AVStreamGroup; struct AVCodecParserContext *av_stream_get_parser(const AVStream *s); diff --git a/libavformat/dump.c b/libavformat/dump.c index 9d37179bb7..c72d7840c1 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -538,6 +538,46 @@ static void dump_sidedata(void *ctx, const AVStream *st, const char *indent, } } +static void dump_disposition(int disposition, int log_level) +{ + if (disposition & AV_DISPOSITION_DEFAULT) + av_log(NULL, log_level, " (default)"); + if (disposition & AV_DISPOSITION_DUB) + av_log(NULL, log_level, " (dub)"); + if (disposition & AV_DISPOSITION_ORIGINAL) + av_log(NULL, log_level, " (original)"); + if (disposition & AV_DISPOSITION_COMMENT) + av_log(NULL, log_level, " (comment)"); + if (disposition & AV_DISPOSITION_LYRICS) + av_log(NULL, log_level, " (lyrics)"); + if (disposition & AV_DISPOSITION_KARAOKE) + av_log(NULL, log_level, " (karaoke)"); + if (disposition & AV_DISPOSITION_FORCED) + av_log(NULL, log_level, " (forced)"); + if (disposition & AV_DISPOSITION_HEARING_IMPAIRED) + av_log(NULL, log_level, " (hearing impaired)"); + if (disposition & AV_DISPOSITION_VISUAL_IMPAIRED) + av_log(NULL, log_level, " (visual impaired)"); + if (disposition & AV_DISPOSITION_CLEAN_EFFECTS) + av_log(NULL, log_level, " (clean effects)"); + if (disposition & AV_DISPOSITION_ATTACHED_PIC) + av_log(NULL, log_level, " (attached pic)"); + if (disposition & AV_DISPOSITION_TIMED_THUMBNAILS) + av_log(NULL, log_level, " (timed thumbnails)"); + if (disposition & AV_DISPOSITION_CAPTIONS) + av_log(NULL, log_level, " (captions)"); + if (disposition & AV_DISPOSITION_DESCRIPTIONS) + av_log(NULL, log_level, " (descriptions)"); + if (disposition & AV_DISPOSITION_METADATA) + av_log(NULL, log_level, " (metadata)"); + if (disposition & AV_DISPOSITION_DEPENDENT) + av_log(NULL, log_level, " (dependent)"); + if (disposition & AV_DISPOSITION_STILL_IMAGE) + av_log(NULL, log_level, " (still image)"); + if (disposition & AV_DISPOSITION_NON_DIEGETIC) + av_log(NULL, log_level, " (non-diegetic)"); +} + /* "user interface" functions */ static void dump_stream_format(const AVFormatContext *ic, int i, int group_index, int index, int is_output, @@ -620,42 +660,7 @@ static void dump_stream_format(const AVFormatContext *ic, int i, print_fps(1 / av_q2d(st->time_base), "tbn", log_level); } - if (st->disposition & AV_DISPOSITION_DEFAULT) - av_log(NULL, log_level, " (default)"); - if (st->disposition & AV_DISPOSITION_DUB) - av_log(NULL, log_level, " (dub)"); - if (st->disposition & AV_DISPOSITION_ORIGINAL) - av_log(NULL, log_level, " (original)"); - if (st->disposition & AV_DISPOSITION_COMMENT) - av_log(NULL, log_level, " (comment)"); - if (st->disposition & AV_DISPOSITION_LYRICS) - av_log(NULL, log_level, " (lyrics)"); - if (st->disposition & AV_DISPOSITION_KARAOKE) - av_log(NULL, log_level, " (karaoke)"); - if (st->disposition & AV_DISPOSITION_FORCED) - av_log(NULL, log_level, " (forced)"); - if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED) - av_log(NULL, log_level, " (hearing impaired)"); - if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED) - av_log(NULL, log_level, " (visual impaired)"); - if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS) - av_log(NULL, log_level, " (clean effects)"); - if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) - av_log(NULL, log_level, " (attached pic)"); - if (st->disposition & AV_DISPOSITION_TIMED_THUMBNAILS) - av_log(NULL, log_level, " (timed thumbnails)"); - if (st->disposition & AV_DISPOSITION_CAPTIONS) - av_log(NULL, log_level, " (captions)"); - if (st->disposition & AV_DISPOSITION_DESCRIPTIONS) - av_log(NULL, log_level, " (descriptions)"); - if (st->disposition & AV_DISPOSITION_METADATA) - av_log(NULL, log_level, " (metadata)"); - if (st->disposition & AV_DISPOSITION_DEPENDENT) - av_log(NULL, log_level, " (dependent)"); - if (st->disposition & AV_DISPOSITION_STILL_IMAGE) - av_log(NULL, log_level, " (still image)"); - if (st->disposition & AV_DISPOSITION_NON_DIEGETIC) - av_log(NULL, log_level, " (non-diegetic)"); + dump_disposition(st->disposition, log_level); av_log(NULL, log_level, "\n"); dump_metadata(NULL, st->metadata, extra_indent, log_level); diff --git a/libavformat/options.c b/libavformat/options.c index 03e6a2a7ff..f54a3c97b5 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -208,28 +208,30 @@ const AVClass *avformat_get_class(void) return &av_format_context_class; } -static const AVOption stream_options[] = { - { "disposition", NULL, offsetof(AVStream, disposition), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, - .flags = AV_OPT_FLAG_ENCODING_PARAM, .unit = "disposition" }, - { "default", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEFAULT }, .unit = "disposition" }, - { "dub", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DUB }, .unit = "disposition" }, - { "original", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ORIGINAL }, .unit = "disposition" }, - { "comment", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_COMMENT }, .unit = "disposition" }, - { "lyrics", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_LYRICS }, .unit = "disposition" }, - { "karaoke", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_KARAOKE }, .unit = "disposition" }, - { "forced", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_FORCED }, .unit = "disposition" }, - { "hearing_impaired", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_HEARING_IMPAIRED }, .unit = "disposition" }, - { "visual_impaired", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_VISUAL_IMPAIRED }, .unit = "disposition" }, - { "clean_effects", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CLEAN_EFFECTS }, .unit = "disposition" }, - { "attached_pic", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ATTACHED_PIC }, .unit = "disposition" }, - { "timed_thumbnails", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_TIMED_THUMBNAILS }, .unit = "disposition" }, - { "non_diegetic", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_NON_DIEGETIC }, .unit = "disposition" }, - { "captions", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, .unit = "disposition" }, - { "descriptions", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, .unit = "disposition" }, - { "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" }, - { "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" }, - { "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" }, +#define DISPOSITION_OPT(ctx) \ + { "disposition", NULL, offsetof(ctx, disposition), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, \ + .flags = AV_OPT_FLAG_ENCODING_PARAM, .unit = "disposition" }, \ + { "default", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEFAULT }, .unit = "disposition" }, \ + { "dub", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DUB }, .unit = "disposition" }, \ + { "original", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ORIGINAL }, .unit = "disposition" }, \ + { "comment", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_COMMENT }, .unit = "disposition" }, \ + { "lyrics", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_LYRICS }, .unit = "disposition" }, \ + { "karaoke", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_KARAOKE }, .unit = "disposition" }, \ + { "forced", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_FORCED }, .unit = "disposition" }, \ + { "hearing_impaired", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_HEARING_IMPAIRED }, .unit = "disposition" }, \ + { "visual_impaired", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_VISUAL_IMPAIRED }, .unit = "disposition" }, \ + { "clean_effects", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CLEAN_EFFECTS }, .unit = "disposition" }, \ + { "attached_pic", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ATTACHED_PIC }, .unit = "disposition" }, \ + { "timed_thumbnails", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_TIMED_THUMBNAILS }, .unit = "disposition" }, \ + { "non_diegetic", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_NON_DIEGETIC }, .unit = "disposition" }, \ + { "captions", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, .unit = "disposition" }, \ + { "descriptions", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, .unit = "disposition" }, \ + { "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" }, \ + { "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" }, \ + { "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" } +static const AVOption stream_options[] = { + DISPOSITION_OPT(AVStream), { "discard", NULL, offsetof(AVStream, discard), AV_OPT_TYPE_INT, { .i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, .flags = AV_OPT_FLAG_DECODING_PARAM, .unit = "avdiscard" }, { "none", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, .unit = "avdiscard" }, @@ -380,6 +382,7 @@ static const AVClass *stream_group_child_iterate(void **opaque) } static const AVOption stream_group_options[] = { + DISPOSITION_OPT(AVStreamGroup), {"id", "Set group id", offsetof(AVStreamGroup, id), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { NULL } }; -- 2.43.0 _______________________________________________ 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:[~2024-02-10 23:09 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-10 23:09 James Almer [this message] 2024-02-12 9:10 ` Anton Khirnov 2024-02-12 12:15 ` James Almer 2024-02-12 12:28 ` James Almer 2024-02-12 13:05 ` James Almer
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=20240210230903.64206-1-jamrial@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