Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat: add a disposition field to AVStreamGroup
@ 2024-02-10 23:09 James Almer
  2024-02-12  9:10 ` Anton Khirnov
  0 siblings, 1 reply; 5+ messages in thread
From: James Almer @ 2024-02-10 23:09 UTC (permalink / raw)
  To: ffmpeg-devel

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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat: add a disposition field to AVStreamGroup
  2024-02-10 23:09 [FFmpeg-devel] [PATCH] avformat: add a disposition field to AVStreamGroup James Almer
@ 2024-02-12  9:10 ` Anton Khirnov
  2024-02-12 12:15   ` James Almer
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Anton Khirnov @ 2024-02-12  9:10 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting James Almer (2024-02-11 00:09:02)
> 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.

Only some group types have that semantics. I'd prefer to either
* move disposition to group-specific struct
* explicitly document with group types this fields is meaningful for

-- 
Anton Khirnov
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat: add a disposition field to AVStreamGroup
  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
  2 siblings, 0 replies; 5+ messages in thread
From: James Almer @ 2024-02-12 12:15 UTC (permalink / raw)
  To: ffmpeg-devel


[-- Attachment #1.1: PGP/MIME version identification --]
[-- Type: application/pgp-encrypted, Size: 11 bytes --]

[-- Attachment #1.2: OpenPGP encrypted message --]
[-- Type: application/octet-stream, Size: 1962 bytes --]

[-- Attachment #2: 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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat: add a disposition field to AVStreamGroup
  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
  2 siblings, 0 replies; 5+ messages in thread
From: James Almer @ 2024-02-12 12:28 UTC (permalink / raw)
  To: ffmpeg-devel

On 2/12/2024 6:10 AM, Anton Khirnov wrote:
> Quoting James Almer (2024-02-11 00:09:02)
>> 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.
> 
> Only some group types have that semantics. I'd prefer to either
> * move disposition to group-specific struct

Can't do this because the iamf groups use a lavu struct that's not 
exclusive to the stream group API.

> * explicitly document with group types this fields is meaningful for

This is ok.

(resent because for some bizarre reason the first email was encrypted).
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [FFmpeg-devel] [PATCH] avformat: add a disposition field to AVStreamGroup
  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
  2 siblings, 0 replies; 5+ messages in thread
From: James Almer @ 2024-02-12 13:05 UTC (permalink / raw)
  To: ffmpeg-devel

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 | 10 +++++
 libavformat/dump.c     | 85 +++++++++++++++++++++++-------------------
 libavformat/options.c  | 45 +++++++++++-----------
 3 files changed, 81 insertions(+), 59 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 5d0fe82250..e3daf4a107 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1093,6 +1093,16 @@ typedef struct AVStreamGroup {
      * Freed by libavformat in avformat_free_context().
      */
     AVStream **streams;
+
+    /**
+     * Stream group disposition - a combination of AV_DISPOSITION_* flags.
+     * This field currently applies to all defined AVStreamGroupParamsType.
+     *
+     * - 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..9bf1695d96 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);
@@ -679,7 +684,9 @@ static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed,
     switch (stg->type) {
     case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT: {
         const AVIAMFAudioElement *audio_element = stg->params.iamf_audio_element;
-        av_log(NULL, AV_LOG_INFO, " IAMF Audio Element\n");
+        av_log(NULL, AV_LOG_INFO, " IAMF Audio Element:");
+        dump_disposition(st->disposition, log_level);
+        av_log(NULL, AV_LOG_INFO, "\n");
         dump_metadata(NULL, stg->metadata, "    ", AV_LOG_INFO);
         for (int j = 0; j < audio_element->nb_layers; j++) {
             const AVIAMFLayer *layer = audio_element->layers[j];
@@ -700,7 +707,9 @@ static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed,
     }
     case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: {
         const AVIAMFMixPresentation *mix_presentation = stg->params.iamf_mix_presentation;
-        av_log(NULL, AV_LOG_INFO, " IAMF Mix Presentation\n");
+        av_log(NULL, AV_LOG_INFO, " IAMF Mix Presentation:");
+        dump_disposition(st->disposition, log_level);
+        av_log(NULL, AV_LOG_INFO, "\n");
         dump_metadata(NULL, stg->metadata, "    ", AV_LOG_INFO);
         dump_dictionary(NULL, mix_presentation->annotations, "Annotations", "    ", AV_LOG_INFO);
         for (int j = 0; j < mix_presentation->nb_submixes; j++) {
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-12 13:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-10 23:09 [FFmpeg-devel] [PATCH] avformat: add a disposition field to AVStreamGroup James Almer
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

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