[vlc-commits] [Git][videolan/vlc][master] 6 commits: codec: ttml: add TTML namespaces definitions

François Cartegnie (@fcartegnie) gitlab at videolan.org
Sat Feb 24 10:51:28 UTC 2024



François Cartegnie pushed to branch master at VideoLAN / VLC


Commits:
b8610b20 by François Cartegnie at 2024-02-24T10:31:24+00:00
codec: ttml: add TTML namespaces definitions

- - - - -
658b85fb by François Cartegnie at 2024-02-24T10:31:24+00:00
mux: mp4: refactor sampledescription header

- - - - -
5c63a62f by François Cartegnie at 2024-02-24T10:31:24+00:00
mux: mp4: fix double header with quicktime text

- - - - -
8b42d7d0 by François Cartegnie at 2024-02-24T10:31:24+00:00
mux: mp4: write proper XMLsubtitlesampleentry for TTML

- - - - -
e2b450ec by François Cartegnie at 2024-02-24T10:31:24+00:00
mux: mp4: TTML keeps original timestamps in 4.0

- - - - -
28a23170 by François Cartegnie at 2024-02-24T10:31:24+00:00
mux: mp4: write proper empty TTML samples

- - - - -


3 changed files:

- modules/codec/ttml/ttml.h
- modules/mux/mp4/libmp4mux.c
- modules/mux/mp4/mp4.c


Changes:

=====================================
modules/codec/ttml/ttml.h
=====================================
@@ -56,6 +56,15 @@ struct tt_searchkey
     tt_time_t *p_last;
 };
 
+/* namespaces */
+#define TT_NS             "http://www.w3.org/ns/ttml"
+#define TT_NS_PARAMETER   TT_NS "#parameter"
+#define TT_NS_STYLING     TT_NS "#styling"
+#define TT_NS_METADATA    TT_NS "#metadata"
+#define TT_NS_PROFILE     TT_NS "/profile/"
+#define TT_NS_FEATURE     TT_NS "/feature/"
+#define TT_NS_EXTENSION   TT_NS "/extension/"
+
 enum
 {
     TT_NODE_TYPE_ELEMENT,


=====================================
modules/mux/mp4/libmp4mux.c
=====================================
@@ -30,6 +30,7 @@
 #include "../../packetizer/h264_nal.h" /* h264_AnnexB_get_spspps */
 #include "../../packetizer/hxxx_nal.h"
 #include "../../packetizer/iso_color_tables.h"
+#include "../../codec/ttml/ttml.h"
 
 #include <vlc_arrays.h>
 #include <vlc_es.h>
@@ -1104,6 +1105,13 @@ static bo_t *GetSratBox(uint32_t i_sample_rate)
     return srat;
 }
 
+static void FillSampleDescBoxHeader(bo_t *bo, uint16_t reference_index)
+{
+    for (int i = 0; i < 6; i++)
+        bo_add_8(bo, 0); // reserved;
+    bo_add_16be(bo, reference_index);// data-reference-index
+}
+
 static bo_t *GetSounBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b_mov)
 {
     VLC_UNUSED(p_obj);
@@ -1249,9 +1257,7 @@ static bo_t *GetSounBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
     bo_t *soun = box_new(fcc);
     if(!soun)
         return NULL;
-    for (int i = 0; i < 6; i++)
-        bo_add_8(soun, 0);        // reserved;
-    bo_add_16be(soun, 1);         // data-reference-index
+    FillSampleDescBoxHeader(soun, 1);
 
     /* SoundDescription */
     bo_add_16be(soun, i_qt_version);
@@ -1357,9 +1363,7 @@ static bo_t *GetVideBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
     bo_t *vide = box_new(fcc);
     if(!vide)
         return NULL;
-    for (int i = 0; i < 6; i++)
-        bo_add_8(vide, 0);        // reserved;
-    bo_add_16be(vide, 1);         // data-reference-index
+    FillSampleDescBoxHeader(vide, 1);
 
     bo_add_16be(vide, 0);         // predefined;
     bo_add_16be(vide, 0);         // reserved;
@@ -1454,10 +1458,7 @@ static bo_t *GetTextBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
         if(!text)
             return NULL;
 
-        /* Sample Entry Header */
-        for (int i = 0; i < 6; i++)
-            bo_add_8(text, 0);        // reserved;
-        bo_add_16be(text, 1);         // data-reference-index
+        FillSampleDescBoxHeader(text, 1);
 
         if(p_track->fmt.i_extra >= 44)
         {
@@ -1466,10 +1467,6 @@ static bo_t *GetTextBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
         }
         else
         {
-            for (int i = 0; i < 6; i++)
-                bo_add_8(text, 0);        // reserved;
-            bo_add_16be(text, 1);         // data-reference-index
-
             bo_add_32be(text, 0);         // display flags
             bo_add_32be(text, 0);         // justification
             for (int i = 0; i < 3; i++)
@@ -1498,10 +1495,7 @@ static bo_t *GetTextBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
         if(!tx3g)
             return NULL;
 
-        /* Sample Entry Header */
-        for (int i = 0; i < 6; i++)
-            bo_add_8(tx3g, 0);        // reserved;
-        bo_add_16be(tx3g, 1);         // data-reference-index
+        FillSampleDescBoxHeader(tx3g, 1);
 
         if(p_track->fmt.i_codec == VLC_CODEC_TX3G &&
            p_track->fmt.i_extra >= 32)
@@ -1556,10 +1550,7 @@ static bo_t *GetTextBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
         if(!wvtt)
             return NULL;
 
-        /* Sample Entry Header */
-        for (int i = 0; i < 6; i++)
-            bo_add_8(wvtt, 0);        // reserved;
-        bo_add_16be(wvtt, 1);         // data-reference-index
+        FillSampleDescBoxHeader(wvtt, 1);
 
         bo_t *ftab = box_new("vttc");
         box_gather(wvtt, ftab);
@@ -1572,10 +1563,13 @@ static bo_t *GetTextBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
         if(!stpp)
             return NULL;
 
-        /* Sample Entry Header */
-        for (int i = 0; i < 6; i++)
-            bo_add_8(stpp, 0);        // reserved;
-        bo_add_16be(stpp, 1);         // data-reference-index
+        FillSampleDescBoxHeader(stpp, 1);
+
+        bo_add_mem(stpp, sizeof(TT_NS)-1, TT_NS);
+        bo_add_8(stpp, ' ');
+        bo_add_mem(stpp, sizeof(TT_NS_STYLING), TT_NS_STYLING);
+        bo_add_8(stpp, '\0'); // schema
+        bo_add_8(stpp, '\0'); // ext-mime
 
         return stpp;
     }
@@ -2382,9 +2376,7 @@ bool mp4mux_CanMux(vlc_object_t *p_obj, const es_format_t *p_fmt,
             msg_Warn(p_obj, "subtitle track added like in .mov (even when creating .mp4)");
         return !b_fragmented;
     case VLC_CODEC_TTML:
-        /* Special case with smooth headers where we need to force frag TTML */
-        /* TTML currently not supported in sout, until we can keep original timestamps */
-            return i_brand == BRAND_smoo;
+        return true;
     case VLC_CODEC_QTXT:
     case VLC_CODEC_TX3G:
     case VLC_CODEC_WEBVTT:


=====================================
modules/mux/mp4/mp4.c
=====================================
@@ -46,6 +46,7 @@
 #include "../../packetizer/hxxx_nal.h"
 #include "../av1_pack.h"
 #include "../extradata.h"
+#include "../../codec/ttml/ttml.h"
 
 /*****************************************************************************
  * Module descriptor
@@ -818,9 +819,10 @@ static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_s
         }
         else if(mp4mux_track_GetFmt(p_stream->tinfo)->i_codec == VLC_CODEC_TTML)
         {
-            p_empty = block_Alloc(40);
+            const char emptyttml[] = "<tt xmlns=\"" TT_NS "\"/>";
+            p_empty = block_Alloc(sizeof(emptyttml));
             if(p_empty)
-                memcpy(p_empty->p_buffer, "<tt><body><div><p></p></div></body></tt>", 40);
+                memcpy(p_empty->p_buffer, emptyttml, p_empty->i_buffer);
         }
         else if(mp4mux_track_GetFmt(p_stream->tinfo)->i_codec == VLC_CODEC_WEBVTT)
         {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0dffba0ebaf05d236e02f0b24ec9ca19786eb842...28a2317047f8970a57b6f5527de7190f345da884

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0dffba0ebaf05d236e02f0b24ec9ca19786eb842...28a2317047f8970a57b6f5527de7190f345da884
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list