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
b8ce6743
Commit
b8ce6743
authored
Jul 08, 2015
by
Hugo Beauzée-Luyssen
Committed by
Jean-Baptiste Kempf
Jul 28, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tx3g: Replace subtext.h's segment_t with text_segment_t
parent
a9c0a1ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
72 deletions
+54
-72
include/vlc_text_style.h
include/vlc_text_style.h
+2
-0
modules/codec/substext.h
modules/codec/substext.h
+7
-26
modules/codec/substx3g.c
modules/codec/substx3g.c
+45
-46
No files found.
include/vlc_text_style.h
View file @
b8ce6743
...
@@ -107,6 +107,8 @@ struct text_segment_t {
...
@@ -107,6 +107,8 @@ struct text_segment_t {
char
*
psz_text
;
/**< text string of the segment */
char
*
psz_text
;
/**< text string of the segment */
text_style_t
*
style
;
/**< style applied to this segment */
text_style_t
*
style
;
/**< style applied to this segment */
text_segment_t
*
p_next
;
/**< next segment */
text_segment_t
*
p_next
;
/**< next segment */
size_t
i_size
;
//FIXME: substx3g specific
};
};
/**
/**
...
...
modules/codec/substext.h
View file @
b8ce6743
#include <vlc_strings.h>
#include <vlc_strings.h>
#include <vlc_text_style.h>
typedef
struct
typedef
struct
{
{
...
@@ -6,21 +7,10 @@ typedef struct
...
@@ -6,21 +7,10 @@ typedef struct
unsigned
int
i_value
;
unsigned
int
i_value
;
}
subpicture_updater_sys_option_t
;
}
subpicture_updater_sys_option_t
;
typedef
struct
segment_t
segment_t
;
struct
segment_t
{
char
*
psz_string
;
unsigned
int
i_size
;
segment_t
*
p_next
;
/* styles applied to that segment */
text_style_t
styles
;
};
struct
subpicture_updater_sys_t
{
struct
subpicture_updater_sys_t
{
char
*
text
;
char
*
text
;
char
*
html
;
char
*
html
;
segment_t
*
p_htmlsegments
;
text_
segment_t
*
p_htmlsegments
;
int
align
;
int
align
;
int
x
;
int
x
;
...
@@ -42,15 +32,6 @@ struct subpicture_updater_sys_t {
...
@@ -42,15 +32,6 @@ struct subpicture_updater_sys_t {
int16_t
i_drop_shadow_alpha
;
int16_t
i_drop_shadow_alpha
;
};
};
static
void
SegmentFree
(
segment_t
*
p_segment
)
{
if
(
p_segment
)
{
free
(
p_segment
->
psz_string
);
free
(
p_segment
);
}
}
static
void
MakeHtmlNewLines
(
char
**
ppsz_src
)
static
void
MakeHtmlNewLines
(
char
**
ppsz_src
)
{
{
unsigned
int
i_nlcount
=
0
;
unsigned
int
i_nlcount
=
0
;
...
@@ -146,13 +127,13 @@ static void HtmlAppend( char **ppsz_dst, const char *psz_src,
...
@@ -146,13 +127,13 @@ static void HtmlAppend( char **ppsz_dst, const char *psz_src,
*
ppsz_dst
=
psz_text
;
*
ppsz_dst
=
psz_text
;
}
}
static
char
*
SegmentsToHtml
(
segment_t
*
p_head
,
const
float
f_scale
)
static
char
*
SegmentsToHtml
(
text_
segment_t
*
p_head
,
const
float
f_scale
)
{
{
char
*
psz_dst
=
NULL
;
char
*
psz_dst
=
NULL
;
char
*
psz_ret
=
NULL
;
char
*
psz_ret
=
NULL
;
while
(
p_head
)
while
(
p_head
)
{
{
HtmlAppend
(
&
psz_dst
,
p_head
->
psz_
string
,
&
p_head
->
styles
,
f_scale
);
HtmlAppend
(
&
psz_dst
,
p_head
->
psz_
text
,
p_head
->
style
,
f_scale
);
p_head
=
p_head
->
p_next
;
p_head
=
p_head
->
p_next
;
}
}
int
i_ret
=
asprintf
(
&
psz_ret
,
"<text>%s</text>"
,
psz_dst
);
int
i_ret
=
asprintf
(
&
psz_ret
,
"<text>%s</text>"
,
psz_dst
);
...
@@ -280,9 +261,9 @@ static void SubpictureTextDestroy(subpicture_t *subpic)
...
@@ -280,9 +261,9 @@ static void SubpictureTextDestroy(subpicture_t *subpic)
free
(
sys
->
html
);
free
(
sys
->
html
);
while
(
sys
->
p_htmlsegments
)
while
(
sys
->
p_htmlsegments
)
{
{
segment_t
*
p_segment
=
sys
->
p_htmlsegments
;
text_
segment_t
*
p_segment
=
sys
->
p_htmlsegments
;
sys
->
p_htmlsegments
=
sys
->
p_htmlsegments
->
p_next
;
sys
->
p_htmlsegments
=
p_segment
->
p_next
;
SegmentFre
e
(
p_segment
);
text_segment_Delet
e
(
p_segment
);
}
}
free
(
sys
);
free
(
sys
);
}
}
...
...
modules/codec/substx3g.c
View file @
b8ce6743
...
@@ -117,14 +117,14 @@ static char * str8indup( const char *psz_string, size_t i_skip, size_t n )
...
@@ -117,14 +117,14 @@ static char * str8indup( const char *psz_string, size_t i_skip, size_t n )
return
strndup
(
psz_string
,
psz_tmp
-
psz_string
);
return
strndup
(
psz_string
,
psz_tmp
-
psz_string
);
}
}
static
void
SegmentDoSplit
(
segment_t
*
p_segment
,
uint16_t
i_start
,
uint16_t
i_end
,
static
void
SegmentDoSplit
(
text_
segment_t
*
p_segment
,
uint16_t
i_start
,
uint16_t
i_end
,
segment_t
**
pp_segment_left
,
text_
segment_t
**
pp_segment_left
,
segment_t
**
pp_segment_middle
,
text_
segment_t
**
pp_segment_middle
,
segment_t
**
pp_segment_right
)
text_
segment_t
**
pp_segment_right
)
{
{
segment_t
*
p_segment_left
=
*
pp_segment_left
;
text_
segment_t
*
p_segment_left
=
*
pp_segment_left
;
segment_t
*
p_segment_right
=
*
pp_segment_right
;
text_
segment_t
*
p_segment_right
=
*
pp_segment_right
;
segment_t
*
p_segment_middle
=
*
pp_segment_middle
;
text_
segment_t
*
p_segment_middle
=
*
pp_segment_middle
;
p_segment_left
=
p_segment_middle
=
p_segment_right
=
NULL
;
p_segment_left
=
p_segment_middle
=
p_segment_right
=
NULL
;
if
(
(
p_segment
->
i_size
-
i_start
<
1
)
||
(
p_segment
->
i_size
-
i_end
<
1
)
)
if
(
(
p_segment
->
i_size
-
i_start
<
1
)
||
(
p_segment
->
i_size
-
i_end
<
1
)
)
...
@@ -132,26 +132,29 @@ static void SegmentDoSplit( segment_t *p_segment, uint16_t i_start, uint16_t i_e
...
@@ -132,26 +132,29 @@ static void SegmentDoSplit( segment_t *p_segment, uint16_t i_start, uint16_t i_e
if
(
i_start
>
0
)
if
(
i_start
>
0
)
{
{
p_segment_left
=
calloc
(
1
,
sizeof
(
segment_t
)
);
char
*
psz_text
=
str8indup
(
p_segment
->
psz_text
,
0
,
i_start
);
p_segment_left
=
text_segment_New
(
psz_text
);
free
(
psz_text
);
if
(
!
p_segment_left
)
goto
error
;
if
(
!
p_segment_left
)
goto
error
;
memcpy
(
&
p_segment_left
->
styles
,
&
p_segment
->
styles
,
sizeof
(
text_style_t
)
);
p_segment_left
->
style
=
text_style_Duplicate
(
p_segment
->
style
);
p_segment_left
->
psz_string
=
str8indup
(
p_segment
->
psz_string
,
0
,
i_start
);
p_segment_left
->
i_size
=
str8len
(
p_segment_left
->
psz_text
);
p_segment_left
->
i_size
=
str8len
(
p_segment_left
->
psz_string
);
}
}
p_segment_middle
=
calloc
(
1
,
sizeof
(
segment_t
)
);
char
*
psz_text
=
str8indup
(
p_segment
->
psz_text
,
i_start
,
i_end
-
i_start
+
1
);
p_segment_middle
=
text_segment_New
(
psz_text
);
free
(
psz_text
);
if
(
!
p_segment_middle
)
goto
error
;
if
(
!
p_segment_middle
)
goto
error
;
memcpy
(
&
p_segment_middle
->
styles
,
&
p_segment
->
styles
,
sizeof
(
text_style_t
)
);
p_segment_middle
->
style
=
text_style_Duplicate
(
p_segment
->
style
);
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_text
);
p_segment_middle
->
i_size
=
str8len
(
p_segment_middle
->
psz_string
);
if
(
i_end
<
(
p_segment
->
i_size
-
1
)
)
if
(
i_end
<
(
p_segment
->
i_size
-
1
)
)
{
{
p_segment_right
=
calloc
(
1
,
sizeof
(
segment_t
)
);
char
*
psz_text
=
str8indup
(
p_segment
->
psz_text
,
i_end
+
1
,
p_segment
->
i_size
-
i_end
-
1
);
p_segment_right
=
text_segment_New
(
psz_text
);
free
(
psz_text
);
if
(
!
p_segment_right
)
goto
error
;
if
(
!
p_segment_right
)
goto
error
;
memcpy
(
&
p_segment_right
->
styles
,
&
p_segment
->
styles
,
sizeof
(
text_style_t
)
);
p_segment_right
->
style
=
text_style_Duplicate
(
p_segment
->
style
);
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_text
);
p_segment_right
->
i_size
=
str8len
(
p_segment_right
->
psz_string
);
}
}
if
(
p_segment_left
)
p_segment_left
->
p_next
=
p_segment_middle
;
if
(
p_segment_left
)
p_segment_left
->
p_next
=
p_segment_middle
;
...
@@ -164,16 +167,16 @@ static void SegmentDoSplit( segment_t *p_segment, uint16_t i_start, uint16_t i_e
...
@@ -164,16 +167,16 @@ static void SegmentDoSplit( segment_t *p_segment, uint16_t i_start, uint16_t i_e
return
;
return
;
error:
error:
SegmentFre
e
(
p_segment_left
);
text_segment_Delet
e
(
p_segment_left
);
SegmentFre
e
(
p_segment_middle
);
text_segment_Delet
e
(
p_segment_middle
);
SegmentFre
e
(
p_segment_right
);
text_segment_Delet
e
(
p_segment_right
);
}
}
static
bool
SegmentSplit
(
segment_t
*
p_prev
,
segment_t
**
pp_segment
,
static
bool
SegmentSplit
(
text_segment_t
*
p_prev
,
text_
segment_t
**
pp_segment
,
const
uint16_t
i_start
,
const
uint16_t
i_end
,
const
uint16_t
i_start
,
const
uint16_t
i_end
,
const
text_style_t
*
p_styles
)
const
text_style_t
*
p_styles
)
{
{
segment_t
*
p_segment_left
=
NULL
,
*
p_segment_middle
=
NULL
,
*
p_segment_right
=
NULL
;
text_
segment_t
*
p_segment_left
=
NULL
,
*
p_segment_middle
=
NULL
,
*
p_segment_right
=
NULL
;
if
(
(
*
pp_segment
)
->
i_size
==
0
)
return
false
;
if
(
(
*
pp_segment
)
->
i_size
==
0
)
return
false
;
if
(
i_start
>
i_end
)
return
false
;
if
(
i_start
>
i_end
)
return
false
;
...
@@ -184,13 +187,13 @@ static bool SegmentSplit( segment_t *p_prev, segment_t **pp_segment,
...
@@ -184,13 +187,13 @@ static bool SegmentSplit( segment_t *p_prev, segment_t **pp_segment,
if
(
!
p_segment_middle
)
if
(
!
p_segment_middle
)
{
{
/* Failed */
/* Failed */
SegmentFre
e
(
p_segment_left
);
text_segment_Delet
e
(
p_segment_left
);
SegmentFre
e
(
p_segment_right
);
text_segment_Delet
e
(
p_segment_right
);
return
false
;
return
false
;
}
}
segment_t
*
p_next
=
(
*
pp_segment
)
->
p_next
;
text_
segment_t
*
p_next
=
(
*
pp_segment
)
->
p_next
;
SegmentFre
e
(
*
pp_segment
);
text_segment_Delet
e
(
*
pp_segment
);
*
pp_segment
=
(
p_segment_left
)
?
p_segment_left
:
p_segment_middle
;
*
pp_segment
=
(
p_segment_left
)
?
p_segment_left
:
p_segment_middle
;
if
(
p_prev
)
p_prev
->
p_next
=
*
pp_segment
;
if
(
p_prev
)
p_prev
->
p_next
=
*
pp_segment
;
...
@@ -199,20 +202,21 @@ static bool SegmentSplit( segment_t *p_prev, segment_t **pp_segment,
...
@@ -199,20 +202,21 @@ static bool SegmentSplit( segment_t *p_prev, segment_t **pp_segment,
else
else
p_segment_middle
->
p_next
=
p_next
;
p_segment_middle
->
p_next
=
p_next
;
p_segment_middle
->
styles
=
*
p_styles
;
text_style_Delete
(
p_segment_middle
->
style
);
p_segment_middle
->
style
=
text_style_Duplicate
(
p_styles
);
return
true
;
return
true
;
}
}
/* Creates a new segment using the given style and split existing ones according
/* Creates a new segment using the given style and split existing ones according
to the start & end offsets */
to the start & end offsets */
static
void
ApplySegmentStyle
(
segment_t
**
pp_segment
,
const
uint16_t
i_absstart
,
static
void
ApplySegmentStyle
(
text_
segment_t
**
pp_segment
,
const
uint16_t
i_absstart
,
const
uint16_t
i_absend
,
const
text_style_t
*
p_styles
)
const
uint16_t
i_absend
,
const
text_style_t
*
p_styles
)
{
{
/* find the matching segment */
/* find the matching segment */
uint16_t
i_curstart
=
0
;
uint16_t
i_curstart
=
0
;
segment_t
*
p_prev
=
NULL
;
text_
segment_t
*
p_prev
=
NULL
;
segment_t
*
p_cur
=
*
pp_segment
;
text_
segment_t
*
p_cur
=
*
pp_segment
;
while
(
p_cur
)
while
(
p_cur
)
{
{
uint16_t
i_curend
=
i_curstart
+
p_cur
->
i_size
-
1
;
uint16_t
i_curend
=
i_curstart
+
p_cur
->
i_size
-
1
;
...
@@ -278,26 +282,21 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
...
@@ -278,26 +282,21 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
for
(
uint16_t
i
=
0
;
i
<
i_psz_bytelength
;
i
++
)
for
(
uint16_t
i
=
0
;
i
<
i_psz_bytelength
;
i
++
)
if
(
psz_subtitle
[
i
]
==
'\r'
)
psz_subtitle
[
i
]
=
'\n'
;
if
(
psz_subtitle
[
i
]
==
'\r'
)
psz_subtitle
[
i
]
=
'\n'
;
segment_t
*
p_segment
=
calloc
(
1
,
sizeof
(
segment_t
)
);
text_segment_t
*
p_segment
=
text_segment_New
(
psz_subtitle
);
if
(
!
p_segment
)
{
free
(
psz_subtitle
);
return
NULL
;
}
p_segment
->
psz_string
=
strdup
(
psz_subtitle
);
p_segment
->
i_size
=
str8len
(
psz_subtitle
);
p_segment
->
i_size
=
str8len
(
psz_subtitle
);
if
(
p_dec
->
fmt_in
.
subs
.
p_style
)
if
(
p_dec
->
fmt_in
.
subs
.
p_style
)
{
{
p_segment
->
styles
.
i_font_color
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_color
;
p_segment
->
style
=
text_style_New
();
p_segment
->
styles
.
i_font_alpha
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_alpha
;
p_segment
->
style
->
i_font_color
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_color
;
p_segment
->
style
->
i_font_alpha
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_alpha
;
if
(
p_dec
->
fmt_in
.
subs
.
p_style
->
i_style_flags
)
if
(
p_dec
->
fmt_in
.
subs
.
p_style
->
i_style_flags
)
p_segment
->
style
s
.
i_style_flags
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_style_flags
;
p_segment
->
style
->
i_style_flags
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_style_flags
;
p_segment
->
style
s
.
i_font_size
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_size
;
p_segment
->
style
->
i_font_size
=
p_dec
->
fmt_in
.
subs
.
p_style
->
i_font_size
;
}
}
if
(
!
p_segment
->
psz_
string
)
if
(
!
p_segment
->
psz_
text
)
{
{
SegmentFre
e
(
p_segment
);
text_segment_Delet
e
(
p_segment
);
free
(
psz_subtitle
);
free
(
psz_subtitle
);
return
NULL
;
return
NULL
;
}
}
...
@@ -307,7 +306,7 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
...
@@ -307,7 +306,7 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
if
(
!
p_spu
)
if
(
!
p_spu
)
{
{
free
(
psz_subtitle
);
free
(
psz_subtitle
);
SegmentFre
e
(
p_segment
);
text_segment_Delet
e
(
p_segment
);
return
NULL
;
return
NULL
;
}
}
subpicture_updater_sys_t
*
p_spu_sys
=
p_spu
->
updater
.
p_sys
;
subpicture_updater_sys_t
*
p_spu_sys
=
p_spu
->
updater
.
p_sys
;
...
...
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