From d7c7ee4e2eecbbf05ee28874bc7561ed1bac3c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sat, 16 May 2026 19:46:53 +0200 Subject: [PATCH] avformat: add AV_STREAM_GROUP_PARAMS_DOLBY_VISION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This uses existing AVStreamGroupLayeredVideo. Signed-off-by: Kacper Michajłow --- doc/APIchanges | 1 + fftools/ffmpeg_mux_init.c | 1 + libavformat/avformat.c | 5 +++++ libavformat/avformat.h | 1 + libavformat/options.c | 28 ++++++++++++++++++++++++++++ libavformat/version.h | 4 ++-- 6 files changed, 38 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index a5b24ef43d..69f098aba7 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -5,6 +5,7 @@ API changes, most recent first: 2026-05-xx - xxxxxxxxxx - lavf 62.19.100 - avformat.h Add AVStreamGroupLayeredVideo Add AVStreamGroup.params.layered_video + Add AV_STREAM_GROUP_PARAMS_DOLBY_VISION 2026-05-xx - xxxxxxxxxx - lavc 62.35.100 - packet.h Add AV_PKT_DATA_HEVC_CONF side data type. diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index a41939d0e5..ef71a7bb54 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -2557,6 +2557,7 @@ static int of_map_group(Muxer *mux, AVDictionary **dict, AVBPrint *bp, const cha } case AV_STREAM_GROUP_PARAMS_LCEVC: case AV_STREAM_GROUP_PARAMS_TREF: + case AV_STREAM_GROUP_PARAMS_DOLBY_VISION: break; default: av_log(mux, AV_LOG_ERROR, "Unsupported mapped group type %d.\n", stg->type); diff --git a/libavformat/avformat.c b/libavformat/avformat.c index 6cb067a3f7..3067be0867 100644 --- a/libavformat/avformat.c +++ b/libavformat/avformat.c @@ -110,6 +110,10 @@ void ff_free_stream_group(AVStreamGroup **pstg) av_opt_free(stg->params.tref); av_freep(&stg->params.tref); break; + case AV_STREAM_GROUP_PARAMS_DOLBY_VISION: + av_opt_free(stg->params.layered_video); + av_freep(&stg->params.layered_video); + break; default: break; } @@ -269,6 +273,7 @@ const char *avformat_stream_group_name(enum AVStreamGroupParamsType type) case AV_STREAM_GROUP_PARAMS_TILE_GRID: return "Tile Grid"; case AV_STREAM_GROUP_PARAMS_LCEVC: return "LCEVC (Split video and enhancement)"; case AV_STREAM_GROUP_PARAMS_TREF: return "Track Reference"; + case AV_STREAM_GROUP_PARAMS_DOLBY_VISION: return "Dolby Vision (Split base and enhancement layer)"; } return NULL; } diff --git a/libavformat/avformat.h b/libavformat/avformat.h index f4c5326f54..95440ef8c2 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1126,6 +1126,7 @@ enum AVStreamGroupParamsType { AV_STREAM_GROUP_PARAMS_TILE_GRID, AV_STREAM_GROUP_PARAMS_LCEVC, AV_STREAM_GROUP_PARAMS_TREF, + AV_STREAM_GROUP_PARAMS_DOLBY_VISION, }; struct AVIAMFAudioElement; diff --git a/libavformat/options.c b/libavformat/options.c index 2f05ec9c11..db9cb76048 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -380,6 +380,22 @@ static const AVClass tref_class = { .option = tref_options, }; +#define OFFSET(x) offsetof(AVStreamGroupLayeredVideo, x) +static const AVOption layered_video_options[] = { + { "el_index", "Index of the enhancement layer stream within the group", OFFSET(el_index), + AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, + { "video_size", "size of the final layered video presentation", OFFSET(width), + AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, INT_MAX, FLAGS }, + { NULL }, +}; +#undef OFFSET + +static const AVClass layered_video_class = { + .class_name = "AVStreamGroupLayeredVideo", + .version = LIBAVUTIL_VERSION_INT, + .option = layered_video_options, +}; + static void *stream_group_child_next(void *obj, void *prev) { AVStreamGroup *stg = obj; @@ -395,6 +411,8 @@ static void *stream_group_child_next(void *obj, void *prev) return stg->params.lcevc; case AV_STREAM_GROUP_PARAMS_TREF: return stg->params.tref; + case AV_STREAM_GROUP_PARAMS_DOLBY_VISION: + return stg->params.layered_video; default: break; } @@ -428,6 +446,9 @@ static const AVClass *stream_group_child_iterate(void **opaque) case AV_STREAM_GROUP_PARAMS_TREF: ret = &tref_class; break; + case AV_STREAM_GROUP_PARAMS_DOLBY_VISION: + ret = &layered_video_class; + break; default: break; } @@ -511,6 +532,13 @@ AVStreamGroup *avformat_stream_group_create(AVFormatContext *s, stg->params.tref->av_class = &tref_class; av_opt_set_defaults(stg->params.tref); break; + case AV_STREAM_GROUP_PARAMS_DOLBY_VISION: + stg->params.layered_video = av_mallocz(sizeof(*stg->params.layered_video)); + if (!stg->params.layered_video) + goto fail; + stg->params.layered_video->av_class = &layered_video_class; + av_opt_set_defaults(stg->params.layered_video); + break; default: goto fail; } diff --git a/libavformat/version.h b/libavformat/version.h index be8ce01160..e063e12b98 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,8 +31,8 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 18 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 19 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \