vlc | branch: master | Francois Cartegnie <[email protected]> | Mon Jul 1 18:53:09 2019 +0200| [bf6c68d32909b470ceba2c386bffafb66c738cc3] | committer: Francois Cartegnie
codecs: subsusf: flatten karaoke string was not displaying at all... > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bf6c68d32909b470ceba2c386bffafb66c738cc3 --- modules/codec/subsusf.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/modules/codec/subsusf.c b/modules/codec/subsusf.c index c02c52b52f..20eab12ed2 100644 --- a/modules/codec/subsusf.c +++ b/modules/codec/subsusf.c @@ -100,6 +100,7 @@ typedef struct static int DecodeBlock ( decoder_t *, block_t * ); static char *CreatePlainText( char * ); +static char *StripTags( char *psz_subtitle ); static int ParseImageAttachments( decoder_t *p_dec ); static subpicture_t *ParseText ( decoder_t *, block_t * ); @@ -850,21 +851,37 @@ static subpicture_region_t *ParseUSFString( decoder_t *p_dec, { subpicture_region_t *p_text_region; - psz_end += strcspn( psz_end, ">" ) + 1; - - p_text_region = CreateTextRegion( p_dec, - psz_subtitle, - p_sys->i_align ); - - if( !p_region_first ) + char *psz_flat = NULL; + char *psz_knodes = strndup( &psz_subtitle[9], psz_end - &psz_subtitle[9] ); + if( psz_knodes ) { - p_region_first = p_region_upto = p_text_region; - } - else if( p_text_region ) - { - p_region_upto->p_next = p_text_region; - p_region_upto = p_region_upto->p_next; + /* remove timing <k> tags */ + psz_flat = CreatePlainText( psz_knodes ); + free( psz_knodes ); + if( psz_flat ) + { + p_text_region = CreateTextRegion( p_dec, + psz_flat, + p_sys->i_align ); + if( p_text_region ) + { + free( p_text_region->p_text->psz_text ); + p_text_region->p_text->psz_text = psz_flat; + if( !p_region_first ) + { + p_region_first = p_region_upto = p_text_region; + } + else if( p_text_region ) + { + p_region_upto->p_next = p_text_region; + p_region_upto = p_region_upto->p_next; + } + } + else free( psz_flat ); + } } + + psz_end += strcspn( psz_end, ">" ) + 1; } } else if(( !strncasecmp( psz_subtitle, "<image ", 7 )) || _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
