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
94ed9110
Commit
94ed9110
authored
Apr 06, 2015
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Subtitle codecs: Use text_style_t instead of segment_style_t
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
efbc00f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
33 deletions
+26
-33
modules/codec/substext.h
modules/codec/substext.h
+12
-19
modules/codec/substx3g.c
modules/codec/substx3g.c
+14
-14
No files found.
modules/codec/substext.h
View file @
94ed9110
...
...
@@ -8,20 +8,13 @@ typedef struct
typedef
struct
segment_t
segment_t
;
typedef
struct
{
uint8_t
i_fontsize
;
uint32_t
i_color
;
//ARGB
uint8_t
i_flags
;
}
segment_style_t
;
struct
segment_t
{
char
*
psz_string
;
unsigned
int
i_size
;
segment_t
*
p_next
;
/* styles applied to that segment */
segmen
t_style_t
styles
;
tex
t_style_t
styles
;
};
struct
subpicture_updater_sys_t
{
...
...
@@ -86,7 +79,7 @@ static void MakeHtmlNewLines( char **ppsz_src )
}
static
void
HtmlAppend
(
char
**
ppsz_dst
,
const
char
*
psz_src
,
const
segmen
t_style_t
*
p_styles
,
const
float
f_scale
)
const
tex
t_style_t
*
p_styles
,
const
float
f_scale
)
{
if
(
!
ppsz_dst
)
return
;
int
i_return
;
...
...
@@ -99,28 +92,28 @@ static void HtmlAppend( char **ppsz_dst, const char *psz_src,
MakeHtmlNewLines
(
&
psz_encoded
);
if
(
p_styles
->
i_
color
&
0xFF00000
0
)
//ARGB
if
(
p_styles
->
i_
font_alpha
>
0
)
//ARGB
{
i_return
=
asprintf
(
&
psz_color
,
" color=
\"
#%6x
\"
"
,
p_styles
->
i_color
&
0x00FFFFFF
);
p_styles
->
i_
font_
color
&
0x00FFFFFF
);
if
(
i_return
<
0
)
psz_color
=
NULL
;
}
if
(
p_styles
->
i_fontsize
>
0
&&
f_scale
>
0
)
if
(
p_styles
->
i_font
_
size
>
0
&&
f_scale
>
0
)
{
i_return
=
asprintf
(
&
psz_fontsize
,
" size=
\"
%u
\"
"
,
(
unsigned
)
(
f_scale
*
p_styles
->
i_fontsize
)
);
(
unsigned
)
(
f_scale
*
p_styles
->
i_font
_
size
)
);
if
(
i_return
<
0
)
psz_fontsize
=
NULL
;
}
i_return
=
asprintf
(
&
psz_subtext
,
"%s%s%s%s%s%s%s"
,
(
p_styles
->
i_flags
&
STYLE_UNDERLINE
)
?
"<u>"
:
""
,
(
p_styles
->
i_flags
&
STYLE_BOLD
)
?
"<b>"
:
""
,
(
p_styles
->
i_flags
&
STYLE_ITALIC
)
?
"<i>"
:
""
,
(
p_styles
->
i_
style_
flags
&
STYLE_UNDERLINE
)
?
"<u>"
:
""
,
(
p_styles
->
i_
style_
flags
&
STYLE_BOLD
)
?
"<b>"
:
""
,
(
p_styles
->
i_
style_
flags
&
STYLE_ITALIC
)
?
"<i>"
:
""
,
psz_encoded
,
(
p_styles
->
i_flags
&
STYLE_ITALIC
)
?
"</i>"
:
""
,
(
p_styles
->
i_flags
&
STYLE_BOLD
)
?
"</b>"
:
""
,
(
p_styles
->
i_flags
&
STYLE_UNDERLINE
)
?
"</u>"
:
""
(
p_styles
->
i_
style_
flags
&
STYLE_ITALIC
)
?
"</i>"
:
""
,
(
p_styles
->
i_
style_
flags
&
STYLE_BOLD
)
?
"</b>"
:
""
,
(
p_styles
->
i_
style_
flags
&
STYLE_UNDERLINE
)
?
"</u>"
:
""
);
if
(
i_return
<
0
)
psz_subtext
=
NULL
;
...
...
modules/codec/substx3g.c
View file @
94ed9110
...
...
@@ -134,14 +134,14 @@ static void SegmentDoSplit( segment_t *p_segment, uint16_t i_start, uint16_t i_e
{
p_segment_left
=
calloc
(
1
,
sizeof
(
segment_t
)
);
if
(
!
p_segment_left
)
goto
error
;
memcpy
(
&
p_segment_left
->
styles
,
&
p_segment
->
styles
,
sizeof
(
segmen
t_style_t
)
);
memcpy
(
&
p_segment_left
->
styles
,
&
p_segment
->
styles
,
sizeof
(
tex
t_style_t
)
);
p_segment_left
->
psz_string
=
str8indup
(
p_segment
->
psz_string
,
0
,
i_start
);
p_segment_left
->
i_size
=
str8len
(
p_segment_left
->
psz_string
);
}
p_segment_middle
=
calloc
(
1
,
sizeof
(
segment_t
)
);
if
(
!
p_segment_middle
)
goto
error
;
memcpy
(
&
p_segment_middle
->
styles
,
&
p_segment
->
styles
,
sizeof
(
segmen
t_style_t
)
);
memcpy
(
&
p_segment_middle
->
styles
,
&
p_segment
->
styles
,
sizeof
(
tex
t_style_t
)
);
p_segment_middle
->
psz_string
=
str8indup
(
p_segment
->
psz_string
,
i_start
,
i_end
-
i_start
+
1
);
p_segment_middle
->
i_size
=
str8len
(
p_segment_middle
->
psz_string
);
...
...
@@ -149,7 +149,7 @@ static void SegmentDoSplit( segment_t *p_segment, uint16_t i_start, uint16_t i_e
{
p_segment_right
=
calloc
(
1
,
sizeof
(
segment_t
)
);
if
(
!
p_segment_right
)
goto
error
;
memcpy
(
&
p_segment_right
->
styles
,
&
p_segment
->
styles
,
sizeof
(
segmen
t_style_t
)
);
memcpy
(
&
p_segment_right
->
styles
,
&
p_segment
->
styles
,
sizeof
(
tex
t_style_t
)
);
p_segment_right
->
psz_string
=
str8indup
(
p_segment
->
psz_string
,
i_end
+
1
,
p_segment
->
i_size
-
i_end
-
1
);
p_segment_right
->
i_size
=
str8len
(
p_segment_right
->
psz_string
);
}
...
...
@@ -171,7 +171,7 @@ error:
static
bool
SegmentSplit
(
segment_t
*
p_prev
,
segment_t
**
pp_segment
,
const
uint16_t
i_start
,
const
uint16_t
i_end
,
const
segmen
t_style_t
*
p_styles
)
const
tex
t_style_t
*
p_styles
)
{
segment_t
*
p_segment_left
=
NULL
,
*
p_segment_middle
=
NULL
,
*
p_segment_right
=
NULL
;
...
...
@@ -207,7 +207,7 @@ static bool SegmentSplit( segment_t *p_prev, segment_t **pp_segment,
/* Creates a new segment using the given style and split existing ones according
to the start & end offsets */
static
void
ApplySegmentStyle
(
segment_t
**
pp_segment
,
const
uint16_t
i_absstart
,
const
uint16_t
i_absend
,
const
segmen
t_style_t
*
p_styles
)
const
uint16_t
i_absend
,
const
tex
t_style_t
*
p_styles
)
{
/* find the matching segment */
uint16_t
i_curstart
=
0
;
...
...
@@ -288,11 +288,11 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
p_segment
->
i_size
=
str8len
(
psz_subtitle
);
if
(
p_dec
->
fmt_in
.
subs
.
p_style
)
{
p_segment
->
styles
.
i_color
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_color
;
p_segment
->
styles
.
i_
color
|=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_alpha
<<
24
;
p_segment
->
styles
.
i_
font_
color
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_color
;
p_segment
->
styles
.
i_
font_alpha
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_alpha
;
if
(
p_dec
->
fmt_in
.
subs
.
p_style
->
i_style_flags
)
p_segment
->
styles
.
i_flags
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_style_flags
;
p_segment
->
styles
.
i_fontsize
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_size
;
p_segment
->
styles
.
i_
style_
flags
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_style_flags
;
p_segment
->
styles
.
i_font
_
size
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_size
;
}
if
(
!
p_segment
->
psz_string
)
...
...
@@ -333,11 +333,11 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
uint16_t
i_start
=
__MIN
(
GetWBE
(
p_buf
),
i_psz_bytelength
-
1
);
uint16_t
i_end
=
__MIN
(
GetWBE
(
p_buf
+
2
),
i_psz_bytelength
-
1
);
segmen
t_style_t
style
;
style
.
i_flags
=
ConvertFlags
(
p_buf
[
6
]
);
style
.
i_fontsize
=
p_buf
[
7
];
style
.
i_
color
=
GetDWBE
(
p_buf
+
8
)
>>
8
;
// RGBA -> A
RGB
style
.
i_
color
|=
(
GetDWBE
(
p_buf
+
8
)
&
0xFF
)
<<
24
;
tex
t_style_t
style
;
style
.
i_
style_
flags
=
ConvertFlags
(
p_buf
[
6
]
);
style
.
i_font
_
size
=
p_buf
[
7
];
style
.
i_
font_color
=
GetDWBE
(
p_buf
+
8
)
>>
8
;
// RGBA ->
RGB
style
.
i_
font_alpha
=
GetDWBE
(
p_buf
+
8
)
&
0xFF
;
ApplySegmentStyle
(
&
p_segment
,
i_start
,
i_end
,
&
style
);
if
(
i_nbrecords
==
1
)
...
...
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