[vlc-commits] codec: substtml: handle display attribute

Francois Cartegnie git at videolan.org
Tue Feb 14 17:51:01 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Feb 14 16:27:56 2017 +0100| [cb6b10b78861f74c92a2a1f1b05921b8c98a6ab7] | committer: Francois Cartegnie

codec: substtml: handle display attribute

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cb6b10b78861f74c92a2a1f1b05921b8c98a6ab7
---

 modules/codec/ttml/substtml.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/modules/codec/ttml/substtml.c b/modules/codec/ttml/substtml.c
index f78bd4a..d6efcc0 100644
--- a/modules/codec/ttml/substtml.c
+++ b/modules/codec/ttml/substtml.c
@@ -50,6 +50,12 @@ typedef struct
     int             i_direction;
     bool            b_direction_set;
     bool            b_preserve_space;
+    enum
+    {
+        TTML_DISPLAY_UNKNOWN = 0,
+        TTML_DISPLAY_AUTO,
+        TTML_DISPLAY_NONE,
+    } display;
 }  ttml_style_t;
 
 typedef struct
@@ -141,6 +147,9 @@ static void ttml_style_Merge( const ttml_style_t *p_src, ttml_style_t *p_dst )
             p_dst->b_direction_set = true;
             p_dst->i_direction = p_src->i_direction;
         }
+
+        if( p_src->display != TTML_DISPLAY_UNKNOWN )
+            p_dst->display = p_src->display;
     }
 }
 
@@ -376,6 +385,13 @@ static void FillTTMLStyle( const char *psz_attr, const char *psz_val,
             p_ttml_style->b_direction_set = true;
         }
     }
+    else if( !strcmp( "tts:display", psz_attr ) )
+    {
+        if( !strcmp( "none", psz_val ) )
+            p_ttml_style->display = TTML_DISPLAY_NONE;
+        else
+            p_ttml_style->display = TTML_DISPLAY_AUTO;
+    }
     else if( !strcasecmp( "xml:space", psz_attr ) )
     {
         p_ttml_style->b_preserve_space = !strcmp( "preserve", psz_val );
@@ -636,6 +652,14 @@ static void AppendTextToRegion( ttml_context_t *p_ctx, const tt_textnode_t *p_tt
             if( s->b_direction_set )
                 BIDIConvert( p_segment, s->i_direction );
 
+            if( s->display == TTML_DISPLAY_NONE )
+            {
+                /* Must not display, but still occupies space */
+                p_segment->style->i_features &= ~(STYLE_BACKGROUND|STYLE_OUTLINE|STYLE_STRIKEOUT|STYLE_SHADOW);
+                p_segment->style->i_font_alpha = STYLE_ALPHA_TRANSPARENT;
+                p_segment->style->i_features |= STYLE_HAS_FONT_ALPHA;
+            }
+
             ttml_style_Delete( s );
         }
     }



More information about the vlc-commits mailing list