This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit b31fdbfde06241a233897fb14f7f24193e8199b9
Author:     Kacper Michajłow <[email protected]>
AuthorDate: Sun May 17 15:59:23 2026 +0200
Commit:     James Almer <[email protected]>
CommitDate: Sun May 31 03:43:29 2026 +0000

    avformat/matroskadec: create Dolby Vision stream group
    
    Matroska has no explicit cross-track Dolby Vision reference, so the
    pairing is recovered from the dvcC/dvvC config records. Find a single
    HEVC track whose record declares a profile 7 enhancement layer
    (el_present_flag=1) and a single sibling HEVC BL candidate. If either
    side is ambiguous, leave the streams ungrouped.
    
    Signed-off-by: Kacper Michajłow <[email protected]>
---
 libavformat/matroskadec.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 7e125bf61a..6570584bab 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3341,6 +3341,75 @@ static int matroska_parse_tracks(AVFormatContext *s)
     return 0;
 }
 
+static int matroska_parse_dovi_streams(AVFormatContext *s)
+{
+    AVStream *bl_st = NULL, *el_st = NULL;
+    AVStreamGroup *stg;
+    int err;
+
+    /* Matroska has no explicit cross-track Dolby Vision reference, so the
+     * pairing is recovered from the dvcC/dvvC config records. Find a single
+     * HEVC track whose record declares a profile 7 enhancement layer
+     * (el_present_flag=1) and a single sibling HEVC BL candidate. If either
+     * side is ambiguous, leave the streams ungrouped. */
+    if (s->nb_streams <= 1)
+        return 0;
+
+    for (int i = 0; i < s->nb_streams; i++) {
+        AVStream *st = s->streams[i];
+        const AVPacketSideData *sd;
+        const AVDOVIDecoderConfigurationRecord *dovi;
+
+        if (st->codecpar->codec_id != AV_CODEC_ID_HEVC)
+            continue;
+
+        sd = av_packet_side_data_get(st->codecpar->coded_side_data,
+                                     st->codecpar->nb_coded_side_data,
+                                     AV_PKT_DATA_DOVI_CONF);
+        if (sd) {
+            dovi = (const AVDOVIDecoderConfigurationRecord *)sd->data;
+            if (dovi->dv_profile == 7 && dovi->el_present_flag) {
+                /* bl_present_flag is not checked, because the files in the
+                 * wild set it to 1 for EL stream, while the expectation, based
+                 * on Dolby spec for MPEG-TS would be that it's set to 0.
+                 * Ignore this, if we have EL track and single other video 
track
+                 * it's safe to assume it's BL. */
+                if (el_st)
+                    return 0;
+                el_st = st;
+                continue;
+            }
+        }
+
+        if (bl_st)
+            return 0;
+        bl_st = st;
+    }
+
+    if (!el_st || !bl_st)
+        return 0;
+
+    stg = avformat_stream_group_create(s, AV_STREAM_GROUP_PARAMS_DOLBY_VISION, 
NULL);
+    if (!stg)
+        return AVERROR(ENOMEM);
+
+    stg->id = el_st->id;
+
+    err = avformat_stream_group_add_stream(stg, bl_st);
+    if (err < 0)
+        return err;
+
+    err = avformat_stream_group_add_stream(stg, el_st);
+    if (err < 0)
+        return err;
+
+    stg->params.layered_video->el_index = stg->nb_streams - 1;
+    stg->params.layered_video->width = bl_st->codecpar->width;
+    stg->params.layered_video->height = bl_st->codecpar->height;
+
+    return 0;
+}
+
 static int matroska_read_header(AVFormatContext *s)
 {
     FFFormatContext *const si = ffformatcontext(s);
@@ -3490,6 +3559,10 @@ static int matroska_read_header(AVFormatContext *s)
 
     matroska_convert_tags(s);
 
+    res = matroska_parse_dovi_streams(s);
+    if (res < 0)
+        return res;
+
     return 0;
 }
 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to