diff mbox series

[FFmpeg-devel,13/19] avformat/matroskadec: Add support for FlagHearing/VisualImpaired

Message ID 20210217101356.1723370-13-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,01/19] fate/matroska: Add test for mastering display metadata
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 17, 2021, 10:13 a.m. UTC
Given that our disposition flags provide no way to distinguish the
cases of "track is unsuitable for hearing impaired users" and "it is
unknown whether the track is suitable for hearing impaired users" we do
not need to use a CountedElement for these flags.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/matroska.h    |  2 ++
 libavformat/matroskadec.c | 10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/matroska.h b/libavformat/matroska.h
index 8ab87eff20..bee08d4398 100644
--- a/libavformat/matroska.h
+++ b/libavformat/matroska.h
@@ -101,6 +101,8 @@ 
 #define MATROSKA_ID_TRACKFLAGFORCED 0x55AA
 #define MATROSKA_ID_TRACKFLAGLACING 0x9C
 #define MATROSKA_ID_TRACKFLAGORIGINAL 0x55AE
+#define MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED 0x55AB
+#define MATROSKA_ID_TRACKFLAGVISUALIMPAIRED  0x55AC
 #define MATROSKA_ID_TRACKMINCACHE 0x6DE7
 #define MATROSKA_ID_TRACKMAXCACHE 0x6DF8
 #define MATROSKA_ID_TRACKDEFAULTDURATION 0x23E383
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index f15bf8f9d2..fa0d86c3e4 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -252,6 +252,8 @@  typedef struct MatroskaTrack {
     uint64_t flag_forced;
     uint64_t flag_comment;
     CountedElement flag_original;
+    uint64_t flag_hearingimpaired;
+    uint64_t flag_visualimpaired;
     uint64_t seek_preroll;
     MatroskaTrackVideo video;
     MatroskaTrackAudio audio;
@@ -411,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[29], 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],
@@ -577,6 +579,8 @@  static EbmlSyntax matroska_track[] = {
     { MATROSKA_ID_TRACKFLAGDEFAULT,      EBML_UINT,  0, 0, offsetof(MatroskaTrack, flag_default), { .u = 1 } },
     { MATROSKA_ID_TRACKFLAGFORCED,       EBML_UINT,  0, 0, offsetof(MatroskaTrack, flag_forced),  { .u = 0 } },
     { MATROSKA_ID_TRACKFLAGORIGINAL,     EBML_UINT,  1, 0, offsetof(MatroskaTrack, flag_original), {.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_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 } },
@@ -2751,6 +2755,10 @@  static int matroska_parse_tracks(AVFormatContext *s)
         if (track->flag_original.count > 0)
             st->disposition |= track->flag_original.el.u ? AV_DISPOSITION_ORIGINAL
                                                          : AV_DISPOSITION_DUB;
+        if (track->flag_hearingimpaired)
+            st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED;
+        if (track->flag_visualimpaired)
+            st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED;
 
         if (!st->codecpar->extradata) {
             if (extradata) {