Commit c57b7837 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

freetype: simplify HTML rendering with the new XML API

parent 70faefb1
......@@ -265,7 +265,7 @@ struct filter_sys_t
int i_display_height;
#ifdef HAVE_FONTCONFIG
char* psz_fontfamily;
xml_t *p_xml;
xml_reader_t *p_xml;
#endif
input_attachment_t **pp_font_attachments;
......@@ -304,7 +304,7 @@ static int Create( vlc_object_t *p_this )
p_filter->p_sys = p_sys = malloc( sizeof( filter_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
#ifdef HAVE_FONTCONFIG
#ifdef HAVE_FONTCONFIG
p_sys->psz_fontfamily = NULL;
p_sys->p_xml = NULL;
#endif
......@@ -514,7 +514,7 @@ static void Destroy( vlc_object_t *p_this )
}
#ifdef HAVE_FONTCONFIG
if( p_sys->p_xml ) xml_Delete( p_sys->p_xml );
if( p_sys->p_xml ) xml_ReaderDelete( p_sys->p_xml );
free( p_sys->psz_fontfamily );
#endif
......@@ -2190,7 +2190,6 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
{
int rv = VLC_SUCCESS;
stream_t *p_sub = NULL;
xml_reader_t *p_xml_reader = NULL;
if( !p_region_in || !p_region_in->psz_html )
return VLC_EGENERIC;
......@@ -2202,14 +2201,18 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
(uint8_t *) p_region_in->psz_html,
strlen( p_region_in->psz_html ),
true );
if( p_sub )
{
if( !p_filter->p_sys->p_xml ) p_filter->p_sys->p_xml = xml_Create( p_filter );
if( p_filter->p_sys->p_xml )
{
if( unlikely(p_sub == NULL) )
return VLC_SUCCESS;
xml_reader_t *p_xml_reader = p_filter->p_sys->p_xml;
bool b_karaoke = false;
p_xml_reader = xml_ReaderCreate( p_filter->p_sys->p_xml, p_sub );
if( !p_xml_reader )
p_xml_reader = xml_ReaderCreate( p_filter, p_sub );
else
p_xml_reader = xml_ReaderReset( p_xml_reader, p_sub );
p_filter->p_sys->p_xml = p_xml_reader;
if( p_xml_reader )
{
/* Look for Root Node */
......@@ -2259,12 +2262,9 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
sizeof( uint32_t ) );
if( psz_text )
{
uint32_t k;
rv = ProcessNodes( p_filter, p_xml_reader,
p_region_in->p_style, psz_text, &i_len,
&i_runs, &pi_run_lengths, &pp_styles,
b_karaoke, &i_k_runs, &pi_k_run_lengths,
&pi_k_durations );
......@@ -2274,42 +2274,33 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
if(( rv == VLC_SUCCESS ) && ( i_len > 0 ))
{
rv = ProcessLines( p_filter, psz_text, i_len, i_runs,
pi_run_lengths, pp_styles, &p_lines, &result,
b_karaoke, i_k_runs, pi_k_run_lengths,
pi_k_durations );
pi_run_lengths, pp_styles, &p_lines,
&result, b_karaoke, i_k_runs,
pi_k_run_lengths, pi_k_durations );
}
for( k=0; k<i_runs; k++)
for( uint_fast32_t k=0; k<i_runs; k++)
DeleteStyle( pp_styles[k] );
free( pp_styles );
free( pi_run_lengths );
free( psz_text );
/* Don't attempt to render text that couldn't be layed out
* properly.
*/
* properly. */
if(( rv == VLC_SUCCESS ) && ( i_len > 0 ))
{
if( var_InheritBool( p_filter, "freetype-yuvp" ) )
{
Render( p_filter, p_region_out, p_lines,
result.x, result.y );
}
else
{
RenderYUVA( p_filter, p_region_out, p_lines,
result.x, result.y );
}
}
}
xml_ReaderReset( p_xml_reader, NULL );
FreeLines( p_lines );
xml_ReaderDelete( p_xml_reader );
}
}
stream_Delete( p_sub );
}
return rv;
}
......
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