Commit ee4a4c4d72 for ffmpeg
commit ee4a4c4d72d2719e6779d17a758885f5a140071c
Author: Niklas Haas <git@haasn.dev>
Date: Mon Oct 19 14:00:47 2026 +0200
avformat/demux: set up size for gain map stream groups
Mirroring the existing logic for LCEVC, except using the size of the base
layer rather than the size of the EL.
Signed-off-by: Niklas Haas <git@haasn.dev>
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 1eb6eb328a..359ae2612b 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -3232,21 +3232,34 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
/* update the stream group parameters from the stream contexts if needed */
for (unsigned i = 0; i < ic->nb_stream_groups; i++) {
AVStreamGroup *const stg = ic->stream_groups[i];
- AVStreamGroupLayeredVideo *lcevc;
- const AVStream *st;
-
- if (stg->type != AV_STREAM_GROUP_PARAMS_LCEVC)
+ AVStreamGroupLayeredVideo *stglv;
+ const AVStreamGroupEntry *stge;
+
+ switch (stg->type) {
+ case AV_STREAM_GROUP_PARAMS_LCEVC:
+ /* For LCEVC in mpegts, the parser is needed to get the
+ * enhancement layer dimensions */
+ stglv = stg->params.layered_video;
+ stge = stg->entries[stglv->el_index];
+ break;
+ case AV_STREAM_GROUP_PARAMS_GAIN_MAP:
+ /* A gain map is presented at the size of its base rendition */
+ stglv = stg->params.layered_video;
+ if (stg->nb_entries != 2 || stglv->el_index >= 2)
+ continue;
+ stge = stg->entries[!stglv->el_index];
+ if (stge->type != AV_STREAM_GROUP_ENTRY_STREAM)
+ continue;
+ break;
+ default:
continue;
+ }
- /* For LCEVC in mpegts, the parser is needed to get the enhancement layer
- * dimensions */
- lcevc = stg->params.layered_video;
- if (lcevc->width && lcevc->height)
+ if (stglv->width && stglv->height)
continue;
- av_assert0(stg->entries[lcevc->el_index]->type == AV_STREAM_GROUP_ENTRY_STREAM);
- st = stg->entries[lcevc->el_index]->stream;
- lcevc->width = st->codecpar->width;
- lcevc->height = st->codecpar->height;
+ av_assert0(stge->type == AV_STREAM_GROUP_ENTRY_STREAM);
+ stglv->width = stge->stream->codecpar->width;
+ stglv->height = stge->stream->codecpar->height;
}
find_stream_info_err: