Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
c57b7837
Commit
c57b7837
authored
Jul 27, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
freetype: simplify HTML rendering with the new XML API
parent
70faefb1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
97 deletions
+88
-97
modules/misc/freetype.c
modules/misc/freetype.c
+88
-97
No files found.
modules/misc/freetype.c
View file @
c57b7837
...
@@ -265,7 +265,7 @@ struct filter_sys_t
...
@@ -265,7 +265,7 @@ struct filter_sys_t
int
i_display_height
;
int
i_display_height
;
#ifdef HAVE_FONTCONFIG
#ifdef HAVE_FONTCONFIG
char
*
psz_fontfamily
;
char
*
psz_fontfamily
;
xml_
t
*
p_xml
;
xml_
reader_t
*
p_xml
;
#endif
#endif
input_attachment_t
**
pp_font_attachments
;
input_attachment_t
**
pp_font_attachments
;
...
@@ -304,7 +304,7 @@ static int Create( vlc_object_t *p_this )
...
@@ -304,7 +304,7 @@ static int Create( vlc_object_t *p_this )
p_filter
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
filter_sys_t
)
);
p_filter
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
filter_sys_t
)
);
if
(
!
p_sys
)
if
(
!
p_sys
)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
#ifdef HAVE_FONTCONFIG
#ifdef HAVE_FONTCONFIG
p_sys
->
psz_fontfamily
=
NULL
;
p_sys
->
psz_fontfamily
=
NULL
;
p_sys
->
p_xml
=
NULL
;
p_sys
->
p_xml
=
NULL
;
#endif
#endif
...
@@ -514,7 +514,7 @@ static void Destroy( vlc_object_t *p_this )
...
@@ -514,7 +514,7 @@ static void Destroy( vlc_object_t *p_this )
}
}
#ifdef HAVE_FONTCONFIG
#ifdef HAVE_FONTCONFIG
if
(
p_sys
->
p_xml
)
xml_Delete
(
p_sys
->
p_xml
);
if
(
p_sys
->
p_xml
)
xml_
Reader
Delete
(
p_sys
->
p_xml
);
free
(
p_sys
->
psz_fontfamily
);
free
(
p_sys
->
psz_fontfamily
);
#endif
#endif
...
@@ -2190,7 +2190,6 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
...
@@ -2190,7 +2190,6 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
{
{
int
rv
=
VLC_SUCCESS
;
int
rv
=
VLC_SUCCESS
;
stream_t
*
p_sub
=
NULL
;
stream_t
*
p_sub
=
NULL
;
xml_reader_t
*
p_xml_reader
=
NULL
;
if
(
!
p_region_in
||
!
p_region_in
->
psz_html
)
if
(
!
p_region_in
||
!
p_region_in
->
psz_html
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
...
@@ -2202,114 +2201,106 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
...
@@ -2202,114 +2201,106 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
(
uint8_t
*
)
p_region_in
->
psz_html
,
(
uint8_t
*
)
p_region_in
->
psz_html
,
strlen
(
p_region_in
->
psz_html
),
strlen
(
p_region_in
->
psz_html
),
true
);
true
);
if
(
p_sub
)
if
(
unlikely
(
p_sub
==
NULL
)
)
return
VLC_SUCCESS
;
xml_reader_t
*
p_xml_reader
=
p_filter
->
p_sys
->
p_xml
;
bool
b_karaoke
=
false
;
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
)
{
{
if
(
!
p_filter
->
p_sys
->
p_xml
)
p_filter
->
p_sys
->
p_xml
=
xml_Create
(
p_filter
);
/* Look for Root Node */
if
(
p_filter
->
p_sys
->
p_xml
)
if
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
{
{
bool
b_karaoke
=
false
;
char
*
psz_node
=
xml_ReaderName
(
p_xml_reader
)
;
p_xml_reader
=
xml_ReaderCreate
(
p_filter
->
p_sys
->
p_xml
,
p_sub
);
if
(
!
strcasecmp
(
"karaoke"
,
psz_node
)
)
if
(
p_xml_reader
)
{
{
/* Look for Root Node */
/* We're going to have to render the text a number
if
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
* of times to show the progress marker on the text.
{
*/
char
*
psz_node
=
xml_ReaderName
(
p_xml_reader
);
var_SetBool
(
p_filter
,
"text-rerender"
,
true
);
b_karaoke
=
true
;
if
(
!
strcasecmp
(
"karaoke"
,
psz_node
)
)
{
/* We're going to have to render the text a number
* of times to show the progress marker on the text.
*/
var_SetBool
(
p_filter
,
"text-rerender"
,
true
);
b_karaoke
=
true
;
}
else
if
(
!
strcasecmp
(
"text"
,
psz_node
)
)
{
b_karaoke
=
false
;
}
else
{
/* Only text and karaoke tags are supported */
msg_Dbg
(
p_filter
,
"Unsupported top-level tag '%s' ignored."
,
psz_node
);
xml_ReaderDelete
(
p_xml_reader
);
p_xml_reader
=
NULL
;
rv
=
VLC_EGENERIC
;
}
free
(
psz_node
);
}
}
}
else
if
(
!
strcasecmp
(
"text"
,
psz_node
)
)
if
(
p_xml_reader
)
{
{
uint32_t
*
psz_text
;
b_karaoke
=
false
;
int
i_len
=
0
;
}
uint32_t
i_runs
=
0
;
else
uint32_t
i_k_runs
=
0
;
{
uint32_t
*
pi_run_lengths
=
NULL
;
/* Only text and karaoke tags are supported */
uint32_t
*
pi_k_run_lengths
=
NULL
;
msg_Dbg
(
p_filter
,
"Unsupported top-level tag '%s' ignored."
,
psz_node
);
uint32_t
*
pi_k_durations
=
NULL
;
xml_ReaderDelete
(
p_xml_reader
);
ft_style_t
**
pp_styles
=
NULL
;
p_xml_reader
=
NULL
;
FT_Vector
result
;
rv
=
VLC_EGENERIC
;
line_desc_t
*
p_lines
=
NULL
;
}
psz_text
=
(
uint32_t
*
)
malloc
(
strlen
(
p_region_in
->
psz_html
)
*
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
,
free
(
psz_node
);
&
pi_k_durations
);
}
}
p_region_out
->
i_x
=
p_region_in
->
i_x
;
if
(
p_xml_reader
)
p_region_out
->
i_y
=
p_region_in
->
i_y
;
{
uint32_t
*
psz_text
;
int
i_len
=
0
;
uint32_t
i_runs
=
0
;
uint32_t
i_k_runs
=
0
;
uint32_t
*
pi_run_lengths
=
NULL
;
uint32_t
*
pi_k_run_lengths
=
NULL
;
uint32_t
*
pi_k_durations
=
NULL
;
ft_style_t
**
pp_styles
=
NULL
;
FT_Vector
result
;
line_desc_t
*
p_lines
=
NULL
;
psz_text
=
(
uint32_t
*
)
malloc
(
strlen
(
p_region_in
->
psz_html
)
*
sizeof
(
uint32_t
)
);
if
(
psz_text
)
{
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
);
if
((
rv
==
VLC_SUCCESS
)
&&
(
i_len
>
0
))
p_region_out
->
i_x
=
p_region_in
->
i_x
;
{
p_region_out
->
i_y
=
p_region_in
->
i_y
;
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
);
}
for
(
k
=
0
;
k
<
i_runs
;
k
++
)
if
((
rv
==
VLC_SUCCESS
)
&&
(
i_len
>
0
))
DeleteStyle
(
pp_styles
[
k
]
);
{
free
(
pp_styles
);
rv
=
ProcessLines
(
p_filter
,
psz_text
,
i_len
,
i_runs
,
free
(
pi_run_lengths
);
pi_run_lengths
,
pp_styles
,
&
p_lines
,
free
(
psz_text
);
&
result
,
b_karaoke
,
i_k_runs
,
pi_k_run_lengths
,
pi_k_durations
);
}
/* Don't attempt to render text that couldn't be layed out
for
(
uint_fast32_t
k
=
0
;
k
<
i_runs
;
k
++
)
* properly.
DeleteStyle
(
pp_styles
[
k
]
);
*/
free
(
pp_styles
);
if
((
rv
==
VLC_SUCCESS
)
&&
(
i_len
>
0
))
free
(
pi_run_lengths
);
{
free
(
psz_text
);
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
);
}
}
}
FreeLines
(
p_lines
);
xml_ReaderDelete
(
p_xml_reader
);
/* Don't attempt to render text that couldn't be layed out
* 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
);
}
}
}
}
stream_Delete
(
p_sub
);
xml_ReaderReset
(
p_xml_reader
,
NULL
);
FreeLines
(
p_lines
);
}
}
stream_Delete
(
p_sub
);
return
rv
;
return
rv
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment