Commit d3d8a8c0 authored by Ilkka Ollakka's avatar Ilkka Ollakka

zvbi: strip leading/end whitespaces from text subtitles

parent a493cee2
python @ e4ce04bc
Subproject commit 391f6383e9568209c3242468c4179645708bdc39 Subproject commit e4ce04bca758d81550894dc88351d96526723278
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
# include "config.h" # include "config.h"
#endif #endif
#include <ctype.h>
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <assert.h> #include <assert.h>
...@@ -414,15 +416,24 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block ) ...@@ -414,15 +416,24 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
if( p_sys->b_text ) if( p_sys->b_text )
{ {
unsigned int i_textsize = 7000; unsigned int i_textsize = 7000;
int i_total; int i_total,offset;
char p_text[i_textsize+1]; char p_text[i_textsize+1];
i_total = vbi_print_page_region( &p_page, p_text, i_textsize, i_total = vbi_print_page_region( &p_page, p_text, i_textsize,
"UTF-8", 0, 0, 0, i_first_row, p_page.columns, i_num_rows ); "UTF-8", 0, 0, 0, i_first_row, p_page.columns, i_num_rows );
p_text[i_total] = '\0';
p_spu->p_region->psz_text = strdup( p_text ); for( offset=1; offset<i_total && isspace( p_text[i_total-offset ] ); offset++)
p_text[i_total-offset] = '\0';
i_total -= offset;
offset=0;
while( offset < i_total && isspace( p_text[offset] ) )
offset++;
p_spu->p_region->psz_text = strdup( &p_text[offset] );
#ifdef ZVBI_DEBUG #ifdef ZVBI_DEBUG
msg_Info( p_dec, "page %x-%x(%d)\n%s", p_page.pgno, p_page.subno, i_total, p_text ); msg_Info( p_dec, "page %x-%x(%d)\n\"%s\"", p_page.pgno, p_page.subno, i_total, &p_text[offset] );
#endif #endif
} }
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment