From 48cf1d878cd2b777a26d3939eef43caac7ced406 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 16 Feb 2021 19:38:19 +0100 Subject: [PATCH] avformat/matroskadec: Add support for FlagTextDescriptions This is the equivalent of the WebM "D_WEBVTT/DESCRIPTIONS" and is therefore only exported for subtitles. Reviewed-by: Ridley Combs Signed-off-by: Andreas Rheinhardt --- libavformat/matroska.h | 1 + libavformat/matroskadec.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 6ce513d788..d77dff982f 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -100,6 +100,7 @@ #define MATROSKA_ID_TRACKFLAGFORCED 0x55AA #define MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED 0x55AB #define MATROSKA_ID_TRACKFLAGVISUALIMPAIRED 0x55AC +#define MATROSKA_ID_TRACKFLAGTEXTDESCRIPTIONS 0x55AD #define MATROSKA_ID_TRACKFLAGCOMMENTARY 0x55AF #define MATROSKA_ID_TRACKFLAGLACING 0x9C #define MATROSKA_ID_TRACKMINCACHE 0x6DE7 diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 4f1f898a54..1f96b49fc4 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -253,6 +253,7 @@ typedef struct MatroskaTrack { uint64_t flag_comment; uint64_t flag_hearingimpaired; uint64_t flag_visualimpaired; + uint64_t flag_textdescriptions; uint64_t seek_preroll; MatroskaTrackVideo video; MatroskaTrackAudio audio; @@ -412,7 +413,7 @@ typedef struct MatroskaDemuxContext { // incomplete type (6.7.2 in C90, 6.9.2 in C99). // Removing the sizes breaks MSVC. static EbmlSyntax ebml_syntax[3], matroska_segment[9], matroska_track_video_color[15], matroska_track_video[19], - matroska_track[30], matroska_track_encoding[6], matroska_track_encodings[2], + matroska_track[31], matroska_track_encoding[6], matroska_track_encodings[2], matroska_track_combine_planes[2], matroska_track_operation[2], matroska_tracks[2], matroska_attachments[2], matroska_chapter_entry[9], matroska_chapter[6], matroska_chapters[2], matroska_index_entry[3], matroska_index[2], matroska_tag[3], matroska_tags[2], matroska_seekhead[2], @@ -579,6 +580,7 @@ static EbmlSyntax matroska_track[] = { { MATROSKA_ID_TRACKFLAGFORCED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_forced), { .u = 0 } }, { MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_hearingimpaired), { .u = 0 } }, { MATROSKA_ID_TRACKFLAGVISUALIMPAIRED, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_visualimpaired), { .u = 0 } }, + { MATROSKA_ID_TRACKFLAGTEXTDESCRIPTIONS, EBML_UINT, 0, 0, offsetof(MatroskaTrack, flag_textdescriptions), { .u = 0 } }, { MATROSKA_ID_TRACKVIDEO, EBML_NEST, 0, 0, offsetof(MatroskaTrack, video), { .n = matroska_track_video } }, { MATROSKA_ID_TRACKAUDIO, EBML_NEST, 0, 0, offsetof(MatroskaTrack, audio), { .n = matroska_track_audio } }, { MATROSKA_ID_TRACKOPERATION, EBML_NEST, 0, 0, offsetof(MatroskaTrack, operation), { .n = matroska_track_operation } }, @@ -2880,6 +2882,9 @@ static int matroska_parse_tracks(AVFormatContext *s) } } else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) { st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; + + if (track->flag_textdescriptions) + st->disposition |= AV_DISPOSITION_DESCRIPTIONS; } }