Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
7
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Steve Lhomme
VLC
Commits
8654ef67
Commit
8654ef67
authored
7 years ago
by
François Cartegnie
Browse files
Options
Downloads
Patches
Plain Diff
codec: ttml: compute sizes from cells (fix
#18347
)
parent
c12fa124
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/codec/ttml/substtml.c
+31
-7
31 additions, 7 deletions
modules/codec/ttml/substtml.c
with
31 additions
and
7 deletions
modules/codec/ttml/substtml.c
+
31
−
7
View file @
8654ef67
...
...
@@ -46,6 +46,7 @@
typedef
struct
{
text_style_t
*
font_style
;
unsigned
i_cell_height
;
int
i_text_align
;
int
i_direction
;
bool
b_direction_set
;
...
...
@@ -104,6 +105,7 @@ static ttml_style_t * ttml_style_New( )
if
(
unlikely
(
!
p_ttml_style
)
)
return
NULL
;
p_ttml_style
->
i_cell_height
=
15
;
p_ttml_style
->
font_style
=
text_style_Create
(
STYLE_NO_DEFAULTS
);
if
(
unlikely
(
!
p_ttml_style
->
font_style
)
)
{
...
...
@@ -199,7 +201,7 @@ static tt_node_t * FindNode( tt_node_t *p_node, const char *psz_nodename,
}
static
void
FillTextStyle
(
const
char
*
psz_attr
,
const
char
*
psz_val
,
text_style_t
*
p_text_style
)
const
ttml_style_t
*
p_ttml_style
,
text_style_t
*
p_text_style
)
{
if
(
!
strcasecmp
(
"tts:fontFamily"
,
psz_attr
)
)
{
...
...
@@ -216,10 +218,15 @@ static void FillTextStyle( const char *psz_attr, const char *psz_val,
{
char
*
psz_end
=
NULL
;
float
size
=
us_strtof
(
psz_val
,
&
psz_end
);
if
(
*
psz_end
==
'%'
)
p_text_style
->
f_font_relsize
=
STYLE_DEFAULT_REL_FONT_SIZE
*
size
/
100
.
0
;
else
p_text_style
->
i_font_size
=
(
int
)(
size
+
0
.
5
);
if
(
size
>
0
.
0
)
{
if
(
*
psz_end
==
'c'
)
p_text_style
->
f_font_relsize
=
100
.
0
*
size
/
p_ttml_style
->
i_cell_height
;
else
if
(
*
psz_end
==
'%'
)
p_text_style
->
f_font_relsize
=
size
/
p_ttml_style
->
i_cell_height
;
else
p_text_style
->
i_font_size
=
(
int
)(
size
+
0
.
5
);
}
}
else
if
(
!
strcasecmp
(
"tts:color"
,
psz_attr
)
)
{
...
...
@@ -334,6 +341,19 @@ static void FillRegionStyle( const char *psz_attr, const char *psz_val,
}
}
static
void
FillTTMLStylePrio
(
const
vlc_dictionary_t
*
p_dict
,
ttml_style_t
*
p_ttml_style
)
{
void
*
value
=
vlc_dictionary_value_for_key
(
p_dict
,
"ttp:cellResolution"
);
if
(
value
!=
kVLCDictionaryNotFound
)
{
const
char
*
psz_val
=
value
;
unsigned
w
,
h
;
if
(
sscanf
(
psz_val
,
"%u %u"
,
&
w
,
&
h
)
==
2
&&
w
&&
h
)
p_ttml_style
->
i_cell_height
=
h
;
}
}
static
void
FillTTMLStyle
(
const
char
*
psz_attr
,
const
char
*
psz_val
,
ttml_style_t
*
p_ttml_style
)
{
...
...
@@ -396,7 +416,7 @@ static void FillTTMLStyle( const char *psz_attr, const char *psz_val,
{
p_ttml_style
->
b_preserve_space
=
!
strcmp
(
"preserve"
,
psz_val
);
}
else
FillTextStyle
(
psz_attr
,
psz_val
,
p_ttml_style
->
font_style
);
else
FillTextStyle
(
psz_attr
,
psz_val
,
p_ttml_style
,
p_ttml_style
->
font_style
);
}
static
void
DictionaryMerge
(
const
vlc_dictionary_t
*
p_src
,
vlc_dictionary_t
*
p_dst
)
...
...
@@ -406,7 +426,9 @@ static void DictionaryMerge( const vlc_dictionary_t *p_src, vlc_dictionary_t *p_
for
(
const
vlc_dictionary_entry_t
*
p_entry
=
p_src
->
p_entries
[
i
];
p_entry
!=
NULL
;
p_entry
=
p_entry
->
p_next
)
{
if
(
!
strncmp
(
"tts:"
,
p_entry
->
psz_key
,
4
)
&&
if
(
(
!
strncmp
(
"tts:"
,
p_entry
->
psz_key
,
4
)
||
!
strncmp
(
"ttp:"
,
p_entry
->
psz_key
,
4
)
||
!
strcmp
(
"xml:space"
,
p_entry
->
psz_key
)
)
&&
!
vlc_dictionary_has_key
(
p_dst
,
p_entry
->
psz_key
)
)
vlc_dictionary_insert
(
p_dst
,
p_entry
->
psz_key
,
p_entry
->
p_value
);
}
...
...
@@ -459,6 +481,8 @@ static void DictMergeWithRegionID( ttml_context_t *p_ctx, const char *psz_id,
static
void
DictToTTMLStyle
(
const
vlc_dictionary_t
*
p_dict
,
ttml_style_t
*
p_ttml_style
)
{
/* Units, defaults, that must be set first to compute styles */
FillTTMLStylePrio
(
p_dict
,
p_ttml_style
);
for
(
int
i
=
0
;
i
<
p_dict
->
i_size
;
++
i
)
{
for
(
vlc_dictionary_entry_t
*
p_entry
=
p_dict
->
p_entries
[
i
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment