Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
9ae83ece
Commit
9ae83ece
authored
Sep 26, 2014
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/srtdec: simpler and more lenient probing
Fixes Ticket #3935.
parent
7dd2005e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
srtdec.c
libavformat/srtdec.c
+16
-11
No files found.
libavformat/srtdec.c
View file @
9ae83ece
...
@@ -31,23 +31,28 @@ typedef struct {
...
@@ -31,23 +31,28 @@ typedef struct {
static
int
srt_probe
(
AVProbeData
*
p
)
static
int
srt_probe
(
AVProbeData
*
p
)
{
{
int
i
,
v
,
num
=
0
;
int
v
;
char
buf
[
64
],
*
pbuf
;
FFTextReader
tr
;
FFTextReader
tr
;
ff_text_init_buf
(
&
tr
,
p
->
buf
,
p
->
buf_size
);
ff_text_init_buf
(
&
tr
,
p
->
buf
,
p
->
buf_size
);
while
(
ff_text_peek_r8
(
&
tr
)
==
'\r'
||
ff_text_peek_r8
(
&
tr
)
==
'\n'
)
while
(
ff_text_peek_r8
(
&
tr
)
==
'\r'
||
ff_text_peek_r8
(
&
tr
)
==
'\n'
)
ff_text_r8
(
&
tr
);
ff_text_r8
(
&
tr
);
for
(
i
=
0
;
i
<
2
;
i
++
)
{
char
buf
[
128
];
/* Check if the first non-empty line is a number. We do not check what the
if
(
ff_subtitles_read_line
(
&
tr
,
buf
,
sizeof
(
buf
))
<
0
)
* number is because in practice it can be anything. */
break
;
if
(
ff_subtitles_read_line
(
&
tr
,
buf
,
sizeof
(
buf
))
<
0
||
if
((
num
==
i
||
num
+
1
==
i
)
strtol
(
buf
,
&
pbuf
,
10
)
<
0
||
*
pbuf
)
&&
buf
[
0
]
>=
'0'
&&
buf
[
1
]
<=
'9'
&&
strstr
(
buf
,
" --> "
)
return
0
;
&&
sscanf
(
buf
,
"%*d:%*2d:%*2d%*1[,.]%*3d --> %*d:%*2d:%*2d%*1[,.]%3d"
,
&
v
)
==
1
)
return
AVPROBE_SCORE_MAX
;
/* Check if the next line matches a SRT timestamp */
num
=
atoi
(
buf
);
if
(
ff_subtitles_read_line
(
&
tr
,
buf
,
sizeof
(
buf
))
<
0
)
}
return
0
;
if
(
buf
[
0
]
>=
'0'
&&
buf
[
1
]
<=
'9'
&&
strstr
(
buf
,
" --> "
)
&&
sscanf
(
buf
,
"%*d:%*2d:%*2d%*1[,.]%*3d --> %*d:%*2d:%*2d%*1[,.]%3d"
,
&
v
)
==
1
)
return
AVPROBE_SCORE_MAX
;
return
0
;
return
0
;
}
}
...
...
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