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
6be80cac
Commit
6be80cac
authored
May 24, 2005
by
Derk-Jan Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Fix some detection logic for SSA/ASS subs
* Added ASS support
parent
b748d47b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
23 deletions
+39
-23
modules/demux/subtitle.c
modules/demux/subtitle.c
+39
-23
No files found.
modules/demux/subtitle.c
View file @
6be80cac
...
...
@@ -49,12 +49,12 @@ static void Close( vlc_object_t *p_this );
"Override frames per second. " \
"It will only work with MicroDVD subtitles."
#define SUB_TYPE_LONGTEXT \
"One from \"microdvd\", \"subrip\", \"ssa1\", \"ssa2-4\", \"vplayer\" " \
"One from \"microdvd\", \"subrip\", \"ssa1\", \"ssa2-4\", \"
ass\", \"
vplayer\" " \
"\"sami\" (auto for autodetection, it should always work)."
static
char
*
ppsz_sub_type
[]
=
{
"auto"
,
"microdvd"
,
"subrip"
,
"subviewer"
,
"ssa1"
,
"ssa2-4"
,
"vplayer"
,
"sami"
"ssa2-4"
,
"
ass"
,
"
vplayer"
,
"sami"
};
vlc_module_begin
();
...
...
@@ -87,6 +87,7 @@ enum
SUB_TYPE_SUBRIP
,
SUB_TYPE_SSA1
,
SUB_TYPE_SSA2_4
,
SUB_TYPE_ASS
,
SUB_TYPE_VPLAYER
,
SUB_TYPE_SAMI
,
SUB_TYPE_SUBVIEWER
,
...
...
@@ -149,6 +150,7 @@ static struct
{
"subviewer"
,
SUB_TYPE_SUBVIEWER
,
"SubViewer"
,
ParseSubViewer
},
{
"ssa1"
,
SUB_TYPE_SSA1
,
"SSA-1"
,
ParseSSA
},
{
"ssa2-4"
,
SUB_TYPE_SSA2_4
,
"SSA-2/3/4"
,
ParseSSA
},
{
"ass"
,
SUB_TYPE_ASS
,
"SSA/ASS"
,
ParseSSA
},
{
"vplayer"
,
SUB_TYPE_VPLAYER
,
"VPlayer"
,
ParseVplayer
},
{
"sami"
,
SUB_TYPE_SAMI
,
"SAMI"
,
ParseSami
},
{
NULL
,
SUB_TYPE_UNKNOWN
,
"Unknown"
,
NULL
}
...
...
@@ -263,28 +265,29 @@ static int Open ( vlc_object_t *p_this )
p_sys
->
i_type
=
SUB_TYPE_SUBRIP
;
break
;
}
else
if
(
sscanf
(
s
,
"!: This is a Sub Station Alpha v%d.x script."
,
&
i_dummy
)
==
1
)
else
if
(
!
strncasecmp
(
s
,
"!: This is a Sub Station Alpha v1"
,
33
)
)
{
if
(
i_dummy
<=
1
)
{
p_sys
->
i_type
=
SUB_TYPE_SSA1
;
}
else
{
p_sys
->
i_type
=
SUB_TYPE_SSA2_4
;
/* I hope this will work */
}
p_sys
->
i_type
=
SUB_TYPE_SSA1
;
break
;
}
else
if
(
strcasestr
(
s
,
"This is a Sub Station Alpha v4 script"
)
)
else
if
(
!
strncasecmp
(
s
,
"ScriptType: v4.00+"
,
18
)
)
{
p_sys
->
i_type
=
SUB_TYPE_SSA2_4
;
/* I hope this will work */
p_sys
->
i_type
=
SUB_TYPE_ASS
;
break
;
}
else
if
(
!
strncasecmp
(
s
,
"ScriptType: v4.00"
,
17
)
)
{
p_sys
->
i_type
=
SUB_TYPE_SSA2_4
;
break
;
}
else
if
(
!
strncasecmp
(
s
,
"Dialogue: Marked"
,
16
)
)
{
p_sys
->
i_type
=
SUB_TYPE_SSA2_4
;
/* could be wrong */
p_sys
->
i_type
=
SUB_TYPE_SSA2_4
;
break
;
}
else
if
(
!
strncasecmp
(
s
,
"Dialogue:"
,
9
)
)
{
p_sys
->
i_type
=
SUB_TYPE_ASS
;
break
;
}
else
if
(
strcasestr
(
s
,
"[INFORMATION]"
)
)
...
...
@@ -371,7 +374,8 @@ static int Open ( vlc_object_t *p_this )
/* *** add subtitle ES *** */
if
(
p_sys
->
i_type
==
SUB_TYPE_SSA1
||
p_sys
->
i_type
==
SUB_TYPE_SSA2_4
)
p_sys
->
i_type
==
SUB_TYPE_SSA2_4
||
p_sys
->
i_type
==
SUB_TYPE_ASS
)
{
es_format_Init
(
&
fmt
,
SPU_ES
,
VLC_FOURCC
(
's'
,
's'
,
'a'
,
' '
)
);
}
...
...
@@ -672,7 +676,7 @@ static int ParseMicroDvd( demux_t *p_demux, subtitle_t *p_subtitle )
* each line:
* {n1}{n2}Line1|Line2|Line3....
* where n1 and n2 are the video frame number...
*
*
{n2} can also be {}
*/
char
*
s
;
...
...
@@ -916,6 +920,7 @@ static int ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle )
text_t
*
txt
=
&
p_sys
->
txt
;
char
buffer_text
[
10
*
MAX_LINE
];
char
buffer_text2
[
10
*
MAX_LINE
];
char
*
s
;
int64_t
i_start
;
int64_t
i_stop
;
...
...
@@ -927,7 +932,6 @@ static int ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle )
for
(
;;
)
{
int
h1
,
m1
,
s1
,
c1
,
h2
,
m2
,
s2
,
c2
;
int
i_dummy
;
if
(
(
s
=
TextGetLine
(
txt
)
)
==
NULL
)
{
...
...
@@ -935,9 +939,20 @@ static int ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle )
}
p_subtitle
->
psz_text
=
malloc
(
strlen
(
s
)
);
/* We expect (SSA2-4):
* Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
* Dialogue: Marked=0,0:02:40.65,0:02:41.79,Wolf main,Cher,0000,0000,0000,,Et les enregistrements de ses ondes delta ?
*
* SSA-1 is similar but only has 8 commas up untill the subtitle text. Probably the Effect field is no present, but not 100 % sure.
*/
/* For ASS:
* Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
* Dialogue: Layer#,0:02:40.65,0:02:41.79,Wolf main,Cher,0000,0000,0000,,Et les enregistrements de ses ondes delta ?
*/
if
(
sscanf
(
s
,
"Dialogue:
Marked=%d,%d:%d:%d.%d,%d:%d:%d.%d
%[^
\r\n
]"
,
&
i_dummy
,
"Dialogue:
%[^,],%d:%d:%d.%d,%d:%d:%d.%d,
%[^
\r\n
]"
,
buffer_text2
,
&
h1
,
&
m1
,
&
s1
,
&
c1
,
&
h2
,
&
m2
,
&
s2
,
&
c2
,
buffer_text
)
==
10
)
...
...
@@ -953,15 +968,16 @@ static int ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle )
(
int64_t
)
c2
*
10
)
*
1000
;
/* The dec expects: ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text */
/* (Layer comes from ASS specs ... it's empty for SSA.) */
if
(
p_sys
->
i_type
==
SUB_TYPE_SSA1
)
{
sprintf
(
p_subtitle
->
psz_text
,
",%
d%s"
,
i_dummy
,
strdup
(
buffer_text
)
);
",%
s"
,
strdup
(
buffer_text
)
);
/* SSA1 has only 8 commas before the text starts, not 9 */
}
else
{
sprintf
(
p_subtitle
->
psz_text
,
",
%d,%s"
,
i_dummy
,
strdup
(
buffer_text
)
);
",
,%s"
,
strdup
(
buffer_text
)
);
/* ReadOrder, Layer, %s(rest of fields) */
}
p_subtitle
->
i_start
=
i_start
;
p_subtitle
->
i_stop
=
i_stop
;
...
...
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