[vlc-commits] ttml demux: Simplify & fix transparent tags generation
Hugo Beauzée-Luyssen
git at videolan.org
Wed Sep 14 18:39:46 CEST 2016
vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Sep 13 14:18:20 2016 +0200| [410319865ca320b6700e6b29910e4d30074e1585] | committer: Hugo Beauzée-Luyssen
ttml demux: Simplify & fix transparent tags generation
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=410319865ca320b6700e6b29910e4d30074e1585
---
modules/demux/ttml.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/modules/demux/ttml.c b/modules/demux/ttml.c
index e27baef..93a3c0b 100644
--- a/modules/demux/ttml.c
+++ b/modules/demux/ttml.c
@@ -377,18 +377,13 @@ static int timeCmp( const void* p_time1, const void* p_time2 )
*/
static char* setOpacityToZero( char* psz_text )
{
- const char* psz_begin = strstr( psz_text, "<span " );
- if( unlikely( psz_begin == NULL ) )
- return NULL;
-
const char* psz_end = strstr( psz_text, ">" );
- char* psz_cpy = malloc( strlen( psz_text ) );
- if( unlikely( psz_cpy == NULL ) )
- return NULL;
- strncpy( psz_cpy, psz_text, psz_end - psz_begin );
- psz_cpy = Append( psz_cpy, " tts:opacity=\"0\">%s", psz_end + 1);
- return psz_cpy;
+ int i_span_length = psz_end - psz_text;
+ char* psz_res;
+ if( asprintf( &psz_res, "%.*s tts:opacity=\"0\">%s", i_span_length, psz_text, psz_end + 1) < 0 )
+ psz_res = NULL;
+ return psz_res;
}
static void CleanSubs( subtitle_t** tab )
More information about the vlc-commits
mailing list