[vlc-devel] [PATCH 08/19] ttml codec: change head parsing to support style and region tag

Stanislas Plessia stplessia at gmail.com
Mon Aug 29 16:01:06 CEST 2016


---
 modules/codec/substtml.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/modules/codec/substtml.c b/modules/codec/substtml.c
index 78c0faa..13d1fc5 100644
--- a/modules/codec/substtml.c
+++ b/modules/codec/substtml.c
@@ -431,22 +431,35 @@ static void ParseTTMLStyles( decoder_t* p_dec )
     const char* psz_node_name;
     int i_type = xml_ReaderNextNode( p_reader, &psz_node_name );
 
-    if ( i_type == XML_READER_STARTELEM && ( !strcasecmp( psz_node_name, "head" ) || !strcasecmp( psz_node_name, "tt:head" ) ) )
+    if( i_type == XML_READER_STARTELEM && ( !strcasecmp( psz_node_name, "tt" ) || !strcasecmp( psz_node_name, "tt:tt" ) ) )
     {
+        int i_type = xml_ReaderNextNode( p_reader, &psz_node_name );
+        while( i_type != XML_READER_STARTELEM || ( strcasecmp( psz_node_name, "styling" ) && strcasecmp( psz_node_name, "tt:styling" ) ) )
+            i_type = xml_ReaderNextNode( p_reader, &psz_node_name );
+
         do
         {
-            i_type = xml_ReaderNextNode( p_reader, &psz_node_name );
-            if ( i_type == XML_READER_STARTELEM && ( !strcasecmp( "styling", psz_node_name ) ||
-                                                     !strcasecmp( "tt:styling", psz_node_name ) ) )
+            /* region and style tag are respectively inside layout and styling tags */
+            if( !strcasecmp( psz_node_name, "styling" ) || !strcasecmp( psz_node_name, "layout" ) ||
+                !strcasecmp( psz_node_name, "tt:styling" ) || !strcasecmp( psz_node_name, "tt:layout" ) )
             {
                 i_type = xml_ReaderNextNode( p_reader, &psz_node_name );
-                while ( i_type != XML_READER_ENDELEM || ( strcasecmp( psz_node_name, "styling" ) && strcasecmp( psz_node_name, "tt:styling" ) ) )
+                while( i_type != XML_READER_ENDELEM )
                 {
-                    ParseTTMLStyle( p_dec, p_reader, psz_node_name );
+                    ttml_style_t* p_ttml_style = ParseTTMLStyle( p_dec, p_reader, psz_node_name );
+                    if ( p_ttml_style == NULL )
+                    {
+                        xml_ReaderDelete( p_reader );
+                        vlc_stream_Delete( p_stream );
+                        return;
+                    }
+                    decoder_sys_t* p_sys = p_dec->p_sys;
+                    TAB_APPEND( p_sys->i_styles, p_sys->pp_styles, p_ttml_style );
                     i_type = xml_ReaderNextNode( p_reader, &psz_node_name );
                 }
             }
-        } while ( i_type != XML_READER_ENDELEM || ( strcasecmp( psz_node_name, "head" ) && strcasecmp( psz_node_name, "tt:head" ) ) );
+            i_type = xml_ReaderNextNode( p_reader, &psz_node_name );
+        }while( i_type != XML_READER_ENDELEM || ( strcasecmp( psz_node_name, "head" ) && strcasecmp( psz_node_name, "tt:head" ) ) );
     }
     xml_ReaderDelete( p_reader );
     vlc_stream_Delete( p_stream );
-- 
2.7.4



More information about the vlc-devel mailing list