static subpicture_region_t *CreateTextRegion( decoder_t *p_dec, char *psz_subtitle, int i_len, int i_sys_align ) { decoder_sys_t *p_sys = p_dec->p_sys; subpicture_region_t *p_text_region; video_format_t fmt; /* Create a new subpicture region */ memset( &fmt, 0, sizeof(video_format_t) ); fmt.i_chroma = VLC_CODEC_TEXT; fmt.i_width = fmt.i_height = 0; fmt.i_x_offset = fmt.i_y_offset = 0; p_text_region = subpicture_region_New( &fmt ); if( p_text_region != NULL ) { ssa_style_t *p_ssa_style = NULL; p_text_region->psz_text = NULL; p_text_region->psz_html = strndup( psz_subtitle, i_len ); if( ! p_text_region->psz_html ) { subpicture_region_Delete( p_text_region ); return NULL; } p_ssa_style = ParseStyle( p_sys, p_text_region->psz_html ); if( !p_ssa_style ) { int i; for( i = 0; i < p_sys->i_ssa_styles; i++ ) { if( !strcasecmp( p_sys->pp_ssa_styles[i]->psz_stylename, "Default" ) ) p_ssa_style = p_sys->pp_ssa_styles[i]; } } if( p_ssa_style ) { msg_Dbg( p_dec, "style is: %s", p_ssa_style->psz_stylename ); p_text_region->p_style = text_style_Duplicate( &p_ssa_style->font_style ); p_text_region->i_align = p_ssa_style->i_align; /* TODO: Setup % based offsets properly, without adversely affecting * everything else in vlc. Will address with separate patch, * to prevent this one being any more complicated. * p_ssa_style->i_margin_percent_h; * p_ssa_style->i_margin_percent_v; */ p_text_region->i_x = p_ssa_style->i_margin_h; p_text_region->i_y = p_ssa_style->i_margin_v; } else { p_text_region->i_align = SUBPICTURE_ALIGN_BOTTOM | i_sys_align; p_text_region->i_x = i_sys_align ? 20 : 0; p_text_region->i_y = 10; } /* Look for position arguments which may override the style-based * defaults. */ SetupPositions( p_text_region, psz_subtitle ); p_text_region->p_next = NULL; } return p_text_region; }
static subpicture_region_t *CreateTextRegion( decoder_t *p_dec, char *psz_subtitle, int i_sys_align ) { decoder_sys_t *p_sys = p_dec->p_sys; subpicture_region_t *p_text_region; video_format_t fmt; /* Create a new subpicture region */ video_format_Init( &fmt, VLC_CODEC_TEXT ); fmt.i_width = fmt.i_height = 0; fmt.i_x_offset = fmt.i_y_offset = 0; p_text_region = subpicture_region_New( &fmt ); video_format_Clean( &fmt ); if( p_text_region != NULL ) { ssa_style_t *p_ssa_style = NULL; p_ssa_style = ParseStyle( p_sys, psz_subtitle ); if( !p_ssa_style ) { for( int i = 0; i < p_sys->i_ssa_styles; i++ ) { if( !strcasecmp( p_sys->pp_ssa_styles[i]->psz_stylename, "Default" ) ) p_ssa_style = p_sys->pp_ssa_styles[i]; } } /* Set default or user align/magin. * Style overriden if no user value. */ p_text_region->i_x = i_sys_align > 0 ? 20 : 0; p_text_region->i_y = 10; p_text_region->i_align = SUBPICTURE_ALIGN_BOTTOM | ((i_sys_align > 0) ? i_sys_align : 0); if( p_ssa_style ) { msg_Dbg( p_dec, "style is: %s", p_ssa_style->psz_stylename ); /* TODO: Setup % based offsets properly, without adversely affecting * everything else in vlc. Will address with separate patch, * to prevent this one being any more complicated. * p_ssa_style->i_margin_percent_h; * p_ssa_style->i_margin_percent_v; */ if( i_sys_align == -1 ) { p_text_region->i_align = p_ssa_style->i_align; p_text_region->i_x = p_ssa_style->i_margin_h; p_text_region->i_y = p_ssa_style->i_margin_v; } p_text_region->p_text = text_segment_NewInheritStyle( p_ssa_style->p_style ); } else { p_text_region->p_text = text_segment_New( NULL ); } /* Look for position arguments which may override the style-based * defaults. */ SetupPositions( p_text_region, psz_subtitle ); p_text_region->p_next = NULL; } return p_text_region; }